globals
List instances
integer debugCounter = 0
endglobals
struct Rebirth
static constant integer DUMMY_TYPE = 'h000'
static constant real DUMMY_DURATION = 5
static constant string respawnEffect = "Abilities\\Spells\\Items\\AIsm\\AIsmTarget.mdl"
integer u
unit deadUnit
location l
real counter
unit egg
static method onInit takes nothing returns nothing
set instances = List.create()
endmethod
static method create takes unit u returns thistype
local thistype this = thistype.allocate()
set this.u = GetUnitTypeId(u)
set this.counter = 0
set this.deadUnit = u
set this.l = GetUnitLoc(u)
set this.egg = CreateUnitAtLoc(GetOwningPlayer(u), DUMMY_TYPE, this.l, 0)
call instances.Add(this)
return this
endmethod
method destroy takes nothing returns nothing
set this.u = 0
call RemoveLocation(this.l)
call instances.Remove(this)
call this.deallocate()
endmethod
method Update takes nothing returns nothing
set debugCounter = debugCounter + 1
set this.counter = this.counter + 0.03
if this.counter > DUMMY_DURATION then
call KillUnit(this.egg)
call AddSpecialEffectLoc(respawnEffect, this.l)
if IsUnitIdType(this.u, UNIT_TYPE_HERO) == false then
call CreateUnitAtLoc(Player(0), this.u, this.l, 0)
call this.destroy()
else
call ReviveHeroLoc(this.deadUnit, this.l, false)
call this.destroy()
endif
endif
endmethod
endstruct