[JASS] Respawning a Unit. Can't think of a good, simple way.

Status
Not open for further replies.
Level 14
Joined
Jul 26, 2008
Messages
1,009
JASS:
scope RespawnCitizens initializer Init requires AutoIndex

globals
    private real array X
    private real array Y
endglobals

private function Actions takes nothing returns nothing
    if GetOwningPlayer(GetTriggerUnit()) == Player(8) then
        call BJDebugMsg("Gray Dies")
        if GetUnitTypeId(GetTriggerUnit()) == 'nvlw' then
            set X[GetUnitId(GetTriggerUnit())] = GetUnitX(GetTriggerUnit())
            set Y[GetUnitId(GetTriggerUnit())] = GetUnitY(GetTriggerUnit())
            call BJDebugMsg("Gray Woman Dies")
            call TriggerSleepAction(22)
            call BJDebugMsg("Gray Woman Revives @ "+R2S(X[GetUnitId(GetTriggerUnit())])+" "+R2S(Y[GetUnitId(GetTriggerUnit())]))
            call CreateUnit(Player(8), 'nvlw', X[GetUnitId(GetTriggerUnit())], Y[GetUnitId(GetTriggerUnit())], GetRandomReal(0,360))
        elseif GetUnitTypeId(GetTriggerUnit()) == 'nvil' then
            set X[GetUnitId(GetTriggerUnit())] = GetUnitX(GetTriggerUnit())
            set Y[GetUnitId(GetTriggerUnit())] = GetUnitY(GetTriggerUnit())
            call TriggerSleepAction(190)
            call CreateUnit(Player(8), 'nvil', X[GetUnitId(GetTriggerUnit())], Y[GetUnitId(GetTriggerUnit())], GetRandomReal(0,360))
        elseif GetUnitTypeId(GetTriggerUnit()) == 'nvl2' then
            set X[GetUnitId(GetTriggerUnit())] = GetUnitX(GetTriggerUnit())
            set Y[GetUnitId(GetTriggerUnit())] = GetUnitY(GetTriggerUnit())
            call TriggerSleepAction(220)
            call CreateUnit(Player(8), 'nvl2', X[GetUnitId(GetTriggerUnit())], Y[GetUnitId(GetTriggerUnit())], GetRandomReal(0,360))
        elseif GetUnitTypeId(GetTriggerUnit()) == 'nvlk' then
            set X[GetUnitId(GetTriggerUnit())] = GetUnitX(GetTriggerUnit())
            set Y[GetUnitId(GetTriggerUnit())] = GetUnitY(GetTriggerUnit())
            call TriggerSleepAction(170)
            call CreateUnit(Player(8), 'nvlk', X[GetUnitId(GetTriggerUnit())], Y[GetUnitId(GetTriggerUnit())], GetRandomReal(0,360))
        elseif GetUnitTypeId(GetTriggerUnit()) == 'hmpr' then
            set X[GetUnitId(GetTriggerUnit())] = GetUnitX(GetTriggerUnit())
            set Y[GetUnitId(GetTriggerUnit())] = GetUnitY(GetTriggerUnit())
            call TriggerSleepAction(190)
            call CreateUnit(Player(8), 'hmpr', X[GetUnitId(GetTriggerUnit())], Y[GetUnitId(GetTriggerUnit())], GetRandomReal(0,360))
        elseif GetUnitTypeId(GetTriggerUnit()) == 'HC37' then
            set X[GetUnitId(GetTriggerUnit())] = GetUnitX(GetTriggerUnit())
            set Y[GetUnitId(GetTriggerUnit())] = GetUnitY(GetTriggerUnit())
            call TriggerSleepAction(300)
            call ReviveHero(GetTriggerUnit(), X[GetUnitId(GetTriggerUnit())], Y[GetUnitId(GetTriggerUnit())], true)
        endif
    endif
endfunction

//===========================================================================
public function Init takes nothing returns nothing
 local trigger t = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( t, Player(8), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( t, function Actions )
 set t= null
endfunction

endscope

Arlight so I realize this doesn't work because the unit is removed from the system by the time the respawn trigger finishes it's wait.

So what I need is a way to save the coordinates of that unit easily and then reference them after the way timer. It seems extremelly simple, and yet I can't think of any way to do it, as I can't think of a proper way to attach a the data to a handle and then reference it again.

I COULD create a dummy unit and attach data to that, but it seems like there's an easier way. Suggestions?

EDIT: Decided to just use Timerutils.
 
Last edited:
Status
Not open for further replies.
Top