HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Detection Script - unit decayed/removed, returning to life, dying

09-13-2008, 07:36 PM#1
Captain Griffen
So, what does this do? Well, basically its a way of detecting when a unit dies, goes out of scope or returns to life.

PurplePoot and I have closed all of the issues we found here, and it should now be bug free. We expect you guys will find plenty of bugs - please try and test this to oblivion.

It adjusts for animated units, works fine with devour, units in transports dying, and reincarnation, resurrection, and normal cases. As far as we know, in those cases it is fine, but they'll probably be a few more special cases.

Credits:

- PurplePoot, for most of the testing and ideas for this.
- Bobo_The_Kodo for the initial idea about undefend on death/removal.

It should be noted that although I wrote this code, most of the actual credit for the non-obvious ideas in it should go to Poot, such as the checking for if the unit is summoned to see if it is animated or not.

The code is in its rough and ready form for testing, rather than a fully polished release candidate.

Expand JASS:
09-13-2008, 07:39 PM#2
PurplePoot
Some stuff we haven't got around to implementing or noting, or that isn't needed but is related:
  • Reincarnation is currently registered as death and then revive. It could be separated with a little footwork with EVENT_PLAYER_UNIT_DIES.

  • If a unit dies in a transport but the transport does not die, then the unit will return false for IsUnitLoaded.

  • If the transport dies and the unit cannot be created (in deep water, for example) and thus dies, the unit will return true for IsUnitLoaded.

  • When loaded or devoured, the unit is ordered to undefend and returns true for IsUnitLoaded.

  • When dying from devour or inside a transport, the unit returns true for IsUnitHidden.

  • I'll add more if I remember them, though I'm not sure there were others.

EDIT: I have a really ghetto hack for detecting reincarnation, but it's pretty much an abomination at present. I'm trying to work out how to make it suck a bit less, if possible.

EDIT2: Here's what I have for a full script so far. Doesn't support dynamic triggers, but everyone knows they suck anyways. Supports reincarnation detection.

EDIT3: I should note that reincarnation with a 0 second duration won't fire the Reincarnation Start event, but all higher intervals will.

Expand JASS: