Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: switches and triggers. and their order
switches and triggers. and their order
Apr 19 2008, 12:58 am
By: major  

Apr 19 2008, 12:58 am major Post #1



Trigger("All players"){
Conditions:
Deaths("Player 8", "Warp Gate", Exactly, 2);
Deaths("Player 8", "Zerg Ultralisk Cavern", Exactly, 0);

Actions:
Set Switch("Switch120", randomize);
Set Switch("Switch121", randomize);
Set Switch("Switch122", randomize);

Display Text Message(Always Display, "trying...");

Preserve Trigger();
}

//-----------------------------------------------------------------//

Trigger("All players"){
Conditions:
Deaths("Player 8", "Warp Gate", Exactly, 2);
Deaths("Player 8", "Zerg Ultralisk Cavern", Exactly, 0);
Switch("Switch120", set);
Switch("Switch121", set);
Switch("Switch122", set);
Actions:
Display Text Message(Always Display, "BANG !");
Set Deaths("Player 8", "Zerg Ultralisk Cavern", Set To, 1);
Preserve Trigger();
}


Warp Gate tells which part of the game you are (choosing a hero/in-game etc.), so don't worry about it.
What i am trying to do is a random generator which generates till it hits one perticular combination - all set.

What happens is, it generates only once ! as if the action: Set Deaths("Player 8", "Zerg Ultralisk Cavern", Set To, 1) was always happening regardless the condintions, however saying BANG not.

If i take the condition "Zerg Ultralisk Cavern", Exactly, 0 away from the second trigger, all works fine, but it is still repeating BANG...
I tried doing it with switches, and it works exactly the same, just as well as using another trigger below to set the death count...



None.

Apr 19 2008, 2:41 am Vrael Post #2



Check your trigger that sets deaths of Zerg Ultralisk Cavern to 0, make sure nothing can kill a Zerg Ultralisk Cavern, and make sure there are no triggers setting Zerg Ultralisk Cavern to 1. Maybe something in your systems somewhere is repeating.

What do you want to happen exactly?

Should it just say "BANG" once?

I don't mean to critique you, but if you used proper sentences I for one would find it much easier to offer assistance. I'm not sure exactly of what you want to happen.



None.

Apr 19 2008, 4:54 am rockz Post #3

ᴄʜᴇᴇsᴇ ɪᴛ!

Indeed, you're quite difficult to understand

However, how many players are there in the game? You've got it set for all players, so player 1 gets a chance first. He tries, and maybe fails, but then player 2 gets a chance and succeeds. Once he succeeds, the trigger has fired. If you were player 1, you don't get to see the "BANG !" because you never ran the trigger, player 2 did.

Make a third trigger (for all players) that says if all 3 are set, or some other condition you can put in (say, zerg ultralisk cavern is set to 1), display "BANG !". Then put a preserve trigger in and a new switch using current player instead of player 8, so everyone will get it once.

I don't feel like making the last paragraph easier to read, so hopefully you can figure it out, or Nude/Falk will come by and help.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Apr 19 2008, 6:36 am fritfrat Post #4



rockz accurately (yet sort of incompletely) described your problem: it is firing for 1 player, that one player sees the message, and then that player sets p8's deaths to 1 so no one else can see it. Fix this by:
1: remove the display text line, replace with Set deaths for all players: 1 for (some random unit)
2. Create a new trigger like this. All players:: IF current player suffers exactly 1 death of (same random unit), THEN set deaths of (that unit) to 0, display text message, preserve trigger.

Another thing to note is that the way you have it set up is having every single player re-randomize it in 1 trigger cycle, so if there are 8 players, there isn't a 12.5% chance of all 3 being set in one trigger cycle, but around 65.6%. This can be fixed by making the first trigger owned by Player 8 (with just doing the same process listed above for the text message); if you do make this change, it also makes the second trigger (after including my above edits) being owned by player 8 the same thing as being owned by All Players. If you do not understand any of these mechanisms or the reasons why what I said fixes things, just ask, as understanding these concepts will help spotting errors before the occur in the future.

As far as difficulty to understand goes, his problem is obvious just by looking at his triggers...



None.

Apr 19 2008, 9:56 am major Post #5



Thanks rockz and fritfrat(U).

Ok it works, but i don't have a clue why it didn't before.
I guess i had a bad idea about how the game loop works.
Correct me if i'm wrong but now i think it works like this:

The game goes to a method which handles the triggers.
It executes the triggers in the order i put it in the trigger editor, having the conditions i gave as parameters. So if the trigger is set for a group of players (for instance p1 and p2), it happens once, just creating a sub-loop, first for p1 and the same for p2 after.
So, the term Current Player just indicates the position of that sub-loop, right ?
If that is true, everything worked ok the way i did it, but it it didn't let me know about it because the current player (it's default for display text message?) was set to some other player lucky enough to get the combination ?

Or maybe it is like this:
When it comes across a trigger with multiple players in the conditions section, it happens once for the first player in the group, procedes with other triggers and goes a loop, and the next time the trigger method is called, the trigger is executed for the next player ? No. But that sounds stupid, doesn't it ?

Supposing the first version is true. Ideally there should be 1/8 chance for that one particular combination each loop. Having it set for the group of all players, (that is all 8 triggerable players, right ?) it went like this:

1 position in the loop (for player 1)

Randomize
Check the outcome.
If it is the outcome I wanted, stop the randomization process and send a message to a player indicated by Current Player.
If not, go to the next player.

2 position in the loop (for player 2):

(the same)
and so on...

If i understand right, chances were greater than I wanted them to be because I triggered Randomize method many times instead of once ?

Post has been edited 1 time(s), last time on Apr 19 2008, 10:07 am by major.



None.

Apr 19 2008, 3:52 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

The second version is closer to the truth.
Triggers are checked player by player. If you made a trigger owned by multiple players the game will split them up and runs a copy for each player.
That means in a trigger loop ALL triggers of player 1 will be checked first (and executed if conditions are met). Then, in the same trigger loop all triggers of P2 are checked, etc.

Thus you're right, you had a much higher chance per trigger loop, because you ran the randomization multiple times. But it was possible that player 2 sees the result 1 trigger loop earlier than player 1 (or, like in your 1st trigger set, not at all).




Apr 20 2008, 6:32 am Wormer Post #7



SC handles triggers exactly like this.
Let's assume you've listed triggers in the next order (from top to bottom in your text file) T1(PlayersGroup1), T2(PG2), ... , Tn(PGn), where Ti is a trigger and PGi is a group of players you've set the trigger Ti to. SC chooses the first player P1 to be current player (cp = P1) and goes through the triggers sequence checking if P1 belongs to PGi, where i is the number of the trigger being currently checked. If P1 belongs to the group PGi (P1 IN PGi) then it is checking all triggers' Ti conditions Ci and If all conditions Ci are met it is executing actions Ai. After all triggers in the seqence are checked for P1 it chooses the next computer or human player still remaning in the game, makes him current player (pc = P2) and checks triggers for him.

Code
FOR j = 1 TO 8 DO
    cp = Pj
    FOR i = 1 TO n DO
        IF Pj IN PGi THEN
            Execute Ti with current player = cp
    ENDFOR
ENDFOR


For example:
The sequence of triggers T1(P1,P3) T2(AllPlayers) T3(P2,P3) with three players P1, P2 and P3 remaining in the game would be actually checked each loop in the next particularly order: T1(P1), T2(P1), T2(P2), T3(P2), T1(P3), T2(P3), T3(P3), where players in braces shows the (current) player the trigger is executed for at the moment.



Some.

Apr 20 2008, 10:30 am 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

Haven't I already said this, just in a way one (not being a machine) can understand more easily? O.o
Or did you add information that I might have missed?




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[05:02 am]
Oh_Man -- whereas just "press X to get 50 health back" is pretty mindless
[05:02 am]
Oh_Man -- because it adds anotherr level of player decision-making where u dont wanna walk too far away from the medic or u lose healing value
[05:01 am]
Oh_Man -- initially I thought it was weird why is he still using the basic pre-EUD medic healing system, but it's actually genius
[03:04 am]
Ultraviolet -- Vrael
Vrael shouted: I almost had a heart attack just thinking about calculating all the offsets it would take to do that kind of stuff
With the modern EUD editors, I don't think they're calculating nearly as many offsets as you might imagine. Still some fancy ass work that I'm sure took a ton of effort
[12:51 am]
Oh_Man -- definitely EUD
[09:35 pm]
Vrael -- I almost had a heart attack just thinking about calculating all the offsets it would take to do that kind of stuff
[09:35 pm]
Vrael -- that is insane
[09:35 pm]
Vrael -- damn is that all EUD effects?
[2024-5-04. : 10:53 pm]
Oh_Man -- https://youtu.be/MHOZptE-_-c are yall seeing this map? it's insane
[2024-5-04. : 1:05 am]
Vrael -- I won't stand for people going around saying things like im not a total madman
Please log in to shout.


Members Online: Roy