- Joined
- Jan 21, 2006
- Messages
- 2,552
SafetyQueue by Berb
Requires
This library addresses the problem that arises when a user wants to have multiple spells that pause the unit, or perhaps make it invulnerable. This will track each time the user pauses/unpauses a unit (using the specialized functions) and will only actually pause/unpause it if the queue goes from 0 to greater than 0 or from greater than 0 to 0.
If the user uses unpause many times it will not result in the queue going negative, instead the queue can only go down if it has gone up; not that this is a very rare event and it is completely controllable, but I figured it was how this kind of thing should work.
By default I have used this for defining
I really wish vJass allowed you to control whether a hook function was executed after or before the hooked function - it would eliminate the need to force the user to use crappy wrapper functions. If it could be detected when
I'm pretty sure there is already something similar to this... I haven't put much effort into finding it though - if anybody knows of one like this (that is hosted at The Hive Workshop) please say something so I can take this down.
Requires
- AutoIndex by Grim001
This library addresses the problem that arises when a user wants to have multiple spells that pause the unit, or perhaps make it invulnerable. This will track each time the user pauses/unpauses a unit (using the specialized functions) and will only actually pause/unpause it if the queue goes from 0 to greater than 0 or from greater than 0 to 0.
If the user uses unpause many times it will not result in the queue going negative, instead the queue can only go down if it has gone up; not that this is a very rare event and it is completely controllable, but I figured it was how this kind of thing should work.
JASS:
library SafetyQueue requires AutoIndex
//! textmacro SafetyQueueData takes stackLabel, nativeLabel, methodLabel, funcLabel
private struct $stackLabel$
private integer queue = 0
method $methodLabel$ takes boolean flag returns nothing
if flag then
if queue == 0 then
call $nativeLabel$(me, true)
endif
set queue = queue + 1
else
set queue = queue - 1
if queue <= 0 then
set queue = 0
call $nativeLabel$(me, false)
endif
endif
endmethod
implement AutoCreate
implement AutoDestroy
endstruct
function $funcLabel$ takes unit u, boolean flag returns nothing
call $stackLabel$[u].$methodLabel$(flag)
endfunction
//! endtextmacro
//! runtextmacro SafetyQueueData("PauseSafetyData","PauseUnit","pause","PauseUnitEx")
//! runtextmacro SafetyQueueData("InvulSafetyData","SetUnitInvulnerable","invul","SetUnitInvulnerableEx")
endlibrary
By default I have used this for defining
function PauseUnitEx takes unit u, boolean flag returns nothing
and function SetUnitInvulnerable takes unit u, boolean flag returns nothing
and off the top of my head I can't think of any other use, but if there is then it can simply be added as I have done so. The user is required to define a struct name (this is not public interface), the native that is used to bestow the effect on the unit, and the name of the new function that the user should use instead.I really wish vJass allowed you to control whether a hook function was executed after or before the hooked function - it would eliminate the need to force the user to use crappy wrapper functions. If it could be detected when
PauseUnit
was called then the queue could be evaluated and the unit could be paused/unpaused after the hook so that the bestowed effect comes from the hook function, rather than the function that was hooked (if any of this makes sense).I'm pretty sure there is already something similar to this... I haven't put much effort into finding it though - if anybody knows of one like this (that is hosted at The Hive Workshop) please say something so I can take this down.