High speed triggers or a slow TriggerRegisterTimerEventPeriodic()

Level 12
Joined
Jan 3, 2022
Messages
117
Hello, I'm back with another WC3 scripting insight that has cost me more time than I'm willing to admit... Timer and Trigger frequencies.

What's the minimum interval of a Timer? "0.0" definitely works for a "fastest possible" setting.
What's the minimum interval of a Periodic Trigger? The famous... it depends!

WorldEdit let's you set both to 0.00 in GUI triggers but their speed was changed in a 1.32.x patch. Periodic triggers can only run at 0.010 (every 10ms) now in Reforged. This shouldn't have any effect on most maps, because in WE you could either set 0.01s or 0.00s. I don't think there're many maps that really relied on the 0.0s triggers. However, timers were not changed in Reforged. Here's a table:
ROC v1.0Reforged 1.32.10
TimerStart(myTimer, 0.000, true, function callback)~10000 times a second~10000 Hz
TriggerRegisterTimerEventPeriodic(thisTrig, 0.00)~10000 Hz100 Hz

In other words, you cannot have a regular Periodic trigger <10ms with new patches. If you need one, you must use timers to execute it at low timeouts.

Timer-vs-TrgTimerEventPeriodic.png

The table below describes frequences in the screenshot:
Trigger or Timer \ Tick countROC 1.0Reforged 1.32.10
1s (1000ms) Trigger Periodic1 Hz1 Hz
100ms Trg Periodic1010
20ms Trg Periodic5050
10ms Trg Periodic100100
5ms Trg Periodic200100
1ms Trg Periodic1000100
0ms Trg Periodic~10000100
GetTimeOfDay() changes per sec200 Hz200 Hz
1ms Timer10001000
0ms Timer~10000~10000

Tested versions:​

v1.0 ROC, 1.27.0 ROC/TFT, 1.31.1.12173 (last PTR): high speed trigger periodic
1.32.10 Reforged: 100ms trigger periodic.

Test map below, the map script was injected with MPQEditor, don't try to open the map in WE or the code will be lost! The v1.0 WE wouldn't let me save at all, even with default melee triggers. If the map doesn't show in old Warcraft, rename it to have a shorter name.
 

Attachments

  • TimeOfDay-codeInjected-ROC-v5.w3m
    121.5 KB · Views: 2
Level 12
Joined
Jan 3, 2022
Messages
117
There's no point but for me to explore the Warcraft Internals :wcool: I consider anything that uses <0.01s for game trigger logic as unnecessary.
Ideally, you wouldn't use 0.01s neither (approx. twice per game tick). Instead have game-tick-aligned triggers. They must run exactly once per game tick, something apparently not possible with regular triggers.
That's what I want to achieve by using Time of Day as a reference source and for that I do need reliable high speed timers (to check as often as possible, and when ToD changes then issue an event).
More tests soon!
 
Top