Hello, I just made my second spell in JASS and I was wondering what I can do to improve my triggering. This spell is called Burrow Strike and what it does is the Crypt Lord burrows into the ground and becomes undetected, when you order the Crypt Lord to move he will move to the point and impales units behind him. The skill is based on Wind Walk.
JASS:
function Trig_BurrowStrike_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A001039;
endfunction
function Trig_BurrowStrike_Actions takes nothing returns nothing
set udg_Caster = GetTriggerUnit()
call UnitAddAbility( udg_Caster, 039;Abun039; )
call IssueImmediateOrder( udg_Caster, "holdposition" )
call SetUnitAnimation( udg_Caster, "morph" )
endfunction
//===========================================================================
function InitTrig_BurrowStrike takes nothing returns nothing
local integer index
set gg_trg_BurrowStrike = CreateTrigger( )
set index = 0
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_BurrowStrike, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition( gg_trg_BurrowStrike, Condition( function Trig_BurrowStrike_Conditions ) )
call TriggerAddAction( gg_trg_BurrowStrike, function Trig_BurrowStrike_Actions )
endfunction
JASS:
function Trig_BurrowStriking_Conditions takes nothing returns boolean
return GetTriggerUnit() == udg_Caster
endfunction
function Distance takes location l, location m returns real
local real dx = GetLocationX(m) - GetLocationX(l)
local real dy = GetLocationY(m) - GetLocationY(l)
return SquareRoot(dx * dx + dy * dy)
endfunction
function Trig_BurrowStriking_Actions takes nothing returns nothing
local location l = GetUnitLoc(udg_Caster)
local location m = GetOrderPointLoc()
local real a = -100.00
local real x = GetLocationX(l) + a * Cos(Distance( l, m ) * bj_DEGTORAD)
local real y = GetLocationY(l) + a * Sin(Distance( l, m ) * bj_DEGTORAD)
local real i = 600.00
call UnitRemoveAbility( udg_Caster, 039;Abun039; )
if GetUnitAbilityLevel( udg_Caster, 039;A001039; ) == 2 then
set i = 700.00
elseif GetUnitAbilityLevel( udg_Caster, 039;A001039; ) == 3 then
set i = 800.00
endif
if Distance( l, m ) >= i then
set m = PolarProjectionBJ( l, i, AngleBetweenPoints( l, m))
endif
call CreateNUnitsAtLoc( 1, 039;h000039;, GetOwningPlayer(udg_Caster), Location( x,y ), GetUnitFacing(udg_Caster) )
call UnitAddAbility( GetLastCreatedUnit(), 039;A000039; )
call SetUnitAbilityLevelSwapped( 039;A000039;, GetLastCreatedUnit(), R2I(Distance( l, m )) / 100 )
call IssuePointOrder( GetLastCreatedUnit(), "impale", GetLocationX(m), GetLocationY(m) )
call TriggerSleepAction( Distance( l, m ) / 4000.00 )
call SetUnitPositionLoc( udg_Caster, m )
call SetUnitAnimation( udg_Caster, "morph defend" )
call UnitRemoveAbility( udg_Caster, 039;B000039; )
call RemoveLocation(l)
call RemoveLocation(m)
set x = 0.00
set y = 0.00
set i = 0.00
set l = null
set m = null
set udg_Caster = null
endfunction
//===========================================================================
function InitTrig_BurrowStriking takes nothing returns nothing
local integer index
set gg_trg_BurrowStriking = CreateTrigger( )
set index = 0
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_BurrowStriking, Player(index), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null)
call TriggerRegisterPlayerUnitEvent(gg_trg_BurrowStriking, Player(index), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition( gg_trg_BurrowStriking, Condition( function Trig_BurrowStriking_Conditions ) )
call TriggerAddAction( gg_trg_BurrowStriking, function Trig_BurrowStriking_Actions )
endfunction