- Joined
- Feb 17, 2007
- Messages
- 368
The bosses in my map are units, not heroes. When the game restarts, I want to be able to revive them. How would I go about doing this?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Init Respawn 2

Events


Time - Elapsed game time is 0.00 seconds

Conditions

Actions


Hashtable - Create a hashtable


Set rhash = (Last created hashtable)


Set units = 0


Custom script: set bj_wantDestroyGroup = true


Unit Group - Pick every unit in (Units owned by Neutral Hostile) and do (Actions)



Loop - Actions




Set units = (units + 1)




Custom script: call SaveReal( udg_rhash , udg_units , StringHash("x") , GetUnitX(GetEnumUnit()))




Custom script: call SaveReal( udg_rhash , udg_units , StringHash("y") , GetUnitY(GetEnumUnit()))




Custom script: call SaveReal( udg_rhash , udg_units , StringHash("f") , GetUnitFacing(GetEnumUnit()))




Custom script: call SaveInteger( udg_rhash , udg_units , StringHash("t") , GetUnitTypeId(GetEnumUnit()))




Custom script: call SaveUnitHandle( udg_rhash , udg_units , StringHash("u") , GetEnumUnit() )




Custom script: call SavePlayerHandle( udg_rhash , udg_units , StringHash("o") , GetOwningPlayer(GetEnumUnit()) )
Respawn 2

Events


Player - Player 1 (Red) skips a cinematic sequence

Conditions

Actions


For each (Integer i1) from 1 to units, do (Actions)



Loop - Actions




Custom script: set udg_u1 = LoadUnitHandle( udg_rhash , udg_i1 , StringHash("u") )




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






(u1 is alive) Equal to False





Then - Actions






Unit - Remove u1 from the game






Custom script: set udg_r1 = LoadReal( udg_rhash , udg_i1 , StringHash("x") )






Custom script: set udg_r2 = LoadReal( udg_rhash , udg_i1 , StringHash("y") )






Custom script: set udg_r3 = LoadReal( udg_rhash , udg_i1 , StringHash("f") )






Custom script: set udg_p1 = LoadPlayerHandle( udg_rhash , udg_i1 , StringHash("o") )






Custom script: set udg_i2 = LoadInteger( udg_rhash , udg_i1 , StringHash("t") )






Custom script: set bj_lastCreatedUnit = CreateUnit( udg_p1 , udg_i2 , udg_r1 , udg_r2 , udg_r3 )






Custom script: call SaveUnitHandle( udg_rhash , udg_i1 , StringHash("u") , bj_lastCreatedUnit )





Else - Actions
It works really well, your awesome lol. But will the units that respawn still have the same <gen>ID? Otherwise the triggers for the bosses wont work
Unit - |cff9932ccFrieza|r 0031 <gen>'s mana becomes Greater than or equal to (Max mana of |cff9932ccFrieza|r 0031 <gen>)
Unit - |cff9932ccFrieza|r 0031 <gen>'s mana becomes Greater than or equal to (Max mana of |cff9932ccFrieza|r 0031 <gen>)
Custom Script: call ReviveUnit(<yourUnit>)
Re add the events to the triggers. The event leak should be of little concern unless people kill the boss hundreds of times.

Unit - Pause |cff9932ccFrieza|r 0031 <gen>
Unit - Set mana of |cff9932ccFrieza|r 0031 <gen> to 0.00
Set FriezaFloatTextPos = (Position of |cff9932ccFrieza|r 0031 <gen>)
Triggers do not point at variables, they point at the unit when the event was added.
You just readd the event to the trigger for the new unit. Do not understand? Then that is because GUI obscures the JASS way how triggers work. You can however add events to triggers despite this being unclear in GUI.
When you respawn the boss, add a new event (via the add event action) for the events the boss needs to the triggers the boss needs. For the reference unit, that you use a variable (it still will only add the unit in the variable to the event at the time the action is run).
Triggers are objects which run triggeraction objects if triggercondition objects evaluate to true. They are executed by eithor another function (via the appropiate native) or when an event fires. Events are objects that are attached to a trigger and govern when it should run. Events that reference specific units will only reference the unit that was passed to the event constructor at the time of creation.
A flaw with WC3 is there is no "RemoveEvent" or "ClearEvents" natives so you have to use trigger destruction to purge them (recreating the trigger is easy). This however introduces instability apparently due to some handle allocation bug which can cause a fatal error.
