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

[Trigger] Desync Issue

Status
Not open for further replies.
Level 24
Joined
Nov 9, 2006
Messages
2,558
So i have these two triggers, i'm curious if theres something here that causes a desync.
It always occurs when the supply drops spawn in.
I've not yet had problems with this trigger until recently when i made a few adjustments.

The jist of it is that the game's a battle royale and a box spawns randomly inside the circle containing items, units or such.

  • Cache Spawn
    • Events
      • Time - CacheTimer expires
    • Conditions
      • GameOver Equal to False
    • Actions
      • Set Cache_TempPoint[1] = (Position of CircleUnit)
      • For each (Integer Cache_Integer1) from 1 to 100, do (Actions)
        • Loop - Actions
          • Set Cache_TempPoint[2] = (Cache_TempPoint[1] offset by ((Random real number between 0.00 and CircleRadius) + 0.00) towards (Random angle) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain pathing at Cache_TempPoint[2] of type Walkability is off) Equal to False
              • ((Playable map area) contains Cache_TempPoint[2]) Equal to True
            • Then - Actions
              • -------- Spacebar Point --------
              • Player Group - Pick every player in (All players) and do (Actions)
                • Loop - Actions
                  • Camera - Set a spacebar-point for (Picked player) at Cache_TempPoint[2]
              • -------- Run Trigger --------
              • Sound - Play Hint <gen>
              • Cinematic - Ping minimap for (All players) at Cache_TempPoint[2] for 30.00 seconds, using a Warning ping of color (25.00%, 100.00%, 25.00%)
              • -------- Clear Nearby Crops --------
              • Set Integer1 = (Random integer number between 1 and 3)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Integer1 Equal to 3
                • Then - Actions
                  • -------- Item Cache --------
                  • Unit - Create 1 Item Cache for Neutral Hostile at Cache_TempPoint[2] facing (Random angle) degrees
                  • Game - Display to (All players) for 5.00 seconds the text: |cffffcc00Note:|r A...
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Integer1 Equal to 2
                    • Then - Actions
                      • -------- Supply Cache --------
                      • Unit - Create 1 Supply Cache for Neutral Hostile at Cache_TempPoint[2] facing (Random angle) degrees
                      • Game - Display to (All players) for 5.00 seconds the text: |cffffcc00Note:|r A...
                    • Else - Actions
                      • -------- Prison Cage --------
                      • Unit - Create 1 Prison Cage for Neutral Hostile at Cache_TempPoint[2] facing (Random angle) degrees
                      • Game - Display to (All players) for 5.00 seconds the text: |cffffcc00Note:|r A...
              • -------- Loop Stuff --------
              • Unit - Set the custom value of (Last created unit) to 100
              • Unit Group - Add (Last created unit) to CacheUnitGroup
              • Unit - Make (Last created unit) Invulnerable
              • Animation - Change (Last created unit)'s vertex coloring to (25.00%, 100.00%, 25.00%) with 100.00% transparency
              • -------- Set New Timer --------
              • Set Real1 = (Random real number between SupplyDropMinCooldown and SupplyDropMaxCooldown)
              • Set Real2 = (20.00 x (Real(CircleNumber)))
              • Countdown Timer - Start CacheTimer as a One-shot timer that will expire in (Real1 + Real2) seconds
              • Set CacheTimer = (Last started timer)
              • -------- Cleaning --------
              • Custom script: call RemoveLocation(udg_Cache_TempPoint[1])
              • Custom script: call RemoveLocation(udg_Cache_TempPoint[2])
              • -------- Cache Loop --------
              • Trigger - Turn on Cache Loop <gen>
              • -------- Skip --------
              • Skip remaining actions
            • Else - Actions
              • Custom script: call RemoveLocation(udg_Cache_TempPoint[2])
      • Custom script: call RemoveLocation(udg_Cache_TempPoint[1])
      • -------- No Spawn --------
      • Game - Display to (All players) the text: Debug: Couldn't fin...
      • -------- Set New Timer --------
      • Set Real1 = (Random real number between SupplyDropMinCooldown and SupplyDropMaxCooldown)
      • Set Real2 = (20.00 x (Real(CircleNumber)))
      • Countdown Timer - Start CacheTimer as a One-shot timer that will expire in (Real1 + Real2) seconds
      • Set CacheTimer = (Last started timer)
The supply drop fades in over time. Becoming less transparent.
  • Cache Loop
    • Events
      • Time - Every 0.30 seconds of game time
    • Conditions
      • GameOver Equal to False
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CacheUnitGroup) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in CacheUnitGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Custom value of (Picked unit)) Greater than or equal to 0
                • Then - Actions
                  • Set Cache_TempPoint[3] = (Position of (Picked unit))
                  • Unit - Set the custom value of (Picked unit) to ((Custom value of (Picked unit)) - 1)
                  • Animation - Change (Picked unit)'s vertex coloring to (25.00%, 100.00%, 25.00%) with (Real((Custom value of (Picked unit))))% transparency
                  • Set Real1 = ((Real((Custom value of (Picked unit)))) - 100.00)
                  • Set Real2 = (Abs(Real1))
                  • Set Real3 = (Real2 x 4.50)
                  • Destructible - Pick every destructible within Real3 of Cache_TempPoint[3] and do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked destructible) is invulnerable) Equal to False
                        • Then - Actions
                          • Destructible - Set life of (Picked destructible) to ((Current life of (Picked destructible)) - 10.00)
                        • Else - Actions
                  • Custom script: call RemoveLocation(udg_Cache_TempPoint[3])
                • Else - Actions
                  • Set Cache_TempPoint[4] = (Position of (Picked unit))
                  • Special Effect - Create a special effect at Cache_TempPoint[4] using Objects\Spawnmodels\Undead\UDeathMedium\UDeath.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Animation - Change (Picked unit)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
                  • Unit Group - Remove (Picked unit) from CacheUnitGroup
                  • Unit - Make (Picked unit) Vulnerable
                  • Custom script: call RemoveLocation(udg_Cache_TempPoint[4])
        • Else - Actions
          • Trigger - Turn off (This trigger)
 
Level 8
Joined
May 21, 2019
Messages
435
Bump

Wondering if it has anything to do with temppoint having arrays?
Have you checked if there's a memory leak by looking at the memory usage of your game client?
Also, I have no idea about this one, but does the destructible "group" leak? It isn't cleaned, so I assume not.
 
Level 8
Joined
May 21, 2019
Messages
435
No i haven't tried that, does that even work?

Destructable group probably leaks, but it's ok.
It's not like i use the trigger a whole lot.
In the first trigger, you are running a terrain check for pathing. Have you tried disabling that line?

I recall hearing a few things about terrain actions being a big bag of bugs and poor optimization, especially with desync issues.

As for the memory thing, I recall seeing others saying that it works, and the only reason I can think of that would make it not work, is of the game has a fixed/static memory allocation of some sort, but I don't see why.
 
Level 8
Joined
May 21, 2019
Messages
435
I think only terrain deformations cause issues.
Checking pathing is something that's used in a lot of systems so i doubt thats it.
Its worth a shot. I am still reading through the code to see if there's something else that sticks out...

Also, you're running the destructible group 100 times per cache spawn. That does seem worth looking into.

Have you tried disabling random functions that may be heavy, to diagnose the root of the issue?
 
Last edited:
Level 24
Joined
Nov 9, 2006
Messages
2,558
It won't run a 100 times, that trigger only runs once.
What it does is check if the location is unpathable or outside map boundaries, then it will spawn a supply drop if it is.
Typically it will check 1 to 3 times.
It can recheck up to 100 times, i've set a limit to prevent an infinite loop should there not be any place for it.

I would try and disable certain things to test if i could, but the problem is that desyncs can only be tested in multiplayer.
My map is pretty big and there might be other desync problems that could happen too.
So it's impossible to find people willing to test with me a number of times.
 
Level 8
Joined
May 21, 2019
Messages
435
It won't run a 100 times, that trigger only runs once.
What it does is check if the location is unpathable or outside map boundaries, then it will spawn a supply drop if it is.
Typically it will check 1 to 3 times.
It can recheck up to 100 times, i've set a limit to prevent an infinite loop should there not be any place for it.

I would try and disable certain things to test if i could, but the problem is that desyncs can only be tested in multiplayer.
My map is pretty big and there might be other desync problems that could happen too.
So it's impossible to find people willing to test with me a number of times.

You're looking at the wrong trigger. I am talking about the periodic that runs on 100 counts of the destructible's custom value.

The pathing thing may actually leak a "path". Shot in the dark, but worth exploring. It could also desync because calculating up to 100 paths could take varying levels of time. It's potentially a quite heavy computation.

You could try amping this computation up to 1000 and then set a condition that it will only be accepted at the count of 1000 to ensure that it runs it 1000 times. If that causes an instant desync, then you've probably found your culprit.
 
Level 24
Joined
Nov 9, 2006
Messages
2,558
Oh yeah you're right lol, my bad.

In my other map Tree Tag Reforged generate terrain and create custom pathing, while also checking if areas are walkable, count as water, etc.
The process is a lot heavier there and i think i count 5000x5000 tiles or something, but i've never had desync problem in that map so i doubt it has anything to do with checking pathing.
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,887
You're leaking Cache_TempPoint[2], it should be outside the if-statement not on the else part on cache spawn.
I couldn't find anything that would cause desync.
"calculating 100 paths" is nothing, what is troublesome is creating a considerable amount of units at same time, since the create function is quite expensive and might cause a few lag spikes.
Only terrain deformations are prone to desyncs, and they also cause a permanent leak. Checking pathing has nothing to do with this.
 
Level 8
Joined
May 21, 2019
Messages
435
You're leaking Cache_TempPoint[2], it should be outside the if-statement not on the else part on cache spawn.
I couldn't find anything that would cause desync.
"calculating 100 paths" is nothing, what is troublesome is creating a considerable amount of units at same time, since the create function is quite expensive and might cause a few lag spikes.
Only terrain deformations are prone to desyncs, and they also cause a permanent leak. Checking pathing has nothing to do with this.
I don't get why that would cause a leak. For each itteration of the loop, he is deleting in either the Then or the Else actions. When would that leak?
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,887
I don't get why that would cause a leak. For each itteration of the loop, he is deleting in either the Then or the Else actions. When would that leak?
I missed it in the Then actions, but it is always better to only put 1 outside the if-statement since it doesn't matter if the condition is met or not. The result is the same, but just less repetition.
 
Level 8
Joined
May 21, 2019
Messages
435
I missed it in the Then actions, but it is always better to only put 1 outside the if-statement since it doesn't matter if the condition is met or not. The result is the same, but just less repetition.
That's true, but he is running a "skip remaining actions" in the then loop, so that would leak in this case.
 
Level 8
Joined
May 21, 2019
Messages
435
There is no destructible ‘group’ to leak because they don’t exist. That action uses EnumDestructiblesInRect(). Wrda is correct that pathing has nothing to do with a desync.
I'm just spitballing ideas here. :)
Doesn't really seem like there's anything obvious wrong with these 2 triggers.
 
Level 24
Joined
Nov 9, 2006
Messages
2,558
I made the first trigger loop now run at a 0.1 to find a valid spawnpoint.
However the desync still occurs, but that means it's trigger number 2 most likely that causes the desync or the moment the box spawns.
Not anything leading up to it.

  • Cache Spawn Time
    • Events
      • Time - CacheTimer expires
    • Conditions
      • GameOver Equal to False
    • Actions
      • Set CacheSpawnLoopInteger = 0
      • Trigger - Turn on Cache Spawn Loop <gen>
  • Cache Spawn Loop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
      • GameOver Equal to False
    • Actions
      • Set CacheSpawnLoopInteger = (CacheSpawnLoopInteger + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CacheSpawnLoopInteger Less than 100
        • Then - Actions
          • Game - Display to (All players) the text: (Debug: Look for valid spawn attempt # + (String(CacheSpawnLoopInteger)))
          • Set Cache_TempPoint1 = (Position of CircleUnit)
          • Set Cache_TempPoint2 = (Cache_TempPoint1 offset by ((Random real number between 0.00 and CircleRadius) + 0.00) towards (Random angle) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain pathing at Cache_TempPoint2 of type Walkability is off) Equal to False
              • ((Playable map area) contains Cache_TempPoint2) Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: Debug: Spawn
              • -------- Spacebar Point --------
              • Player Group - Pick every player in (All players) and do (Actions)
                • Loop - Actions
                  • Camera - Set a spacebar-point for (Picked player) at Cache_TempPoint2
              • -------- Run Trigger --------
              • Sound - Play Hint <gen>
              • Cinematic - Ping minimap for (All players) at Cache_TempPoint2 for 30.00 seconds, using a Warning ping of color (25.00%, 100.00%, 25.00%)
              • -------- Clear Nearby Crops --------
              • Set Integer1 = (Random integer number between 1 and 3)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Integer1 Equal to 3
                • Then - Actions
                  • -------- Item Cache --------
                  • Unit - Create 1 Item Cache for Neutral Hostile at Cache_TempPoint2 facing (Random angle) degrees
                  • Game - Display to (All players) for 5.00 seconds the text: |cffffcc00Note:|r A...
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Integer1 Equal to 2
                    • Then - Actions
                      • -------- Supply Cache --------
                      • Unit - Create 1 Supply Cache for Neutral Hostile at Cache_TempPoint2 facing (Random angle) degrees
                      • Game - Display to (All players) for 5.00 seconds the text: |cffffcc00Note:|r A...
                    • Else - Actions
                      • -------- Prison Cage --------
                      • Unit - Create 1 Prison Cage for Neutral Hostile at Cache_TempPoint2 facing (Random angle) degrees
                      • Game - Display to (All players) for 5.00 seconds the text: |cffffcc00Note:|r A...
              • -------- Loop Stuff --------
              • Game - Display to (All players) the text: Debug: Start fade l...
              • Unit - Set the custom value of (Last created unit) to 100
              • Unit Group - Add (Last created unit) to CacheUnitGroup
              • Unit - Make (Last created unit) Invulnerable
              • Animation - Change (Last created unit)'s vertex coloring to (25.00%, 100.00%, 25.00%) with 100.00% transparency
              • -------- Set New Timer --------
              • Set Real1 = (Random real number between SupplyDropMinCooldown and SupplyDropMaxCooldown)
              • Set Real2 = (20.00 x (Real(CircleNumber)))
              • Countdown Timer - Start CacheTimer as a One-shot timer that will expire in (Real1 + Real2) seconds
              • Set CacheTimer = (Last started timer)
              • -------- --------
              • Trigger - Turn on Cache Fade Loop <gen>
              • -------- --------
              • Trigger - Turn off (This trigger)
            • Else - Actions
          • Custom script: call RemoveLocation(udg_Cache_TempPoint1)
          • Custom script: call RemoveLocation(udg_Cache_TempPoint2)
        • Else - Actions
          • -------- No Spawn --------
          • Game - Display to (All players) the text: Debug: Couldn't fin...
          • -------- Set New Timer --------
          • Set Real1 = (Random real number between SupplyDropMinCooldown and SupplyDropMaxCooldown)
          • Set Real2 = (20.00 x (Real(CircleNumber)))
          • Countdown Timer - Start CacheTimer as a One-shot timer that will expire in (Real1 + Real2) seconds
          • Set CacheTimer = (Last started timer)
          • -------- --------
          • Trigger - Turn off (This trigger)
  • Cache Fade Loop
    • Events
      • Time - Every 0.30 seconds of game time
    • Conditions
      • GameOver Equal to False
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CacheUnitGroup) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in CacheUnitGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Custom value of (Picked unit)) Greater than or equal to 0
                • Then - Actions
                  • Set Cache_TempPoint1 = (Position of (Picked unit))
                  • Unit - Set the custom value of (Picked unit) to ((Custom value of (Picked unit)) - 1)
                  • Animation - Change (Picked unit)'s vertex coloring to (25.00%, 100.00%, 25.00%) with (Real((Custom value of (Picked unit))))% transparency
                  • Set Real1 = ((Real((Custom value of (Picked unit)))) - 100.00)
                  • Set Real2 = (Abs(Real1))
                  • Set Real3 = (Real2 x 4.50)
                  • Destructible - Pick every destructible within Real3 of Cache_TempPoint1 and do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked destructible) is invulnerable) Equal to False
                        • Then - Actions
                          • Destructible - Set life of (Picked destructible) to ((Current life of (Picked destructible)) - 10.00)
                        • Else - Actions
                  • Custom script: call RemoveLocation(udg_Cache_TempPoint1)
                • Else - Actions
                  • Set Cache_TempPoint1 = (Position of (Picked unit))
                  • Special Effect - Create a special effect at Cache_TempPoint1 using Objects\Spawnmodels\Undead\UDeathMedium\UDeath.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Animation - Change (Picked unit)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
                  • Unit Group - Remove (Picked unit) from CacheUnitGroup
                  • Unit - Make (Picked unit) Vulnerable
                  • Custom script: call RemoveLocation(udg_Cache_TempPoint1)
        • Else - Actions
          • Trigger - Turn off (This trigger)
 
Last edited:
Level 24
Joined
Nov 9, 2006
Messages
2,558
No i don't have anything local stuff going on.
I tested by removing the tree stuff, that wasn't it either.
So it's probably between playing the sound to starting the timer.

Starting to doubt it has anything to do with the trigger then.
Gonna test removing Giga Drain spell which uses a lot of systems.
 
Last edited:
Status
Not open for further replies.
Top