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

High speed triggers or a slow TriggerRegisterTimerEventPeriodic()

Status
Not open for further replies.
Level 19
Joined
Jan 3, 2022
Messages
320
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.

PS: TriggerRegisterTimerEvent is used by as TriggerRegisterTimerEventPeriodic, TriggerRegisterTimerEventSingle, PostTriggerExecuteBJ.
 

Attachments

  • TimeOfDay-codeInjected-ROC-v5.w3m
    121.5 KB · Views: 6
Last edited:
Level 19
Joined
Jan 3, 2022
Messages
320
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!
 
Level 19
Joined
Jan 3, 2022
Messages
320
Nice, I thought I was the only one. I encountered this not with TriggerRegisterTimerEventPeriodic but regular timers set to 0s (in August):
zeromstimer-v1-screenshot.png

His video also stops at 8:58 (538s), I found that Reforged freezes after 512s. So he started a timer at approximately 0:26 (when he learned the Améliorer skill).
What I didn't find during tests, whether a timer set to 0.001 or 0.01 (minimum in WE without workarounds) will crash too? My conclusion so far: no, they will not crash.
Volsung: So far it seems that what was causing my freezes was all the 0.01 time related datas.
If you have spells with 0.01 duration for instance, it might cause the game to freeze eventually. Check if you have any custom spell with time data lower than 0.10 and replace it by either 0.10 or 0 (cooldown, duration, intervals, etc…). Check if you have any trigger with 0.01 wait or elapse and replace by 0.10. Retry after that.
 
Status
Not open for further replies.
Top