[Solved] wincondition if 0 players in a group

Level 6
Joined
Sep 24, 2015
Messages
173
hello there,

I have an issue with my wincondition trigger, it's not working as intended :

each time a specific unit (builder or aitz- dies) then remove the owner of the player from the Human group player.
each time a specific unit (vampire or vampire support dies) then remove the owner of the player from the Vamp group player.

If 0 players in Human group then show victory screen for vamp group players and show defeat screen to human group players.

If 0 players in Vamp group then show defeat screen for vamp group players and show victory screen to human group players.

Here are all the triggers :

  • Human dies
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Triggering unit)) Equal to Builder
              • (Unit-type of (Triggering unit)) Equal to aitz-
        • Then - Actions
          • Player Group - Remove (Owner of (Dying unit)) from HumanGroup.
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • Game - Display to (Player group((Picked player))) the text: ((Name of (Owner of (Triggering unit))) + 's Builder died. Rest in Pieces.)
              • Game - Display to (Player group((Picked player))) the text: (number of alive builders : + (String((Number of players in HumanGroup))))
              • Game - Display to (Player group((Picked player))) the text: (number of alive vampires : + (String((Number of players in VampGroup))))
          • Trigger - Run Wincondition <gen> (ignoring conditions)
          • Sound - Play humandie <gen>
          • Set VariableSet playerNr = (Player number of (Owner of (Dying unit)))
          • Player - Set (Owner of (Dying unit)).Current gold to 0
          • Player - Set (Owner of (Dying unit)).Current lumber to 0
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row playerNr to Defeated
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Owner of (Triggering unit)) Equal to Protector1
                  • (Owner of (Triggering unit)) Equal to Protector2
            • Then - Actions
              • Player Group - Pick every player in HumanGroup and do (Actions)
                • Loop - Actions
                  • Game - Display to (Player group((Picked player))) the text: |cff00ffffYou can e...
              • Set VariableSet tempUnitGroup = (Units of type Builder)
              • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Picked unit) Equal to (Triggering unit)
                    • Then - Actions
                    • Else - Actions
                      • Unit - Add Inventory (Builder) to (Picked unit)
                      • Hero - Create |cffff0000Slayer election item|r and give it to (Picked unit)
              • Custom script: call DestroyGroup ( udg_tempUnitGroup )
              • Set VariableSet tempUnitGroup = (Units of type aitz-)
              • Unit Group - Pick every unit in (Units of type aitz-) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Picked unit) Equal to (Triggering unit)
                    • Then - Actions
                    • Else - Actions
                      • Unit - Add Inventory (Builder) to (Picked unit)
                      • Hero - Create |cffff0000Slayer election item|r and give it to (Picked unit)
              • Custom script: call DestroyGroup ( udg_tempUnitGroup )
              • Set VariableSet VampSlayerOld = (Owner of (Triggering unit))
              • Set VariableSet VampSlayerStatus = 0
            • Else - Actions
          • Set VariableSet tempUnitGroup = (Units owned by (Owner of (Dying unit)).)
          • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Unit-type of (Picked unit)) Equal to Slayer
                      • (Unit-type of (Picked unit)) Equal to Berserk
                • Then - Actions
                  • Unit - Change ownership of (Picked unit) to Neutral Extra and Change color
                  • Unit - Kill (Picked unit)
                • Else - Actions
                  • Unit - Kill (Picked unit)
          • Custom script: call DestroyGroup ( udg_tempUnitGroup )
          • Set VariableSet tempUnitGroup = (Units owned by (Owner of (Dying unit)).)
          • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Unit-type of (Picked unit)) Equal to Slayer
                      • (Unit-type of (Picked unit)) Equal to Berserk
                • Then - Actions
                  • Unit - Kill (Picked unit)
                • Else - Actions
                  • Unit - Kill (Picked unit)
          • Custom script: call DestroyGroup ( udg_tempUnitGroup )
        • Else - Actions
  • Vampire dies
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Triggering unit)) Equal to Vampire [solo or double vamp]
              • (Unit-type of (Triggering unit)) Equal to Vampire [triple vamp]
              • (Unit-type of (Triggering unit)) Equal to Vampire Support
          • ((Owner of (Triggering unit)) is in VampGroup.) Equal to True
        • Then - Actions
          • Set VariableSet tempPlayerGroup = (All players)
          • Game - Display to tempPlayerGroup the text: ((Name of (Owner of (Triggering unit))) + 's Vampire died. Burn in hell.)
          • Sound - Play BloodElfMageYesAttack3 <gen>
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row boardPlayer[((Player number of (Owner of (Dying unit))) - 1)] to Defeated
          • Player Group - Remove (Owner of (Triggering unit)) from VampGroup.
          • Player Group - Remove (Owner of (Triggering unit)) from VampRandomPlayer.
          • Game - Display to tempPlayerGroup the text: (number of alive builders : + (String((Number of players in HumanGroup))))
          • Game - Display to tempPlayerGroup the text: (number of alive vampires : + (String((Number of players in VampGroup))))
          • Custom script: call DestroyForce ( udg_tempPlayerGroup )
          • Trigger - Run Wincondition <gen> (ignoring conditions)
          • -------- Checking player number --------
          • Player Group - Add (Random player from VampGroup) to VampRandomPlayer
          • Set VariableSet tmp_point = (Random point in GoblinLeaving2 <gen>)
          • Player Group - Pick every player in VampRandomPlayer and do (Actions)
            • Loop - Actions
              • Player - Add ((Owner of (Triggering unit)) Current gold) to (Picked player).Current gold
              • Unit - Remove GenerousGoblin[(Player number of (Owner of (Triggering unit)))] from the game
              • Player - Set (Owner of (Triggering unit)).Current gold to 0
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in (Units owned by (Picked player) of type Vampire Gravestone)) Equal to 1
                • Then - Actions
                  • Set VariableSet tempUnitGroup = (Units owned by (Owner of (Dying unit)).)
                  • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
                    • Loop - Actions
                      • Hero - Give (Item carried by (Dying unit) in slot 1) to Gravestone_unit
                      • Hero - Give (Item carried by (Dying unit) in slot 2) to Gravestone_unit
                      • Hero - Give (Item carried by (Dying unit) in slot 3) to Gravestone_unit
                      • Hero - Give (Item carried by (Dying unit) in slot 4) to Gravestone_unit
                      • Hero - Give (Item carried by (Dying unit) in slot 5) to Gravestone_unit
                      • Hero - Give (Item carried by (Dying unit) in slot 6) to Gravestone_unit
                      • Unit - Remove (Picked unit) from the game
                  • Custom script: call DestroyGroup ( udg_tempUnitGroup )
                • Else - Actions
                  • Set VariableSet tmp_point = (Random point in Goblin2 <gen>)
                  • Unit - Create 1 Vampire Gravestone for (Picked player) at tmp_point facing Default building facing degrees
                  • Set VariableSet Gravestone_unit = (Last created unit)
                  • Custom script: call RemoveLocation(udg_tmp_point)
                  • Quest - Display to VampGroup the Hint message: (((Name of (Triggering player)) + 's vampire died, his items were given to ) + (Name of (Picked player)))
                  • Set VariableSet tempUnitGroup = (Units owned by (Owner of (Triggering unit)).)
                  • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
                    • Loop - Actions
                      • Hero - Give (Item carried by (Dying unit) in slot 1) to Gravestone_unit
                      • Hero - Give (Item carried by (Dying unit) in slot 2) to Gravestone_unit
                      • Hero - Give (Item carried by (Dying unit) in slot 3) to Gravestone_unit
                      • Hero - Give (Item carried by (Dying unit) in slot 4) to Gravestone_unit
                      • Hero - Give (Item carried by (Dying unit) in slot 5) to Gravestone_unit
                      • Hero - Give (Item carried by (Dying unit) in slot 6) to Gravestone_unit
                      • Unit - Remove (Picked unit) from the game
                  • Custom script: call DestroyGroup ( udg_tempUnitGroup )
        • Else - Actions
Wincondtion trigger fires everytime a unit dies or if a player leaves the game:

  • Wincondition
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • 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
              • (Number of players in HumanGroup) Equal to 0
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked player) is in HumanGroup.) Equal to True
                • Then - Actions
                  • Player Group - Pick every player in HumanGroup and do (Actions)
                    • Loop - Actions
                      • Game - Display to (Player group((Picked player))) the text: |cffff3b00THE WORLD...
                      • Game - Defeat (Picked player) with the message: Defeat!
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked player) is in VampGroup.) Equal to True
                    • Then - Actions
                      • Player Group - Pick every player in HumanGroup and do (Actions)
                        • Loop - Actions
                          • Game - Display to (Player group((Picked player))) the text: |cffff3b00THE WORLD...
                          • Game - Victory (Picked player) (Show dialogs, Show scores)
                    • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of players in VampGroup) Equal to 0
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked player) is in VampGroup.) Equal to True
                • Then - Actions
                  • Player Group - Pick every player in VampGroup and do (Actions)
                    • Loop - Actions
                      • Game - Display to (Player group((Picked player))) the text: |c0096FF96THE WORLD...
                      • Game - Defeat (Picked player) with the message: Defeat!
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked player) is in HumanGroup.) Equal to True
                    • Then - Actions
                      • Player Group - Pick every player in HumanGroup and do (Actions)
                        • Loop - Actions
                          • Game - Display to (Player group((Picked player))) the text: |c0096FF96THE WORLD...
                          • Game - Victory (Picked player) (Show dialogs, Show scores)
                    • Else - Actions
            • Else - Actions
I don't know why but the trigger is broken and is not working...i tried to fix it myself but i couldn't...not enough knowledge it seems...i also tried to print the number of players in each groups as debug messages. the thing is that as soon as a unit dies then it shows the victory or defeat screen.

Please someone could help ?
 
Last edited:
Level 16
Joined
Mar 21, 2011
Messages
1,580
You are probably overthinking this.
Thats all you need ->
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Triggering unit)) Equal to something
              • (Unit-type of (Triggering unit)) Equal to something
        • Then - Actions
          • Player Group - Remove (Triggering player) from group1.
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of players in group1) Equal to 0
            • Then - Actions
              • Player Group - Pick every player in group1 and do (Actions)
                • Loop - Actions
                  • Game - Defeat (Picked player) with the message: Defeat!
              • Player Group - Pick every player in group2 and do (Actions)
                • Loop - Actions
                  • Game - Victory (Picked player) (Show dialogs, Show scores)
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Triggering unit)) Equal to something
              • (Unit-type of (Triggering unit)) Equal to something
        • Then - Actions
          • Player Group - Remove (Triggering player) from group2.
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of players in group2) Equal to 0
            • Then - Actions
              • Player Group - Pick every player in group2 and do (Actions)
                • Loop - Actions
                  • Game - Defeat (Picked player) with the message: Defeat!
              • Player Group - Pick every player in group1 and do (Actions)
                • Loop - Actions
                  • Game - Victory (Picked player) (Show dialogs, Show scores)
            • Else - Actions
        • Else - Actions
 
Top