• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Event Death/Removal Detection

Status
Not open for further replies.
Level 18
Joined
Jan 21, 2006
Messages
2,552
When a unit dies, it triggers a few event responses.

  • TriggerRegisterDeathEvent
  • TriggerRegisterUnitEvent...EVENT_UNIT_DEATH
  • TriggerRegisterUnitEvent...EVENT_UNIT_ISSUED_ORDER

The last one is only registered if the unit has the "defend" ability, in which case it is ordered "undefend". When the unit is removed from the game (after being killed) it registers another "undefend" ability.

Does anybody know which of these is the fastest? I have a unit-data system that uses the event from TriggerRegisterDeathEvent to detect when the unit dies, but at the same time I have an event registered by TriggerRegisterUnitEvent that will tell me when the unit is ordered "undefend". I'm wondering if I should base the unit's "death" as the unit is ordered "undefend" or just use that to figure out when the unit is removed from the map entirely (in which case I can get rid of the unit-data for that specific unit).
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Try it out for yourself. When a unit dies, it randomly issues an "undefend" order at the moment of death. Also, when the unit finishes decaying and is completely removed from the game, it issues another one of these orders. I also believe that there is an "undefend" order issued when a unit is revived.

The ability 'Adef' or a custom version of it does not even have meet the necessary tech requirements or be available to the user for these orders to be issued anyways. This means you can hide the ability from the user using SetPlayerAbilityAvailable() but still have the functionality of knowing when a unit's "state" changes.
 
Status
Not open for further replies.
Top