• 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.

[JASS] Whats up with this simple loop?

Status
Not open for further replies.
JASS:
function FB_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local location l = GetSpellTargetLoc()
local real x
local real y
local real X
local real Y
local integer loop1int = 0
local integer loop1end = 1
local location h
local effect e
local location o
local real f
local real r

set X = GetUnitX(u)
set Y = GetUnitY(u)
set h = Location(X,Y)
set loop1end = R2I(DistanceBetweenPoints(h,l) / 64.00)
set f = AngleBetweenPoints(h,l)
call RemoveLocation(h)
call RemoveLocation(l)

call DisplayTextToPlayer(Player(0),0,0,I2S(loop1int))
call DisplayTextToPlayer(Player(0),0,0,I2S(loop1end))

set loop1int = 0
loop
    exitwhen loop1int > loop1end
    set loop1int = loop1int + 1
    set r = r + 64.00
    set o = Location(X,Y)
    set h = PolarProjectionBJ(o,r,f)
    set x = GetLocationX(h)
    set y = GetLocationY(h)
    call RemoveLocation(h)
    call RemoveLocation(o)
    set e = AddSpecialEffect("Abilities\\Weapons\\ZigguratFrostMissile\\ZigguratFrostMissile.mdl",x,y)
    call TriggerSleepAction(0.10)
    call DestroyEffect(e)
    call DisplayTextToPlayer(Player(0),0,0,I2S(loop1int))
endloop

call DisplayTextToPlayer(Player(0),0,0,"Cleared!")
set u = null
endfunction

function FB_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00J' 
endfunction
//===========================================================================
function InitTrig_FB takes nothing returns nothing
    local trigger gg_trg_FB = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_FB, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_FB, Condition( function FB_Conditions ) )
    call TriggerAddAction( gg_trg_FB, function FB_Actions )
endfunction

why doesn't this work? I've tried many things, the spell is based of shockwave and everything works, exepct that it stops at the loop?!?!?!
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Or why not just not use locations and BJs (PolarProjectionBJ, DistanceBetwenPoints, AngleBetweenPoints) altogether?

For reference (all in Jass syntax in terms of functions) --

Code:
Project a point towards a specified angle, a specific distance -

newX = oldX + distance * Cos(angle)
newY = oldY + distance * Sin(angle)

angle is measured in radians. (Degrees can be converted to radians via 3.14159/180 * angle, with angle in degrees)

Find the angle of the slope of a line, given two points on that line -

angle = Atan2(y2-y1,x2-x1)

Where angle is measured in radians, and the angle found is the angle from x1/y1 to x2/y2

Find the distance between two arbitrary points -

distance = SquareRoot((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))

Since the values are squared, the order of x1/y1 and x2/y2 does not matter, as long as it is consistent.
 
Level 11
Joined
Apr 6, 2008
Messages
760
just a little hint
JASS:
call TriggerSleepAction(0.10)
has a minimum time of 0.3 if im correct so if u want smaller waits then that you have to use a timer which can go as low as 0.035 (lower i think but not recommended)
 
Status
Not open for further replies.
Top