• 🏆 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 Revival System

Status
Not open for further replies.
Level 8
Joined
Jun 13, 2010
Messages
344
Hi again,
So I have tried to search for a decent Hero Revival System.
Most of them were not MUI friendly and made huge bugs like respawning 50% of the time.

But I found this system:
http://chaosrealm.info/topic/8103180/1/

Although it seems to be MUI and confirmed by the modirators, I can't seem to get it to work.
I have modified it a bit, since I have 4 areas of save points I have added to the revival point, by string variables.
Alkarean Outpost (Default)
Vevarian City
Misty Isles Camp
Alkarah Throne Room

Here are my triggers so far:

Trigger 1:
  • Hero Revive1
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Hero_Revival_Integer1 Equal to 0
        • Then - Actions
          • Trigger - Turn on Hero Revive2 <gen>
        • Else - Actions
          • Do nothing
      • Set Hero_Revival_Integer1 = (Hero_Revival_Integer1 + 1)
      • Set Hero_Revival_Integer2 = (Hero_Revival_Integer2 + 1)
      • Set Hero_Revival_Unit[Hero_Revival_Integer2] = (Triggering unit)
      • Set Hero_Revival_Timer[Hero_Revival_Integer2] = ((Real((Level of Hero_Revival_Unit[Hero_Revival_Integer2]))) + 10.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Area_HeroSave[(Player number of (Owner of Hero_Revival_Unit[Hero_Revival_Integer2]))] Equal to Alkarean Outpost
        • Then - Actions
          • Set Hero_Revival_Point[Hero_Revival_Integer2] = (Center of Starting Spawn Point <gen>)
          • Skip remaining actions
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Area_HeroSave[(Player number of (Owner of Hero_Revival_Unit[Hero_Revival_Integer2]))] Equal to Vevarian City
        • Then - Actions
          • Set Hero_Revival_Point[Hero_Revival_Integer2] = (Center of Area Vevarian City Revive <gen>)
          • Skip remaining actions
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Area_HeroSave[(Player number of (Owner of Hero_Revival_Unit[Hero_Revival_Integer2]))] Equal to The Misty Isles
        • Then - Actions
          • Set Hero_Revival_Point[Hero_Revival_Integer2] = (Center of Zeppelin Misty Isles Camp <gen>)
          • Skip remaining actions
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Area_HeroSave[(Player number of (Owner of Hero_Revival_Unit[Hero_Revival_Integer2]))] Equal to Alkarah Throne Room
        • Then - Actions
          • Set Hero_Revival_Point[Hero_Revival_Integer2] = (Center of Area Alkarah Throne Room <gen>)
          • Skip remaining actions
        • Else - Actions
          • Do nothing
Trigger 2:
  • Hero Revive2
    • Events
      • Time - Elapsed game time is 0.03 seconds
    • Conditions
    • Actions
      • For each (Integer Hero_Revival_Integer_MUI) from 1 to Hero_Revival_Integer2, do (Actions)
        • Loop - Actions
          • Set Hero_Revival_Timer[Hero_Revival_Integer_MUI] = (Hero_Revival_Timer[Hero_Revival_Integer_MUI] - 0.03)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer(Hero_Revival_Timer[Hero_Revival_Integer_MUI])) Less than or equal to 0
            • Then - Actions
              • Hero - Instantly revive Hero_Revival_Unit[Hero_Revival_Integer_MUI] at Hero_Revival_Point[Hero_Revival_Integer_MUI], Hide revival graphics
              • Camera - Pan camera for (Owner of Hero_Revival_Unit[Hero_Revival_Integer_MUI]) to (Position of Hero_Revival_Unit[Hero_Revival_Integer_MUI]) over 0.00 seconds
              • Selection - Select Hero_Revival_Unit[Hero_Revival_Integer_MUI] for (Owner of Hero_Revival_Unit[Hero_Revival_Integer_MUI])
              • Set Hero_Revival_Integer2 = (Hero_Revival_Integer2 - 1)
              • Custom script: call RemoveLocation (udg_Hero_Revival_Point[udg_Hero_Revival_Integer_MUI])
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Hero_Revival_Integer2 Equal to 0
            • Then - Actions
              • Set Hero_Revival_Integer1 = 0
              • Trigger - Turn off (This trigger)
            • Else - Actions
I do have decent understanding of MUI, but when it comes to this sort of many variables I still have problems finding my way around.

I have skipped the Revival_TimeFactor, (Map initialization) since I do not have use for it.

I have the string Area_HeroSave default to Alkarean Outpost, so my test heroes should just respawn at that point by default, right?
 
Level 8
Joined
Jan 28, 2016
Messages
486
You specifically didn't mention what it was about the triggers that didn't work but from what I can tell, your Area_HeroSave array is MPI rather than MUI because you're saving the strings under the Player number which can be over-written if there is more than one unit triggering the event.

On a side note, you can get rid of all those Do nothing actions.
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
As said above, please specify what isn't working.


On another side note, why do you loop your second trigger every 0.03 seconds? On your demo trigger, your hero revives in 10 seconds. Making your second trigger loop every 1 or so seconds would drastically improve performance.
 
Level 8
Joined
Jun 13, 2010
Messages
344
Well my problem is that it will not respawn my heroes..
And it is no problem with the hero overlap per player. Because you will only have 1 hero for each player.
 
Level 8
Joined
Jan 28, 2016
Messages
486
Well my problem is that it will not respawn my heroes..
And it is no problem with the hero overlap per player. Because you will only have 1 hero for each player.

If you only have one Hero per player, then you could make it MPI. Like this:
  • Revive Hero
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • Unit Group - Add (Dying unit) to RevivableHeroes
      • Set TempReal = (((Real((Hero level of (Dying unit)))) x Hero_Revive_Time_Factor) + 5.00)
      • Countdown Timer - Start ReviveTimers[(Player number of (Owner of (Dying unit)))] as a One-shot timer that will expire in TempReal seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Multiboard_ShowDeaths Equal to False
        • Then - Actions
          • Countdown Timer - Create a timer window for (Last started timer) with title (Name of (Owner of (Dying unit)))
          • Countdown Timer - Show (Last created timer window) for (Owner of (Dying unit))
          • Set RevivableTimersWindows[(Player number of (Owner of (Dying unit)))] = (Last created timer window)
        • Else - Actions
  • Revive Hero Timer
    • Events
      • Time - ReviveTimers[2] expires
      • Time - ReviveTimers[3] expires
      • Time - ReviveTimers[4] expires
      • Time - ReviveTimers[5] expires
      • Time - ReviveTimers[6] expires
      • Time - ReviveTimers[8] expires
      • Time - ReviveTimers[9] expires
      • Time - ReviveTimers[10] expires
      • Time - ReviveTimers[11] expires
      • Time - ReviveTimers[12] expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in RevivableHeroes and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Remaining time for ReviveTimers[(Player number of (Owner of (Picked unit)))]) Less than 1.00
              • ((Owner of (Picked unit)) is in PlayersSentinel) Equal to True
            • Then - Actions
              • Hero - Instantly revive (Picked unit) at (Center of Sentinel Start <gen>), Show revival graphics
            • Else - Actions
              • Hero - Instantly revive (Picked unit) at (Center of Scourge Start <gen>), Show revival graphics
I got this from a DotA Template from World Editor Tutorials but I slightly modified it. Nevertheless this should serve as a good foundation for your revival system.
 
Level 8
Joined
Jun 13, 2010
Messages
344
If you only have one Hero per player, then you could make it MPI. Like this:
  • Revive Hero
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • Unit Group - Add (Dying unit) to RevivableHeroes
      • Set TempReal = (((Real((Hero level of (Dying unit)))) x Hero_Revive_Time_Factor) + 5.00)
      • Countdown Timer - Start ReviveTimers[(Player number of (Owner of (Dying unit)))] as a One-shot timer that will expire in TempReal seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Multiboard_ShowDeaths Equal to False
        • Then - Actions
          • Countdown Timer - Create a timer window for (Last started timer) with title (Name of (Owner of (Dying unit)))
          • Countdown Timer - Show (Last created timer window) for (Owner of (Dying unit))
          • Set RevivableTimersWindows[(Player number of (Owner of (Dying unit)))] = (Last created timer window)
        • Else - Actions
  • Revive Hero Timer
    • Events
      • Time - ReviveTimers[2] expires
      • Time - ReviveTimers[3] expires
      • Time - ReviveTimers[4] expires
      • Time - ReviveTimers[5] expires
      • Time - ReviveTimers[6] expires
      • Time - ReviveTimers[8] expires
      • Time - ReviveTimers[9] expires
      • Time - ReviveTimers[10] expires
      • Time - ReviveTimers[11] expires
      • Time - ReviveTimers[12] expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in RevivableHeroes and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Remaining time for ReviveTimers[(Player number of (Owner of (Picked unit)))]) Less than 1.00
              • ((Owner of (Picked unit)) is in PlayersSentinel) Equal to True
            • Then - Actions
              • Hero - Instantly revive (Picked unit) at (Center of Sentinel Start <gen>), Show revival graphics
            • Else - Actions
              • Hero - Instantly revive (Picked unit) at (Center of Scourge Start <gen>), Show revival graphics
I got this from a DotA Template from World Editor Tutorials but I slightly modified it. Nevertheless this should serve as a good foundation for your revival system.

Great, thanks Ill check it out. :)
 
Level 8
Joined
Jan 28, 2016
Messages
486
Well it worked at first. But when he dies a second time, he does not revive.

I looked into this and initially thought it was caused by a trigger I forgot to post with the other two but turns out it had no affect in stopping the respawn.
  • Revive Hero Tavern
    • Events
      • Unit - A unit Finishes reviving
    • Conditions
      • ((Reviving Hero) is in RevivableHeroes) Equal to True
    • Actions
      • Unit Group - Remove (Reviving Hero) from RevivableHeroes
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Multiboard_ShowDeaths Equal to True
        • Then - Actions
          • Multiboard - Set the text for (Last created multiboard) item in column 2, row Multiboard_Spots[(Player number of (Owner of (Reviving Hero)))] to
        • Else - Actions
          • Countdown Timer - Destroy RevivableTimersWindows[(Player number of (Owner of (Reviving Hero)))]
      • Camera - Pan camera for (Owner of (Reviving Hero)) to (Position of (Reviving Hero)) over 0.60 seconds
      • Selection - Select (Reviving Hero) for (Owner of (Reviving Hero))
This trigger is to remove the Heroes from the RevivableHeroes group and destroy the respawn timer window. The reason the multiboard action ends with 'to' is because the string value after it is a space.

I then remembered a similar issue when trying to implement these triggers in a map of my own. The ReviveTimers variable needs to have the array size set to 12 because with timer arrays, only the first two are initialised by default as explained by Spartipilo and Maker in this thread.
 
Status
Not open for further replies.
Top