- Joined
- Feb 22, 2013
- Messages
- 161
Here are two separate triggers I made in GUI and converted to JASS, I can get rid of BJs easily, but merging and optimizing the trigger as one I don't fully understand, can I get some help with that?
Renew Casted:
Renew Loop:
Renew Casted:
JASS:
function Trig_Renew_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'RE00' ) ) then
return false
endif
return true
endfunction
function Trig_Renew_Func003C takes nothing returns boolean
if ( not ( udg_NewIndex >= 1 ) ) then
return false
endif
return true
endfunction
function Trig_Renew_Actions takes nothing returns nothing
set udg_NewIndex = ( udg_NewIndex + 1 )
set udg_TempTarget[udg_NewIndex] = GetSpellTargetUnit()
if ( Trig_Renew_Func003C() ) then
call TimerStart(udg_RenewTimer, 1.00, true, null )
else
endif
endfunction
//===========================================================================
function InitTrig_Renew takes nothing returns nothing
set gg_trg_Renew = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Renew, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Renew, Condition( function Trig_Renew_Conditions ) )
call TriggerAddAction( gg_trg_Renew, function Trig_Renew_Actions )
endfunction
Renew Loop:
JASS:
function Trig_Renew_Loop_Func002Func003C takes nothing returns boolean
if ( not ( udg_RenewCount[udg_CurrentIndex] == 10 ) ) then
return false
endif
return true
endfunction
function Trig_Renew_Loop_Actions takes nothing returns nothing
set udg_CurrentIndex = 1
loop
exitwhen udg_CurrentIndex > udg_NewIndex
set udg_RenewCount[udg_CurrentIndex] = ( udg_RenewCount[udg_CurrentIndex] + 1 )
call SetUnitLifeBJ( udg_TempTarget[udg_CurrentIndex], ( GetUnitStateSwap(UNIT_STATE_LIFE, udg_TempTarget[udg_CurrentIndex]) + 20.00 ) )
if ( Trig_Renew_Loop_Func002Func003C() ) then
set udg_TempTarget[udg_CurrentIndex] = null
set udg_CurrentIndex = ( udg_CurrentIndex - 1 )
else
endif
set udg_CurrentIndex = udg_CurrentIndex + 1
endloop
endfunction
//===========================================================================
function InitTrig_Renew_Loop takes nothing returns nothing
set gg_trg_Renew_Loop = CreateTrigger( )
call TriggerRegisterTimerExpireEventBJ( gg_trg_Renew_Loop, udg_RenewTimer )
call TriggerAddAction( gg_trg_Renew_Loop, function Trig_Renew_Loop_Actions )
endfunction