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

Move unit instantly without "stun" effect

Status
Not open for further replies.
Level 3
Joined
Jun 15, 2021
Messages
30
Hello. Is there a way to move unit to a certain location periodically (let's say that the location is somewhere 100 points ahead and we're moving unit by 4 points every 0.01 sec) without that "stun" effect that comes along with 'Move Unit (instantly)' action? I know the reason, I'm just trying to find an alternative, so I can make a skill like black hole (it's sucking units in its' center, but they still can make it if they have blinks, jumps, high move speed, etc.).

I'm certain that it's possible, I've seen something like that in a custom map. And it's core mechanic of famous "Warlocks" map where almost every skill knockbacks enemies.

Thanks in advance!
 
Hello.
The following natives are useful for your needs.

JASS:
// Sets the X coordinate of the unit
native SetUnitX takes unit whichUnit, real X returns nothing
// Sets the Y coordinate of the unit
native SetUnitY takes unit whichUnit, real Y returns nothing

You can incorporate this in your triggers via custom script. A sample is provided below:

  • Comment - ---- Working with coordinates directly ----
  • Custom Script - call SetUnitX(<unit>, <number>)
  • Custom Script - call SetUnitY(<unit>, <number>)
  • Comment - ---- Working with location handles ----
  • Custom Script - call SetUnitX(<unit>, GetLocationX(<location>))
  • Custom Script - call SetUnitY(<unit>, GetLocationY(<location>))
 
Level 3
Joined
Jun 15, 2021
Messages
30
Hello.
The following natives are useful for your needs.

JASS:
// Sets the X coordinate of the unit
native SetUnitX takes unit whichUnit, real X returns nothing
// Sets the Y coordinate of the unit
native SetUnitY takes unit whichUnit, real Y returns nothing

You can incorporate this in your triggers via custom script. A sample is provided below:

  • Comment - ---- Working with coordinates directly ----
  • Custom Script - call SetUnitX(<unit>, <number>)
  • Custom Script - call SetUnitY(<unit>, <number>)
  • Comment - ---- Working with location handles ----
  • Custom Script - call SetUnitX(<unit>, GetLocationX(<location>))
  • Custom Script - call SetUnitY(<unit>, GetLocationY(<location>))
Thanks! I will try it :)
 
Level 3
Joined
Jun 15, 2021
Messages
30
Wow. It works just fine for me. But now I kinda can't imagine how to move unit in the right direction, since I almost never used custom scripts by myself. I could easely do it with Polar Offset, gonna try figure out something, I'll say smth in the thread if I'll make any progress
 
Level 3
Joined
Jun 15, 2021
Messages
30
1627346867573.png


So, this is my progress for today. It works well, but I guess I can optimize it somehow?
 
Last edited:

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,457
View attachment 384179

So, this is my progress for today. It works well, but I guess I can optimize it somehow?
If you want efficiency then some more variables can help. Plus you're leaking a point.

First keep track of the Picked unit in a variable:
  • Loop - Actions
  • Set Variable pickedUnit = Picked unit
And reference the variable instead of (Picked unit).

Then in your Actions you need to avoid the point leak by using another variable:
  • Then - Actions
  • Set Variable pickedLoc = Position of pickedUnit
  • Set Variable tempLoc = pickedLoc offset by 3.00 towards Angle from pickedLoc to TornadoLoc degrees
  • Custom script: call SetUnitX(udg_pickedUnit, GetLocationX(udg_tempLoc))
  • Custom script: call SetUnitY(udg_pickedUnit, GetLocationY(udg_tempLoc))
  • Custom script: call RemoveLocation(udg_pickedLoc)
  • Custom script: call RemoveLocation(udg_tempLoc)
 
Level 3
Joined
Jun 15, 2021
Messages
30
If you want efficiency then some more variables can help. Plus you're leaking a point.

First keep track of the Picked unit in a variable:
  • Loop - Actions
  • Set Variable pickedUnit = Picked unit
And reference the variable instead of (Picked unit).

Then in your Actions you need to avoid the point leak by using another variable:
  • Then - Actions
  • Set Variable pickedLoc = Position of pickedUnit
  • Set Variable tempLoc = pickedLoc offset by 3.00 towards Angle from pickedLoc to TornadoLoc degrees
  • Custom script: call SetUnitX(udg_pickedUnit, GetLocationX(udg_tempLoc))
  • Custom script: call SetUnitY(udg_pickedUnit, GetLocationY(udg_tempLoc))
  • Custom script: call RemoveLocation(udg_pickedLoc)
  • Custom script: call RemoveLocation(udg_tempLoc)
Sure, a helpful opinion. It'd leak hard if you won't make it optimized. Thank you once more, kind sir :)
 
Status
Not open for further replies.
Top