• 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.

Victory if computer has no units left

Status
Not open for further replies.
Level 2
Joined
Jan 20, 2009
Messages
18
Hi

how can I end the game (with a victory) if the player destroyed all of the computers units. (There are no buildings on the map just a computer controlled Nightelf armee.)

I tried
event: unit - a unit dies
cond: number of living <soldiers> units owned by <player 2 (blue)> equals <0>
aktion: game - victory <player 1 (red)>

My problem is that in the condition I am asked for a particular unit type.

Thank you for your help
 
Level 4
Joined
Sep 18, 2007
Messages
104
0.01 is way too fast o_O

But maybe this will work?

  • Victory
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Dying unit)) Equal to Player 2 (Blue)) and ((Number of units in (Units owned by Player 2 (Blue))) Equal to 0)
    • Actions
      • Game - Victory Player 1 (Red) (Show dialogs, Show scores)
      • Game - Defeat Player 2 (Blue) with the message: Defeat!
 
Level 2
Joined
Jan 20, 2009
Messages
18
  • Events
    • Time - Every 1 seconds
  • Conditions
    • ((Units owned by Player 2 (Blue)) is empty) Equal to True
  • Actions
    • Game - Victory Player 1 (Red) (Show dialogs, Show scores)
    • Game - Defeat Player 2 (Blue) with the message: Defeat!
    • Trigger - Turn off (This Trigger)

I tried
  • Events
    • Unit - A unit dies
  • Conditions
    • (Number of units in (Units owned by Spieler 2 (Blau))) equal 0
  • Actions
    • Game - Victory Spieler 1 (red) (show dialogs, show scores)
but that doesnt work. I read somewhere that "living" is missing, and counting units also counts the corpses.

Counting non-structure units seems to work.

  • Events
    • Unit - A unit dies
  • Conditions
    • (Count non-structure units controlled by Spieler 2 (blue) (Ausschließen incomplete units)) equals 0
  • Actions
    • Game - Victory Spieler 1 (red) (show dialogs, show scores)
 
Level 2
Joined
Jan 20, 2009
Messages
18
Doesn't enforcing Melee victory conditions help?

I forgot to mention that there are no buildings on the map. As far as I understand melee victory conditions: losing all buildings means you lost. I dont want that.
 
Level 4
Joined
Sep 18, 2007
Messages
104
Well make a trigger to set a integer variable and +1 for every unit blue owns, then when a unit owned by blue dies, reduce the variable by one, and when the variable reaches 0, then it's game over. Though this most likely isn't the best way of doing this.
 
Level 10
Joined
Apr 13, 2005
Messages
630
That really isnt. How about making it basic. Set every unit food cost 1. Allow the max to be w.e u want it to be. Anyway heres the trigger. This trigger is a failsafe besides the integer trigger u saw above.

  • MY FUCKING TRIGGER
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Player 2 (Blue) Food used) Equal to 0
    • Actions
      • Game - Victory Player 1 (Red) (Show dialogs, Show scores)
that simple lol

another way is to say

  • MY FUCKING TRIGGER
    • Events
      • Unit - A unit Dies
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Player 2 (Blue) Food used) Equal to 0
          • (Owner of (Dying unit)) Equal to Player 2 (Blue)
    • Actions
      • Game - Victory Player 1 (Red) (Show dialogs, Show scores)
There are many ways to do this. Food is just one if ur using food for something else i have to suggest use wood or gold Else u got to seek using variables to store all units counting them and the rest of the shit. need anymore help pm me
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Why not just the condition:
  • Dies
  • Events
    • Unit - A owned by Player 2(Blue) Unit dies
  • Conditions
    • Number of units in (Playable map area) Matching ((Matching unit) is dead equal to false) And ((Matching unit) is a structure equal to false) and (Owner of (Matching Unit) Equal to Player2(Blue)) equal to 0
  • Actions
    • Victoire!! ^^
 
Level 8
Joined
Sep 13, 2006
Messages
431
I personally would go with something like this, as it is more customizable, and it doesn't have to be player-specific:

  • Trigger
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set UnitGroup = (Units owned by (Owner of (Dying unit)) matching (((Matching unit) is alive) Equal to True))
      • Set Integer = (Number of units in UnitGroup)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Int Equal to 0
        • Then - Actions
          • -------- Victory/Defeat Actions --------
        • Else - Actions
      • Custom script: call DestroyGroup(udg_UnitGroup)
Additionally, if you are making some kind of game where you have to hunt down all the units, you may consider adding a message/leaderboard that tells you how many there are left. This could easily be added in under:
  • Else -Actions
 
Last edited:
I use global vars over and over, in different triggers and spells, so, if I'm not mistaken, there's really no need to remove it... (correct me if I'm wrong)
You're mainly right, but you don't destroy the group properly. Removing all the units from a group doesn't actually destroy it. You need to do Custom Script: call DestroyGroup(udg_UnitGroup)
 
Status
Not open for further replies.
Top