Detect Reincarnation

Status
Not open for further replies.

hdm

hdm

Level 9
Joined
Nov 19, 2011
Messages
384
In my case, I want to detect when the unit reincarnates to order the game to select that unit. If the unit dies and reincarnates, it does not select the unit Meaning you haev to press F1 (if you main hero) or find it when it dies. How to make the game select the unit after it dies ? I know, by triggers, but how trigger it ? Like unit dies wait seconds (bug, waits bug the game) and then select ?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
You need to create a trigger system to detect when reincarnation occurs. There is no in-built way to do this.

Vexorian made such a system long ago and demoed it with some abilities. Chances are it no longer works (like most of his stuff) due to the dependency on type casting exploit which was patched. The ideas he used could possibly be ported and modernized to fulfill what you require.
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
Reincarnation does

-not apply any detectable buff
-not trigger "order ...", "ability ...", "unit dies" or "unit life becomes smaller than x" events, the life is just set to 0 when below the death threshold
-work with the UnitAlive and IsUnitType(u, UNIT_TYPE_DEAD) natives, meaning the unit will be marked as dead during the effect

So it might be easiest to just keep track of all units that have reincarnation and use triggers to keep track of the cooldown in addition to periodic health checks.
Or alternatively keep track of the reincarnation units with a data structure whether a death event triggered and periodic health checks to determine whether a unit is reincarnating.
 

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,267
Interesting, I didn't knew the unit was counted as dead during the delay of waiting for reincarnation effect if I understood Ezekiel correctly.

Just keep track of units "dead" during reincarnation effect, for example in unit groups and periodic timer checks and it shouldn't be difficult at all to keep track. You need to make sure your system don't kick in when the unit dies and reincarnation cd is still present. DSG and Ezekiel has provided enough basic info you need to know.



Reincarnation ability sidenote:
As I made it in cruiser command where the crew is normal units, not heroes, I didn't base it on the reincarnation ability, I made a custom reincarnation ability (not cloned from reincarnation, but using a dummy ability) using timers and unitgroups, since normal units tend to often not leaving a corpse after death when the reincarnation cd hasn't finished and the crew in my map is not a hero type unit. (The original wc3 roc game was probably never originally designed reincarnations ability for normal units to have this ability in the first place and was never fixed in any later wc3 updates, its only really intended on heroes and works good for them since they don't leave a normal unit corpse in death)
 
http://www.hiveworkshop.com/forums/spells-569/gui-unit-event-v2-1-0-0-a-201641/ handles reincarnation with perfect accuracy.

Edit: Ezekiel12, reincarnation does trigger an order event, "Undefend", if the unit has a defend ability. GUI Unit Event is partially derived from Nestharus' Unit Event, which is a more optimized method than AutoEvents - but all of which use a disabled "defend" ability added on each unit so as to allow the undefend order to fire for each unit.

How it works: a unit dies and issues the undefend order. If IsUnitType(u, UNIT_TYPE_DEAD) is true, you know it's dead so you tell the system "this unit is dead". The "any unit dies" fires after this event, so what has to be done is to use a 0 second timer to check if the unit triggered that event (has died normally) or has skipped it (has started reincarnating).

You also use this order to detect when a unit is removed from the game, which is another thing that is used in GUI Unit Event, Nestharus' Unit Indexer and Anitarf's AutoIndex.
 
Status
Not open for further replies.
Top