• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Unit Indexing and Deindexing

Status
Not open for further replies.
You would probably have to add special cases. Idk if you're using an indexer here or one of your own, but you should add a death register event. If a unit dies, and the unit is a building, then deindex the unit.

Undefend is actually only used for cases where units are removed (e.g., via RemoveUnit()). Those are actually really easy to get around in map-specific cases (just deindex a unit when you use the RemoveUnit() native), so just disregard the defend ability and use a regular death event + be considerate with RemoveUnit() (or write a custom RemoveUnit() function).
 
How can you get around undefend by removing a unit? I do know that it is ordered to undefend on death and remove (twice if you use RemoveUnit()). I was more curious with how to stop a building from undefending when it gets an ability based on defend.

I didn't mean you should remove the unit, I meant that you can just deindex it if you happen to remove a structure. Otherwise you can just check for death (in the case of buildings only). That way, you really don't need to rely on the undefend, and you can ignore it if the unit is a building (in the deindexing trigger). It is sort of a band-aid solution though, and I am aware that it doesn't answer your main question.
 
Status
Not open for further replies.
Top