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

Custom script SetUnitX&Y

Status
Not open for further replies.
Level 7
Joined
Nov 19, 2015
Messages
283
I don't know any Jass and only use GUI. This is what I am using for my triggers.

  • Set X = (X of missile_point_2)
  • Set Y = (Y of missile_point_2)
  • Custom script: call SetUnitX(udg_missile,udg_X)
  • Custom script: call SetUnitY(udg_missile,udg_Y)
Is there a single line I can use?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
No.
You can use SetUnitPosition(u, x, y) but that is not the same as SetUnitX() and SetUnitY() because the first will also check for collision and interrupt orders.

You could possibly make the function yourself, but as far as this goes, it is not really necessary.
Just write those two lines.
 
Level 7
Joined
Nov 19, 2015
Messages
283
Automatic library for checking bounds? Boundsentinel?

I usually just have a check that the point is pathing equals true.
 
Automatic library for checking bounds? Boundsentinel?

I usually just have a check that the point is pathing equals true.

SetUnitX/SetUnitY behaves a bit differently than SetUnitPosition (the GUI action "Unit - Move <Unit> instantly to <Point>"). There are a few trade-offs to consider:
SetUnitX - SetUnitY
SetUnitPosition
  • Does not check pathing
  • Does not interrupt animations
  • Does not stop orders
  • Does pathing checks
  • Issues a "stop" order
  • Interrupts animations

If you choose to use SetUnitX/SetUnitY, then you'll have to check the pathing manually--but that is a bit tricky. The normal "is point walkable" GUI check only covers static pathing, i.e. cliffs, water, etc. However, it will not check for units, buildings, destructables, etc. so your units will simply pass through. The process for checking walkability *properly* is a bit convoluted, so I recommend using this script:
http://www.hiveworkshop.com/forums/spells-569/check-walkability-239115/

There is a newer method that uses build orders:
http://www.hiveworkshop.com/forums/spells-569/pathinglib-v1-5-a-263230/
But it is written in vJASS and has its own pros/cons (read the thread for more info).

P.S. As far as I know, BoundSentinel is only necessary when you don't have pathing checks. (iirc boundaries are considered not pathable) BoundSentinel tends to be useful for dummies (e.g. dummy casters) where you don't really need to worry about pathability.
 
Level 7
Joined
Nov 19, 2015
Messages
283
I like the check walkability system you have. Its pretty awesome, I will use it for my other map that uses a arrow key movement system. I don't understand the PathingLib but probs a bit too complex for me.
I asked a basic question and learnt more in the process. Thanks guys

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Terrain pathing at TempLoc[3] of type Flyability is off) Equal to False
    • Then - Actions
      • Custom script: call SetUnitX(GetEnumUnit(),GetLocationX(udg_TempLoc[3]))
      • Custom script: call SetUnitY(GetEnumUnit(),GetLocationY(udg_TempLoc[3]))
    • Else - Actions
 
Last edited:
Status
Not open for further replies.
Top