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

[Trigger] Auto hero revive not working

Status
Not open for further replies.
Level 4
Joined
Jul 10, 2013
Messages
73
I have my auto hero revive triggers here, I am just wondering why it is not working. My hero doesn't revive as well as the timer not starting.

  • Revive12
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Dying unit)) Equal to Player 12 (Brown)
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Dying unit)) Equal to |CFF20C000Biomind (Basic Hero)
          • (Unit-type of (Dying unit)) Equal to |CFF20C000Biomind (Intellect Hero)
          • (Unit-type of (Dying unit)) Equal to |CFF20C000Biomind (Strength Hero)
    • Actions
      • Countdown Timer - Start Revive12 as a One-shot timer that will expire in 30.00 seconds
      • Countdown Timer - Show (Last created timer window) for Player 12 (Brown)
      • Wait 30.00 seconds
      • Set tempunit3 = (Random unit from Zombies2)
      • Set Point = (Position of tempunit3)
      • Hero - Instantly revive (Dying unit) at Point, Show revival graphics
      • Custom script: call RemoveLocation(udg_Point)
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
The problem you are facing, is that you need to data after a certain time, but don't have access to the data anymore. You have to store your data. There are several ways to do this, but it's not really that easy in GUI.
You can use waits + local variables (custom script), dynamic indexing (GUI), timer + hashtable (JASS).
If you only have a very low number of units that are revived, you could also use simple arrays without index recycling and assign every index to one specific unit. For example in your case, if every player has up to 3 heroes, you can say index 0-2 is player 1, 3-5 player 2, .... and use a unit and a timer array to store the units/timers.
I don't really understand why you first start a timer, but then use wait. You should avoid using waits here and use the timer.
 
Level 4
Joined
Jul 10, 2013
Messages
73
I don't really know what it should look like, could you give me an example? I have the timer working now, I would like to know how to optimize it though like you said.

  • Revive12
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Dying unit)) Equal to Player 12 (Brown)
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Dying unit)) Equal to |CFF20C000Biomind (Basic Hero)
          • (Unit-type of (Dying unit)) Equal to |CFF20C000Biomind (Intellect Hero)
          • (Unit-type of (Dying unit)) Equal to |CFF20C000Biomind (Strength Hero)
    • Actions
      • Countdown Timer - Start Revive12 as a One-shot timer that will expire in 30.00 seconds
      • Countdown Timer - Create a timer window for Revive12 with title Revive
      • Countdown Timer - Show (Last created timer window) for Player 12 (Brown)
      • Set ReviveWindow12 = (Last created timer window)
      • Wait 30.00 seconds
      • Set tempunit3 = (Random unit from Zombies2)
      • Set Point = (Position of tempunit3)
      • Hero - Instantly revive Hero12 at Point, Show revival graphics
      • Custom script: call RemoveLocation(udg_Point)
      • Countdown Timer - Destroy ReviveWindow12
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
You are still not using the timer correctly. The timer is your tool to make it happen after a certain time, it's not just for displaying a timer window.
I used 33-35, because (12-1)*3 = 33, so I have a index for every player. This solution will have a timer for 3 heroes per player.
  • Revive 12
    • Events
      • Unit - A unit owned by Player 12 (Brown) Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Paladin
        • Then - Actions
          • Set ReviveUnit[33] = (Triggering unit)
          • Countdown Timer - Start ReviveTimer[33] as a One-shot timer that will expire in 30.00 seconds
          • -------- create timer window if you want --------
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Archmage
        • Then - Actions
          • Set ReviveUnit[34] = (Triggering unit)
          • Countdown Timer - Start ReviveTimer[34] as a One-shot timer that will expire in 30.00 seconds
          • -------- create timer window if you want --------
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Mountain King
        • Then - Actions
          • Set ReviveUnit[35] = (Triggering unit)
          • Countdown Timer - Start ReviveTimer[35] as a One-shot timer that will expire in 30.00 seconds
          • -------- create timer window if you want --------
        • Else - Actions
When you use timers you always want to have this event: "timer ... expires", at least in GUI.
  • Revive 12 First
    • Events
      • Time - ReviveTimer[33] expires
    • Conditions
    • Actions
      • Hero - Instantly revive ReviveUnit[33] at (Center of (Playable map area)), Hide revival graphics
The same for 34 and 35.
 
Level 4
Joined
Jul 10, 2013
Messages
73
So if you create a timer window and want it to only show to the player the hero is reviving for it would look like this? (and to also get rid of the window afterwards)

  • Revive12
    • Events
      • Unit - A unit owned by Player 12 (Brown) Dies
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Dying unit)) Equal to |CFF20C000Biomind (Basic Hero)
          • (Unit-type of (Dying unit)) Equal to |CFF20C000Biomind (Intellect Hero)
          • (Unit-type of (Dying unit)) Equal to |CFF20C000Biomind (Strength Hero)
    • Actions
      • Countdown Timer - Start Revive12 as a One-shot timer that will expire in 30.00 seconds
      • Countdown Timer - Create a timer window for Revive12 with title Revive
      • Countdown Timer - Show (Last created timer window) for Player 12 (Brown)
      • Set ReviveWindow12 = (Last created timer window)
  • Revive12expire
    • Events
      • Time - Revive12 expires
    • Conditions
    • Actions
      • Set tempunit3 = (Random unit from Zombies2)
      • Set Point = (Position of tempunit3)
      • Hero - Instantly revive Hero12 at Point, Show revival graphics
      • Custom script: call RemoveLocation(udg_Point)
      • Countdown Timer - Destroy ReviveWindow12
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Yes.
In this case only Hero12 will be revived, no matter if it's basic, strength or intellect. If every player only has one hero that's ok, but make sure that Hero12 is initialized.
I can't see all triggers, so I mentioned this in case you forgot.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Hide it for the other players then. Maybe it shows on default and you have to hide it, if you don't want to show it.
 
Level 4
Joined
Jul 10, 2013
Messages
73
So it would look like this?

  • Revive1
    • Events
      • Unit - A unit owned by Player 1 (Red) Dies
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Dying unit)) Equal to |CFF20C000Biomind (Basic Hero)
          • (Unit-type of (Dying unit)) Equal to |CFF20C000Biomind (Intellect Hero)
          • (Unit-type of (Dying unit)) Equal to |CFF20C000Biomind (Strength Hero)
    • Actions
      • Countdown Timer - Start Revive1 as a One-shot timer that will expire in 30.00 seconds
      • Countdown Timer - Create a timer window for Revive1 with title Revive
      • Countdown Timer - Hide (Last created timer window) for Player 3 (Teal)
      • Countdown Timer - Hide (Last created timer window) for Player 4 (Purple)
      • Countdown Timer - Hide (Last created timer window) for Player 5 (Yellow)
      • Countdown Timer - Hide (Last created timer window) for Player 6 (Orange)
      • Countdown Timer - Hide (Last created timer window) for Player 7 (Green)
      • Countdown Timer - Hide (Last created timer window) for Player 8 (Pink)
      • Countdown Timer - Hide (Last created timer window) for Player 9 (Gray)
      • Countdown Timer - Hide (Last created timer window) for Player 10 (Light Blue)
      • Countdown Timer - Hide (Last created timer window) for Player 12 (Brown)
      • Set ReviveWindow1 = (Last created timer window)
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
I would use a player group. It's shorter. Just test it and see if it works. What about player 2?
If you put "ReviveWindow1 = (Last created timer window)" above all the hide actions, you use ReviveWindow1 instead of (Last created timer window). It's a but faster.
 
Status
Not open for further replies.
Top