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

GetUnitX/Y Help

Status
Not open for further replies.
Well every unit has an X and Y co-ordinate on the map, if you look in the world editor, put your mouse on the active map it actually gives you the co-ordinates of that point on the map, Setting the Unit's X and Y moves is (but more efficiently and lag-lessly than locations)

"How to use them" depends on what you're planning on using them for:

Their parameters are as such:

SetUnitX(Unit, Real)
SetUnitY(Unit, Real)

Unit obviously being which unit to move, and the real being the co-ordinate to move them to.

For unit manipulation for things like knockback, jump, running, etc. with spells you will find you need to use the following

GetUnitX(Unit)
GetUnitY(Unit)

Again, which unit to get the real of, Typically you need to set these to variables, or call them within another function

set TempX = GetUnitX(Unit)
set TempY = GetUnitY(Unit)

However while you can just add numbers to these variables to move the unit, normally they aren't relative and look wrong in given situations. To get them right you need to be using Sin and Cos and bj_DEGTORAD, typically, but are only relevent to use depending on what you're planning to use them for.

In the case that you've shown GetAttackedUnitBJ() returns the unit which triggered the event, which I'm guessing is a unit is attacked (although abusable) TempX and TempY in those cases have been set elsewhere, but again they are just real values (numbers) of co-ordinates on the map
 
Level 7
Joined
Oct 16, 2010
Messages
193
So can you tell me if I am doing this right? I just want the unit to move towards the enemy and face him.
  • Speed Evasion Copy
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacked unit) has buff Evasion ) Equal to True
    • Actions
      • Custom script: local real x
      • Custom script: local real y
      • Unit - Cause (Attacked unit) to damage (Attacking unit), dealing (Real((Agility of (Attacked unit) (Exclude bonuses)))) damage of attack type Spells and damage type Normal
      • Special Effect - Create a special effect attached to the origin of (Attacked unit) using Abilities\Spells\Orc\MirrorImage\MirrorImageCaster.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: set x = GetUnitX(GetAttacker())
      • Custom script: set y = GetUnitY(GetAttacker())
      • Custom script: set udg_TempX = x
      • Custom script: set udg_TempY = y
      • Custom script: call SetUnitX(GetAttackedUnitBJ(), udg_TempX)
      • Custom script: call SetUnitY(GetAttackedUnitBJ(), udg_TempY)
Oh, and is it possible to get the X,Y of points?
 
Status
Not open for further replies.
Top