Warcraft III: MapsModelsSkinsIconsSpellsToolsTutorials
WC3 JASS: Code SnippetsJASS and vJASS Spells and SystemsJass Tutorials
Chat @Discord

vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation - Zinc documentation - WC3 Optimizer documentation

Author Topic: [Snippet] DisableUnitMovement  (Read 7347 times)

  • Rookie - level 1
  • *
  • Posts: 46
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 13
    • View Profile
[Snippet] DisableUnitMovement
« on: July 24, 2012, 07:29:15 PM »
Category: Units
Language: vJASS
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%.

Code: jass  [Select]
  1. library DisableUnitMovement /* v1.0.0.1
  2. *******************************************************************
  3. *
  4. *   Disables unit movement. They can still turn, but will stay in
  5. *   place. It simulates an ensnare-like effect, except that it will
  6. *   not ground units, it does not have buffs, does not interrupt
  7. *   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 nothing
  14. *
  15. *       - Prevents a unit from moving.
  16. *
  17. *   function EnableUnitMovement takes unit u returns nothing
  18. *
  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.     endfunction
  26.  
  27.     function EnableUnitMovement takes unit u returns nothing
  28.         call SetUnitPropWindow(u, GetUnitDefaultPropWindow(u) * bj_DEGTORAD)
  29.     endfunction
  30.  
  31. endlibrary

Code: jass  [Select]
  1. /*    Demo    */
  2. scope Demo initializer Test
  3.     globals
  4.         private unit footman
  5.     endglobals
  6.  
  7.     private function OnExpire takes nothing returns nothing
  8.         call EnableUnitMovement(footman)
  9.         call BJDebugMsg("Movement enabled!")
  10.     endfunction
  11.  
  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.     endfunction
  18. endscope
  19.  

EDIT: Updated thanks to kStiyl. Apparently SetUnitPropWindow expects radians. Seems to be true judging by SetUnitPropWindowBJ(). Also fixed a syntax error, oops.
« Last Edit: December 19, 2017, 11:28:07 AM by moyack »

  • Site Owner
  • Administrator
  • Starter - level 4
  • *
  • Posts: 958
  • WC3 Models: 59
  • WC3 Tutorials: 13
  • WC3 Tools: 14
  • WC3 Maps: 12
  • WC3 Skins: 6
  • WC3 Icons: 2
  • WC3 Spells: 15
  • Reputation: 1153
  • Site Admin - I love fix things
    • View Profile
    • Blizzard Modding Information Center
Re: [Snippet] DisableUnitMovement
« Reply #1 on: July 24, 2012, 08:43:49 PM »
I do love how nice are this simple scripts. Adn this technique is lovely, Good job :)

And of Course, uber approved :)

We can give you full hosting for your projects, a complete page!!

A custom altered melee map where you can play Naga and Demons. Check it out!!
Use Dropbox...

 

[Snippet] Group Units in line, with distance and optional spread-value

Started by rvonsonsnadtzBoard Codes & Snippets

Replies: 5
Views: 12784
Last post March 13, 2013, 06:52:16 PM
by rvonsonsnadtz
[Snippet] Single Player Detector

Started by moyackBoard Codes & Snippets

Replies: 12
Views: 23017
Last post March 13, 2013, 12:48:49 PM
by Magtheridon96
[Snippet] Simple Unit Indexer

Started by moyackBoard Codes & Snippets

Replies: 17
Views: 29510
Last post September 30, 2013, 08:07:19 AM
by moyack
[Snippet] Disable Transmission Skip

Started by PurgeandfireBoard Codes & Snippets

Replies: 2
Views: 9657
Last post July 02, 2013, 01:34:55 PM
by Purgeandfire
[Snippet] Timed Effects

Started by moyackBoard Codes & Snippets

Replies: 0
Views: 8391
Last post January 09, 2012, 07:03:32 PM
by moyack
Blizzard Modding Information Center Wacraft III Modding Information Center WC3JASS.com - The JASS Vault Chronicles of Darkness - A Warcraft III mod Jetcraft - A Starcraft II mod Troll Smash - A Warcraft III Arena Starcraft II Modding Information Center
  Mod DB - Change the Game Power of Corruption - A Warcraft III altered melee map Chaos Realm - The world of Game modders and wc3 addicts Follow us on Facebook!!