Help with angle math

Discussion in 'JASS Zone' started by Dirac, Jun 15, 2011.

  1. Dirac

    Dirac 22710180

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

            set x = GetUnitX(d.u)+(40*d.cosa)
            set y = GetUnitY(d.u)+(40*
            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
  2. Weep

    Weep Godspeed to the sound of the pounding

    +400 / 0 / -0
    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...
  3. Sevion

    Sevion The DIY Ninja

    +423 / 0 / -0
    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.
  4. emjlr3

    emjlr3 Change can be a good thing Staff Member

    +396 / 0 / -0

Share This Page