Real Variable Event

Status
Not open for further replies.
Level 5
Joined
May 6, 2013
Messages
125
I have a damage detection system in my map that uses the real variable event to communicate what happens to other triggers. Its a beautifully convenient way, especially when working with GUI stuff (which most of my triggers that use this system are).

Now, i've noticed that some of the triggers don't work sometimes. Problem seems to have been that some of those triggers that react to damage do damage themselves, triggering the DDS. And apparently, the variable event doesnt like it. Here is a little test:


  • Trigger starter
    • Events
      • Player - Player 1 (Red) types a chat message containing test as Exact Match
    • Conditions
    • Actions
      • Set var = 1.00
  • Trigger 11
    • Events
      • Game - var becomes Equal to 1.00
    • Conditions
    • Actions
      • Game - Display to (All players) the text: 1-1 start
      • Set var = 2.00
      • Game - Display to (All players) the text: 1-1 end
  • Trigger 12
    • Events
      • Game - var becomes Equal to 1.00
    • Conditions
    • Actions
      • Game - Display to (All players) the text: 1-2 start
      • Game - Display to (All players) the text: 1-2 end
  • Trigger 21
    • Events
      • Game - var becomes Equal to 2.00
    • Conditions
    • Actions
      • Game - Display to (All players) the text: 2-1 start
      • Game - Display to (All players) the text: 2-1 end
  • Trigger 22
    • Events
      • Game - var becomes Equal to 2.00
    • Conditions
    • Actions
      • Game - Display to (All players) the text: 2-2 start
      • Set var = 3.00
      • Game - Display to (All players) the text: 2-2 end
  • Trigger 31
    • Events
      • Game - var becomes Equal to 3.00
    • Conditions
    • Actions
      • Game - Display to (All players) the text: 3-1 start
      • Game - Display to (All players) the text: 3-1 end
Now, i expected them to fire off recursively (like most triggers and their events do), executing the triggers 21 and 22 after var has been set to 2, and within them, executing trigger 31 when at var = 3, to then return and finish executing Trigger 11 and 12. Thats what i expected anyway. Here is what really happened:

Code:
1-1 start
  2-1 start
  2-1 end
  2-2 start
    3-1 start
    3-1 end
  2-2 end
  3-1 start 	<--- wtf
  3-1 end 	<--- wtf
1-1 end
		<-- skipped 1-2
3-1 start 	<--- wtf
3-1 end 	<--- wtf

i can't even really tell whats happening here. It's just randomly executing trigger 20.

With that behavior, the event doesnt work. If i can't be sure that every trigger that registered the event actually gets it, the event is not doing what it's supposed to do. How do other systems deal with that? Is there a different solution to do these events that can be used from GUI?
 
Last edited:
Level 5
Joined
May 6, 2013
Messages
125
Copied the Triggers incorrectly, fixed it now.
The System in question actually does go over 0, so that doesnt seem to do the trick as welll.
Using multiple different real variables in a circular-buffer-kind-of-way might work, but then i'd have to register the event for every single variable in it. It also would only work for recursions as deep as i used variables for.
 
Level 5
Joined
May 6, 2013
Messages
125
Same result when going over the takes damage event.

Note: turnEventTo is initialized with 1.
Also, excuse the lazy translations.

  • DDS
    • Events
      • Unit - Worker 0000 <gen> Takes Damage
    • Conditions
    • Actions
      • Custom script: local integer changeTo = udg_turnEventTo
      • Set turnEventTo = 1
      • Custom script: set udg_event = 0
      • Custom script: set udg_event = changeTo
  • Trigger 1
    • Events
      • Player - Player 1 (Rot) types a chat message containing test as Exact Match
    • Conditions
    • Actions
      • Unit - Cause Worker 0000 <gen> to damage Worker 0000 <gen>, dealing 10.00 damage of attack type <Spell? no idea how this is called in english> and damage type Normal
  • Trigger 11
    • Events
      • Spiel - event becomes Gleich 1.00
    • Conditions
    • Actions
      • Game - Display to (All players) the text: doing more damage
      • Set turnEventTo = 2
      • Unit - Cause Worker 0000 <gen> to damage Worker 0000 <gen>, dealing 10.00 damage of attack type Zaubersprüche and damage type Normal
      • Game - Display to (All players) the text: did more damage
  • Trigger 12
    • Events
      • Spiel - event becomes Gleich 1.00
    • Conditions
    • Actions
      • Game - Display to (All players) the text: trigger listening on event 1 (12)
  • Trigger 21
    • Events
      • Spiel - event becomes Gleich 2.00
    • Conditions
    • Actions
      • Game - Display to (All players) the text: trigger listening on event 2 (21)
  • Trigger 22
    • Events
      • Spiel - event becomes Gleich 2.00
    • Conditions
    • Actions
      • Game - Display to (All players) the text: trigger listening on event 2 (22)
Output:
Code:
doing more damage
trigger listening on event 2 (21)
trigger listening on event 2 (22)
did more damage
trigger listening on event 2 (21)
trigger listening on event 2 (22)

If you go deeper (event 3 inside 2, 4 inside 3 etc.), it looks like the pattern behind this is that he takes the triggers from the deepest recursion and executes them whenever he leaves one recursion step instead of the ones he was supposed to call. (if no trigger was supposed to be called, nothing happens).
Oddly enough though, thats not how it behaves when you only ever use the same event (always set event to 1); in these cases, it works perfectly. Even when you turn triggers on and off, it seems to never misbehave (even tho the on/off state seems to only be checked right before the trigger would fire, so that a trigger executed before a disabled trigger can turn it on and make it listen to an event that was thrown when it was actually disabled; thats normal behaviour though i guess.)

I suspect that they use the same, global trigger queue for this event. It would get overwritten when you activate it recursively, so once he leaves the recursion, he lost the information about what triggers remain as they are replaced with the queue from the recursion. When always the same event is used, the queue gets filled with always the same triggers, so that problem would probably not occur. The information at which trigger the execution was could be saved locally and thus not be affected by the recursion.

So, i guess using only one value as an event would do the trick. And if every trigger gets into that queue anyway, it cant be too much worse in terms of efficiency i guess.
 
Status
Not open for further replies.
Top