Hi,
after learning the basics of timer, i tried to create a trigger using periodic timers.
When unit x enters playable map area, it will count down a timer (just for testing) and it works for me. If i create 2 units, it will create 2 indipendent timers.
My question is: wouldnt it be better to run 1 timer that covers both units?
after learning the basics of timer, i tried to create a trigger using periodic timers.
When unit x enters playable map area, it will count down a timer (just for testing) and it works for me. If i create 2 units, it will create 2 indipendent timers.
My question is: wouldnt it be better to run 1 timer that covers both units?
JASS:
struct NuclearBomb extends array
unit Bomb
integer Time
endstruct
function Nuclear_Bomb_Timed takes nothing returns nothing
local timer t = GetExpiredTimer()
local NuclearBomb data = GetTimerData(t)
local unit u = data.Bomb
if (GetUnitState(u, UNIT_STATE_LIFE) > 0) then
set data.Time = data.Time - 1
call BJDebugMsg(GetUnitName(u) + ": " + I2S(data.Time))
else
call ReleaseTimer(t)
endif
set t = null
set u = null
endfunction
function Trig_Nuclear_Bomb_Conditions takes nothing returns boolean
local NuclearBomb data
local unit u = GetTriggerUnit()
if (GetUnitTypeId(u) == 'n005') then
set data = GetUnitUserData(u)
set data.Bomb = u
set data.Time = 50
call UnitApplyTimedLife(u, 'BTLF', 50.00)
call TimerStart(NewTimerEx(data), 1.00, true, function Nuclear_Bomb_Timed)
set u = null
endif
return false
endfunction
//===========================================================================
function InitTrig_Nuclear_Bomb takes nothing returns nothing
local region r = CreateRegion()
call RegionAddRect(r, bj_mapInitialPlayableArea)
set gg_trg_Nuclear_Bomb = CreateTrigger()
call TriggerRegisterEnterRegion(gg_trg_Nuclear_Bomb, r, null)
call TriggerAddCondition(gg_trg_Nuclear_Bomb, Condition(function Trig_Nuclear_Bomb_Conditions))
set r = null
endfunction