I doubt there is a problem with this system as many people use it, but i found an odd problem with it. Here are my base functions for it:
Now, whenever i run the spell, the timers return in a weird way.
So lets say d.t is started after 2.5 seconds.
MeteoritesStructs is an array that is declared in a previous function to use multiple data structs.
Now here's the problem:
In the actual spell in-game, I see: reg0, reg1, reg2, and then I see it recycling.. going back to reg0 again. How the hell is that possible?
What makes me think its a NewTimer() problem, is that if I use CreateTimer(), it runs fine and doesnt get reset, its supposed to show reg* until reg8.
Any idea?
Code:
function NewTimer takes nothing returns timer
if (TIMERS_N==0) then
return CreateTimer()
endif
set TIMERS_N = TIMERS_N - 1
return TIMERS[TIMERS_N]
endfunction
function ReleaseTimer takes timer t returns nothing
call PauseTimer(t)
set TIMERS[TIMERS_N] = t
set TIMERS_N = TIMERS_N + 1
endfunction
Now, whenever i run the spell, the timers return in a weird way.
Code:
function SpawnMeteorites takes nothing returns nothing
local unit u = gg_unit_Hblm_0270
local player p = GetOwningPlayer(u)
local unit m=null
local integer i=var_MeteoritesSpawned
local MeteoritesData d=MeteoritesStructs[i]
if var_MeteoritesSpawned < var_MeteoritesMaxSpawned and GetUnitCurrentOrder(u) == 852503 then
set var_MeteoritesSpawned=var_MeteoritesSpawned+1
set m=d.m
set d.m=null
set d.ma=m
set d.t=NewTimer()
call TimerStart(d.t,2.5,false,function InitMeteorites)
So lets say d.t is started after 2.5 seconds.
MeteoritesStructs is an array that is declared in a previous function to use multiple data structs.
Now here's the problem:
Code:
function InitMeteorites takes nothing returns nothing
local integer i=0
local MeteoritesData d
loop
set d=MeteoritesStructs[i]
exitwhen i>8 or GetExpiredTimer()==d.t
set i=i+1
endloop
[B][I][U]call DebugMsg("reg"+I2S(i))[/U][/I][/B]
In the actual spell in-game, I see: reg0, reg1, reg2, and then I see it recycling.. going back to reg0 again. How the hell is that possible?
What makes me think its a NewTimer() problem, is that if I use CreateTimer(), it runs fine and doesnt get reset, its supposed to show reg* until reg8.
Any idea?