• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Win/Lose trigger conditions

Status
Not open for further replies.
Level 6
Joined
Dec 4, 2016
Messages
42
Hi people, Can someone help me with a trigger for my altered melee map that could make the winners players "victorious" and the losers "defeated"?

following the next condition:
-Defeated if living units = 0
-Win if all enemy team is defeated (obviously).

Thanks in advance..

PS 1: Could be great if you drag the W3O doc here (pleaseeee).
PS 2: if you help me I promise you to put your name in my credit list.
 
Level 9
Joined
Sep 20, 2015
Messages
385
Hi, well you have to use unit gruops variales for this i think, or maybe there are other things but i dnt have access to the editor right now.
if u create varaibles like uni group(x) = all units owned by player x
-for the defeat

Events
Every 1 second of the game
conditions
all unit in (unit group(x)) are dead equal to true
actions
player x defeat

for vicroty

Events
every 1 second of the game
conditions
and (multiple conditions)
all units in (unit gruop(x)) are dead equal to true
all units in (unit gruop(y)) are dead equal to true
eccc
actions
player z victory



As i said this could be the worst possible way to do it, i just dnt remember any other way, maybe i'll post again with triggers (when i can use WE)
 
Level 13
Joined
May 10, 2009
Messages
868
Hello! I've made one as I told you, and I hope it works for you.

  • WL Initialization
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Custom script: local integer teams = 1
      • -------- Since the function GetTeams() does not return the correct value - it's returning the number of players ... --------
      • -------- ...I had to make the following in order to count the teams properly --------
      • Custom script: local boolean different
      • Set WinLose_TeamsNum = 0
      • For each (Integer WinLose_Loop) from 0 to 11, do (Actions)
        • Loop - Actions
          • Custom script: set udg_WinLose_Player = Player(udg_WinLose_Loop)
          • Custom script: set different = true
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (WinLose_Player slot status) Equal to Is playing
              • Or - Any (Conditions) are true
                • Conditions
                  • (Count structures controlled by WinLose_Player (Include incomplete structures)) Greater than 0
                  • (Count non-structure units controlled by WinLose_Player (Exclude incomplete units)) Greater than 0
            • Then - Actions
              • -------- Keep in mind that WinLose_AvailableTeams[x] is set to -1 by default in the variable editor. --------
              • For each (Integer WinLose_Counter) from 0 to WinLose_TeamsNum, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Team number of WinLose_Player) Equal to WinLose_AvailableTeams[WinLose_Counter]
                    • Then - Actions
                      • Custom script: set different = false
                    • Else - Actions
              • Custom script: if different then
              • Set WinLose_AvailableTeams[WinLose_TeamsNum] = (Team number of WinLose_Player)
              • Set WinLose_TeamsNum = (WinLose_TeamsNum + 1)
              • Custom script: endif
            • Else - Actions
      • Custom script: loop
      • Custom script: exitwhen teams > udg_WinLose_TeamsNum
      • Custom script: set udg_WinLose_Teams[teams] = CreateForce()
      • Custom script: set udg_WinLose_IsTeamDefeated[teams] = false // safety first
      • Custom script: set teams = teams + 1
      • Custom script: endloop
      • For each (Integer WinLose_Loop) from 0 to 11, do (Actions)
        • Loop - Actions
          • Custom script: set udg_WinLose_Player = Player(udg_WinLose_Loop)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (WinLose_Player slot status) Equal to Is playing
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Count structures controlled by WinLose_Player (Include incomplete structures)) Equal to 0
                  • (Count non-structure units controlled by WinLose_Player (Exclude incomplete units)) Equal to 0
                • Then - Actions
                  • -------- Defeat players that don't own anything --------
                  • Player Group - Add WinLose_Player to WinLose_Team
                • Else - Actions
                  • -------- This player has, at least, a unit. --------
                  • Player Group - Add WinLose_Player to WinLose_Teams[(Team number of WinLose_Player)]
            • Else - Actions
              • -------- If a player is not playing, choose here whatever you want to do with their units - If they have any, of course. --------
              • -------- For example: Change ownership of the units to Neutral Victim (It does not attack anyone, but it's considered as enemy by other players) --------
      • -------- I'm not sure about players who leave the game when the map is loading. --------
      • -------- Better safe than sorry --------
      • Trigger - Turn on WL Unit Dies <gen>
      • Trigger - Turn on WL Player Leaves <gen>
      • -------- Our friendly WAIT function, as usual --------
      • Wait 2.00 seconds
      • -------- Check if there's only one team playing. --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WinLose_TeamsNum Equal to 1
        • Then - Actions
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked player) slot status) Equal to Is playing
                • Then - Actions
                  • Game - Victory (Picked player) (Show dialogs, Skip scores)
                • Else - Actions
                  • -------- This player probably left the game when the map was loading --------
          • Skip remaining actions
        • Else - Actions
      • -------- Defeat players who have no units --------
      • Player Group - Pick every player in WinLose_Team and do (Actions)
        • Loop - Actions
          • Game - Defeat (Picked player) with the message: You have no units.
      • Player Group - Remove all players from WinLose_Team
  • WL Unit Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering player) Not equal to Neutral Victim
      • ((Triggering player) slot status) Equal to Is playing
    • Actions
      • Custom script: local integer teamsLeft
      • Set WinLose_Player = (Triggering player)
      • Set WinLose_Counter = (Team number of WinLose_Player)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Count structures controlled by WinLose_Player (Include incomplete structures)) Equal to 0
          • (Count non-structure units controlled by WinLose_Player (Exclude incomplete units)) Equal to 0
        • Then - Actions
          • -------- The player has no units nor structures. Defeat them! --------
          • Game - Defeat WinLose_Player with the message: Defeat!
          • Player Group - Remove WinLose_Player from WinLose_Teams[WinLose_Counter]
          • -------- Now check if that player group is empty --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of players in WinLose_Teams[WinLose_Counter]) Equal to 0
            • Then - Actions
              • Set WinLose_IsTeamDefeated[WinLose_Counter] = True
              • -------- All players from this team were defeated. Check if there's still any unit left and make them belong to neutral victim player. --------
              • Player Group - Remove all players from WinLose_Team
              • Custom script: call ForceEnumAllies(udg_WinLose_Team, udg_WinLose_Player, null)
              • Player Group - Pick every player in WinLose_Team and do (Actions)
                • Loop - Actions
                  • Custom script: set bj_wantDestroyGroup = true
                  • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
                    • Loop - Actions
                      • Unit - Change ownership of (Picked unit) to Neutral Victim and Retain color
              • -------- Then, check if all the other teams were defeated, and apply victory to the remaining players. --------
              • Custom script: set teamsLeft = 0
              • For each (Integer WinLose_Loop) from 0 to (WinLose_TeamsNum - 1), do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • WinLose_IsTeamDefeated[WinLose_Loop] Equal to False
                    • Then - Actions
                      • Custom script: set teamsLeft = teamsLeft + 1
                      • Set WinLose_RemainingTeam = WinLose_Loop
                    • Else - Actions
              • Custom script: if teamsLeft == 1 then
              • -------- There's currently one team left. Make it victorious! --------
              • Player Group - Pick every player in WinLose_Teams[WinLose_RemainingTeam] and do (Actions)
                • Loop - Actions
                  • Game - Victory (Picked player) (Show dialogs, Show scores)
              • Custom script: endif
            • Else - Actions
        • Else - Actions
  • WL Player Leaves
    • Events
      • Player - Player 1 (Red) leaves the game
      • Player - Player 2 (Blue) leaves the game
      • Player - Player 3 (Teal) leaves the game
      • Player - Player 4 (Purple) leaves the game
      • Player - Player 5 (Yellow) leaves the game
      • Player - Player 6 (Orange) leaves the game
      • Player - Player 7 (Green) leaves the game
      • Player - Player 8 (Pink) leaves the game
      • Player - Player 9 (Gray) leaves the game
      • Player - Player 10 (Light Blue) leaves the game
      • Player - Player 11 (Dark Green) leaves the game
      • Player - Player 12 (Brown) leaves the game
    • Conditions
    • Actions
      • Custom script: local integer teamsLeft
      • Set WinLose_Player = (Triggering player)
      • Set WinLose_Counter = (Team number of WinLose_Player)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (WinLose_Player is in WinLose_Teams[WinLose_Counter]) Equal to True
        • Then - Actions
          • Game - Display to (All players) for 60.00 seconds the text: ((Name of WinLose_Player) + has left the game.)
          • Player Group - Remove WinLose_Player from WinLose_Teams[WinLose_Counter]
          • -------- Now check if that player group is empty --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of players in WinLose_Teams[WinLose_Counter]) Equal to 0
            • Then - Actions
              • Set WinLose_IsTeamDefeated[WinLose_Counter] = True
              • -------- All players from this team either have left the game or were defeated. Make their units belong to neutral victim player. --------
              • Player Group - Remove all players from WinLose_Team
              • Custom script: call ForceEnumAllies(udg_WinLose_Team, udg_WinLose_Player, null)
              • Player Group - Pick every player in WinLose_Team and do (Actions)
                • Loop - Actions
                  • Custom script: set bj_wantDestroyGroup = true
                  • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
                    • Loop - Actions
                      • Unit - Change ownership of (Picked unit) to Neutral Victim and Retain color
              • -------- Then, check if all the other teams were defeated, and apply victory to the remaining players. --------
              • Custom script: set teamsLeft = 0
              • For each (Integer WinLose_Loop) from 0 to (WinLose_TeamsNum - 1), do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • WinLose_IsTeamDefeated[WinLose_Loop] Equal to False
                    • Then - Actions
                      • Custom script: set teamsLeft = teamsLeft + 1
                      • Set WinLose_RemainingTeam = WinLose_Loop
                    • Else - Actions
              • Custom script: if teamsLeft == 1 then
              • -------- There's currently one team left. Make it victorious! --------
              • Player Group - Pick every player in WinLose_Teams[WinLose_RemainingTeam] and do (Actions)
                • Loop - Actions
                  • Game - Victory (Picked player) (Show dialogs, Show scores)
              • Custom script: endif
            • Else - Actions
        • Else - Actions

I don't know whether you have the "create unknown variables automatically" enabled, but here I go:

In order to copy and paste these triggers into your map with ease, it would be a good idea to have the option checked: Automatically create unknown variables while pasting trigger data

File -> Preferences...
wpu2v6y.png


EDIT: I fixed a very small mistake that I left in the "WL Initialization" trigger.

EDIT 2: I forgot to tell you when copying and pasting the trigger data from the attached map below, you need to modify the WinLose_AvailableTeams variable by setting its initial value to -1, and its array size to 12. Otherwise, it won't work properly (you'll always be victorious).

QpML4JQ.png
 

Attachments

  • WinLose Conditions.w3x
    28.2 KB · Views: 142
Last edited:
Level 6
Joined
Dec 4, 2016
Messages
42
Hello! I've made one as I told you, and I hope it works for you.

  • WL Initialization
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Custom script: local integer teams = 1
      • -------- Since the function GetTeams() does not return the correct value - it's returning the number of players ... --------
      • -------- ...I had to make the following in order to count the teams properly --------
      • Custom script: local boolean different
      • Set WinLose_TeamsNum = 0
      • For each (Integer WinLose_Loop) from 0 to 11, do (Actions)
        • Loop - Actions
          • Custom script: set udg_WinLose_Player = Player(udg_WinLose_Loop)
          • Custom script: set different = true
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (WinLose_Player slot status) Equal to Is playing
              • Or - Any (Conditions) are true
                • Conditions
                  • (Count structures controlled by WinLose_Player (Include incomplete structures)) Greater than 0
                  • (Count non-structure units controlled by WinLose_Player (Exclude incomplete units)) Greater than 0
            • Then - Actions
              • -------- Keep in mind that WinLose_AvailableTeams[x] is set to -1 by default in the variable editor. --------
              • For each (Integer WinLose_Counter) from 0 to WinLose_TeamsNum, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Team number of WinLose_Player) Equal to WinLose_AvailableTeams[WinLose_Counter]
                    • Then - Actions
                      • Custom script: set different = false
                    • Else - Actions
              • Custom script: if different then
              • Set WinLose_AvailableTeams[WinLose_TeamsNum] = (Team number of WinLose_Player)
              • Set WinLose_TeamsNum = (WinLose_TeamsNum + 1)
              • Custom script: endif
            • Else - Actions
      • Custom script: loop
      • Custom script: exitwhen teams > udg_WinLose_TeamsNum
      • Custom script: set udg_WinLose_Teams[teams] = CreateForce()
      • Custom script: set udg_WinLose_IsTeamDefeated[teams] = false // safety first
      • Custom script: set teams = teams + 1
      • Custom script: endloop
      • For each (Integer WinLose_Loop) from 0 to 11, do (Actions)
        • Loop - Actions
          • Custom script: set udg_WinLose_Player = Player(udg_WinLose_Loop)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (WinLose_Player slot status) Equal to Is playing
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Count structures controlled by WinLose_Player (Include incomplete structures)) Equal to 0
                  • (Count non-structure units controlled by WinLose_Player (Exclude incomplete units)) Equal to 0
                • Then - Actions
                  • -------- Defeat players that don't own anything --------
                  • Player Group - Add WinLose_Player to WinLose_Team
                • Else - Actions
                  • -------- This player has, at least, a unit. --------
                  • Player Group - Add WinLose_Player to WinLose_Teams[(Team number of WinLose_Player)]
            • Else - Actions
              • -------- If a player is not playing, choose here whatever you want to do with their units - If they have any, of course. --------
              • -------- For example: Change ownership of the units to Neutral Victim (It does not attack anyone, but it's considered as enemy by other players) --------
      • -------- I'm not sure about players who leave the game when the map is loading. --------
      • -------- Better safe than sorry --------
      • Trigger - Turn on WL Unit Dies <gen>
      • Trigger - Turn on WL Player Leaves <gen>
      • -------- Our friendly WAIT function, as usual --------
      • Wait 2.00 seconds
      • -------- Check if there's only one team playing. --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WinLose_TeamsNum Equal to 1
        • Then - Actions
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked player) slot status) Equal to Is playing
                • Then - Actions
                  • Game - Victory (Picked player) (Show dialogs, Skip scores)
                • Else - Actions
                  • -------- This player probably left the game when the map was loading --------
          • Skip remaining actions
        • Else - Actions
      • -------- Defeat players who have no units --------
      • Player Group - Pick every player in WinLose_Team and do (Actions)
        • Loop - Actions
          • Game - Defeat (Picked player) with the message: You have no units.
      • Player Group - Remove all players from WinLose_Team
  • WL Unit Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering player) Not equal to Neutral Victim
      • ((Triggering player) slot status) Equal to Is playing
    • Actions
      • Custom script: local integer teamsLeft
      • Set WinLose_Player = (Triggering player)
      • Set WinLose_Counter = (Team number of WinLose_Player)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Count structures controlled by WinLose_Player (Include incomplete structures)) Equal to 0
          • (Count non-structure units controlled by WinLose_Player (Exclude incomplete units)) Equal to 0
        • Then - Actions
          • -------- The player has no units nor structures. Defeat them! --------
          • Game - Defeat WinLose_Player with the message: Defeat!
          • Player Group - Remove WinLose_Player from WinLose_Teams[WinLose_Counter]
          • -------- Now check if that player group is empty --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of players in WinLose_Teams[WinLose_Counter]) Equal to 0
            • Then - Actions
              • Set WinLose_IsTeamDefeated[WinLose_Counter] = True
              • -------- All players from this team were defeated. Check if there's still any unit left and make them belong to neutral victim player. --------
              • Player Group - Remove all players from WinLose_Team
              • Custom script: call ForceEnumAllies(udg_WinLose_Team, udg_WinLose_Player, null)
              • Player Group - Pick every player in WinLose_Team and do (Actions)
                • Loop - Actions
                  • Custom script: set bj_wantDestroyGroup = true
                  • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
                    • Loop - Actions
                      • Unit - Change ownership of (Picked unit) to Neutral Victim and Retain color
              • -------- Then, check if all the other teams were defeated, and apply victory to the remaining players. --------
              • Custom script: set teamsLeft = 0
              • For each (Integer WinLose_Loop) from 0 to (WinLose_TeamsNum - 1), do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • WinLose_IsTeamDefeated[WinLose_Loop] Equal to False
                    • Then - Actions
                      • Custom script: set teamsLeft = teamsLeft + 1
                      • Set WinLose_RemainingTeam = WinLose_Loop
                    • Else - Actions
              • Custom script: if teamsLeft == 1 then
              • -------- There's currently one team left. Make it victorious! --------
              • Player Group - Pick every player in WinLose_Teams[WinLose_RemainingTeam] and do (Actions)
                • Loop - Actions
                  • Game - Victory (Picked player) (Show dialogs, Show scores)
              • Custom script: endif
            • Else - Actions
        • Else - Actions
  • WL Player Leaves
    • Events
      • Player - Player 1 (Red) leaves the game
      • Player - Player 2 (Blue) leaves the game
      • Player - Player 3 (Teal) leaves the game
      • Player - Player 4 (Purple) leaves the game
      • Player - Player 5 (Yellow) leaves the game
      • Player - Player 6 (Orange) leaves the game
      • Player - Player 7 (Green) leaves the game
      • Player - Player 8 (Pink) leaves the game
      • Player - Player 9 (Gray) leaves the game
      • Player - Player 10 (Light Blue) leaves the game
      • Player - Player 11 (Dark Green) leaves the game
      • Player - Player 12 (Brown) leaves the game
    • Conditions
    • Actions
      • Custom script: local integer teamsLeft
      • Set WinLose_Player = (Triggering player)
      • Set WinLose_Counter = (Team number of WinLose_Player)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (WinLose_Player is in WinLose_Teams[WinLose_Counter]) Equal to True
        • Then - Actions
          • Game - Display to (All players) for 60.00 seconds the text: ((Name of WinLose_Player) + has left the game.)
          • Player Group - Remove WinLose_Player from WinLose_Teams[WinLose_Counter]
          • -------- Now check if that player group is empty --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of players in WinLose_Teams[WinLose_Counter]) Equal to 0
            • Then - Actions
              • Set WinLose_IsTeamDefeated[WinLose_Counter] = True
              • -------- All players from this team either have left the game or were defeated. Make their units belong to neutral victim player. --------
              • Player Group - Remove all players from WinLose_Team
              • Custom script: call ForceEnumAllies(udg_WinLose_Team, udg_WinLose_Player, null)
              • Player Group - Pick every player in WinLose_Team and do (Actions)
                • Loop - Actions
                  • Custom script: set bj_wantDestroyGroup = true
                  • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
                    • Loop - Actions
                      • Unit - Change ownership of (Picked unit) to Neutral Victim and Retain color
              • -------- Then, check if all the other teams were defeated, and apply victory to the remaining players. --------
              • Custom script: set teamsLeft = 0
              • For each (Integer WinLose_Loop) from 0 to (WinLose_TeamsNum - 1), do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • WinLose_IsTeamDefeated[WinLose_Loop] Equal to False
                    • Then - Actions
                      • Custom script: set teamsLeft = teamsLeft + 1
                      • Set WinLose_RemainingTeam = WinLose_Loop
                    • Else - Actions
              • Custom script: if teamsLeft == 1 then
              • -------- There's currently one team left. Make it victorious! --------
              • Player Group - Pick every player in WinLose_Teams[WinLose_RemainingTeam] and do (Actions)
                • Loop - Actions
                  • Game - Victory (Picked player) (Show dialogs, Show scores)
              • Custom script: endif
            • Else - Actions
        • Else - Actions

I don't know whether you have the "create unknown variables automatically" enabled, but here I go:

In order to copy and paste these triggers into your map with ease, it would be a good idea to have the option checked: Automatically create unknown variables while pasting trigger data

File -> Preferences...
wpu2v6y.png


EDIT: I fixed a very small mistake that I left in the "WL Initialization" trigger.
Cool bro, this trigger looks amazing, i'll try it later when I arrive to my house and text you back.
 
Status
Not open for further replies.
Top