Revival Timer

Revengez

New Member
Reaction score
1
Istar made this awesome revival trigger for me.

Can anyone help me out with a revival timer? It'd be appreciated, and you'll be in credits with istar and get +rep.

JASS:
function Trig_rivive_Conditions takes nothing returns boolean
    return ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true )   //this is the condition of trigger, checking if the dying unit is a hero
endfunction

function Trig_rivive_Actions takes nothing returns nothing
    local unit dying = GetTriggerUnit()
    local player owner = GetOwningPlayer(dying)
    local integer id = GetPlayerId(owner)
    if (id == 1) or (id == 2) or (id==3) or (id==4) or (id==5) then
        call TriggerSleepAction( ( 4 * GetUnitLevel(dying) ) ) //wait for unit's level multiply by 4
        call ReviveHeroLoc( dying, GetRectCenter(gg_rct_Region_001), true ) //this means if the owner is player 1 to 5, revive in region 1
    endif
    if (id==7) or (id==8) or (id==9) or (id==10) or (id==11) then
        call TriggerSleepAction( ( 4* GetUnitLevel(dying) ) )
        call ReviveHeroLoc( dying, GetRectCenter(gg_rct_Region_002), true ) //the same, if owner is player 7 to 11, revive the hero at region 2 instead
    endif
    set dying = null
    set owner = null
endfunction

//===========================================================================
function InitTrig_rivive takes nothing returns nothing
    set gg_trg_rivive = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_rivive, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_rivive, Condition( function Trig_rivive_Conditions ) )
    call TriggerAddAction( gg_trg_rivive, function Trig_rivive_Actions )
endfunction
 

Kenny

Back for now.
Reaction score
202
What exactly are you asking? Does it not work? Must something be improved?
 

Kenny

Back for now.
Reaction score
202
I haven't really done one of these before, but i gave it a shot:

JASS:
library HeroDies initializer Init

globals    
    private timerdialog array Dialogs
    private timer array Timers
    private unit array Heroes
endglobals

//=======================================================================
private function Update takes nothing returns nothing   
    local timer t = GetExpiredTimer() 
    local integer i = 0
    
    loop
        exitwhen Timers<i> == t or i == 15
        set i = i + 1
    endloop
    
    if i == 15 then
        set t = null
        return
    endif
    
    call PauseTimer(t)
    call DestroyTimerDialog(Dialogs<i>)
    
    if (i == 1) or (i == 2) or (i == 3) or (i == 4) or (i == 5) then
        call ReviveHero(Heroes<i>,GetRectCenterX(gg_rct_Region_001),GetRectCenterY(gg_rct_Region_001),true)
    elseif (i == 7) or (i == 8) or (i == 9) or (i == 10) or (i == 11) then
        call ReviveHero(Heroes<i>,GetRectCenterX(gg_rct_Region_002),GetRectCenterY(gg_rct_Region_002),true)
    endif
    
    if GetLocalPlayer() == GetOwningPlayer(Heroes<i>) then
        call ClearSelection()
        call SelectUnit(Heroes<i>,true)        
        call PanCameraToTimed(GetUnitX(Heroes<i>),GetUnitY(Heroes<i>),1.00)
    endif
    
    call SetUnitState(Heroes<i>,UNIT_STATE_LIFE,GetUnitState(Heroes<i>,UNIT_STATE_MAX_LIFE))        
    call SetUnitState(Heroes<i>,UNIT_STATE_MANA,GetUnitState(Heroes<i>,UNIT_STATE_MAX_MANA))


    call DestroyTimer(t)    
    set t = null
endfunction   

//=======================================================================
private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer i = GetPlayerId(GetOwningPlayer(u))
    
    set Timers<i> = CreateTimer()
    set Dialogs<i> = CreateTimerDialog(Timers<i>)
    call TimerDialogSetTitle(Dialogs<i>,&quot;Revive Time&quot;)    
    set Heroes<i> = u
    call TimerStart(Timers<i>,(GetUnitLevel(Heroes<i>)*4),false,function Update)
    
    if GetLocalPlayer() == GetOwningPlayer(u) then
        call TimerDialogDisplay(Dialogs<i>,true)
    endif
    
    set u = null
endfunction

private function Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) == true 
endfunction

//=======================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(trig,Condition(function Conditions))
    call TriggerAddAction(trig,function Actions)
endfunction

endlibrary</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>


That will also revive your heroes at each Region specified.
 

Revengez

New Member
Reaction score
1
I haven't really done one of these before, but i gave it a shot:

JASS:
library HeroDies initializer Init

globals    
    private timerdialog array Dialogs
    private timer array Timers
    private unit array Heroes
endglobals

//=======================================================================
private function Update takes nothing returns nothing   
    local timer t = GetExpiredTimer() 
    local integer i = 0
    
    loop
        exitwhen Timers<i> == t or i == 15
        set i = i + 1
    endloop
    
    if i == 15 then
        set t = null
        return
    endif
    
    call PauseTimer(t)
    call DestroyTimerDialog(Dialogs<i>)
    
    if (i == 1) or (i == 2) or (i == 3) or (i == 4) or (i == 5) then
        call ReviveHero(Heroes<i>,GetRectCenterX(gg_rct_Region_001),GetRectCenterY(gg_rct_Region_001),true)
    elseif (i == 7) or (i == 8) or (i == 9) or (i == 10) or (i == 11) then
        call ReviveHero(Heroes<i>,GetRectCenterX(gg_rct_Region_002),GetRectCenterY(gg_rct_Region_002),true)
    endif
    
    if GetLocalPlayer() == GetOwningPlayer(Heroes<i>) then
        call ClearSelection()
        call SelectUnit(Heroes<i>,true)        
        call PanCameraToTimed(GetUnitX(Heroes<i>),GetUnitY(Heroes<i>),1.00)
    endif
    
    call SetUnitState(Heroes<i>,UNIT_STATE_LIFE,GetUnitState(Heroes<i>,UNIT_STATE_MAX_LIFE))        
    call SetUnitState(Heroes<i>,UNIT_STATE_MANA,GetUnitState(Heroes<i>,UNIT_STATE_MAX_MANA))


    call DestroyTimer(t)    
    set t = null
endfunction   

//=======================================================================
private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer i = GetPlayerId(GetOwningPlayer(u))
    
    set Timers<i> = CreateTimer()
    set Dialogs<i> = CreateTimerDialog(Timers<i>)
    call TimerDialogSetTitle(Dialogs<i>,&quot;Revive Time&quot;)    
    set Heroes<i> = u
    call TimerStart(Timers<i>,(GetUnitLevel(Heroes<i>)*4),false,function Update)
    
    if GetLocalPlayer() == GetOwningPlayer(u) then
        call TimerDialogDisplay(Dialogs<i>,true)
    endif
    
    set u = null
endfunction

private function Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) == true 
endfunction

//=======================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(trig,Condition(function Conditions))
    call TriggerAddAction(trig,function Actions)
endfunction

endlibrary</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>


That will also revive your heroes at each Region specified.


Trying this out.
 

Kenny

Back for now.
Reaction score
202
I cant test it but i have a feeling i missed something. let me look through it some more.
 

Kenny

Back for now.
Reaction score
202
JASS:
library HeroDies initializer Init

globals   
    private constant boolean ShowAll = true // If true, it will show all death timers to everyone. Good for testing purposes.
    public timerdialog array Dialogs // Don&#039;t touch.
    public timer array Timers        // Don&#039;t touch.
    public unit array Heroes         // Don&#039;t touch.
endglobals

//=======================================================================
private function Interval takes unit u returns integer
    return GetHeroLevel(u)*4 // Revive time.
endfunction

//=======================================================================
private function Update takes nothing returns nothing   
    local timer t = GetExpiredTimer() 
    local player p
    local integer i = 0
    
    loop
        exitwhen Timers<i> == t or i == 15
        set i = i + 1
    endloop
    
    if i == 15 then
        set t = null
        return
    endif
    
    set p = GetOwningPlayer(Heroes<i>)    
    call PauseTimer(t)
    call DestroyTimerDialog(Dialogs<i>)
    
    if (i &lt;= 5 and i &gt; 1) then
        call ReviveHero(Heroes<i>,GetRectCenterX(gg_rct_Region_001),GetRectCenterY(gg_rct_Region_001),true)
    elseif (i &gt;= 7) then
        call ReviveHero(Heroes<i>,GetRectCenterX(gg_rct_Region_002),GetRectCenterY(gg_rct_Region_002),true)
    endif
    
    if GetLocalPlayer() == p then
        call ClearSelection()
        call SelectUnit(Heroes<i>,true)        
        call PanCameraToTimed(GetUnitX(Heroes<i>),GetUnitY(Heroes<i>),1.00)
    endif
    
    call SetUnitState(Heroes<i>,UNIT_STATE_LIFE,GetUnitState(Heroes<i>,UNIT_STATE_MAX_LIFE))        
    call SetUnitState(Heroes<i>,UNIT_STATE_MANA,GetUnitState(Heroes<i>,UNIT_STATE_MAX_MANA))


    call DestroyTimer(t)    
    set t = null
endfunction   

//=======================================================================
private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player p = GetOwningPlayer(u)
    local integer i = GetPlayerId(p)
    
    set Timers<i> = CreateTimer()
    set Dialogs<i> = CreateTimerDialog(Timers<i>)
    call TimerDialogSetTitle(Dialogs<i>,&quot;Revive Time&quot;)    
    set Heroes<i> = u
    call TimerStart(Timers<i>,Interval(Heroes<i>),false,function Update)
    call TriggerSleepAction(0.00)
    
    if ShowAll then
        call TimerDialogDisplay(Dialogs<i>,true)
    else
        if GetLocalPlayer() == p then
            call TimerDialogDisplay(Dialogs<i>,true)
        endif
    endif
endfunction

//=======================================================================
private function Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) == true 
endfunction

//=======================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(trig,Condition(function Conditions))
    call TriggerAddAction(trig,function Actions)
endfunction

endlibrary</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>


That one should work.

However you need NewGen world editor.

EDIT: added an updated version, allows all players to see the timer if you want. For testing purposes.
 

saw792

Is known to say things. That is all.
Reaction score
280
It requires JASS Newgen Pack, which you can download from a sticky in this forum.
 

Revengez

New Member
Reaction score
1
It works just normal revive... But i wanted like a timer, at the top of the screen counting down how long until you revive.
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
Try this:

JASS:
library HeroDies initializer Init

globals   
    private constant boolean ShowAll = true // If true, it will show all death timers to everyone. Good for testing purposes.
    public timerdialog array Dialogs // Don&#039;t touch.
    public timer array Timers        // Don&#039;t touch.
    public unit array Heroes         // Don&#039;t touch.
endglobals

//=======================================================================
private function Interval takes unit u returns integer
    return GetHeroLevel(u)*4 // Revive time.
endfunction

//=======================================================================
private function Update takes nothing returns nothing   
    local timer t = GetExpiredTimer() 
    local player p
    local integer i = 0
    
    loop
        exitwhen Timers<i> == t or i == 15
        set i = i + 1
    endloop
    
    if i == 15 then
        set t = null
        return
    endif
    
    set p = GetOwningPlayer(Heroes<i>)    
    call PauseTimer(t)
    call DestroyTimerDialog(Dialogs<i>)
    
    if (i &lt;= 5 and i &gt; 1) then
        call ReviveHero(Heroes<i>,GetRectCenterX(gg_rct_Region_001),GetRectCenterY(gg_rct_Region_001),true)
    elseif (i &gt;= 7) then
        call ReviveHero(Heroes<i>,GetRectCenterX(gg_rct_Region_002),GetRectCenterY(gg_rct_Region_002),true)
    endif
    
    if GetLocalPlayer() == p then
        call ClearSelection()
        call SelectUnit(Heroes<i>,true)        
        call PanCameraToTimed(GetUnitX(Heroes<i>),GetUnitY(Heroes<i>),1.00)
    endif
    
    call SetUnitState(Heroes<i>,UNIT_STATE_LIFE,GetUnitState(Heroes<i>,UNIT_STATE_MAX_LIFE))        
    call SetUnitState(Heroes<i>,UNIT_STATE_MANA,GetUnitState(Heroes<i>,UNIT_STATE_MAX_MANA))


    call DestroyTimer(t)    
    set t = null
endfunction   

//=======================================================================
private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player p = GetOwningPlayer(u)
    local integer i = GetPlayerId(p)

    
    set Timers<i> = CreateTimer()
    
    set Dialogs<i> = CreateTimerDialog(Timers<i>)
    //set d = CreateTimerDialog(Timers<i>)
    
    call TimerDialogDisplay(Dialogs<i>, true)
    call TimerDialogSetTitle(Dialogs<i>, &quot;Revive Time&quot;)
    call TimerDialogSetTitleColor(Dialogs<i>, PercentToInt(100,255), PercentToInt(0.00,255), PercentToInt(20.,255), PercentToInt(100.0-0,255))
       
    
    //call TimerDialogSetTitle(Dialogs<i>,&quot;Revive Time&quot;)    
    set Heroes<i> = u
    call TimerStart(Timers<i>,Interval(Heroes<i>),false,function Update)
    //call TriggerSleepAction(0.00)
    
   // if ShowAll then
      //  call TimerDialogDisplay(Dialogs<i>,true)
    //else
      //  if GetLocalPlayer() == p then
        //    call TimerDialogDisplay(Dialogs<i>,true)
       // endif
    //endif
endfunction

//=======================================================================
private function Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) == true 
endfunction

//=======================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(trig,Condition(function Conditions))
    call TriggerAddAction(trig,function Actions)
endfunction

endlibrary</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
Doesn't revive? I mostly just copied kenny's trigger and did some dialog work. If his revived, just copy my dialog edits into his without changing anything else.
 

Kenny

Back for now.
Reaction score
202
JASS:
library HeroDies initializer Init

globals   
    private constant boolean ShowAll = true // If true, it will show all death timers to everyone. Good for testing purposes.
    public timerdialog array Dialogs // Don&#039;t touch.
    public timer array Timers        // Don&#039;t touch.
    public unit array Heroes         // Don&#039;t touch.
endglobals

//=======================================================================
private function Interval takes unit u returns integer
    return GetHeroLevel(u)*4 // Revive time.
endfunction

//=======================================================================
private function Update takes nothing returns nothing   
    local timer t = GetExpiredTimer() 
    local player p
    local integer i = 0
    
    loop
        exitwhen Timers<i> == t or i == 15
        set i = i + 1
    endloop
    
    if i == 15 then
        set t = null
        return
    endif
    
    set p = GetOwningPlayer(Heroes<i>)    
    call PauseTimer(t)
    call DestroyTimerDialog(Dialogs<i>)
    
    if (i &lt;= 5 and i &gt; 1) then
        call ReviveHero(Heroes<i>,GetRectCenterX(gg_rct_Region_001),GetRectCenterY(gg_rct_Region_001),true)
    elseif (i &gt;= 7) then
        call ReviveHero(Heroes<i>,GetRectCenterX(gg_rct_Region_002),GetRectCenterY(gg_rct_Region_002),true)
    endif
    
    if GetLocalPlayer() == p then
        call ClearSelection()
        call SelectUnit(Heroes<i>,true)        
        call PanCameraToTimed(GetUnitX(Heroes<i>),GetUnitY(Heroes<i>),1.00)
    endif
    
    call SetUnitState(Heroes<i>,UNIT_STATE_LIFE,GetUnitState(Heroes<i>,UNIT_STATE_MAX_LIFE))        
    call SetUnitState(Heroes<i>,UNIT_STATE_MANA,GetUnitState(Heroes<i>,UNIT_STATE_MAX_MANA))


    call DestroyTimer(t)    
    set t = null
endfunction   

//=======================================================================
private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player p = GetOwningPlayer(u)
    local integer i = GetPlayerId(p)
    
    set Timers<i> = CreateTimer()
    set Dialogs<i> = CreateTimerDialog(Timers<i>)
    call TimerDialogSetTitle(Dialogs<i>,&quot;Revive Time&quot;)    
    set Heroes<i> = u
    call TimerStart(Timers<i>,Interval(Heroes<i>),false,function Update)
    call TriggerSleepAction(0.00)
    
    if ShowAll then
        call TimerDialogDisplay(Dialogs<i>,true)
    else
        if GetLocalPlayer() == p then
            call TimerDialogDisplay(Dialogs<i>,true)
        endif
    endif
endfunction

//=======================================================================
private function Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) == true 
endfunction

//=======================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(trig,Condition(function Conditions))
    call TriggerAddAction(trig,function Actions)
endfunction

endlibrary

</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>


That works as intended, I have tested it and everything is ok. Either you haven't specified to correct regions, or you changed the top boolean to false, which means if an enemy hero dies you cant see it.
 

Revengez

New Member
Reaction score
1
JASS:
library HeroDies initializer Init

globals   
    private constant boolean ShowAll = true // If true, it will show all death timers to everyone. Good for testing purposes.
    public timerdialog array Dialogs // Don&#039;t touch.
    public timer array Timers        // Don&#039;t touch.
    public unit array Heroes         // Don&#039;t touch.
endglobals

//=======================================================================
private function Interval takes unit u returns integer
    return GetHeroLevel(u)*4 // Revive time.
endfunction

//=======================================================================
private function Update takes nothing returns nothing   
    local timer t = GetExpiredTimer() 
    local player p
    local integer i = 0
    
    loop
        exitwhen Timers<i> == t or i == 15
        set i = i + 1
    endloop
    
    if i == 15 then
        set t = null
        return
    endif
    
    set p = GetOwningPlayer(Heroes<i>)    
    call PauseTimer(t)
    call DestroyTimerDialog(Dialogs<i>)
    
    if (i &lt;= 5 and i &gt; 1) then
        call ReviveHero(Heroes<i>,GetRectCenterX(gg_rct_Region_001),GetRectCenterY(gg_rct_Region_001),true)
    elseif (i &gt;= 7) then
        call ReviveHero(Heroes<i>,GetRectCenterX(gg_rct_Region_002),GetRectCenterY(gg_rct_Region_002),true)
    endif
    
    if GetLocalPlayer() == p then
        call ClearSelection()
        call SelectUnit(Heroes<i>,true)        
        call PanCameraToTimed(GetUnitX(Heroes<i>),GetUnitY(Heroes<i>),1.00)
    endif
    
    call SetUnitState(Heroes<i>,UNIT_STATE_LIFE,GetUnitState(Heroes<i>,UNIT_STATE_MAX_LIFE))        
    call SetUnitState(Heroes<i>,UNIT_STATE_MANA,GetUnitState(Heroes<i>,UNIT_STATE_MAX_MANA))


    call DestroyTimer(t)    
    set t = null
endfunction   

//=======================================================================
private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player p = GetOwningPlayer(u)
    local integer i = GetPlayerId(p)
    
    set Timers<i> = CreateTimer()
    set Dialogs<i> = CreateTimerDialog(Timers<i>)
    call TimerDialogSetTitle(Dialogs<i>,&quot;Revive Time&quot;)    
    set Heroes<i> = u
    call TimerStart(Timers<i>,Interval(Heroes<i>),false,function Update)
    call TriggerSleepAction(0.00)
    
    if ShowAll then
        call TimerDialogDisplay(Dialogs<i>,true)
    else
        if GetLocalPlayer() == p then
            call TimerDialogDisplay(Dialogs<i>,true)
        endif
    endif
endfunction

//=======================================================================
private function Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) == true 
endfunction

//=======================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(trig,Condition(function Conditions))
    call TriggerAddAction(trig,function Actions)
endfunction

endlibrary

</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>


That works as intended, I have tested it and everything is ok. Either you haven't specified to correct regions, or you changed the top boolean to false, which means if an enemy hero dies you cant see it.


For the Region_01 What do i switch this too? I don't understand. Shouldn't it be Region01 since that's its name?
 

Kenny

Back for now.
Reaction score
202
They have to have: gg_rct_ in front of their name, and it should then be: Region_001, with 2 0's.

so:

gg_rct_Region_001 and gg_rct_Region_002
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top