Win/Loss Conditions

DonMushroom

Member
Reaction score
4
Hi :)

I'm trying to set up victory conditions and cant seem to get them to work :(

I'm looking for the game to end for the player when they run our of units and the last unit standing wins the game.

Any help would be greatly appreciated :)
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
First of all, welcome to Thehelper!

Since I don't know entirely how your map works, I'll give you a general trigger that you might want to modify to fit your needs. I also don't know how good you are with triggers, so I'll try to explain quite thoroughly but if something is unclear, feel free to ask and I'll clarify.

Okay, first of all you'll need a variable of the "Player Group" type (let's call it "In-game players"). We're going to use it to save all players that are still in the game. (If you don't know what a variable is, check out these links: 1 and 2)

This means that when the map starts, you want to make sure "In-game players" is filled with all the players that are currently playing the game. One way to do this is to just set it to "Active Players". This is a function that returns all the active players. However, if I remember correctly, that function also returns computer players. If you have computer players in your game, you'll have to remove them manually or do it another way. Another simpler way would be to add them all manually. Have a trigger with the "Map initialization" event and actions like: "Add player X to In-game".

Here's the trigger:
Trigger:
  • Victory Condition
    • Events
      • Unit - Any Unit dies
    • Local Variables
    • Conditions
      • (Number of Living units in (Any units in (Entire map) owned by player (Triggering player) matching Excluded: Missile, Dead, Hidden, with at most Any Amount)) == 0
    • Actions
      • Player Group - Remove player (Triggering player) from In-game players
      • Game - End game in Defeat for player (Triggering player) (Show dialogs, Show score screen)
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • (Number of players in In-game players) == 1
        • Then
          • Game - End game in Victory for player (Player 1 from In-game players) (Show dialogs, Show score screen)
        • Else


Depending on your previous experience with the trigger editor, this might look scary. Don't worry though, it's all quite simple when you understand the basics.

The trigger runs when a unit dies. When a unit dies, it checks how many units that player has left and it only runs the trigger if the player only has 0 units left(that's what the condition is for).

So, if the player has 0 units left, it runs all the actions. This means it'll remove the player from the "In-game players" variable, since the player is no longer playing. Using the "End game for player" action, we end the game in defeat for this player since he lots all his units.

Finally, we have an "If then else". This checks if there's only one player left playing. If that is the case, he's won so we end the game in victory for him.

Now, if you only want to count units in a certain area, you could change "(Entire map)" in the condition to the actual region you're using.
 

Jokker

Member
Reaction score
16
This works with more than one players.
The if condition in the end only checks the last man standing. So you don't need to change a thing.
 

DonMushroom

Member
Reaction score
4
Hi again :)

I was wondering how i could modify this to work with lobby teams. The map has custom teams so it could range from 1v1 to 7v1 to 8v8 and it only seem to work for free for all at the mo.
Any info would be great. :D

I need it like a normal melee game really
 

DonMushroom

Member
Reaction score
4
So does anyone know how i would go about editing this trigger? :)

At the moment it works for Free for all. I need it to work for ffa, 2v2, 3v3, 4v4 and custom teams.

So how would i change the win conditions to be if no units are left alive on the other teams the team remaining wins. :)
 

DonMushroom

Member
Reaction score
4
Ok this is what i have ended up with...

Events
Unit - Any Unit dies
Local Variables
Conditions
(Number of Living units in (Any units in (Entire map) owned by player (Owner of (Triggering unit)) matching Excluded: Structure, Missile, Dead, Hidden, with at most Any Amount)) == 0
(Number of Living units in (Any units in (Entire map) owned by player (Number of players in (Allies of player (Triggering player))) matching Excluded: Structure, Missile, Dead, Hidden, with at most Any Amount)) == 0
Actions
Game - End game in Defeat for player (Triggering player) (Show dialogs, Show score screen)
Game - End game in Defeat for player (Number of players in (Allies of player (Triggering player))) (Show dialogs, Show score screen)

I was going for if you and your allies have no units its game over. Where am i going wrong? :(
 

Kyuft

Member
Reaction score
11
Ok this is what i have ended up with...

(Number of Living units in (Any units in (Entire map) owned by player (Number of players in (Allies of player (Triggering player))) matching Excluded: Structure, Missile, Dead, Hidden, with at most Any Amount)) == 0

I think I might know the problem. the field that is underlined is looking for a number or Triggering player/ killing player. So, instead of taking the players that are allies of the triggering player, it is inputting the number of allies he has. For example, if he has 4 allies, it will say "player 4".

-Kyuft:shades:
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
Look through your second condition. "Owned by player (Number of players in (Allies of player (Triggering player)))".

Number of players in Player Group is a function that returns an integer, the number of players in that player group. The player group in this case is all the allies of (Triggering Player). So let's assume player 5 and 6 are allies of the triggering player. You would then have a player group with player 5 and 6. How many players are in that group? Two!(5 and 6).

This means that the Numer of players in Player Group will return 2. So in that example, what you actually got is (Number of Living units in (Any units in (Entire map) owned by player 2 matching Excluded: Structure, Missile, Dead, Hidden, with at most Any Amount)) == 0

In other words, you're checking if player 2 has 0 units left, when in fact you were only interested in the triggering player, player 5 and player 6.

So how do you do it? Well, using the "Pick every player in Player group" action, you can loop through all the allies of a player. Here's an example trigger that uses this:
Trigger:
  • Loss
    • Events
      • Unit - Any Unit dies
    • Local Variables
      • units = 0 <Integer>
    • Conditions
      • (Number of Living units in (Any units in (Entire map) owned by player (Triggering player) matching Excluded: Missile, Dead, Hidden, with at most Any Amount)) == 0
    • Actions
      • Player Group - Pick each player in (Allies of player (Triggering player)) and do (Actions)
        • Actions
          • Variable - Set units = (units + (Number of Living units in (Any units in (Entire map) owned by player (Picked player) matching Excluded: Missile, Dead, Hidden, with at most Any Amount)))
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • units == 0
        • Then
          • Player Group - Pick each player in (Allies of player (Triggering player)) and do (Actions)
            • Actions
              • Game - End game in Defeat for player (Picked player) (Show dialogs, Show score screen)
          • Game - End game in Defeat for player (Triggering player) (Show dialogs, Show score screen)
        • Else


Now what does this trigger do? If a unit dies, and it's the last unit the player has, go through all his allies and add the number of units everyone has to the units variable. If the units variable is 0, no one on his team has any units, so we go through them all and end the game for them.

There is however an easier way to do this that I thought of while doing the trigger for you. Here it is:
Trigger:
  • Loss
    • Events
      • Unit - Any Unit dies
    • Local Variables
      • units = 0 <Integer>
    • Conditions
      • (Number of Living units in (Units in (Entire map) having alliance Ally with player (Triggering player) matching Excluded: Missile, Dead, Hidden, with at most Any Amount)) == 0
    • Actions
      • Player Group - Pick each player in (Allies of player (Triggering player)) and do (Actions)
        • Actions
          • Game - End game in Defeat for player (Picked player) (Show dialogs, Show score screen)
      • Game - End game in Defeat for player (Triggering player) (Show dialogs, Show score screen)


It is very similar. It ends the game in the same way and it has the same event. The condition, however, is different. It uses a function called "Units in Region with Alliance To Player". This includes the player himself so you don't have to have two different conditions.
 

Kyuft

Member
Reaction score
11
That is exactly what I meant to say, but I guess I wasn't clear enough.

-Kyuft:shades:
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top