• 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.

Hero Revival

Status
Not open for further replies.
Level 5
Joined
Jan 23, 2014
Messages
152
Hi, I have a problem with this hero revive trigger, it's kinda simple,although I used the wait function. It revives a hero after 8 seconds. but when I killed 8 heroes at the same time, only 7 of them were revived, I even tried killing them with an interval of less than 1 second. but still 7 were revived. Can someone teach me how to fix this? Here's the trigger:

  • Hero Revival
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • Wait 8.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Dying unit) belongs to an ally of Player 1 (Red)) Equal to True
        • Then - Actions
          • Set CentOfRegion[1] = (Center of Base 1 Revival Region <gen>)
          • Hero - Instantly revive (Dying unit) at CentOfRegion[1], Show revival graphics
          • Custom script: call RemoveLocation (udg_CentOfRegion[1])
        • Else - Actions
          • Set CentOfRegion[2] = (Center of Base 2 Revival Region <gen>)
          • Hero - Instantly revive (Dying unit) at CentOfRegion[2], Show revival graphics
          • Custom script: call RemoveLocation (udg_CentOfRegion[2])
 
Instead of a wait use a timer.

When a hero dies add the hero to a Unit Group.
If - Number of units in Unit Group Equal to 0
Then -
Start Timer as a oneshot timer that will expire in 8 seconds
Else -


Seconds trigger:
Events - Timer expires
Conditions -
Actions -
Pick all units in Unit Group
Loop -
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Dying unit) belongs to an ally of Player 1 (Red)) Equal to True
Then - Actions
Set CentOfRegion[1] = (Center of Base 1 Revival Region <gen>)
Hero - Instantly revive (Dying unit) at CentOfRegion[1], Show revival graphics
Custom script: call RemoveLocation (udg_CentOfRegion[1])
Else - Actions
Set CentOfRegion[2] = (Center of Base 2 Revival Region <gen>)
Hero - Instantly revive (Dying unit) at CentOfRegion[2], Show revival graphics
Custom script: call RemoveLocation (udg_CentOfRegion[2])
Remove picked unit from Unit Group <- (inside the loop)


Assuming the 8 seconds are a general spawn interval and not for each unit.
 
Level 12
Joined
Nov 3, 2013
Messages
989
You can set the point before the wait and then use triggering unit and it would still work with the wait.

The point would leak with a global point variable but I think that you can make a custom script to have it local instead as well.
 
You can set the point before the wait and then use triggering unit and it would still work with the wait.

The point would leak with a global point variable but I think that you can make a custom script to have it local instead as well.
What would be the advantage to set it before the wait? Or better question, what is the disadvantage he sets it after the wait?

But he could set 2 constant point variables in init once for the respawn points and never remove them. (because they are always the same)
 
Level 12
Joined
Nov 3, 2013
Messages
989
What would be the advantage to set it before the wait? Or better question, what is the disadvantage he sets it after the wait?

But he could set 2 constant point variables in init once for the respawn points and never remove them. (because they are always the same)

Yeah init would better.
 
Level 5
Joined
Jan 23, 2014
Messages
152
I tried Icemanbo's suggestion, only 7 names came up. All the heroes are of the same type, Dreadlord. the 8 seconds are for each unit, not the general spawn interval. If I were to make it a timer, how should I do that?
 
And before the wait it displays all 8 names? Can you ensure unit won't get removed during these 8 seconds?

If I were to make it a timer, how should I do that?
You could create a timer[array] and use the PlayerNumber as index. And if a timer expires you revive the Hero[IndexOfExpiredTimer].

But else, directly using a timer for each unit is not very smart in GUI, But you also could index all dead heroes and create trigger that runs periodicly. (each ~0.1 seconds)

In this periodic trigger you always decrease the time[index] and revive the hero[index] if the time reaches 0.
 
Level 5
Joined
Jan 23, 2014
Messages
152
Yeah I made a debug, I increased the heroes to 10. Before the wait, it displays 10 names, but when they revive, it's still 7. I put 5 more heroes in another area and all 5 revived. So there are a total of 12 heroes now. I tried killing all 12 at the same time and all 12 revived. I dunno maybe there's an error with the first group of heroes killed?
 
Status
Not open for further replies.
Top