Timer Handles

theXact

New Member
Reaction score
0
I'm currently trying to make a spell in which I'm using a timer to perform a periodic event. So, I need a system that will allow me to use handles... I've been doing some research and there is a lot of stuff out there I don't understand so I was hoping someone here could introduce me to a simple yet effective system.

To give you an idea of what im trying to do...

JASS:
function Cast_Sleep_T takes nothing returns nothing
    local timer HauntSleepTimer = GetExpiredTimer()
    local unit Caster = GetHandleUnit(HauntSleepTimer, "HauntCaster")
    local unit Target = GetHandleUnit(HauntSleepTimer, "HauntTarget")
//actions
if(//end condition)then
    call PauseTimer(HauntSleepTimer)
    call SetHandleHandle(HauntSleepTimer, "Caster", null)
    call SetHandleHandle(HauntSleepTimer, "Target", null)
    set Caster = null
    set Target = null
    set AL = 0
endif
endfunction

function Trig_HauntJASS_Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local unit Target = GetSpellTargetUnit()
    local timer HauntSleepTimer = CreateTimer()
    call SetHandle(HauntSleepTarget, "HauntCaster", Caster)
    call SetHandle(HauntSleepTarget, "HauntTarget", Target)
    call TimerStart(HauntSleepTimer, 0.1, true, function Cast_Sleep_T)
    set Target = null
    set Caster = null
endfunction
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Use struct and there are CSData, TimerUtils, ABC, HSAS to let you to do so.
 

Viikuna

No Marlo no game.
Reaction score
265
Handle Vars system is not working anymore, because of those new patches blizzard just did, but there is lot of better alternatives.

Get NewGen, TimerUtils and learn how to use structs.

There are also loads of other timersystems than TimerUtils, but all of them work with structs, so learning struct syntax is essential.

If you have problems with installing NewGen or understanding structs, just post here and ask.

If you are a mac user, which means that NewGen doesnt work for you, you should write your own system using these new hashtable natives.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
If you are a mac user, which means that NewGen doesnt work for you, you should write your own system using these new hashtable natives.
Or, for a more efficient method which, technically speaking, beats out proper TU Red use in fastness, modify Rising_Dusk's TIU so that it uses basic user defined globals and no vJass syntax.
After doing so it should look something like:
JASS:

function NewPublicTimer takes nothing returns timer
    if udg_Index == 0 then
        call BJDebugMsg("Error: No More Timers")
        return null
    endif
    set udg_Index = udg_Index - 1
    return udg_Stack[udg_Index]
endfunction

function FreePublicTimer takes timer t returns nothing
    if t != null then
        call PauseTimer(t)
        set udg_Stack[udg_Index] = t
        set udg_Index = udg_Index + 1
    endif
endfunction

function GetTimerId takes timer t returns integer
    return GetHandleId(t) - udg_IdOffset
endfunction

function Init takes nothing returns nothing
    local integer i = 1
    set udg_Stack[0] = CreateTimer()
    set udg_IdOffset = GetHandleId(udg_Stack[0])-1
    loop
        exitwhen i == udg_MaxTimers
        set udg_Stack<i> = CreateTimer()
        set i = i + 1
    endloop
    set udg_Index = udg_MaxTimers
endfunction
</i>
 

theXact

New Member
Reaction score
0
Thanks everyone, I went off and read up on structs and I ended up using CSData. It all works perfectly and my spell is just how I imagined it!

Thanks again!
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
This thread might not be the place for it, since the original poster has been helped, but since you mention it:

If you are a mac user, which means that NewGen doesnt work for you, you should write your own system using these new hashtable natives.
Sadly, the new hashtable natives also don't work. A map that was already made using them will play fine in WC3, but the World Editor for Mac will not recognize the new 1.24 natives and won't validate or save if you try to use them.

e.g. uberfoop's code will not pass syntax checking due to use of GetHandleId().
 

Viikuna

No Marlo no game.
Reaction score
265
Meh, thats too bad. I think I need to shut up about all this mac things, since I dont have mac myself. I just know that NewGen doesnt work with mac.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top