I created my first trigger in JASS. Actually I converted it from GUI trigger, but I added local variables and used timer instead of wait. At first there were of course some errors, but I fixed them. Then I thought to make that trigger local instead of local, well, then the WE crashed. I can't find any mistakes from my code, so I don't know what's wrong. Here's the code
Inside the loops everything is allright. *Before it crashed, it said there was an error. Why does WE crash?
Code:
function Cond takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A039' ) ) then
return false
endif
return true
endfunction
function Trig_Tri_Attack_Func004Func001Func005C takes nothing returns boolean
if ( not ( GetHeroLevel(GetTriggerUnit()) >= 60 ) ) then
return false
endif
return true
endfunction
function Trig_Tri_Attack_Func004Func001Func006C takes nothing returns boolean
if ( not ( GetHeroLevel(GetTriggerUnit()) >= 80 ) ) then
return false
endif
return true
endfunction
function Trig_Tri_Attack_Func004Func002Func005C takes nothing returns boolean
if ( not ( GetHeroLevel(GetTriggerUnit()) >= 60 ) ) then
return false
endif
return true
endfunction
function Trig_Tri_Attack_Func004Func002Func006C takes nothing returns boolean
if ( not ( GetHeroLevel(GetTriggerUnit()) >= 80 ) ) then
return false
endif
return true
endfunction
function Trig_Tri_Attack_Func004Func003Func005C takes nothing returns boolean
if ( not ( GetHeroLevel(GetTriggerUnit()) >= 60 ) ) then
return false
endif
return true
endfunction
function Trig_Tri_Attack_Func004Func003Func006C takes nothing returns boolean
if ( not ( GetHeroLevel(GetTriggerUnit()) >= 80 ) ) then
return false
endif
return true
endfunction
function Trig_Tri_Attack_Actions takes nothing returns nothing
local unit u
set u = GetTriggerUnit()
set bj_forLoopBIndex = 1
set bj_forLoopBIndexEnd = 10
loop
exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd
call CreateNUnitsAtLoc( 1, 'n000', GetOwningPlayer(u), PolarProjectionBJ(GetUnitLoc(u), ( 400.00 - ( 40.00 * I2R(GetForLoopIndexB()) ) ), ( 0.00 + ( 10.00 * I2R(GetForLoopIndexA()) ) )), bj_UNIT_FACING )
call UnitApplyTimedLifeBJ( 5.00, 'BTLF', GetLastCreatedUnit() )
call ShowUnitHide( GetLastCreatedUnit() )
call UnitAddAbilityBJ( 'A03E', GetLastCreatedUnit() )
if ( Trig_Tri_Attack_Func004Func001Func005C() ) then
call IncUnitAbilityLevelSwapped( 'A03E', GetLastCreatedUnit() )
else
endif
if ( Trig_Tri_Attack_Func004Func001Func006C() ) then
call IncUnitAbilityLevelSwapped( 'A03E', GetLastCreatedUnit() )
else
endif
call IssueImmediateOrderBJ( GetLastCreatedUnit(), "fanofknives" )
set bj_forLoopBIndex = bj_forLoopBIndex + 1
endloop
set bj_forLoopBIndex = 1
set bj_forLoopBIndexEnd = 10
loop
exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd
call CreateNUnitsAtLoc( 1, 'n000', GetOwningPlayer(u), PolarProjectionBJ(GetUnitLoc(u), ( 400.00 - ( 40.00 * I2R(GetForLoopIndexB()) ) ), ( 120.00 + ( 10.00 * I2R(GetForLoopIndexA()) ) )), bj_UNIT_FACING )
call UnitApplyTimedLifeBJ( 5.00, 'BTLF', GetLastCreatedUnit() )
call ShowUnitHide( GetLastCreatedUnit() )
call UnitAddAbilityBJ( 'A03F', GetLastCreatedUnit() )
if ( Trig_Tri_Attack_Func004Func002Func005C() ) then
call IncUnitAbilityLevelSwapped( 'A03F', GetLastCreatedUnit() )
else
endif
if ( Trig_Tri_Attack_Func004Func002Func006C() ) then
call IncUnitAbilityLevelSwapped( 'A03F', GetLastCreatedUnit() )
else
endif
call IssueImmediateOrderBJ( GetLastCreatedUnit(), "fanofknives" )
set bj_forLoopBIndex = bj_forLoopBIndex + 1
endloop
set bj_forLoopBIndex = 1
set bj_forLoopBIndexEnd = 10
loop
exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd
call CreateNUnitsAtLoc( 1, 'n000', GetOwningPlayer(u), PolarProjectionBJ(GetUnitLoc(u), ( 400.00 - ( 40.00 * I2R(GetForLoopIndexB()) ) ), ( 240.00 + ( 10.00 * I2R(GetForLoopIndexA()) ) )), bj_UNIT_FACING )
call UnitApplyTimedLifeBJ( 5.00, 'BTLF', GetLastCreatedUnit() )
call ShowUnitHide( GetLastCreatedUnit() )
call UnitAddAbilityBJ( 'A03D', GetLastCreatedUnit() )
if ( Trig_Tri_Attack_Func004Func003Func005C() ) then
call IncUnitAbilityLevelSwapped( 'A03D', GetLastCreatedUnit() )
else
endif
if ( Trig_Tri_Attack_Func004Func003Func006C() ) then
call IncUnitAbilityLevelSwapped( 'A03D', GetLastCreatedUnit() )
else
endif
call IssueImmediateOrderBJ( GetLastCreatedUnit(), "fanofknives" )
set bj_forLoopBIndex = bj_forLoopBIndex + 1
endloop
set u = null
endfunction
function Timer takes nothing returns nothing
local timer t
set t = CreateTimer()
call TimerStart(t,0.01,true,function Trig_Tri_Attack_Actions)
call TriggerSleepAction(10.00)
call DestroyTimer(t)
[B]set t = null[/B] *
andfunction
function InitTrig_trigger takes nothing returns nothing
local trigger t
set t= CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Cond))
call TriggerAddAction(t, function Timer)
endfunction