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.
[02:08 pm]
SiKiN -- oh yea and a mech version
[02:05 pm]
SiKiN -- We are working on a Marine version next with a Zergling version aswell. not sure about protoss because of the sprite limits
[02:04 pm]
SiKiN -- I think its done, finaly
[10:00 am]
KrayZee -- :0
[09:36 am]
Suicidal Insanity -- They just have a discord for posting even more memes than they post here ;(
[08:20 am]
SiKiN -- You guys have a testing group for maps? Or a discord?
[06:34 am]
MasterJohnny -- Zoan
Zoan shouted: guys im going to China in 2 days
Bring dust mask things and a mosquitoes net. If anyone asks nothing happened on June 4 1984.
[06:34 am]
O)FaRTy1billion[MM] -- NudeRaider
NudeRaider shouted: FaRTy1billion I'm wondering: Does extended anything (like place extended units for supply) count as euds (i'd guess no)? Do these overflows still work?
I'm pretty sure all extended units and extended players were fixed
[06:14 am]
Pr0nogo -- I mean I get people not wanting to put in the work, it's not easy, but then they'll say as much without people whining in the shoutbox about my posts
Please log in to shout.


Members Online: Roy, plums386sr, jjf28, Pandut, SiKiN