• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Detect Unload vs Un-Defend

Level 18
Joined
Mar 16, 2008
Messages
721
Using the un-defend thing inspired from Bribe's system to detect if unit dies to track Ankh cooldowns and stuff. Problem is when unit is unloaded from transport it casts un-defend. Can anyone think of a way to detect if the unit is being unloaded from transport as opposed to dying?
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
From testing this on latest version, the undefend is ordered when unit enters transport, not when it leaves it (at least in case of zeppelin).
The 'cast' of Load ability can be detected and there is also an event for when unit enters a transport.
Events are fired in this order:
1. Casting Load
  • Zeppelin Load
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Load (Goblin Zeppelin)
    • Actions
      • ...
2. Footman ordered 'undefend'
  • Footman Undefend
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(undefend))
    • Actions
      • ...
3. Unit loaded into transport
  • Zeppelin Loaded
    • Events
      • Unit - A unit Is loaded into a transport
    • Conditions
    • Actions
      • ...
So what you could do is:
1. When unit casts 'Load', flag the target as 'Being loaded' for example in hashtable
2. When unit casts 'undefend', check the 'Being loaded' flag
3. When unit is actually loaded into the transport, clear the flag (that is mainly to prevent unit boarding the transport with inactive defend already and then falsely evaluation step #2 when unit is ordered 'undefend')
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
The mirror image ability is cast before the 'undefend' order, so you can use the "Unit - A unit Starts the effect of an ability" event to detect when unit casts mirror image and flag the unit so that when 'undefend' is ordered, you can safely ignore it.
 
Top