I have a unit that gets replaced by another unit when it dies. I'd really like for the newly spawned unit to have the same orders as the original unit, but I can't find any way to do this. I tried storing the unit's dying orders in a variable, using both the "Unit Dies" and the "Unit takes Damage" events (with the damage set to Fatal). However, in both cases, it just stored "No Order" because the unit lost it's orders upon death.
It seems that the only way to know the units orders are to store them before the unit dies, but there is no way to predict that the unit is going to die!
Might be a bit much overhead, but you could store the unit's current orders, update when unit gets new orders, then just use that when the new unit is spawned. It's inelegant and I'm sure someone else will have a better idea, but that might work.
There are many problems with this approach.
The number of units this applies to is potentially unlimited. I could make an array with a very large size and give each unit a unique custom value and use the custom value as an index so that i have an array of EVERY unit's orders, but that's not very elegant.
The other problem is that a units orders can change even if the unit is not issued an order. If a bunch of orders are queued up at once, then the unit's orders will change whenever it finishes a queued order, but this doesn't cause the "Unit Issued Order" event to go off.
Make a behavior that checks fatal blow, modify damage to 0, use handle dummy effect (apply dummy behavior) [Damage Response section, just in case you can't find it]. When the unit is damaged and has dummy behavior (dummy effect/behavior happens before the actual fatal damage, damage handling before damage), save/transfer the order then make a kill unit (option) damage effect (effect credit should be the damage dealer of course). The problem with this method is it removes the custom death animation although there is a way around this by using catalog get/set.
I'm having some trouble getting this to work. I created a behavior and an effect which applies it. I created a behavior called "AvoidFatal" with damage response chance 1, fatal enabled, modify fraction to 0, and "Handled" response is the apply behavior effect.
When the unit takes fatal damage, it is reduced to zero, but he never gains the dummy behavior, so the trigger doesn't run! I don't know why the effect isn't going off.
I'm having some trouble getting this to work. I created a behavior and an effect which applies it. I created a behavior called "AvoidFatal" with damage response chance 1, fatal enabled, modify fraction to 0, and "Handled" response is the apply behavior effect.
When the unit takes fatal damage, it is reduced to zero, but he never gains the dummy behavior, so the trigger doesn't run! I don't know why the effect isn't going off.
So who is your "target" for your dummy effect? ^^
EDIT: Maybe I didn't make the above hint obvious enough. Set Unit - Unit Value - Target to Caster, In (Apply Behavior) Effect
I figured it out finally. Everything works great, but I still can't figure out how to preserve the damage type for the custom death animation. The only thing is I can't figure out how to credit the kill to certain player, or to set the type of damage that killed the unit (for custom death animations). The only trigger I can find is just "Kill Unit" and all it lets me do is choose the unit.
This isn't that big of a deal, since the kill credit doesn't matter for my map, but the custom death animations would be nice to have.
I figured it out finally. Everything works great, but I still can't figure out how to preserve the damage type for the custom death animation. The only thing is I can't figure out how to credit the kill to certain player, or to set the type of damage that killed the unit (for custom death animations). The only trigger I can find is just "Kill Unit" and all it lets me do is choose the unit.
This isn't that big of a deal, since the kill credit doesn't matter for my map, but the custom death animations would be nice to have.
Kill Credit:
Data Editor: Create Dummy Effect (Damage) -> Flags - Kill
Trigger: Create effect on unit from unit
Get information on killing damage:
Set Variable (String) BLAH = CatalogGet Catalog get parameters -
Catalog: Effects
Entry: Convert Game Link to String(Function-Damaging Effect) {important to note you have to manually click unit-type change it to game-link then sub category to Effects then click on function then select damaging effect, thx blizzard}
Field: Death
Player: Triggering player
Now use Action catalog set parameters Catalog set parameters -
Catalog: Effects
Entry: Convert Game Link to String(Your Dummy Effect with "kill option")
Field: Death
Player: Triggering player
To: BLAH
I have a unit that gets replaced by another unit when it dies. I'd really like for the newly spawned unit to have the same orders as the original unit, but I can't find any way to do this. I tried storing the unit's dying orders in a variable, using both the "Unit Dies" and the "Unit takes Damage" events (with the damage set to Fatal). However, in both cases, it just stored "No Order" because the unit lost it's orders upon death. It seems that the only way to know the units orders are to store them before the unit dies, but there is no way to predict that the unit is going to die!
Anyone have any ideas?
Might be a bit much overhead, but you could store the unit's current orders, update when unit gets new orders, then just use that when the new unit is spawned. It's inelegant and I'm sure someone else will have a better idea, but that might work.
@Ghrabthaar: Go
There are many problems with this approach. The number of units this applies to is potentially unlimited. I could make an array with a very large size and give each unit a unique custom value and use the custom value as an index so that i have an array of EVERY unit's orders, but that's not very elegant.
The other problem is that a units orders can change even if the unit is not issued an order. If a bunch of orders are queued up at once, then the unit's orders will change whenever it finishes a queued order, but this doesn't cause the "Unit Issued Order" event to go off.
Make a behavior that checks fatal blow, modify damage to 0, use handle dummy effect (apply dummy behavior) [Damage Response section, just in case you can't find it]. When the unit is damaged and has dummy behavior (dummy effect/behavior happens before the actual fatal damage, damage handling before damage), save/transfer the order then make a kill unit (option) damage effect (effect credit should be the damage dealer of course). The problem with this method is it removes the custom death animation although there is a way around this by using catalog get/set.
@zifoon: Go
Brilliant! I'll give a try.
Seems like a dummy behavior isn't really necessary. I can just check for the existing behavior (the one that prevented the fatal blow) right?
Nevermind, I see that the damage doesn't count as fatal for the purposes of the trigger. Dummy it is.
@MasterDinadan: Go
I'm having some trouble getting this to work. I created a behavior and an effect which applies it. I created a behavior called "AvoidFatal" with damage response chance 1, fatal enabled, modify fraction to 0, and "Handled" response is the apply behavior effect.
When the unit takes fatal damage, it is reduced to zero, but he never gains the dummy behavior, so the trigger doesn't run! I don't know why the effect isn't going off.
So who is your "target" for your dummy effect? ^^
EDIT: Maybe I didn't make the above hint obvious enough. Set Unit - Unit Value - Target to Caster, In (Apply Behavior) Effect
I figured it out finally. Everything works great, but I still can't figure out how to preserve the damage type for the custom death animation. The only thing is I can't figure out how to credit the kill to certain player, or to set the type of damage that killed the unit (for custom death animations). The only trigger I can find is just "Kill Unit" and all it lets me do is choose the unit.
This isn't that big of a deal, since the kill credit doesn't matter for my map, but the custom death animations would be nice to have.
Kill Credit:
Data Editor: Create Dummy Effect (Damage) -> Flags - Kill
Trigger: Create effect on unit from unit
Get information on killing damage:
Set Variable (String) BLAH = CatalogGet
Catalog get parameters -
Catalog: Effects
Entry: Convert Game Link to String(Function-Damaging Effect) {important to note you have to manually click unit-type change it to game-link then sub category to Effects then click on function then select damaging effect, thx blizzard}
Field: Death
Player: Triggering player
Now use Action catalog set parameters
Catalog set parameters -
Catalog: Effects
Entry: Convert Game Link to String(Your Dummy Effect with "kill option")
Field: Death
Player: Triggering player
To: BLAH
Put this in before you kill command.