14 years
edited 8 years
Disables the movement of a particular unit. This method was discovered by WaterKnight (or at least, it was first exposed to the public by WaterKnight) in this thread:
http://www.hiveworkshop.com/forums/world-editor-help-zone-98/setunitpropwindow-disableunitmovement-206527/
I made this library to be a simple wrapper for it. Of course, this is all inlineable, but it is a useful technique for people to know.
Setting a unit movespeed to 1 will still allow it to move (ever so slowly) and will interrupt orders. Ensnares ground units and whatnot. This has no debuff, and works 100%.
EDIT: Updated thanks to kStiyl. Apparently SetUnitPropWindow expects radians. Seems to be true judging by SetUnitPropWindowBJ(). Also fixed a syntax error, oops.
http://www.hiveworkshop.com/forums/world-editor-help-zone-98/setunitpropwindow-disableunitmovement-206527/
I made this library to be a simple wrapper for it. Of course, this is all inlineable, but it is a useful technique for people to know.
Setting a unit movespeed to 1 will still allow it to move (ever so slowly) and will interrupt orders. Ensnares ground units and whatnot. This has no debuff, and works 100%.
library DisableUnitMovement /* v1.0.0.1
*******************************************************************
*
* Disables unit movement. They can still turn, but will stay in
* place. It simulates an ensnare-like effect, except that it will
* not ground units, it does not have buffs, does not interrupt
* channeled casts and appears to have no downsides.
*
* Full credits to WaterKnight for discovering this technique.
*
*******************************************************************
*
* function DisableUnitMovement takes unit u returns nothing
*
* - Prevents a unit from moving.
*
* function EnableUnitMovement takes unit u returns nothing
*
* - Allows a unit to move once again.
*
*******************************************************************/
function DisableUnitMovement takes unit u returns nothing
call SetUnitPropWindow(u, 0)
endfunction
function EnableUnitMovement takes unit u returns nothing
call SetUnitPropWindow(u, GetUnitDefaultPropWindow(u) * bj_DEGTORAD)
endfunction
endlibrarySpoiler
/* Demo */
scope Demo initializer Test
globals
private unit footman
endglobals
private function OnExpire takes nothing returns nothing
call EnableUnitMovement(footman)
call BJDebugMsg("Movement enabled!")
endfunction
private function Test takes nothing returns nothing
set footman = CreateUnit(Player(0), 'hfoo', 0, 0, 0)
call DisableUnitMovement(footman)
call BJDebugMsg("Movement disabled!")
call TimerStart(CreateTimer(), 5, false, function OnExpire)
endfunction
endscope
EDIT: Updated thanks to kStiyl. Apparently SetUnitPropWindow expects radians. Seems to be true judging by SetUnitPropWindowBJ(). Also fixed a syntax error, oops.
