• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Is it possible to run multiple instances of the same periodic trigger at a time?

Level 5
Joined
May 10, 2024
Messages
57
Hi. I have a triggerA which fires every 0.05 seconds (periodic time event). TriggerA has no wait function calls.

1. If triggerA takes more than 0.05 seconds to fire, does the engine fire a second instance of that trigger before the first one finishes?
2. If something in the game takes up the thread for 1 second (game freezing). What would happen? Will engine start 1 instance of triggerA or 20 instances?

I assume that both are false but I have no idea how to check it. Probably a lot of nested loops will help?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Is there something specific that you're trying to accomplish that requires this information?

Anyway, I imagine if everything runs on the main thread, and the main thread is paused, then the timers would be paused as well (periodic interval uses a timer), so the timer keeping track of the elapsed time in TriggerA would be paused as well.

So for example, it's been 0.02/0.05 seconds, you need 0.03 more seconds until TriggerA runs. You then do something crazy to freeze the main thread for 1s. After 1s, the craziness stops and everything resumes. You're still at ~0.02/0.05 seconds.

Although I'm basically talking out of my ass here. I'm not much of an expert on this sort of thing.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
1. If triggerA takes more than 0.05 seconds to fire, does the engine fire a second instance of that trigger before the first one finishes?
Yes. If you block a thread of triggerA for more than 0.05 seconds, such as using TriggerSleepAction, then another thread will be created and run in parallel. Same for all events. This can lead to thread leaks if the thread ends up blocking or running forever and more instances of it are allowed to be created.
2. If something in the game takes up the thread for 1 second (game freezing). What would happen? Will engine start 1 instance of triggerA or 20 instances?
Game freezes do not advance game time. Real time and game time are two different concepts. Although game time tries to relate to real time, if freezes or other CPU bottlenecks exist it can fall behind. Like wise game speed changes this attempted relationship between game time and real time.

TriggerSleepAction is one of the few exceptions since it uses network synchronised real time rather than game time like timers and periodic events. This is why its timing accuracy is so poor. TriggerSleepAction should only really be used when you want actions to relate to real time, such as playing sounds.
 
Top