Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Does creating a unit at location X trigger Bring at location X?
Does creating a unit at location X trigger Bring at location X?
Mar 8 2019, 11:01 pm
By: sethmachine  

Mar 8 2019, 11:01 pm sethmachine Post #1



Hi,

I have two triggers in this order. Trigger 2 should not be executing but it does:

Trigger 1
Code
If Foes brings at least 1 men to Location X:
  Create 10 terran marines for Player 1 at Location X


Trigger 2
Code
If Player 1 brings exactly 0 men to Location X:
 DisplayText("Foe has won Location X!")


When I run my map, both triggers execute immediately. Trigger 2 executes even though Player 1 has men at Location X, due to the create units trigger.

How is this possible?



None.

Mar 9 2019, 1:05 am Ultraviolet Post #2

We do a little trolling

If I remember correctly, some things take a cycle to update after being done.

Edit: NudeRaider posted this in your other topic:

Quote
But there's several quirks one has to account for:

- The bring exception: There's some actions that won't immediately update the unit array that is checked by bring, so depending on the actions used, the bring condition might behave unexpectedly. Bring will always update at the beginning of a new trigger loop.

I think your problem is related to this, but I'm not 100% sure about it.



My Projects:

Impossible Ultraviolet | Impossible UV 2 | Impossible UV 3
Mercenaries 2020 | Mercenaries III
Squad Defense

Legacy Projects (No guarantee of functionality in modern SC):

Pixel Adventure 2 | Space Snipers | Control the Ball

______________________________________________

Join me in Torn City

Mar 9 2019, 4:34 am sethmachine Post #3



That seems to be my problem.

I have found a solution. I force another trigger cycle before checking for the presence of units, so that way the Bring will properly detect the created units. I did this with a very short death counter timer.

I am curious if there is another way.



None.

Mar 9 2019, 7:06 am Lanthanide Post #4



This post and thread explains how to use Bring and Command conditions 100% correctly every time without any errors: http://www.staredit.net/topic/14321/#9



None.

Mar 9 2019, 1:54 pm sethmachine Post #5



Quote from Lanthanide
This post and thread explains how to use Bring and Command conditions 100% correctly every time without any errors: http://www.staredit.net/topic/14321/#9

Hmm:

Quote
There is a variable involved. It is first set to 0 as the trigger cycle begins. If this value is different than the value assigned by certain conditions then the count is updated.
Command, Command the Most, Command the Least, leaderboard sorting ---- Value is set to 1.
Bring, Command the Most At, Command the Least At, leaderboard sorting ---- Value is set to 2. Reset if location is different than previous call.
Move Location, Remove Unit, Remove Unit At, Kill Unit, Kill Unit At, Move Unit ---- Value is reset to 0.

So at the start of the cycle, there is some "cache" variable C that is set to 0. "Create Units" does not invalidate the cache variable C (stays at 0), so in the same trigger cycle Bring won't detect any units created in the same loop. However, Move Units does invalidate the cache variable, since Bring sets it to 2 but Move Unit sets it 0. So if I have a random Move Unit, e.g. Move Cantina Owned By Player 8 to Anywhere, then the next trigger with Bring will see the created units at Location X?



None.

Mar 9 2019, 2:04 pm NudeRaider Post #6

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

Quote from sethmachine
Quote from Lanthanide
This post and thread explains how to use Bring and Command conditions 100% correctly every time without any errors: http://www.staredit.net/topic/14321/#9

Hmm:

Quote
There is a variable involved. It is first set to 0 as the trigger cycle begins. If this value is different than the value assigned by certain conditions then the count is updated.
Command, Command the Most, Command the Least, leaderboard sorting ---- Value is set to 1.
Bring, Command the Most At, Command the Least At, leaderboard sorting ---- Value is set to 2. Reset if location is different than previous call.
Move Location, Remove Unit, Remove Unit At, Kill Unit, Kill Unit At, Move Unit ---- Value is reset to 0.

So at the start of the cycle, there is some "cache" variable C that is set to 0. "Create Units" does not invalidate the cache variable C (stays at 0), so in the same trigger cycle Bring won't detect any units created in the same loop. However, Move Units does invalidate the cache variable, since Bring sets it to 2 but Move Unit sets it 0. So if I have a random Move Unit, e.g. Move Cantina Owned By Player 8 to Anywhere, then the next trigger with Bring will see the created units at Location X?
Here's a thread that explains the bring issue more clearly.
Basically you run any of the mentioned actions after creating the unit, to make sure follow-up triggers register correctly.
Quote
Kill Unit
Kill Unit at Location
Remove Unit
Remove Unit At Location
Move Location
Move Unit





Mar 9 2019, 2:21 pm sethmachine Post #7



Thanks, but still confused.

Can you fix my example so it invalidates the cache and correctly detects the created marines in the same trigger cycle for Location X?

Trigger 1
If Foes brings at least 1 men to Location X:
Create 10 terran marines for Player 1 at Location X


Trigger 2
Code
If Player 1 brings exactly 0 men to Location X:
DisplayText("Foe has won Location X!")



None.

Mar 9 2019, 5:50 pm NudeRaider Post #8

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

Quote
Kill Unit
Kill Unit at Location
Remove Unit
Remove Unit At Location
Move Location
Move Unit
just choose one:

Trigger 1
If Foes brings at least 1 men to Location X:
Create 10 terran marines for Player 1 at Location X
Center Location X on Terran Marines for P1 at Location X




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[02:13 pm]
Vrael -- pee poo sibling
[2026-6-28. : 7:00 pm]
Symmetry -- poo poo papa
[2026-6-28. : 2:46 pm]
lil-Inferno -- pee pee child
[2026-6-27. : 6:10 pm]
Ultraviolet -- sweet summer child
[2026-6-26. : 10:31 am]
NudeRaider -- blessed innocent soul knows nothing of the strife we had before EUDs were discovered :teehee:
[2026-6-23. : 3:29 am]
DarkenedFantasies -- Probably just didn't care. For example, at some point before release, they've updated the graphics of some of the Protoss buildings (Forge, CyberCore, Citadel, Observatory, Arbiter Tribunal), but instead of properly re-rendering them with edited 3D models, they did crappy copy-paste jobs on the rendered graphics.
[2026-6-22. : 8:35 pm]
Ultraviolet -- :wob:
[2026-6-21. : 11:38 pm]
Symmetry -- :wob:
[2026-6-21. : 4:56 am]
Ultraviolet -- I suppose we'll likely never know, but my guess would be that they already saw it operating successfully and there was no monetary incentive to finish the original work. And the dev cycle in old school Blizzard was so hectic, it's possible it just got forgotten about after the original game got released. Plus there's an element of existing MPQ files that were packaged with the original discs becoming outdated if they updated it. And it's not like they remade the original MPQs, they just made new ones for BW specifically
[2026-6-21. : 4:26 am]
Oh_Man -- so that makes me think maybe the theory they are unfinished is not true and its a deliberate design decision, coz why not finish them wen ur making brood war?
Please log in to shout.


Members Online: O)FaRTy1billion[MM], Prankenstein