• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Reviving Units

Status
Not open for further replies.
Level 8
Joined
Feb 17, 2007
Messages
368
Can you demonstrate? I'm using GUI, so in that would be nice. :p Also would this give the revived units the same <gen> id that the dead units would have? Because these units are preplaced at the start of the game, and the triggers for them are for that specific <gen> unit id.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
This still counts as GUI, right?


  • 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


Press ESC to respawn units.
 

Attachments

  • Resp.w3x
    14.3 KB · Views: 60
Level 8
Joined
Feb 17, 2007
Messages
368
Yeah I've actually been pondering this problem for a while now, haha, I have no idea how to do it. Would I have to store the units in variables? But then wait, that wouldnt work either because your setting the variable for that specific unit ID. Hmmmm, lol
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Instead of using hashtables, you can change units' point value and save required values inside a variable with array, when a unit dies, give old unit's point value to new one.
 
Level 8
Joined
Feb 17, 2007
Messages
368
These are some of the bosses events:

  • Unit - |cff9932ccFrieza|r 0031 <gen>'s mana becomes Greater than or equal to (Max mana of |cff9932ccFrieza|r 0031 <gen>)
So what would I replace the Frieza with? I need this trigger to apply to the respawned boss.

Same thing here:

  • Unit - |cff9932ccFrieza|r 0031 <gen>'s mana becomes Greater than or equal to (Max mana of |cff9932ccFrieza|r 0031 <gen>)
 

Dr Super Good

Spell Reviewer
Level 65
Joined
Jan 18, 2005
Messages
27,296
You can not revive units as far as I know, especially since they may be removed if left dead too long.

The easiest way is to just recreate them (crate a new boss unit type at the boss position).

You could also use some complex unit recycle system like TKoK RPG does where it prevents any units from dieing but instead of creating new units, it just reallocates an existing unit back into play.
 
Level 8
Joined
Feb 17, 2007
Messages
368
Re add the events to the triggers. The event leak should be of little concern unless people kill the boss hundreds of times.

But this is what I'm trying to get answered lol, what would I put in the event for the unit? It can't be a specific unit because the revived unit wont have the same id and this event needs a specific unit. Maker I need your help :wink:
 
Level 8
Joined
Feb 17, 2007
Messages
368
Nice ok this seems to work really well, even though the whole concept of a restart system in my map is pretty complicated, I'll figure that part out. What about the actions in the triggers that are for the old units? Like for example, is there a way to pause all unit types of a unit? Because I would need to replace my actions to something that would work for the new unit to....

For example:
  • Unit - Pause |cff9932ccFrieza|r 0031 <gen>
or
  • Unit - Set mana of |cff9932ccFrieza|r 0031 <gen> to 0.00
or
  • Set FriezaFloatTextPos = (Position of |cff9932ccFrieza|r 0031 <gen>)
 
Level 8
Joined
Feb 17, 2007
Messages
368
OH, lol. So I just set the last created unit as a variable, in the trigger where you add the event? I don't want to create extra variables, so I will set the bosses variable at map init to that 1st try gen id, then set it to the new 2nd try gen id unit created in your trigger. Sounds GOOD! Your awesome, lol. Bet you get that a lot. :p
 

Dr Super Good

Spell Reviewer
Level 65
Joined
Jan 18, 2005
Messages
27,296
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.
 
Level 8
Joined
Feb 17, 2007
Messages
368
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.

Oh yeah I understand now, don't worry, Maker set me straight, haha. :thumbs_up: Yeah but I agree, this wasn't the easiest concept to get, and would've been taken considerably longer without some help. Now I'm just in the process of fixing all the triggers and replacing them with variables for the units. Sooo tedious, haha, but I've already got it working for 3 bosses, and it works perfectly. And I agree when you say there should be a way to delete events. There's so much more they could improve on with the wc3 editor, wouldn't even take that long I imagine. 1 quick patch.
 
Status
Not open for further replies.
Top