• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Help

Status
Not open for further replies.
Level 2
Joined
Mar 21, 2020
Messages
14
Hello guys, this trigger: Pasteboard - Uploaded Image has function to enable victory when all enemy buildings are destroyed. but the problem is that i have 7 opponents. is there a shorter way to make this working or i need to make this 7 times in row? i am new on world editor.
thanks
 
Level 3
Joined
Mar 18, 2020
Messages
20
Yes, there is an easier way to do this. You can use Unit Groups with just these two short triggers.

Setup trigger:
  • SetupBuildings
    • Events
      • Time - Elapsed game time is 0.05 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Set VariableSet Buildings_UnitGroup[(Integer A)] = (Units owned by (Player((Integer A))) matching (((Matching unit) is A structure) Equal to True).)
Trigger to check for victory:
  • BuildingDies
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A structure) Equal to True
    • Actions
      • Unit Group - Remove (Dying unit) from Buildings_UnitGroup[(Player number of (Owner of (Dying unit)))].
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Buildings_UnitGroup[(Player number of (Owner of (Dying unit)))]) Equal to 0
        • Then - Actions
          • Set VariableSet IsDefeated[(Player number of (Owner of (Dying unit)))] = True
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • IsDefeated[2] Equal to True
              • IsDefeated[3] Equal to True
              • IsDefeated[4] Equal to True
              • IsDefeated[5] Equal to True
              • IsDefeated[6] Equal to True
              • IsDefeated[7] Equal to True
              • IsDefeated[8] Equal to True
            • Then - Actions
              • Game - Victory Player 1 (Red) (Show dialogs, Show scores)
            • Else - Actions
        • Else - Actions
The variables here are Buildings_UnitGroup, which is a Unit Group Array variable of size 8. Each number corresponds to the player index of the player (1 = red, 2 = blue, 3 = teal, so on).

The other variable is IsDefeated, which is a Boolean Array variable of size 8. When the Buildings_UnitGroup has 0 buildings left in it, it is set to True. If all of them are True when a building dies, then you win.

By the way, you don't need to take images of triggers to post them here. You can right click on your trigger in the Trigger Functions: window of the Trigger Editor and hit "Copy As Text", then paste it between the tags ["trigger"] and "["/trigger"] (remove quotes).

If the enemies can build more buildings, then you can add them to the Buildings_UnitGroup when they are built with another trigger.

Good luck.
 
Status
Not open for further replies.
Top