• 🏆 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!

[Spell] Unit x:y polar offset

Status
Not open for further replies.
Level 6
Joined
Apr 23, 2011
Messages
182
Hi this is an example of what i need to achive. I could try myself but my jngp is crashing because of this trigger.
I just need to move a unit with polar offset everty 0.03 a little bit further. But with set unit x and y because i dont want that the unit forgets the orders.

Code:
Untitled Trigger 001
    Events
        Time - Every 0.03 seconds of game time
    Conditions
    Actions
        Custom script:   set bj_wantDestroyGroup = true
        Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
            Loop - Actions
                Set u = (Picked unit)
                Custom script:   call SetUnitX(GetUnitX(udg_u) * Cos(Angle * (3.14159/180.0)))
                Custom script:   call SetUnitY(GetUnitY(udg_u) * Sin(Angle * (3.14159/180.0)))
 
Level 6
Joined
Apr 23, 2011
Messages
182
SetUnitX/Y needs a unit as first parameter: SetUnitX(whichunit, whichcoordinate)

Also read rulerofiron99's post.

And I don't see a variable called "Angle".

You could use the DEGTORAD bj instead your calculation.

Thanks it work! But i dont understand the degtorad bj. Do i still need to use the cos and sin?

Also i noticed that some times its fails when getting the angle of a unit. I think for example if this units are created on Init.
 
Thanks it work! But i dont understand the degtorad bj. Do i still need to use the cos and sin?

You write: 3.14159/180
You write this to convert a value from DEG to RAD. (unit facing is in DEG)
You can use the bj_DEGTORAD instead. It is the very same.

call SetUnitX(unit, GetUnitX(unit) + speed*(angle*bj_DEGTORAD))

Also i noticed that some times its fails when getting the angle of a unit. I think for example if this units are created on Init.

I'm not sure what you mean.
 
Status
Not open for further replies.
Top