- Joined
- Nov 22, 2006
- Messages
- 1,260
Enable/Disable Movement
By: Silvenon
JASS:
function MovementDisable_Conditions takes nothing returns boolean
local integer i = GetIssuedOrderId()
return (i == 851971 or i == 851986 or i == 851983 or i == 851990) and not GetHandleBoolean(GetTriggerUnit(), "b")
endfunction
function MovementDisable_Execute takes nothing returns nothing
call DestroyTimer(GetExpiredTimer())
call IssueImmediateOrder(udg_MoveUnit, "stop")
endfunction
function MovementDisable_Actions takes nothing returns nothing
set udg_MoveUnit = GetTriggerUnit()
call TimerStart(CreateTimer(), 0.00, false, function MovementDisable_Execute)
endfunction
function UnitEnableMovement takes unit u returns nothing
call SetHandleBoolean(u, "b", true)
endfunction
function UnitDisableMovement takes unit u returns nothing
call SetHandleBoolean(u, "b", false)
endfunction
function Init_MovementToggle takes nothing returns nothing
call TriggerAddCondition(udg_Trig, Condition(function MovementDisable_Conditions))
call TriggerAddAction(udg_Trig, function MovementDisable_Actions)
endfunction
function Init_UnitMovement takes unit u returns nothing
call SetHandleBoolean(u, "b", true)
call TriggerRegisterUnitEvent(udg_Trig, u, EVENT_UNIT_ISSUED_POINT_ORDER)
endfunction
A simple system which allows you to disable/enable user movement orders (right-click) given to a certain unit.
If someone is curious about the MovementDisable_Conditions function, these are the ID translations (thanks to PurplePoot):
- 851971 - smart
- 851986 - move
- 851983 - attack
- 851990 - patrol
Instructions:
- put this code in your map header
- create a global trigger variable named Trig and a global unit variable named MoveUnit
- initialize the system like this:
call Init_MovementToggle()
- initialize the system for a unit like this:
call Init_UnitMovement(udg_MyUnitVar)
- after calling Init_UnitMovement, enable/disable the movement with
UnitEnableMovement(udg_MyUnitVar)
andUnitDisableMovement(udg_MyUnitVar)
, example:
-
Events
- Map initialization
- Conditions
-
Actions
- Custom script: call Init_MovementToggle()
-
Events
- Unit - A unit starts the effect of an ability
-
Conditions
- (Ability being cast) Equal to Tornado
-
Actions
- set Caster = (Triggering unit)
- Custom script: call Init_Movement(udg_Caster)
- Custom script: call UnitEnableMovement(udg_Caster)
- Wait 5.00 seconds
- Custom script: call UnitDisableMovement(udg_Caster)
Requires: KaTTaNa's Local Handle Vars
The reason why I made this lame simple system is because I discovered that it doesn't work if ordering a unit to stop directly, but a timer is needed (some lame bug).
If this doesn't work right, please report it!
Last edited: