• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Hero Revive

Status
Not open for further replies.
Level 4
Joined
Jan 27, 2020
Messages
51
A player hero died will revive in a certain place/location to instantly revive
and also
  • team 1 small
    • Events
      • Unit - A unit enters warden selection <gen>
    • Conditions
      • (Owner of (Entering unit)) Equal to Player 1 (Red)
      • (Unit-type of (Entering unit)) Equal to Soul
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Picked unit)) is in Group_Player) Equal to True
        • Then - Actions
          • Unit - Create 1 Warden for (Owner of (Entering unit)) at (Center of hero spawn team 1 2 3 <gen>) facing Default building facing degrees
        • Else - Actions
          • Unit - Create 1 Warden for (Owner of (Entering unit)) at (Center of hero spawn team 4 5 6 <gen>) facing Default building facing degrees
          • Unit - Remove (Entering unit) from the game
a example that if the unit enter the region will create a hero in a certain place/location too. just like a Dota
 
Level 4
Joined
Jan 27, 2020
Messages
51
You may want to track the selected unit using variables for reference later. If such a unit dies, then revive it at the revive point after some time. Wait could be used, but a per player timer (timer array) would allow more accurate timing.
What do you mean can u tell me and make aome trigger?
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,197
Your hero selection trigger appears fine. One wants to extend it so it does the following.
  • Add the created unit to a unit group stored in a global variable. This unit group tracks all revive-able heroes so something like "HeroGroup" would be fine for a name.
  • Use a global unit array to map player slot number to the hero unit. This allows one to resolve a player's selected hero unit from their player slot number so could be called something like "PlayerHeroes".
Now for the revive system there is a separate trigger. Event when any unit dies. Check if dying unit is in HeroGroup (a Boolean comparison). If this passes then the hero will need to be revived.

For the revival create a global timer array with size 24. The size is important to pre-populate it with timer objects. This will map player slot number to a unique timer to track their revival delay. In the actions of the death trigger you get the timer for player slot number of owner of dying unit and start it for the revive delay time. Optionally one could create and manage a timer window as well so the player knows when their hero will revive.

When that timer expires it is time to revive the hero. So that the trigger fires when any of the 24 timers expire it will either need 24 events specifically for each timer, or at map initialization use an integer loop that runs from 1 to 24 (inclusive) and dynamically adds the timer expires event to the trigger. The actions for the timer expires trigger is then to loop through all 24 timers using an integer loop and store in a temporary global integer variable the array index number that the triggering timer equals the timer from the array. An appropriately named variable would be "MatchingIndex". This is the slot number of the player to revive so can be converted to a unit to revive using the PlayerHeroes variable. Use the hero action to instantly revive a hero at a location on this unit.

Be aware that instantly reviving a hero only works if the player's current food used added to the hero's food used is less than the game constant defined food limit. If this is not the case the revive will fail. This is a hidden mechanic with the revive hero instantly action that can be difficult to debug if one is not aware it exists.
 
Status
Not open for further replies.
Top