• 🏆 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!

How can I use countdown timers instead of unit expiration timer ?

Status
Not open for further replies.
Level 11
Joined
Oct 9, 2015
Messages
721
How can I properly use countdown timers instead of using an dummy unit with expiration timer and detecting when it dies ? I need to use the timer as an array, I already have the trigger using dummy unit if it needs to be posted (it's a very long trigger). What I wanted was to change my existing system to a more efficient one, in this case change unit expiration timer to countdown timer.
Thanks!
 
If you want to effictly use timers one needs knowledge about hashtable and GetHandleId() function, which is only useable with "Custom script" in GUI.

In real GUI though there is also a good way of mimic timer behaviour, using artifical wait behaviour: http://www.hiveworkshop.com/threads/mui-spells-using-artificial-waits.223315/
In here you have pretty much control over your instance that is about being killed because you have a counter and a possible check periodicly provided by yourself.
 
You definitely want to use timers, creating dummy units for the purpose of emulating a timer is extremely redundant and can be resource intensive if done often enough. My suggestion for you is to get Jass Gen New Pack http://blizzardmodding.info/4263/the-jass-newgen-pack-jngp-2-0/

Then try converting triggers to custom text/script/whatever it calls itself

Play around with it a bit before continuing development on your map. Trust me it pays off big time, allowing you to circumvent many problems that GUI presents. GUI lacks MANY functions and is generally slower once you get the hang of jass/vjass. With GUI you end up doing hacky weird things such as using dummy units as timers, instead of being able to fully harness the power of the editor.

It may seem daunting at first, but is well worth it in the end.

This is all a suggestion of course; you can get by with doing hacky things, but it has its limits especially when it comes to effeciency. Unfortunately my answer involving using timers requires you to have some knowledge of jass. If you wish to learn further, you can PM me and I could send you tutorials. If not, thats okay too.
 
Level 12
Joined
May 22, 2015
Messages
1,051
If you use JASS, the functions are fairly simple to use:
JASS:
function timerCallBack takes nothing returns nothing
    // Do stuff after timer has expired.
    call DestroyTimer(GetExpiredTimer()) // Destroy the timer so you don't leak it.
endfunction

function doStuffWithDelay takes nothing returns nothing
    local timer t = CreateTimer()
    call TimerStart(t, 5, false, function timerCallBack) // Starts the timer with 5 second delay, no repeat, and calls the timerCallBack function after the 5 seconds.
    set t = null
endfunction

You can also use hashtables to store data with the timers. It is also possible to recycle timers. There are systems built for that, though.
 
Status
Not open for further replies.
Top