• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Identifying Location in loop that skips a point

Hello Hive community, I am very new to Jass Scripting and I'm slowly learning. Its only weeks since I started to. I need help with my trigger in JASS. Basically, I had the trigger in GUI. I will post it too so that you might understand what I'm trying to do. So I had a spell that is called Ice Spikes, I based it on the ability Impale. Now I intend to fan out the spell in 4 additional points adjacent to the caster by using dummies to cast the same ability. The first point is 300 distance from the caster towards -30 degrees angle of the casters facing angle. The second one -15 degrees, the third one is 15 degrees, and the fourth one is 30 degrees. So, it would appear that 5 lines of Ice Spikes, fan out from the caster, 4 is cast by the dummy towards the enumerated angles, and the original line is from the caster. I tested my Jass and the world editor crashes when the spell is cast

Here's my GUI trigger:
  • Ice Spikes
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Ice Spikes (Neutral Hostile)
    • Actions
      • Set Ice_Spikes_Point[1] = (Position of (Triggering unit))
      • Set Ice_Spikes_Point[2] = (Target point of ability being cast)
      • -------- Point 2 right --------
      • Set Ice_Spikes_Point[3] = (Ice_Spikes_Point[1] offset by 300.00 towards ((Angle from Ice_Spikes_Point[1] to Ice_Spikes_Point[2]) + 15.00) degrees)
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at Ice_Spikes_Point[1] facing Ice_Spikes_Point[3]
      • Set Ice_Spikes_Dummy[1] = (Last created unit)
      • Unit - Add Ice Spikes (Dummy Spell) to Ice_Spikes_Dummy[1]
      • Unit - Order Ice_Spikes_Dummy[1] to Undead Crypt Lord - Impale Ice_Spikes_Point[3]
      • Unit - Add a 1.50 second Generic expiration timer to Ice_Spikes_Dummy[1]
      • -------- Point 3 right --------
      • Set Ice_Spikes_Point[4] = (Ice_Spikes_Point[1] offset by 300.00 towards ((Angle from Ice_Spikes_Point[1] to Ice_Spikes_Point[2]) + 30.00) degrees)
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at Ice_Spikes_Point[1] facing Ice_Spikes_Point[4]
      • Set Ice_Spikes_Dummy[2] = (Last created unit)
      • Unit - Add Ice Spikes (Dummy Spell) to Ice_Spikes_Dummy[2]
      • Unit - Order Ice_Spikes_Dummy[2] to Undead Crypt Lord - Impale Ice_Spikes_Point[4]
      • Unit - Add a 1.50 second Generic expiration timer to Ice_Spikes_Dummy[2]
      • -------- Point 4 left --------
      • Set Ice_Spikes_Point[5] = (Ice_Spikes_Point[1] offset by 300.00 towards ((Angle from Ice_Spikes_Point[1] to Ice_Spikes_Point[2]) - 15.00) degrees)
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at Ice_Spikes_Point[1] facing Ice_Spikes_Point[5]
      • Set Ice_Spikes_Dummy[3] = (Last created unit)
      • Unit - Add Ice Spikes (Dummy Spell) to Ice_Spikes_Dummy[3]
      • Unit - Order Ice_Spikes_Dummy[3] to Undead Crypt Lord - Impale Ice_Spikes_Point[5]
      • Unit - Add a 1.50 second Generic expiration timer to Ice_Spikes_Dummy[3]
      • -------- Point 5 left --------
      • Set Ice_Spikes_Point[6] = (Ice_Spikes_Point[1] offset by 300.00 towards ((Angle from Ice_Spikes_Point[1] to Ice_Spikes_Point[2]) - 30.00) degrees)
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at Ice_Spikes_Point[1] facing Ice_Spikes_Point[6]
      • Set Ice_Spikes_Dummy[4] = (Last created unit)
      • Unit - Add Ice Spikes (Dummy Spell) to Ice_Spikes_Dummy[4]
      • Unit - Order Ice_Spikes_Dummy[4] to Undead Crypt Lord - Impale Ice_Spikes_Point[6]
      • Unit - Add a 1.50 second Generic expiration timer to Ice_Spikes_Dummy[4]
      • Custom script: call RemoveLocation ( udg_Ice_Spikes_Point[1])
      • Custom script: call RemoveLocation ( udg_Ice_Spikes_Point[2])
      • Custom script: call RemoveLocation ( udg_Ice_Spikes_Point[3])
      • Custom script: call RemoveLocation ( udg_Ice_Spikes_Point[4])
      • Custom script: call RemoveLocation ( udg_Ice_Spikes_Point[5])
      • Custom script: call RemoveLocation ( udg_Ice_Spikes_Point[6])
      • Custom script: set udg_Ice_Spikes_Point[1] = null
      • Custom script: set udg_Ice_Spikes_Point[2] = null
      • Custom script: set udg_Ice_Spikes_Point[3] = null
      • Custom script: set udg_Ice_Spikes_Point[4] = null
      • Custom script: set udg_Ice_Spikes_Point[5] = null
      • Custom script: set udg_Ice_Spikes_Point[6] = null
      • Custom script: set udg_Ice_Spikes_Dummy[1] = null
      • Custom script: set udg_Ice_Spikes_Dummy[2] = null
      • Custom script: set udg_Ice_Spikes_Dummy[3] = null
      • Custom script: set udg_Ice_Spikes_Dummy[4] = null
      • Custom script: set udg_Ice_Spikes_Dummy[5] = null
      • Custom script: set udg_Ice_Spikes_Dummy[6] = null
And this is my JASS, suggestions and help are highly appreciated.
JASS:
//========================
//      Ice Spikes
//========================

function Trig_Ice_Spikes_Conditions takes nothing returns boolean
    local integer lvl = GetSpellAbilityId()
    return lvl == 'Aids'
endfunction   

function Trig_Ice_Spikes_Actions takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local real x = GetUnitX(c)
    local real y = GetUnitY(c)
    local real facing = GetUnitFacing(c)
    local real array angles
    local integer i
    local real dumfac
    local unit dummy
    local real px
    local real py
    local real point = 300.00
   
    set angles[0] = -30.0
    set angles[1] = -15.0
    set angles[2] = 15.00
    set angles[3] = 30.00
   
    loop
        set i = 0
        exitwhen i > 3
        set dumfac = facing + angles[i]
        set px = x + point * Cos(dumfac * bj_DEGTORAD)
        set py = y + point * Sin(dumfac * bj_DEGTORAD)
        set dummy = CreateUnit(GetOwningPlayer(c), 'ndum', x, y, dumfac)
        call UnitAddAbility(dummy, 'AZis')
        call IssuePointOrder(dummy, "impale", px, py)
        set i = i + 1    
    endloop   
   
endfunction

//===========================================================================
function InitTrig_Ice_Spires takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddAction(t, function Trig_Ice_Spikes_Conditions )
    call TriggerAddAction(t, function Trig_Ice_Spikes_Actions )
endfunction
 
You've created an infinite loop:
vJASS:
    loop
        set i = 0 // <-- BAD
        exitwhen i > 3
        set dumfac = facing + angles[i]
        set px = x + point * Cos(dumfac * bj_DEGTORAD)
        set py = y + point * Sin(dumfac * bj_DEGTORAD)
        set dummy = CreateUnit(GetOwningPlayer(c), 'ndum', x, y, dumfac)
        call UnitAddAbility(dummy, 'AZis')
        call IssuePointOrder(dummy, "impale", px, py)
        set i = i + 1
    endloop
You're setting i to 0 at the start of every loop cycle, so it's never going to be > 3.

Delete that line of code and set i to 0 when you declare the variable:
vJASS:
local integer i = 0
 
Back
Top