Hello,
Want to respawn my "creeps" when it dies after 3 seconds and unsure about the best approach. I have the TimerQueue lib, and this is how I do it currently (is it leaking because I don't destroy the timer?)
Want to respawn my "creeps" when it dies after 3 seconds and unsure about the best approach. I have the TimerQueue lib, and this is how I do it currently (is it leaking because I don't destroy the timer?)
Lua:
if Debug and Debug.beginFile then Debug.beginFile("Main") end
OnInit.final("Main", function()
function RaccoonRespawnInit()
trig = CreateTrigger()
TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_DEATH)
TriggerAddAction(trig, function ()
u = GetDyingUnit()
uid = GetUnitTypeId(u)
if uid == FourCC('m000') then
TimerQueue:callDelayed(3, function ()
CreateUnit(Player(11), FourCC('m000'), GetRectRandomX(gg_rct_RaccoonSpawn1), GetRectRandomY(gg_rct_RaccoonSpawn1), 0)
end)
elseif uid == FourCC('m001') then
TimerQueue:callDelayed(3, function ()
CreateUnit(Player(11), FourCC('m001'), GetRectRandomX(gg_rct_RaccoonSpawn2), GetRectRandomY(gg_rct_RaccoonSpawn2), 0)
end)
end
end)
end
function CreateRaccoonsLoop()
for i = 1, 12 do
CreateUnit(Player(11), FourCC('m000'), GetRectRandomX(gg_rct_RaccoonSpawn1), GetRectRandomY(gg_rct_RaccoonSpawn1), 0)
CreateUnit(Player(11), FourCC('m001'), GetRectRandomX(gg_rct_RaccoonSpawn2), GetRectRandomY(gg_rct_RaccoonSpawn2), 0)
end
end
CreateRaccoonsLoop()
RaccoonRespawnInit()
end)
if Debug and Debug.endFile then Debug.endFile() end