- Joined
- Sep 6, 2013
- Messages
- 6,743
Info
Sometimes it's not recommended to use the
because it has some (usually) unwanted side effets like:
But in some cases we might want need a good alternative which completly makes a unit unuseable.
Code
Small test map is attached. (demo code is not up to date)
Sometimes it's not recommended to use the
PauseUnit()
function,because it has some (usually) unwanted side effets like:
- Buffs/effects suspend.
- Orders are stored when paused, and fired on UnPause.
- Can screw up animations. (link)
- Unit does not accept PowerUpss, UnitAddItem returns true, but item is not picked up. (link)
But in some cases we might want need a good alternative which completly makes a unit unuseable.
Code
JASS:
library SuspendUnit /* v1.1 By IcemanBo (credits to Maker for this method)
Alternative for the PauseUnit() function without known side effects.
A paused unit will be completly unuseable until unpaused.
Unit's current order will be forgetten.
API
¯¯¯¯¯¯
function SuspendUnit(unit, boolean) returns nothing
function IsUnitSuspended(unit) returns boolean
Instructions:
¯¯¯¯¯¯¯¯¯¯¯¯¯¯
After copying the library save the map and restart the editor.
When done, then comment out the next line:*/
//! external ObjectMerger w3a ANcl paus Ncl6 1 "defend" anam "Channel Pause" acat "" atat "" aher 0 alev 1 Ncl1 1 10000 aani "stand" aeat "" |
globals
private constant integer PAUSE = 'paus'
private constant integer DEFEND = 852055
endglobals
function SuspendUnit takes unit u, boolean b returns nothing
if (b) then
call UnitAddAbility(u, PAUSE)
call IssueImmediateOrderById(u, DEFEND)
else
call UnitRemoveAbility(u, PAUSE)
endif
endfunction
function IsUnitSuspended takes unit u returns boolean
return (GetUnitAbilityLevel(u, PAUSE) > 0)
endfunction
endlibrary
Small test map is attached. (demo code is not up to date)
Attachments
Last edited: