• 🏆 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!

Revival Timer for multiple heroes

Status
Not open for further replies.
Level 5
Joined
Oct 20, 2019
Messages
60
Hello, i have a revival trigger that shows a timer for how long it will take for your fallen hero to come back to Life.

However, it only works properly if its only 1 player playing, if theres multiple players and they all die, the timer seems to be unable to keep track.

I would appreciate if someone could show me how to make this work but with 5 players =)

This is how it looks right now

  • Hero Revival System
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Countdown Timer - Start HeroRevivalTimer as a One-shot timer that will expire in 30.00 seconds
      • Set HeroRevivalTimer = (Last started timer)
      • Countdown Timer - Create a timer window for HeroRevivalTimer with title (Name of (Triggering unit))
      • Set HeroRevivalWindow = (Last created timer window)
      • Countdown Timer - Show HeroRevivalWindow
      • Wait 30.00 seconds
      • Countdown Timer - Hide HeroRevivalWindow
      • Countdown Timer - Destroy HeroRevivalWindow
      • Hero - Instantly revive (Triggering unit) at (Center of Hero Revival <gen>), Show revival graphics
      • Camera - Pan camera for (Owner of (Triggering unit)) to (Center of Hero Revival <gen>) over 1.00 seconds
 
Level 39
Joined
Feb 27, 2007
Messages
5,010
Make the variables arrays with size 5. Normally size doesn’t matter but here it’s needed to allocate the right number of timers. I also fixed a point leak you had; you can read about leaks here: Things That Leak

  • Hero Revival System
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering Unit)))
      • Set HeroToRevive[TempInt] = (Triggering Unit)
      • Countdown Timer - Start HeroRevivalTimer[TempInt] as a One-shot timer that will expire in 30.00 seconds
      • Countdown Timer - Create a timer window for HeroRevivalTimer[TempInt] with title (Name of (HeroToRevive[TempInt]))
      • Set HeroRevivalWindow[TempInt] = (Last created timer window)
      • Countdown Timer - Show HeroRevivalWindow[TempInt]
  • Events
    • Time - HeroRevivalTimer[1] expires
    • Time - HeroRevivalTimer[2] expires
    • Time - HeroRevivalTimer[3] expires
    • Time - HeroRevivalTimer[4] expires
    • Time - HeroRevivalTimer[5] expires
  • Conditions
  • Actions
    • For each (Integer A) from 1 to 5 do Actions
      • Loop - Actions
        • If (All conditions are true) then do (Then actions) else do (Else actions)
          • If - Conditions
            • (Expired Timer) equal to HeroRevivalTimer[(Integer A)]
          • Then - Actions
            • Set TempInt = (Integer A)
          • Else - Actions
    • Countdown Timer - Hide HeroRevivalWindow[TempInt]
    • Countdown Timer - Destroy HeroRevivalWindow[TempInt]
    • Set TempPoint = (Center of Hero Revival <gen>)
    • Hero - Instantly revive HeroToRevive[TempInt] at TempPoint, Show revival graphics
    • Camera - Pan camera for (Owner of HeroToRevive[TempInt]) to TempPoint over 1.00 seconds
    • Custom script: call RemoveLocation(udg_TempPoint) //cleans up a point leak
 
Last edited:
Level 5
Joined
Oct 20, 2019
Messages
60
Make the variables arrays with size 5. Normally size doesn’t matter but here it’s needed to allocate the right number of timers. I also fixed a point leak you had; you can read about leaks here: Things That Leak

  • Hero Revival System
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering Unit)))
      • Set HeroToRevive[TempInt] = (Triggering Unit)
      • Countdown Timer - Start HeroRevivalTimer[TempInt] as a One-shot timer that will expire in 30.00 seconds
      • Countdown Timer - Create a timer window for HeroRevivalTimer[TempInt] with title (Name of (HeroToRevive[TempInt]))
      • Set HeroRevivalWindow[TempInt] = (Last created timer window)
      • Countdown Timer - Show HeroRevivalWindow[TempInt]
  • Events
    • Time - HeroRevivalTimer[1] expires
    • Time - HeroRevivalTimer[2] expires
    • Time - HeroRevivalTimer[3] expires
    • Time - HeroRevivalTimer[4] expires
    • Time - HeroRevivalTimer[5] expires
  • Conditions
  • Actions
    • For each (Integer A) from 1 to 5 do Actions
      • Loop - Actions
        • If (All conditions are true) then do (Then actions) else do (Else actions)
          • If - Conditions
            • (Expired Timer) equal to HeroRevivalTimer[(Integer A)]
          • Then - Actions
            • Set TempInt = (Integer A)
          • Else - Actions
    • Countdown Timer - Hide HeroRevivalWindow[TempInt]
    • Countdown Timer - Destroy HeroRevivalWindow[TempInt]
    • Set TempPoint = (Center of Hero Revival <gen>)
    • Hero - Instantly revive HeroToRevive[TempInt] at TempPoint, Show revival graphics
    • Camera - Pan camera for (Owner of HeroToRevive[TempInt]) to TempPoint over 1.00 seconds
    • Custom script: call RemoveLocation(udg_TempPoint) //cleans up a point leak

Thank you very much for showing me how to fix this =) +rep
But theres one thing i can't find tho, where do i find (Expired Timer) equal to HeroRevivalTimer[(Integer A)]
And just to be sure about the Variable types TempInt = Integer without Array
HeroToRevive = Unit with Array 5
TempPoint = Point without array
 
Level 39
Joined
Feb 27, 2007
Messages
5,010
It would be a “timer comparison” but such a check may not be implemented in GUI. If not the way is to use a JASS if:

  • Custom script: if GetExpiredTimer() == udg_HeroRevivalTimer[bj_forLoopAIndex] then
  • Set TempInt = (Integer A)
  • Custom script: endif
 
Level 5
Joined
Oct 20, 2019
Messages
60
It would be a “timer comparison” but such a check may not be implemented in GUI. If not the way is to use a JASS if:

  • Custom script: if GetExpiredTimer() == udg_HeroRevivalTimer[bj_forLoopAIndex] then
  • Set TempInt = (Integer A)
  • Custom script: endif

I think i've done everything right but the heros dosen't get revived any longer, maybe i didn't get the custom script right because the timers seems to be working properly and are keeping track of all 5 players hero deaths.

This is how i made it

HeroRevivalTimer = Timer (Array 5)
HeroRevivalWindow = Timer Window (Array 5)
HeroToRevive = Unit (Array 5)
TempInt = Integer (No Array)
TempPoint = Point (No Array)


  • Hero Revival System
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • Set HeroToRevive[TempInt] = (Triggering unit)
      • Countdown Timer - Start HeroRevivalTimer[TempInt] as a One-shot timer that will expire in 30.00 seconds
      • Countdown Timer - Create a timer window for HeroRevivalTimer[TempInt] with title (Name of HeroToRevive[TempInt])
      • Set HeroRevivalWindow[TempInt] = (Last created timer window)
      • Countdown Timer - Show HeroRevivalWindow[TempInt]

  • Hero Revival System part 2
    • Events
      • Time - HeroRevivalTimer[1] expires
      • Time - HeroRevivalTimer[2] expires
      • Time - HeroRevivalTimer[3] expires
      • Time - HeroRevivalTimer[4] expires
      • Time - HeroRevivalTimer[5] expires
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
            • Then - Actions
              • Custom script: if GetExpiredTimer() == udg_HeroRevivalTimer[bj_forLoopAIndex] then
              • Set TempInt = (Integer A)
              • Custom script: endif
            • Else - Actions
              • Countdown Timer - Hide HeroRevivalWindow[TempInt]
              • Countdown Timer - Destroy HeroRevivalWindow[TempInt]
              • Set TempPoint = (Center of Hero Revival <gen>)
              • Hero - Instantly revive HeroToRevive[TempInt] at TempPoint, Show revival graphics
              • Camera - Pan camera for (Owner of HeroToRevive[TempInt]) to TempPoint over 1.00 seconds
              • Custom script: call RemoveLocation(udg_TempPoint)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Compare your second trigger to Pyros, it looks completely different than his. You have an unnecessary If Then Else statement splitting the Actions between "Then - Actions" and "Else - Actions". You need to move all of the actions out of that If Then Else and then delete the If Then Else.

That custom script he gave you replaces the If Then Else statement. You were supposed to delete the old one and replace it with the custom script.
 
Level 5
Joined
Oct 20, 2019
Messages
60
Compare your second trigger to Pyros, it looks completely different than his. You have an unnecessary If Then Else statement splitting the Actions between "Then - Actions" and "Else - Actions". You need to move all of the actions out of that If Then Else and then delete the If Then Else.

That custom script he gave you replaces the If Then Else statement. You were supposed to delete the old one and replace it with the custom script.

Ok, it works better now, all the heroes are being revived and all the timer windows are being removed but theres still an issue with the reviving, some heroes revive at the same time together even if they didn't die at the same time together.

obviously i've made an error but maybe you can help me point it out, this is how it looks now


  • TEST
    • Events
      • Time - HeroRevivalTimer[1] expires
      • Time - HeroRevivalTimer[2] expires
      • Time - HeroRevivalTimer[3] expires
      • Time - HeroRevivalTimer[4] expires
      • Time - HeroRevivalTimer[5] expires
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Custom script: if GetExpiredTimer() == udg_HeroRevivalTimer[bj_forLoopAIndex] then
          • Set TempInt = (Integer A)
          • Custom script: endif
          • Countdown Timer - Hide HeroRevivalWindow[TempInt]
          • Countdown Timer - Destroy HeroRevivalWindow[TempInt]
          • Set TempPoint = (Center of Hero Revival <gen>)
          • Hero - Instantly revive HeroToRevive[TempInt] at TempPoint, Show revival graphics
          • Camera - Pan camera for (Owner of HeroToRevive[TempInt]) to TempPoint over 1.00 seconds
          • Custom script: call RemoveLocation(udg_TempPoint)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
You'll need a Timer for each player. Right now it only works for players 1 to 5. Set the Array size to however many players are in your game that use Heroes and add Events for them like HeroRevivalTimer[6], HeroRevivalTimer[7], etc... Also, this is designed to work with only 1 Hero per Player.
 
Level 5
Joined
Oct 20, 2019
Messages
60
You'll need a Timer for each player. Right now it only works for players 1 to 5. Set the Array size to however many players are in your game that use Heroes and add Events for them like HeroRevivalTimer[6], HeroRevivalTimer[7], etc... Also, this is designed to work with only 1 Hero per Player.

Thank you for clearing this up for me =) +rep
However, theres still an odd thing about the revival, the map is made for up to 5 players and each player does only have 1 hero to control so it shouldn't be an issue there right?

The odd thing is that all players seems to revive as they should except for the player with the hero that dies last (if all 5 dies), he always revives together with the player who had the hero that died first.
It seems it dosen't matter who dies first but the one dying last will always revive with the one dying first, whats up with that?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Oh, whoops. What I said about the 0 to 4 indices was true but not for GUI so you don't have to worry about it. I deleted my comment, just keep everything as 1 to 5 like you had it.

Anyway, I figured it out. Move all of the actions under "Custom script endif" outside of the Loop. Put them under the Loop.
 
Level 39
Joined
Feb 27, 2007
Messages
5,010
Triggers aren't voodoo magic, they do exactly what you tell them to do. Think about what that loop is supposed to accomplish. It's to identify which index of the variables we should be using, so all that should be in there is the line that sets the TempInt variable. Everything else comes after the loop because we don't want to do all of that for ALL players, we only want to do it for the one that matches the timer that just expired.

  • TEST
    • Events
      • Time - HeroRevivalTimer[1] expires
      • Time - HeroRevivalTimer[2] expires
      • Time - HeroRevivalTimer[3] expires
      • Time - HeroRevivalTimer[4] expires
      • Time - HeroRevivalTimer[5] expires
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Custom script: if GetExpiredTimer() == udg_HeroRevivalTimer[bj_forLoopAIndex] then
          • Set TempInt = (Integer A)
          • Custom script: endif
      • Countdown Timer - Hide HeroRevivalWindow[TempInt]
      • Countdown Timer - Destroy HeroRevivalWindow[TempInt]
      • Set TempPoint = (Center of Hero Revival <gen>)
      • Hero - Instantly revive HeroToRevive[TempInt] at TempPoint, Show revival graphics
      • Camera - Pan camera for (Owner of HeroToRevive[TempInt]) to TempPoint over 1.00 seconds
      • Custom script: call RemoveLocation(udg_TempPoint)
 
Status
Not open for further replies.
Top