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

A revive timmer

Status
Not open for further replies.
Level 5
Joined
Jun 27, 2010
Messages
73
Im very noobish when it comes to triggers. Can some1 please create me a map with a Resurrection triggers, like 1 similar to Hero line wars.

Example: When a hero dies. A timer comes up counting down from 30 seconds when it gets to zero the hero revives. But i want the timer to be different for each player hero so they dont get confuse like example: Purple Hero.
 
Level 8
Joined
Apr 23, 2010
Messages
312
I'm not sure what a Hero Line Wars revival timer looks like, but here's one I made. The higher level of the hero that dies means a longer waiting period. You can take it out if you want.

  • Hero Revival
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set DeadHero[(Player number of (Owner of (Dying unit)))] = (Dying unit)
      • Countdown Timer - Create a timer window for RevivalTimer with title (Name of (Owner of (Dying unit)))
      • Set RevivalPlayer[(Player number of (Owner of (Dying unit)))] = (Last created timer window)
      • Countdown Timer - Start RevivalTimer as a One-shot timer that will expire in (5.00 + ((Real((Hero level of (Dying unit)))) x 2.00)) seconds
      • Wait (4.50 + ((Real((Hero level of (Triggering unit)))) x 2.00)) seconds
      • Countdown Timer - Destroy RevivalPlayer[(Player number of (Owner of (Dying unit)))]
      • Wait 0.50 seconds
      • Hero - Instantly revive DeadHero[(Player number of (Owner of (Dying unit)))] at (Center of (Playable map area)), Show revival graphics
      • Unit - Set life of DeadHero[(Player number of (Owner of (Dying unit)))] to 85.00%
      • Unit - Set mana of DeadHero[(Player number of (Owner of (Dying unit)))] to 85.00%
 
Level 13
Joined
Oct 25, 2009
Messages
995
I'm not sure what a Hero Line Wars revival timer looks like, but here's one I made. The higher level of the hero that dies means a longer waiting period. You can take it out if you want.

  • Hero Revival
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set DeadHero[(Player number of (Owner of (Dying unit)))] = (Dying unit)
      • Countdown Timer - Create a timer window for RevivalTimer with title (Name of (Owner of (Dying unit)))
      • Set RevivalPlayer[(Player number of (Owner of (Dying unit)))] = (Last created timer window)
      • Countdown Timer - Start RevivalTimer as a One-shot timer that will expire in (5.00 + ((Real((Hero level of (Dying unit)))) x 2.00)) seconds
      • Wait (4.50 + ((Real((Hero level of (Triggering unit)))) x 2.00)) seconds
      • Countdown Timer - Destroy RevivalPlayer[(Player number of (Owner of (Dying unit)))]
      • Wait 0.50 seconds
      • Hero - Instantly revive DeadHero[(Player number of (Owner of (Dying unit)))] at (Center of (Playable map area)), Show revival graphics
      • Unit - Set life of DeadHero[(Player number of (Owner of (Dying unit)))] to 85.00%
      • Unit - Set mana of DeadHero[(Player number of (Owner of (Dying unit)))] to 85.00%

Leaks and not MUI,just check the mckill2009's smell Like DotA :p
 
Level 7
Joined
Jul 3, 2011
Messages
251
Solution

Use this; replace l where you want the hero to revive, and after 30 seconds he will revive there.

JASS:
function Trig_MUI_Revive_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_MUI_Revive_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local player p = GetOwningPlayer(GetTriggerUnit())
    local unit u = GetTriggerUnit()
    local location l = GetUnitLoc(GetTriggerUnit())
    local timerdialog w
    call StartTimerBJ( t, false, 30 )
    set t = GetLastCreatedTimerBJ()
    call CreateTimerDialogBJ( t, GetPlayerName(p) )
    set w = GetLastCreatedTimerDialogBJ()
    call TriggerSleepAction( 30.00 )
    call ReviveHeroLoc( u, l, true )
    call SetUnitLifeBJ( u, GetUnitStateSwap(UNIT_STATE_MAX_LIFE, u) )
    call SetUnitManaBJ( u, GetUnitStateSwap(UNIT_STATE_MAX_MANA, u) )
    call DestroyTimerDialogBJ( w )
    set l = null
    set u = null
    set p = null
    set t = null
endfunction

//===========================================================================
function InitTrig_MUI_Revive takes nothing returns nothing
    set gg_trg_MUI_Revive = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_MUI_Revive, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_MUI_Revive, Condition( function Trig_MUI_Revive_Conditions ) )
    call TriggerAddAction( gg_trg_MUI_Revive, function Trig_MUI_Revive_Actions )
endfunction
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
D.O.N.T U.S.E trigger above.
Zaio, have you just converted GUI yo jass and.. thats it? It's inefficient, leaking and full of BJ jass code.

Condition:
JASS:
// Instead of this ugly function
function Trig_MUI_Revive_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction
// Use
function Trig_MUI_Revive_Conditions takes nothing returns boolean
    return IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == true
endfunction

Other replacements:
JASS:
// Instead of StartTimerBJ:
native TimerStart           takes timer whichTimer, real timeout, boolean periodic, code handlerFunc returns nothing

// SetUnitLifeBJ:
native          SetUnitState        takes unit whichUnit, unitstate whichUnitState, real newVal returns nothing
// Or:
native  SetWidgetLife   takes widget whichWidget, real newLife returns nothing

// SetUnitManaBJ:
native          SetUnitState        takes unit whichUnit, unitstate whichUnitState, real newVal returns nothing
Also, timers are used for executing given function on expiration, and you have used TriggerSleepAction what is totaly not MUI.

Mostly, calling function with revive using timer it should require additional loop (on expire) function.
Fixed trigger (still revives hero after 30 seconds):

JASS:
function GetDelay takes nothing returns real
    return 30.00
endfunction

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

function Loop takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer id = GetHandleId(t)
    local real x = LoadReal(udg_Hash, id, 1)
    local real y = LoadReal(udg_Hash, id, 2)
    local unit u = LoadUnitHandle(udg_Hash, id, 3)
    call ReviveHero(u, x, y, true)
    call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_MAX_LIFE)
    call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MAX_MANA)
    call PauseTimer(t)
    call DestroyTimer(t)
    call FlushChildHashtable(udg_Hash, id)
    set u = null
    set t = null
endfunction

function Trig_MUI_Revive_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local integer id = GetHandleId(t)
    local unit u = GetTriggerUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    call SaveReal(udg_Hash, id, 1, x)
    call SaveReal(udg_Hash, id, 2, y)
    call SaveUnitHandle(udg_Hash, id, 3, u)
    call TimerStart(t, GetDelay, false, function Loop)
    set u = null
    set t = null
endfunction

function InitTrig_MUI_Revive takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( t, Condition( function Trig_MUI_Revive_Conditions ) )
    call TriggerAddAction( t, function Trig_MUI_Revive_Actions )
    set udg_Hash = InitHashtable()
    set t = null
endfunction
 
Level 1
Joined
Aug 5, 2011
Messages
1
I tried setting it up like a few ways above but when I test map with enemy hero, he respawns in the same spot I do while we are on opposing forces? can anyone help?
 
Status
Not open for further replies.
Top