[Spell] instantly move unit without stopping issued order

Status
Not open for further replies.
Level 25
Joined
Mar 29, 2020
Messages
1,466
Hey there,

I want to have a terrain function on my map that slightly moves units (a whirlpool), but without interupting their orders (the default is - after being insta-moved they stop.)
I want the units to continue trying to go wherever they were going while they are getting moved by the whirlpool (or conveyor belt...wtvr)

any ideas how to go about doing that?

thanks!
 
Level 25
Joined
Mar 29, 2020
Messages
1,466
thanks, that did it!

so it seems - SetUnitPosition is hardcoded to order the unit to stop, but if you SetunitY and SetunitX seperately it doesn't do that. also then it lets you get units stuck in buildings and fun things like that...
 
Level 13
Joined
Feb 5, 2018
Messages
567
thanks, that did it!

so it seems - SetUnitPosition is hardcoded to order the unit to stop, but if you SetunitY and SetunitX seperately it doesn't do that. also then it lets you get units stuck in buildings and fun things like that...

You can still check the walkability when using X/Y thought to prevent this from happening.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
If you wanted a Move Unit Instantly function that didn't interrupt orders you could come up with a function for it. Something like this:
vJASS:
function MoveUnitInstantly takes unit u, location l returns nothing
    // move the dummy to the location (takes pathing into consideration)
    ShowUnit(moveDummy, true)
    SetUnitPositionLoc(moveDummy, l)
    ShowUnit(moveDummy, false)
    // move the unit to the position of the dummy (uninterrupted)
    SetUnitX(u, GetUnitX(moveDummy))
    SetUnitY(u, GetUnitY(moveDummy))
endfunction
Haven't tested it but I think the logic is sound.

The moveDummy unit would be a hidden/invulnerable ground unit with an average collision size (32 comes to mind). You would create it at the start of the game, hide it, and store it as moveDummy. It would NOT have the Locust ability.
 
Status
Not open for further replies.
Top