• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Timers: How Do You Use Them

Status
Not open for further replies.
Level 4
Joined
Nov 24, 2007
Messages
55
So either I'm stupid (very possible) or there isn't one, but I can't seem to find a (decent) tutorial on how to use Timers in JASS (as in to do a periodic event that ticks or something that just lasts a couple seconds) so that I can avoid using the TriggerSleepAction call.

Could someone either point me to a tutorial on how to use them (please no VJass or NewGenEdit, as unfortunately I am on a mac and cannot find my RoC disk to install this on my windows partition), explain how to use them, or show me how i would replace some of this code which I know is buggy (probably because i do use the wait command)

JASS:
function Trig_Ice_Block_locals_Actions takes nothing returns nothing
    local unit icedUnit = GetTriggerUnit()
    local integer level = GetUnitAbilityLevelSwapped('A015', GetTriggerUnit())
    call UnitRemoveBuffsBJ( bj_REMOVEBUFFS_NEGATIVE, icedUnit )
    call PauseUnitBJ( true, icedUnit )
    if ( level == 1 ) then
        call TriggerSleepAction( 2 )  
    endif
    if ( level == 2 ) then
        call TriggerSleepAction( 3 )
    endif
    if ( level == 3 ) then
        call TriggerSleepAction( 5 )
    endif
    call PauseUnitBJ( false, icedUnit )
    set icedUnit = null
endfunction

Yes, I am aware I am using BJ functions. Yes, I know they aren't the "most efficient" but w/e, I'm more concerned with fixing the wait part first.

Also, could timers fix how this other spell of mine works...this loop works to 'pull' the unit towards the caster (no, not a Hook remake, but a Lasso ability.)

Note: This function works fine, I just think it probably can be smoother if it uses a timer in some way then this wait command.

JASS:
    loop 
    exitwhen ( (curDistance < 120) or (GetUnitState(target,UNIT_STATE_LIFE) <= 0) or (areWeCasting < 1) )
        set curDistance = curDistance - 100
        set thePos = PolarProjectionBJ( myPos, curDistance, theAngle )
        call SetUnitPositionLoc( target, thePos )
        call RemoveLocation( thePos )
        call GlobalCauseSpellDamage( caster, target, damagePerTick )
        call TriggerSleepAction( 0.01 )
        set loopIndex = loopIndex + 1
        set areWeCasting = GetUnitAbilityLevel(caster,'Bmlc')
    endloop
(I am aware of the leaks from certain function calls here and there...)
Finally, I do not want to rely on "turning on" other triggers and using the periodic event, as I have a feeling that would get hairy with keeping it MUI.

Thank you for reading this far.
 
Status
Not open for further replies.
Top