• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Strange location issues

Status
Not open for further replies.
Hello,

In my map I have players that reported units that spawn at a different location than expected.

For example the trigger below. I set TempPoint as a global variable, the location where I will create my units. Is it possible that my global variable TempPoint is modified between my 2 calls to the function "Unit - Create" ?

- For exemple, events like "Unit enters in (Entire Map)" or "Unit is issued an order" could fire between the 2 calls ?
- Can there be any asynchronous trigger executing at the same time ?

  • For each (Integer A) from 1 to 4, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (WaveNumber Equal to (Integer A)) or ((WaveNumber Equal to ((Integer A) + 4)) or (WaveNumber Equal to ((Integer A) + 8)))
        • Then - Actions
          • Set TempPoint = (Center of WaveCome[(Integer A)])
          • Unit - Create (5 + WaveNumber) WaveUnit[WaveNumber] for Player 11 (Dark Green) at TempPoint facing DefensePoint
          • Unit Group - Pick every unit in (Last created unit group) and do (Actions)
            • Loop - Actions
              • Unit - Order (Picked unit) to Attack-Move To DefensePoint
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ModeSingle Equal to False
            • Then - Actions
              • Unit - Create (5 + WaveNumber) WaveUnit[WaveNumber] for Player 11 (Dark Green) at TempPoint facing DefensePoint
              • Unit Group - Pick every unit in (Last created unit group) and do (Actions)
                • Loop - Actions
                  • Unit - Order (Picked unit) to Attack-Move To DefensePoint
            • Else - Actions
              • Do nothing
          • Custom script: call RemoveLocation(udg_TempPoint)
        • Else - Actions
          • Do nothing
Edit: WaveCome is a region array of 4 rectangle regions. Because my creeps can spawn from west, north, east or south
 
Last edited:
For exemple, events like "Unit enters in (Entire Map)" or "Unit is issued an order" could fire between the 2 calls ?
Yes, exactly. "Create Unit" will fire respective "Enters Region" event, if it matches. And "Ordering Unit" does fire registered order event triggers.

Can there be any asynchronous trigger executing at the same time ?
Nope. Like also the above noted triggers will fire, it's executed all one after an other. We just might not always know everything what happens in such "one" step, if other things are called behind.

Same goes for IntegerA, it can be changed by such calls, when executed triggers again use IntegerA loops. Have a look: 5. Loop Interfering - Problem.
 
Yes, exactly. "Create Unit" will fire respective "Enters Region" event, if it matches. And "Ordering Unit" does fire registered order event triggers.

So the events don't fire after the end of the execution of the triggers already in the queue, but right now, in the middle of my currently executing trigger ?
If yes, that's an akward event system that Blizzard made us here :S
 
Yes, they fire right away.
It's actually pretty normal though. One does expect the events to fire directly at the event, not at some (from event side seen) arbitary operation queue.
The result is similar to using:
  • Trigger - MyTrigger <gen> (checking conditions)
^here one can more easily see that the "registered" trigger will directly run.

Edit:

Or maybe a better example is how the real event works.

  • Events
    • Game - MyRealVariable becomes Equal to 1.00
Any other trigger doing this:
  • Set MyRealVAriable = 1.00
would directly call the trigger above, before proceeding to further actions.
That's how most custom events in GUI work, and can use it for structering before/after events.
 
Last edited:
It's actually pretty normal though. One does expect the events to fire directly at the event, not at some (from event side seen) arbitary operation queue.

Well I am a software developer, and I don't usualy see that. In multithreading softwares like User Interfaces, that work mainly with events (button clicked, etc...) there is no problem, the code just has to be safe for multithreading.

In 3D rendering software, usually the events fire at the next frame (so only your FPS matters).

Back to our topic. This is a nightmare for me... Since I am developing in GUI, I am using some "TempXXX" globals as temporary variables. And many triggers use the same globals. So I'll have to check any of them...

Edit: will the local global trick solve my issue of TempXXX variables ?
The GUI Local Variable Trick - Wc3C.net
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Well I am a software developer, and I don't usualy see that. In multithreading softwares like User Interfaces, that work mainly with events (button clicked, etc...) there is no problem, the code just has to be safe for multithreading.

In 3D rendering software, usually the events fire at the next frame (so only your FPS matters).

Although you can't apply same logic to games. Consider a scenario where unit X uses a triggered spell that does damage to unit Y and if life of target unit is under a certain threshold after damage it dies, and unit Y has a triggered skill that blocks damage. By your proposition Y's damage block skill would not work. You can think of many other scenarios.
 
Yes, using the shadowing trick used to solve it as workaround. You might also think switching to JASS or Lua, it might be not hard you as software developer, and then just proper ways like alwys using locals can be used.

Well the legacy of my map uses GUI. I modified it to avoid memory leaks (before the TempPoint & other variables didn't exist). However I did not expect this behavior. Changing it all would need days and days. However I agree than for my future developments, if they are complex, it is better to switch to JASS, vJASS or Lua ^^
 
Interesting, the unit can already be moved out of region when the EnterRegion event fires, or can be actually there again when the LeaveRegion event fires. So, the event does not necessarily say something about a unit's position. Seems kind of wrong.

It feels like regions periodically check if the event has to run, instead of an instant run. And the events get fired all at once for enter- or leave event for a region, like from a queue.

I changed the testmap, to create one unit at a region, and moving it a few times back and forth into an other region, right after creation.
 

Attachments

  • TestVariable.w3x
    25.6 KB · Views: 27
Last edited:
Status
Not open for further replies.
Top