Im currently learning JASS and i just convert one of my GUI trigger into JASS. I wanna know how I can change it to make it MUI and clear useless stuff (I can see some but I dunno how to). I had an array in GUI to simulate MUI and i know its useless if I can use locals. Plz help.
JASS:
function Trig_Multi_Lightning_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A05Z'
endfunction
function Trig_Multi_Lightning_1 takes nothing returns boolean
return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_MultiLightningCaster[udg_randomML])) == true )
endfunction
function Trig_Multi_Lightning_2 takes nothing returns boolean
return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction
function Trig_Multi_Lightning_3 takes nothing returns boolean
return GetBooleanAnd( Trig_Multi_Lightning_1(), Trig_Multi_Lightning_2() )
endfunction
function Trig_Multi_Lightning_Actions takes nothing returns nothing
set udg_randomML = GetRandomInt(1, 1000)
set udg_MultiLightningCaster[udg_randomML] = GetSpellAbilityUnit()
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 10
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
call CreateNUnitsAtLoc( 1, 'h00A', GetOwningPlayer(udg_MultiLightningCaster[udg_randomML]), GetUnitLoc(udg_MultiLightningCaster[udg_randomML]), bj_UNIT_FACING )
call UnitApplyTimedLifeBJ( 2.00, 'BTLF', GetLastCreatedUnit() )
call UnitAddAbilityBJ( 'A05Y', GetLastCreatedUnit() )
call SetUnitAbilityLevelSwapped( 'A05Y', GetLastCreatedUnit(), GetRandomInt(1, 100) )
call IssueTargetOrderBJ( GetLastCreatedUnit(), "chainlightning", GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(( 100.00 * I2R(GetForLoopIndexA()) ), GetUnitLoc(udg_MultiLightningCaster[udg_randomML]), Condition(function Trig_Multi_Lightning_3))) )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
endfunction
//=====================================
function InitTrig_Multi_Lightning takes nothing returns nothing
local trigger t
set t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Multi_Lightning, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Multi_Lightning, Condition( function Trig_Multi_Lightning_Conditions ) )
call TriggerAddAction( gg_trg_Multi_Lightning, function Trig_Multi_Lightning_Actions )
set t = null
call DestroyTrigger(t)
endfunction
Last edited: