Is triggering good?

l1lshadow

New Member
Reaction score
4
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() == 'A001'
endfunction

function Trig_BurrowStrike_Actions takes nothing returns nothing
    set udg_Caster = GetTriggerUnit()
    call UnitAddAbility( udg_Caster, 'Abun' )
    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, 'Abun' )

     if GetUnitAbilityLevel( udg_Caster, 'A001' ) == 2 then
      set i = 700.00
      elseif GetUnitAbilityLevel( udg_Caster, 'A001' ) == 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, 'h000', GetOwningPlayer(udg_Caster), Location( x,y ), GetUnitFacing(udg_Caster) )
    call UnitAddAbility( GetLastCreatedUnit(), 'A000' )
    call SetUnitAbilityLevelSwapped( 'A000', 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, 'B000' )
    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
 

Exide

I am amazingly focused right now!
Reaction score
448
This should be posted in the JASS forum.

You should remove as many Locations as you can, and use Coordinates (X,Y) instead. Start by getting rid of 'function Distance ...', and replace it with coordinates. It will help a lot in the rest of the trigger.

You should get rid of BJs, such as SetUnitAbilityLevelSwapped.

These are not needed:
JASS:

    set x = 0.00
    set y = 0.00
    set i = 0.00


CreateNUnitsAtLoc should be: CreateUnit.

Don't use: GetLastCreatedUnit() instead, use a local unit variable.
 

l1lshadow

New Member
Reaction score
4
When I change CreateNUnitsAtLoc to CreateUnit it doesn't work, this is what i put
JASS:
call CreateUnit( GetOwningPlayer(udg_Caster), 'h000', x, y, 90.0 )
I changed the model and it showed up but after that call nothing works.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top