Help with some Math (Probably easy)

dudeim

New Member
Reaction score
22
Hey,

as I'm not that much of a math genius, well not much of a math anything I need some help with a calculation.

What I want to do is I'm gonna fire an arrow towards an angle that the player can just click.
So the player clicks to his precise left (for example) the arrow flies that way and then I want to know when the arrow is like 800 range further or 1000 range further etc.. so i can destroy it.

Can anyone help me with this?
I know I didn't explain it too good if you need extra description just ask:p

Thanks!
 

luorax

Invasion in Duskwood
Reaction score
67
Well, you can always attach the starting XY coordinates to the projectile. Then when you move that projectile, check the distance between its current and starting positions:

JASS:

function DistanceBetweenXY takes real x1, real y1, real x2, real y2 returns real
    return SquareRoot((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
endfunction


private method periodic takes nothing returns nothing
    local real x=<New X>
    local real y=<New Y>
    call SetUnitPosition(this.dummy,x,y)
    if DistanceBetweenXY (x,y,this.strX,this.strY)<=800. then
        call this.stopPeriodic()
    endif
endmethod
 
Reaction score
456
Better idea is to increase the distance moved on every interval, and compare that to the maximum range.
 

dudeim

New Member
Reaction score
22
Well as I'm not calculating the distance itself every interval (using a system for it) I think it's easier to go with luorax's way.
 
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