Help with angle math

Dirac

22710180
Reaction score
147
I can't get my head around this... the angle this equation returns is always wrong
JASS:
        local real x
        local real y
        local location l = GetSpellTargetLoc()
        set x = GetUnitX(GetTriggerUnit())
        set y = GetUnitY(GetTriggerUnit())
        set d.lx = GetLocationX(l)
        set d.ly = GetLocationY(l)
        set d.d = SquareRoot((d.lx - x) * (d.lx - x) + (d.ly - y) * (d.ly - y))
        set d.a = bj_RADTODEG * Atan2(d.ly-y,d.lx-x)
        set d.cosa = Cos(d.a)
        set d.sina = Sin(d.a)

JASS:
        set x = GetUnitX(d.u)+(40*d.cosa)
        set y = GetUnitY(d.u)+(40*d.sina)
        call SetUnitX(d.u,x)
        call SetUnitY(d.u,y)

What should this trigger do?: move a certain projectile towards the angle between the casting unit and the target point
What does it do?: fires the projectile in what it seems always a random angle
help me fix it plz
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
1. You shouldn't have bj_RADTODEG, since Cos and Sin take radians.
2. I'm surprised it works at all because you didn't initialize the local real x nor y, which ought to be crashing the thread...
 

Sevion

The DIY Ninja
Reaction score
413
He does initialize x and y.

It's the fourth and fifth line.

The error is, as Weep said, that you're passing Degrees when they take Radians.
 

emjlr3

Change can be a good thing
Reaction score
395
[ljass]GetSpellTargetX/GetSpellTargetY[/ljass] work well
 
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