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%.
1 library DisableUnitMovement /* v1.0.0.1
2 *******************************************************************3 *4 * Disables unit movement. They can still turn, but will stay in5 * place. It simulates an ensnare-like effect, except that it will6 * not ground units, it does not have buffs, does not interrupt7 * channeled casts and appears to have no downsides.8 *9 * Full credits to WaterKnight for discovering this technique.10 *11 *******************************************************************12 *13 * function DisableUnitMovement takes unit u returns nothing14 *15 * - Prevents a unit from moving.16 *17 * function EnableUnitMovement takes unit u returns nothing18 *19 * - Allows a unit to move once again.20 *21 *******************************************************************/22 23 function DisableUnitMovement takes unit u returns nothing
24 call SetUnitPropWindow(u, 0)
25 endfunction26 27 function EnableUnitMovement takes unit u returns nothing
28 call SetUnitPropWindow(u, GetUnitDefaultPropWindow(u) * bj_DEGTORAD)
29 endfunction30 31 endlibrary
Spoiler
1 /* Demo */2 scope Demo initializer Test
3 globals4 private unit footman
5 endglobals6 7 private function OnExpire takes nothing returns nothing
8 call EnableUnitMovement(footman)
9 call BJDebugMsg("Movement enabled!")
10 endfunction11
12 private function Test takes nothing returns nothing
13 set footman = CreateUnit(Player(0), 'hfoo', 0, 0, 0)
14 call DisableUnitMovement(footman)
15 call BJDebugMsg("Movement disabled!")
16 call TimerStart(CreateTimer(), 5, false, function OnExpire)
17 endfunction18 endscope19
EDIT: Updated thanks to kStiyl. Apparently SetUnitPropWindow expects radians. Seems to be true judging by SetUnitPropWindowBJ(). Also fixed a syntax error, oops.
