• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[vJASS] how to get x and y of certain location?

Status
Not open for further replies.
Level 8
Joined
Jun 13, 2008
Messages
345
hi all,

well since there's no any site like stackoverflow for even finding this kind of basic stuff by googling it, unfortunately I have to create a thread here just find and learn the answer.

I need to get x and y of the position of the triggerer unit but 150 offset away by facing angle of triggerer unit.

I'll give rep to fastest reply...since it's gonna be way to easy for most of you:)

when i convert the gui code, it generates something like this:

Code:
PolarProjectionBJ(GetUnitLoc(GetTriggerUnit()), 150.00, GetUnitFacing(GetTriggerUnit()))

but have no idea how to get x and y of this location.
 
Level 8
Joined
Jun 13, 2008
Messages
345
I did it like this which it works but I doubt it's the most efficient way:

Code:
            set u = GetTriggerUnit()
        set l = PolarProjectionBJ(GetUnitLoc(u), 150.00, GetUnitFacing(u))
            set x = GetLocationX(l)
            set y = GetLocationY(l)
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
One can also do this with a bit of high school mathematics and the X and Y of the unit. Polar projection involves basic trigonometry and JASS/Lua provides one with basic trigonometric functions such as Sine and Cosine. Of course this is assuming one is 13 and older so as to have actually gone to high school to learn this.

x = GetUnitX(u) +150 * Cos(GetUnitFacing(u) * bj_DEGTORAD)
y = GetUnitY(u) +150 * Sin(GetUnitFacing(u) * bj_DEGTORAD)

JASS:
function PolarProjectionBJ takes location source,real dist,real angle returns location
    local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD)
    local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD)
    return Location(x, y)
endfunction
 
Level 8
Joined
Jun 13, 2008
Messages
345
One can also do this with a bit of high school mathematics and the X and Y of the unit. Polar projection involves basic trigonometry and JASS/Lua provides one with basic trigonometric functions such as Sine and Cosine. Of course this is assuming one is 13 and older so as to have actually gone to high school to learn this.

x = GetUnitX(u) +150 * Cos(GetUnitFacing(u) * bj_DEGTORAD)
y = GetUnitY(u) +150 * Sin(GetUnitFacing(u) * bj_DEGTORAD)

JASS:
function PolarProjectionBJ takes location source,real dist,real angle returns location
    local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD)
    local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD)
    return Location(x, y)
endfunction
oh...yeah I'm gonna change that code with this.
 
Status
Not open for further replies.
Top