When are periodic triggers executed?

Imp Midna

Active Member
Reaction score
52
Basically, after a few minutes of testing, i found out that this trigger:
Trigger:
  • inflBurn
    • Events
      • Player - Spieler 1 (Rot) types a chat message containing -inflBurn as Ein Teil-String
    • Conditions
    • Actions
      • Set AT_Real = (Real((Substring((Entered chat string), 11, (Length of (Entered chat string))))))
      • Game - Display to (All players) the text: (vorher; + (String(AT_Real)))
      • Unit Group - Pick every unit in (Units currently selected by Spieler 1 (Rot)) and do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (vorher; + (String(AT_Real)))
          • Custom script: set udg_AT_Int = inflBurn(GetEnumUnit(), GetEnumUnit(), udg_AT_Real)
          • Game - Display to (All players) the text: ((String(AT_Real)) + ( - + (String(AT_Int))))

occasionally fails, because AT_Real (where AT is short for "Allgemein Temporär", which means it is a 'General, temporarily used' variable) gets a new value between the first and the second Display action. The new value seemingly comes from a callback function using it which should be executed every 0.25 seconds.

Now, originally when i came up with the whole temp var concept, i thought a trigger is fully executed before the next trigger is picked from the trigger queue. With the time i found out that some triggers instantly execute another one (damaging a unit will cause triggers with the "unit takes damage" to be executed before the damaging trigger continues; other examples are the item drop event and such); but this timer-event really messes things up.

To reduce the paranoia that this issue brings up, i just want to aks if anybody knows:
when the heck is a periodic trigger executed? after every call? after every user defined function? can it interrupt anything happening in the trigger? does that mean that even using LastCreatedEffectBj is never ever save anymore from the point where you have a timer-based trigger? dafuq?
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
I'm not really getting the problem here. A demonstration of what's going on would be nice.
 

Dameon

"All the power in the world resides in the eyes"
Reaction score
127
he is saying that his values are being reset by other triggers as the trigger runs, in this case his real value is being reset by another trigger before the trigger he posted finishes running.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
he is saying that his values are being reset by other triggers as the trigger runs, in this case his real value is being reset by another trigger before the trigger he posted finishes running.
I get that, but what's changing the value? Something happens to it in the inflBurn function, as far as I can tell, but after that I'm lost.
 

Dameon

"All the power in the world resides in the eyes"
Reaction score
127
the triggers all run in a que and all triggers are made up of functions, basically some functions have a higher priority then others and are moved to the front of the que, this over writes the variables with the info from the new function.

All this is only a guess on my part since I haven't looked at the coding for the game my self. But it seems like it would be the most likely reason.
 

Imp Midna

Active Member
Reaction score
52
Broken down example:
Trigger:
  • Periodic trigger
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Set tmpReal = 10.00
      • Game - Display to (All players) the text: ---> resetting

Trigger:
  • Test-Trigger
    • Events
      • Spieler - Spieler 1 (Rot) types a chat message containing -test as Exakte Ãœbereinstimmung
    • Conditions
    • Actions
      • Set tmpReal = 5.00
      • Game - Display to (All players) the text: setting
      • Unitgroup - Pick every unit in (Units currently selected by Spieler 1 (Rot)) and do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: in the loop


In the game, write "-test" a few times to trigger the Test-Trigger, and you will, after a few tries, get this output:
--->resetting
--->resetting
setting
--->resetting
in the loop
--->resetting

instead of
--->resetting
--->resetting
setting
in the loop
--->resetting
Well, if you are more into 'visual' effects, take a look at these example triggers:

Trigger:
  • Periodic
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Special Effect - Create a special effect at ((Center of (Playable map area)) offset by (1000.00, 1000.00)) using Abilities\Spells\Orc\Ensnare\EnsnareMissile.mdl
      • Special Effect - Destroy (Last created special effect)

Trigger:
  • Important Mechanic
    • Events
      • Spieler - Spieler 1 (Rot) types a chat message containing -important as Exakte Ãœbereinstimmung
    • Conditions
    • Actions
      • Special Effect - Create a special effect at (Center of (Playable map area)) using Abilities\Weapons\IllidanMissile\IllidanMissile.mdl
      • Unit Group - Pick every unit in (Units currently selected by Triggering Player) and do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: ((Name of (Picked unit)) + is selected <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" />)
          • Unit - Order (Picked Unit) to Attack Important_Target
      • Special Effect - Destroy (Last created special effect)


In Furstratingly many cases, the Special Effect in the "Important Mechanic" Trigger will_not_be_destroyed; reason's the same as in the first example. And that would mean: from the point where you have a periodic trigger creating a special effect, you may never be sure if it ain't kicking some triggers in its nuts by killing Last created special effect.

Seeing that my variable might get crushed for doing something that looks totally fine actually scares me off. In fact, the Black Sheep seems to be the "Units selected by Player" action; it works fine for like 10 minutes perma-testing if i use other methods to fill my group. Problem is that you cant tell by the look of the action that it would allow periodic triggers to be executed; neither does that proof that it always works with the over filling methods (i simply gave up). And if you never know when they are executed, youre screwed. It's as if you would have a wait after every action: nothing is save anymore. And that causes Paranoia.
 

Dameon

"All the power in the world resides in the eyes"
Reaction score
127
converting it to jass makes it a little clearer. These are direct converts.
1g
Trigger:
  • set gui
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Set r_temp = 10.00

1j
JASS:
function Trig_set_Actions takes nothing returns nothing
    set udg_r_temp = 10.00
endfunction
 
//===========================================================================
function InitTrig_set takes nothing returns nothing
    set gg_trg_set = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_set, 0.25 )
    call TriggerAddAction( gg_trg_set, function Trig_set_Actions )
endfunction

2g
Trigger:
  • Test gui
    • Events
      • Player - Player 1 (Red) types a chat message containing -test as An exact match
    • Conditions
    • Actions
      • Set r_temp = 5.00
      • Game - Display to (All players) the text: (String(r_temp))
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (String(r_temp))

2j
JASS:
function Trig_Test_Func003A takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), R2S(udg_r_temp) )
endfunction
 
function Trig_Test_Actions takes nothing returns nothing
    set udg_r_temp = 5.00
    call DisplayTextToForce( GetPlayersAll(), R2S(udg_r_temp) )
    call ForGroupBJ( GetUnitsInRectAll(GetPlayableMapRect()), function Trig_Test_Func003A )
endfunction
 
//===========================================================================
function InitTrig_Test takes nothing returns nothing
    set gg_trg_Test = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Test, Player(0), &quot;-test&quot;, true )
    call TriggerAddAction( gg_trg_Test, function Trig_Test_Actions )
endfunction
 
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