Whoa, that's a bit a chew though. I think you may have accounted for more things than I really need to. First of all, I guess I should've mentioned that this ability does not need to be MUI at all - only have one unit that can use it. But let me decipher what I can:
-
ini
-
Events
-
Map initialization
-
Conditions
-
Actions
-
Set ug = (Units in (Playable map area) matching ((Level of Reincarnation for (Matching unit)) Not equal to (!=) 0))
-
Do Multiple ActionsFor each (Integer A) from 1 to (Number of units in ug), do (Actions)
-
Loop - Actions
-
Custom script: set udg_u = FirstOfGroup( udg_ug )
-
Unit Group - Remove u from ug
-
Trigger - Add to ReincarnEvent <gen> the event (Unit - u's life becomes Less than 1.00)
-
Custom script: call DestroyGroup( udg_ug )
The hero learns the ability halfway through the game, they don't start with it. So...call me a fool, but why not just replace this whole hassle with Unit learns a skill and keep the action to add the event to another trigger?
-
ReincarnEvent
-
Events
-
Conditions
-
((Triggering unit) is dead) Equal to (==) False
-
Actions
-
Do Multiple ActionsFor each (Integer A) from 1 to 6, do (Actions)
-
Loop - Actions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Item-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to (==) Ankh of Reincarnation
-
Then - Actions
-
Skip remaining actions
-
Else - Actions
-
Do Multiple ActionsFor each (Integer A) from 1 to 1000, do (Actions)
-
Loop - Actions
-
Wait 0.10 seconds
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Life of (Triggering unit)) Greater than (>) 1.00
-
Then - Actions
-
Game - Display to (All players) the text: I was Reincarnating!
-
Skip remaining actions
-
Else - Actions
This is where it gets a little confusing for me, but maybe I'm just paying too much attention to things that don't actually do anything. But first of all, wouldn't this make the item reincarnation go off first and ignore the ability if the hero has the item, when it's the other way around I'd like to do this if possible?
Finally, I guess I was a bit unclear on what exactly I'm looking to detect. The first guy who responded had the right idea with trying to detect when the hero is about to die, although I haven't tried his suggestion just yet, because I'm not sure how to work around the inevitable "unit dies" event even if I do catch the right moment there.
The idea is that my custom stuff is supposed to take place during the reincarnation animation (by default, the little tombstone and all that), not after it.
EDIT: I solved it. Turns out all I had to do is give the hero a stock reincarnation spell (with modified tooltip and icons) and then use the unit takes damage event suggested by the first poster anyway. Add a boolean to mark when reincarnation is on cooldown, a trigger that's only point is to wait out the cooldown and mark it ready again, and this lets me slot in whatever I want
on top of the reincarnation animation, which is what I was looking to do here all along.
Still, thanks for all the other ideas. Might come in handy someday.