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



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.




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.
[05:00 pm]
lil-Inferno -- benis
[10:41 am]
v9bettel -- Nice
[01:39 am]
Ultraviolet -- no u elky skeleton guy, I'll use em better
[10:50 pm]
Vrael -- Ultraviolet
Ultraviolet shouted: How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
hey cut it out I'm getting all the minerals
[10:11 pm]
Ultraviolet -- :P
[10:11 pm]
Ultraviolet -- How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
[2024-4-17. : 11:50 pm]
O)FaRTy1billion[MM] -- nice, now i have more than enough
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- if i don't gamble them away first
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- o, due to a donation i now have enough minerals to send you minerals
[2024-4-17. : 3:26 am]
O)FaRTy1billion[MM] -- i have to ask for minerals first tho cuz i don't have enough to send
Please log in to shout.


Members Online: Roy, Ultraviolet