JASS:
scope SEF initializer InitTrig_SEF
globals
boolean array SB
boolean array EB
boolean array FB
unit array SU
unit array EU
unit array FU
unit array SEF_U
real array SEF_X
real array SEF_Y
timer array SEF_T
integer array SEF_C
integer array TC
endglobals
private function PeriodicCheck takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local unit c = LoadUnitHandle(udg_Table, id, 'cast')
local unit u = LoadUnitHandle(udg_Table, id, 'targ')
local integer i = GetPlayerId(GetOwningPlayer(c))
set TC[i] = TC[i] + 1
if TC[i] >= 20 or IsUnitDeadBJ(c) or IsUnitDeadBJ(u) then
call DestroyLightning(LoadLightningHandle(udg_Table, id, 'ligh'))
endif
set t = null
set c = null
set u = null
endfunction
function SEF_Init takes unit u, unit c returns nothing
local timer t = GetFreeTimer()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real xc = GetUnitX(c)
local real yc = GetUnitY(c)
local integer id = GetHandleId(t)
call SaveLightningHandle(udg_Table, id, 'ligh', AddLightning("SPLK", true, x, y, xc, yc))
call SaveUnitHandle(udg_Table, id, 'cast', c)
call SaveUnitHandle(udg_Table, id, 'targ', u)
call SetUnitFacing( u, bj_RADTODEG*Atan2(yc-y,xc-x))
call PauseUnit( u , true )
call TimerStart( t, 0.10, true, function PeriodicCheck)
endfunction
function SEF_Check takes nothing returns boolean
local unit c = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local integer utid = GetUnitTypeId(t)
local player p = GetOwningPlayer(c)
local integer i = GetPlayerId(p)
call BJDebugMsg("ran")
if GetSpellAbilityId() == 'A02J' then
if utid == 'odoc' then
call ShowB(FB[i])
if not FB[i] then
set FU[i] = t
set FB[i] = true
call SEF_Init(t, c)
else
call DisplayTextToPlayer(p, 0, 0, "You already have a chosen caster for the Fire part of the spell.")
endif
elseif utid == 'oshm' then
if not SB[i] then
set SU[i] = t
set SB[i] = true
call SEF_Init(t, c)
else
call DisplayTextToPlayer(p, 0, 0, "You already have a chosen caster for the Storm part of the spell.")
endif
elseif utid == 'ospw' then
if not EB[i] then
set EU[i] = t
set EB[i] = true
call SEF_Init(t, c)
else
call DisplayTextToPlayer(p, 0, 0, "You already have a chosen caster for the Earth part of the spell.")
endif
endif
endif
set c = null
set t = null
set p = null
return false
endfunction
//function Trig_TEST_Actions takes nothing returns nothing
// call UnitRemoveAbilityBJ( 'A02J', gg_unit_o000_0181 )
// call UnitAddAbilityBJ( 'A02J', gg_unit_o000_0181 )
//endfunction
//==============================================================================
function InitTrig_SEF takes nothing returns nothing
local integer i = 0
set gg_trg_SEF = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SEF, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_SEF, Condition( function SEF_Check ) )
loop
exitwhen i > 11
set SB[i] = false
set EB[i] = false
set FB[i] = false
set i = i + 1
endloop
endfunction
endscope
When I cast it - I get "ran", "false", "ran", "true".
Any idea why is this happening? x_x
The spell is based on Channel.
EDIT: I must be cursed.... Every time I post an issue with my triggers - I discover what's wrong by myself after few minutes.
Apparently it was getting initialized 2-ce, since I had "initializer InitTrig_SEF" in the top row.
This is the 1-st trigger in which I'm using a scope (and an initializer).
So now I wanna ask, what are initializers used for if people can just use "InitTrig_" in their scopes?