So, I have a map, where if a frog gets too close to a driving car, it explodes.
The frog is then revived and the player gets locked onto it.
However, I wanted the player to see the bloodsplatter when they died, so I decided to put a 1 second wait onto the event. However, as it turns out, this made the map unable to refer to frog when creating a new one for the owner. So apparently, an exploded unit is removed from the memory fairly fast.
In order to fix it, I came up with this abomination (which works perfectly):
However, that's a ridiculously long trigger, it looks like crap in the GUI as it keeps indenting to the right, and making changes or refactoring it is harder because it has 12 layers. So, I made slimmer loop based version:
I have no idea why, but it seems like the loop sometimes ends up getting a different Integer A. Maybe the wait is causing it to run and overlap another execution of it? Would make sense, except that I have had this thing pick the wrong player on the first execution so... I am a bit lost. What is making this loop unstable? How do I fix it?
The frog is then revived and the player gets locked onto it.
However, I wanted the player to see the bloodsplatter when they died, so I decided to put a 1 second wait onto the event. However, as it turns out, this made the map unable to refer to frog when creating a new one for the owner. So apparently, an exploded unit is removed from the memory fairly fast.
In order to fix it, I came up with this abomination (which works perfectly):
-
CrossRoad Frog Killer
-
Events
-
Conditions
-
(Unit-type of (Triggering unit)) Equal to Squishy Frog
-
-
Actions
-
Player - Add 1 to (Owner of (Triggering unit)) Current lumber
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Owner of (Triggering unit)) Equal to Player 1 (Red)
-
-
Then - Actions
-
Unit - Explode (Triggering unit)
-
Wait 1.00 seconds
-
Set RespawnPoint = (Random point in CurrentRespawnRegion)
-
Unit - Create 1 GameCharacterType for Player 1 (Red) at RespawnPoint facing Default building facing degrees
-
Custom script: call RemoveLocation(udg_RespawnPoint)
-
Camera - Lock camera target for (Owner of (Last created unit)) to (Last created unit), offset by (0.00, 0.00) using Default rotation
-
Selection - Select (Last created unit) for (Owner of (Last created unit))
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Owner of (Triggering unit)) Equal to Player 2 (Blue)
-
-
Then - Actions
-
Unit - Explode (Triggering unit)
-
Wait 1.00 seconds
-
Set RespawnPoint = (Random point in CurrentRespawnRegion)
-
Unit - Create 1 GameCharacterType for Player 2 (Blue) at RespawnPoint facing Default building facing degrees
-
Custom script: call RemoveLocation(udg_RespawnPoint)
-
Camera - Lock camera target for (Owner of (Last created unit)) to (Last created unit), offset by (0.00, 0.00) using Default rotation
-
Selection - Select (Last created unit) for (Owner of (Last created unit))
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Owner of (Triggering unit)) Equal to Player 3 (Teal)
-
-
Then - Actions
-
Unit - Explode (Triggering unit)
-
Wait 1.00 seconds
-
Set RespawnPoint = (Random point in CurrentRespawnRegion)
-
Unit - Create 1 GameCharacterType for Player 3 (Teal) at RespawnPoint facing Default building facing degrees
-
Custom script: call RemoveLocation(udg_RespawnPoint)
-
Camera - Lock camera target for (Owner of (Last created unit)) to (Last created unit), offset by (0.00, 0.00) using Default rotation
-
Selection - Select (Last created unit) for (Owner of (Last created unit))
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Owner of (Triggering unit)) Equal to Player 4 (Purple)
-
-
Then - Actions
-
Unit - Explode (Triggering unit)
-
Wait 1.00 seconds
-
Set RespawnPoint = (Random point in CurrentRespawnRegion)
-
Unit - Create 1 GameCharacterType for Player 4 (Purple) at RespawnPoint facing Default building facing degrees
-
Custom script: call RemoveLocation(udg_RespawnPoint)
-
Camera - Lock camera target for (Owner of (Last created unit)) to (Last created unit), offset by (0.00, 0.00) using Default rotation
-
Selection - Select (Last created unit) for (Owner of (Last created unit))
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Owner of (Triggering unit)) Equal to Player 5 (Yellow)
-
-
Then - Actions
-
Unit - Explode (Triggering unit)
-
Wait 1.00 seconds
-
Set RespawnPoint = (Random point in CurrentRespawnRegion)
-
Unit - Create 1 GameCharacterType for Player 5 (Yellow) at RespawnPoint facing Default building facing degrees
-
Custom script: call RemoveLocation(udg_RespawnPoint)
-
Camera - Lock camera target for (Owner of (Last created unit)) to (Last created unit), offset by (0.00, 0.00) using Default rotation
-
Selection - Select (Last created unit) for (Owner of (Last created unit))
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Owner of (Triggering unit)) Equal to Player 6 (Orange)
-
-
Then - Actions
-
Unit - Explode (Triggering unit)
-
Wait 1.00 seconds
-
Set RespawnPoint = (Random point in CurrentRespawnRegion)
-
Unit - Create 1 GameCharacterType for Player 6 (Orange) at RespawnPoint facing Default building facing degrees
-
Custom script: call RemoveLocation(udg_RespawnPoint)
-
Camera - Lock camera target for (Owner of (Last created unit)) to (Last created unit), offset by (0.00, 0.00) using Default rotation
-
Selection - Select (Last created unit) for (Owner of (Last created unit))
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Owner of (Triggering unit)) Equal to Player 7 (Green)
-
-
Then - Actions
-
Unit - Explode (Triggering unit)
-
Wait 1.00 seconds
-
Set RespawnPoint = (Random point in CurrentRespawnRegion)
-
Unit - Create 1 GameCharacterType for Player 7 (Green) at RespawnPoint facing Default building facing degrees
-
Custom script: call RemoveLocation(udg_RespawnPoint)
-
Camera - Lock camera target for (Owner of (Last created unit)) to (Last created unit), offset by (0.00, 0.00) using Default rotation
-
Selection - Select (Last created unit) for (Owner of (Last created unit))
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Owner of (Triggering unit)) Equal to Player 8 (Pink)
-
-
Then - Actions
-
Unit - Explode (Triggering unit)
-
Wait 1.00 seconds
-
Set RespawnPoint = (Random point in CurrentRespawnRegion)
-
Unit - Create 1 GameCharacterType for Player 8 (Pink) at RespawnPoint facing Default building facing degrees
-
Custom script: call RemoveLocation(udg_RespawnPoint)
-
Camera - Lock camera target for (Owner of (Last created unit)) to (Last created unit), offset by (0.00, 0.00) using Default rotation
-
Selection - Select (Last created unit) for (Owner of (Last created unit))
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Owner of (Triggering unit)) Equal to Player 9 (Gray)
-
-
Then - Actions
-
Unit - Explode (Triggering unit)
-
Wait 1.00 seconds
-
Set RespawnPoint = (Random point in CurrentRespawnRegion)
-
Unit - Create 1 GameCharacterType for Player 9 (Gray) at RespawnPoint facing Default building facing degrees
-
Custom script: call RemoveLocation(udg_RespawnPoint)
-
Camera - Lock camera target for (Owner of (Last created unit)) to (Last created unit), offset by (0.00, 0.00) using Default rotation
-
Selection - Select (Last created unit) for (Owner of (Last created unit))
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Owner of (Triggering unit)) Equal to Player 10 (Light Blue)
-
-
Then - Actions
-
Unit - Explode (Triggering unit)
-
Wait 1.00 seconds
-
Set RespawnPoint = (Random point in CurrentRespawnRegion)
-
Unit - Create 1 GameCharacterType for Player 10 (Light Blue) at RespawnPoint facing Default building facing degrees
-
Custom script: call RemoveLocation(udg_RespawnPoint)
-
Camera - Lock camera target for (Owner of (Last created unit)) to (Last created unit), offset by (0.00, 0.00) using Default rotation
-
Selection - Select (Last created unit) for (Owner of (Last created unit))
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Owner of (Triggering unit)) Equal to Player 11 (Dark Green)
-
-
Then - Actions
-
Unit - Explode (Triggering unit)
-
Wait 1.00 seconds
-
Set RespawnPoint = (Random point in CurrentRespawnRegion)
-
Unit - Create 1 GameCharacterType for Player 11 (Dark Green) at RespawnPoint facing Default building facing degrees
-
Custom script: call RemoveLocation(udg_RespawnPoint)
-
Camera - Lock camera target for (Owner of (Last created unit)) to (Last created unit), offset by (0.00, 0.00) using Default rotation
-
Selection - Select (Last created unit) for (Owner of (Last created unit))
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Owner of (Triggering unit)) Equal to Player 12 (Brown)
-
-
Then - Actions
-
Unit - Explode (Triggering unit)
-
Wait 1.00 seconds
-
Set RespawnPoint = (Random point in CurrentRespawnRegion)
-
Unit - Create 1 GameCharacterType for Player 12 (Brown) at RespawnPoint facing Default building facing degrees
-
Custom script: call RemoveLocation(udg_RespawnPoint)
-
Camera - Lock camera target for (Owner of (Last created unit)) to (Last created unit), offset by (0.00, 0.00) using Default rotation
-
Selection - Select (Last created unit) for (Owner of (Last created unit))
-
-
Else - Actions
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
CrossRoad Frog Killer Copy
-
Events
-
Conditions
-
(Unit-type of (Triggering unit)) Equal to Squishy Frog
-
-
Actions
-
Player - Add 1 to (Owner of (Triggering unit)) Current lumber
-
For each (Integer A) from 1 to 12, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Owner of (Triggering unit)) Equal to (Player((Integer A)))
-
-
Then - Actions
-
Unit - Explode (Triggering unit)
-
Wait 1.00 seconds
-
Set RespawnPoint = (Random point in CurrentRespawnRegion)
-
Unit - Create 1 GameCharacterType for (Player((Integer A))) at RespawnPoint facing Default building facing degrees
-
Custom script: call RemoveLocation(udg_RespawnPoint)
-
Camera - Lock camera target for (Owner of (Last created unit)) to (Last created unit), offset by (0.00, 0.00) using Default rotation
-
Selection - Select (Last created unit) for (Owner of (Last created unit))
-
-
Else - Actions
-
-
-
-
-
I have no idea why, but it seems like the loop sometimes ends up getting a different Integer A. Maybe the wait is causing it to run and overlap another execution of it? Would make sense, except that I have had this thing pick the wrong player on the first execution so... I am a bit lost. What is making this loop unstable? How do I fix it?