- Joined
- Feb 27, 2019
- Messages
- 401
Hello,
Some well-known systems for your custom maps use "Value of Real Variable" events as API you can use to get notified of some game actions. For example a well known is GUI Unit Event by @Bribe :
For example, the system executes the code below:
And you can create triggers with event "Value of Real Variable" Event1 equals 1.00. The 2 times you set it to zero is to be sure is modified, and to clean it afterward.
I discovered a limitation of those events through a bug in my map : Blizzard coded the engine behavior for such events soo poorly than a nested "Value of Real Variable" event will change the variable value of the caller/parent, thus if you have a listener later on it won't work properly. But only in the listener contexts, in GUI or JASS. I haven't tested a vJASS listener.
Le me show you through an example (map attached to this topic):
And the result is WTF: it's the logger for Event1 = 33.00 that is called, instead of the logger for Event1 = 5.00. But when I check 5s later, Event1 is equal to 5.00 as expected.
So my guess is that Blizzard fucked its implementation of the event listener system, and uses a reference on a static variable that is the same for all "Value of Real Variable" events.
So for ex with GUI Unit Event by @Bribe, if you've listeners to UnitIndexEvent & UnitInActionEvent you may encounter the bug.
Some well-known systems for your custom maps use "Value of Real Variable" events as API you can use to get notified of some game actions. For example a well known is GUI Unit Event by @Bribe :
For example, the system executes the code below:
JASS:
Set VariableSet Event1 = 0.00
Set VariableSet Event1 = 1.00
Set VariableSet Event1 = 0.00
And you can create triggers with event "Value of Real Variable" Event1 equals 1.00. The 2 times you set it to zero is to be sure is modified, and to clean it afterward.
I discovered a limitation of those events through a bug in my map : Blizzard coded the engine behavior for such events soo poorly than a nested "Value of Real Variable" event will change the variable value of the caller/parent, thus if you have a listener later on it won't work properly. But only in the listener contexts, in GUI or JASS. I haven't tested a vJASS listener.
Le me show you through an example (map attached to this topic):
- We have a map with 2 real variables "Event1" & "Event2".
- Let's fire "Event1" = 0.5 on map initialization, and let's have a trigger listening Event1 that emits a second event, Event2 = 1. For a better visibility, instead of reseting Event2 to 0.00 I'll reset it to 0.33.
-
Fire event1 on init
-
Events
-
Map initialization
-
-
Conditions
-
Actions
-
Set VariableSet Event1 = 0.00
-
Set VariableSet Event1 = 5.00
-
Set VariableSet Event1 = 0.00
-
-
-
ChainEvents
-
Events
-
Game - Event1 becomes Equal to 0.50
-
-
Conditions
-
Actions
-
Game - Display to (All players) the text: Chaining events!
-
Set VariableSet Event2 = 0.00
-
Set VariableSet Event2 = 10.00
-
Set VariableSet Event2 = 33.00
-
Game - Display to (All players) the text: (Check OK: Event1 still equal to + (String(Event1)))
-
-
And the result is WTF: it's the logger for Event1 = 33.00 that is called, instead of the logger for Event1 = 5.00. But when I check 5s later, Event1 is equal to 5.00 as expected.
So my guess is that Blizzard fucked its implementation of the event listener system, and uses a reference on a static variable that is the same for all "Value of Real Variable" events.
So for ex with GUI Unit Event by @Bribe, if you've listeners to UnitIndexEvent & UnitInActionEvent you may encounter the bug.