Stack Safety (Snippet Pack) Requirements: - Jass NewGen - AIDS (required by all) Overview Description: This is essentially a snippet pack based on recording the level of certain things so that they are not prematurely removed due to poor multi-instancability in the native functions. Released by request. Pause Safety: Spoiler JASS: library PauseSafety uses AIDS private struct UnitData extends array //! runtextmacro AIDS() integer pauseLevel private method AIDS_onDestroy takes nothing returns nothing set this.pauseLevel=0 endmethod endstruct function SafePause takes unit whichUnit, boolean flag returns nothing local UnitData dat=UnitData[whichUnit] if flag then set dat.pauseLevel=dat.pauseLevel+1 call PauseUnit(whichUnit,true) else set dat.pauseLevel=dat.pauseLevel-1 if dat.pauseLevel<=0 then call PauseUnit(whichUnit,false) set dat.pauseLevel=0 endif endif endfunction endlibrary Pause safety allows you to use unit pausing without worry about unpause having poor multi-instancing. Example: Spell pauses a unit for 5 seconds. Spell is cast twice, exactly 4 seconds apart. Usually, this would result in the second instance lasting 1 second. Using SafePause(unit, pause/unpause boolean), the pause count is recorded, so only when the last pause is released will the unit be unpaused. Invulnerability Safety: Spoiler JASS: library InvulnerableSafety uses AIDS private struct UnitData extends array //! runtextmacro AIDS() integer invulnLevel private method AIDS_onDestroy takes nothing returns nothing set this.invulnLevel=0 endmethod endstruct function SafeInvulnerable takes unit whichUnit, boolean flag returns nothing local UnitData dat=UnitData[whichUnit] if flag then set dat.invulnLevel=dat.invulnLevel+1 call SetUnitInvulnerable(whichUnit,true) else set dat.invulnLevel=dat.invulnLevel-1 if dat.invulnLevel<=0 then call SetUnitInvulnerable(whichUnit,false) set dat.invulnLevel=0 endif endif endfunction endlibrary Same principle as PauseSafety. If two spells make a unit invulnerable for 5 seconds, and cast 4 seconds apart, the second instance will only last 1 second. With SafeInvulnerable(unit, invulnerable/vulnerable boolean), it will be made vulnerable after the last invulnerability has been revoked (the number of invulnerabilities on a unit is once again recorded).