• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] hero revive problem

Not open for further replies.
Level 24
Jun 16, 2008
Hi the Hive Community
I have a problem with the revive system i use
it works when only one hero dies but the variable might be overwritten when a seconds hero dies while the other wasnt reborn yet
i didnt test it out but it is obvious that it will happen
what i need is an effective hero revive system in GUI wich is MUI

here is my system so far, plz help me:

  • herorevive
    • Events
      • Unit - A unit dies
    • Conditions
      • ((Triggering unit) is a hero) equal to True
    • Actions
      • Set TempLoc01 = (Center of gg_rct_HeroSpawnLeft)
      • Set TempLoc02 = (Center of gg_rct_HeroSpawnRight)
      • Game - Display to (All allies of (Owner of (Triggering unit))) the text: (((Name of (Triggering unit)) + will be revived in ) + ((String(((Level of (Triggering unit)) x 3))) + seconds.))
      • Wait (3.00 x (Real((Level of (Triggering unit))))) seconds
      • If (((Owner of (Triggering unit)) is in (All allies of player 6 (Orange))) equal to True) then do (hero - Instantly revive (Triggering unit) at TempLoc01, showing revival graphics) else do (Do nothing)
      • If (((Owner of (Triggering unit)) is in (All allies of player 12 (Braun))) equal to True) then do (hero - Instantly revive (Triggering unit) at TempLoc02, Zeigen revival graphics) else do (Do nothing)
      • Set TempLoc00 = (Position of (Triggering unit))
      • camera - Pan camera for (Owner of (Triggering unit)) to TempLoc00 over 2.00 seconds
      • Custom script: call RemoveLocation(udg_TempLoc00)
      • Custom script: call RemoveLocation(udg_TempLoc01)
      • Custom script: call RemoveLocation(udg_TempLoc02)
i know the w8 function should be done wiht a timer or a polled w9 but since the polled isnt available in GUI as far as i know and i was to lazy to do a second trigger i used the w8 function

i w8 for a quick answer,

Level 11
Feb 22, 2006
I'm pretty sure Get Triggering Unit is the only event function that still works after waits. I'm not completely sure though...I always use JASS and just use locals, but something in my head wants to say that there was one event response function that sleeping threads didn't screw up and that Get Triggering Unit was that function. So if anyone sees this and knows for sure I'm wrong, PLEASE set the record straight.

If I'm right, you're trigger should already be MUI as it is, as long as TempLoc01 and TempLoc02 are always at the same location (i.e. those two hero respawn regions are never redefined in-game).

By the way, if that is the case, you don't need to create and destroy those two locations (TempLoc01 and TempLoc02) every time this trigger runs. Just initialize them with a trig at map init and leave them there.

Also, you're leaking two player groups when you call All Allies of Player 6 and All Allies of Player 12. To fix this simply use the function Is Unit an Ally Of (probably not the exact name, but it should be close).
Level 24
Jun 16, 2008

thats why i asked
can u give me a MUI hero revive system? it would be exhausting to care if another unit died before u in-game....
what i mean is that if a unit dies and it will be revived in 20 secs within these 20 secs another hero dies the first variable will be overwritten and only the second hero will be revived. am i right??
the first would have to quit the game because his hero cant be revived anymore ....
Level 5
Nov 14, 2007
im no pro, but from my experience this is how it works.
yes you are correct GetTriggerUnit() works after waits, but if the event fires and condition met, you have a new GetTriggerUnit() *example 2 heroes die 1 after the other, the first one is set, then the second one overwrites the first. the first one is forgotten and will NEVER spawn*

there are a few ways you can fix this. if only 1 hero per person, save that hero into a variable (Unit Array) such as:
  • Set Var_Unit[(Player number of (Owner of (Triggering unit)))] = (Dying unit)
then wait the desired time and have him re-spawn, or set it to run every X seconds re-spawn all the player in the array.

another alternative would be using locals, which store the unit locally and do not overwrite if the trigger runs again. easiest way would be:
  • Custom script: local unit hero = GetDyingUnit()
now there will be a variable "hero" for all the dying units, kinda hard to comprehend at first, but once u get it. its awesome.

function Trig_Revive_Hero_JASS_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true

function Trig_Revive_Hero_JASS_Actions takes nothing returns nothing
    local timerdialog WINDOW
    local integer HEROWAIT
    local timer OURTIMER
    local unit OURHERO
    set OURHERO = GetDyingUnit()
    set HEROWAIT = ( GetHeroLevel(OURHERO) * 2 + 10 )
    set OURTIMER = CreateTimer()
    call StartTimerBJ( OURTIMER, false, ( I2R(HEROWAIT) ))
    call CreateTimerDialogBJ( OURTIMER, GetPlayerName(GetOwningPlayer(OURHERO)) )
    set WINDOW = GetLastCreatedTimerDialogBJ()
    call TimerDialogDisplayBJ( true, WINDOW )
    call PolledWait( HEROWAIT )
    call ReviveHeroLoc(OURHERO, udg_RessPoint, true )  //set this global point in map init.
    call PanCameraToTimedLocForPlayer( GetOwningPlayer(OURHERO), GetUnitLoc(OURHERO), 0.60 )
    call DestroyTimerDialog(WINDOW)

//TRIGGER USED FROM [url]www.world-editor-tutorials.thehelper.net/revive.php[/url]

if this doesnt make sense i recommend reading this tutorial. it's what helped me to understand the theory behind your problems.

Good luck to you, and let us know if u have more problems.

PS: i re-read one of ur post, and tomorrow, after school, i may be able to right you up something more to your needs. But do give it a shot while you wait, you learn better that way.
Not open for further replies.