• 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 when Enemy doesn't have any unit alive?

Status
Not open for further replies.
Level 4
Joined
Aug 26, 2015
Messages
71
Hey. I'm sure that this is a very easy question, but I don't know what is the trigger I'm talking xD.
How do I set the victory when Enemy Player doesn't have any unit alive/left?

I tried with:

  • TriggerVictoria
    • Events
      • Unit - A unit dies
    • Conditions
      • (Number of units in (Units owned by Jugador 7 (verde))) Less than or equal to 0
    • Actions
      • Game - Victory Jugador 2 (azul) (Show dialogs, Show scores)
But didn't work.
 
how do I put it then xD?
Add a filter for units that are alive.

  • (Number of units in (Units in (Playable map area) matching ((((Matching unit) is alive) Equal to True) and ((Owner of (Matching unit)) Equal to Player 7 (Green))))) Less than or equal to 0
Of course there is a unit group leak that you will want to get rid of.
 
Level 4
Joined
Aug 26, 2015
Messages
71
Lol... I think I discovered the best action:

  • (All units of (Units owned by Jugador 1 (rojo)) are dead) Igual a True
What do you think?
It worked but I want to know your opinion
It's a Boolean Comparison
 
Level 15
Joined
Sep 6, 2015
Messages
576
I use that trigger in the first post with the condition in your last post in my map. It performs well, although it may have some problems as others said:
  • Victory 11
    • Events
      • Unit - A unit owned by Player 1 (Red) Dies
    • Conditions
      • (All units of (Units owned by Player 1 (Red)) are dead) Equal to True
    • Actions
      • Game - Victory Player 3 (Teal) (Show dialogs, Show scores)
 
Dead units might still be marked as alive due to abilities like tranquillity.
The alive condition of GUI suffers from the problem that DSG described.

I was not able to replicate the problem you both bring up. Let me know if I did something wrong:
  • Untitled Trigger 001
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) for 30.00 seconds the text: (String((Number of units in (Units in (Playable map area) matching (((Matching unit) is alive) Equal to True)))))
Animation0.gif
Animation1.gif
 
Last edited:
Level 15
Joined
Sep 6, 2015
Messages
576
To fix you need to bring the condition down into a conditional statement in the actions where you can then clean up the leak.
Like this?

  • Victory 11
    • Events
      • Unit - A unit owned by Player 1 (Red) Dies
    • Conditions
    • Actions
      • Set units = (Units owned by Player 1 (Red))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (All units of units are dead) Equal to True
        • Then - Actions
          • Game - Victory Player 3 (Teal) (Show dialogs, Show scores)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_units)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,287
Like this?
Yes. That would work.

I was not able to replicate the problem you both bring up. Let me know if I did something wrong:
Could you put the images in hidden tags please. Some browsers (apparently Edge... despite it being one of the fastest) and weaker computers can have problems with large gifs.
 
Level 4
Joined
Aug 26, 2015
Messages
71
My mistake! I totally forgot to add the tags. Edited.
Like this?

  • Victory 11
    • Events
      • Unit - A unit owned by Player 1 (Red) Dies
    • Conditions
    • Actions
      • Set units = (Units owned by Player 1 (Red))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (All units of units are dead) Equal to True
        • Then - Actions
          • Game - Victory Player 3 (Teal) (Show dialogs, Show scores)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_units)

Sorry guys , it worked because I didn't put any building in my map test.

With "units" i mean only "units?" or "persons?" not buildings.
How could I put that trigger to only "persons"?
 
Sorry guys , it worked because I didn't put any building in my map test.
You will just need to add a filter for structures. All though I tend to not recommend the use of (Matching unit), I will let it slide here for simplicity :p

  • Set UnitGroup = (Units owned by Player 1 (Red) matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is alive) Equal to True)))
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Number of units in UnitGroup) Less than or equal to 0
    • Then - Actions
      • Game - Victory Player 3 (Teal) (Show dialogs, Show scores)
    • Else - Actions
  • Custom script: call DestroyGroup(udg_UnitGroup)
 
Level 4
Joined
Aug 26, 2015
Messages
71
You will just need to add a filter for structures. All though I tend to not recommend the use of (Matching unit), I will let it slide here for simplicity :p

  • Set UnitGroup = (Units owned by Player 1 (Red) matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is alive) Equal to True)))
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Number of units in UnitGroup) Less than or equal to 0
    • Then - Actions
      • Game - Victory Player 3 (Teal) (Show dialogs, Show scores)
    • Else - Actions
  • Custom script: call DestroyGroup(udg_UnitGroup)

I was getting tired until I remember Chaosy in this post mentioned something about unit corpses. Yes, your trigger counts unit corpses :/
So I think I'll need to use your
  • Set UnitGroup = (Units owned by Player 1 (Red) matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is alive) Equal to True)))
but with a Boolean Condition:
  • (All units of UnitGroup are dead) Equal to True
. It worked this way. Thanks :)
 
Level 4
Joined
Aug 26, 2015
Messages
71
How does my trigger count corpses? You don't need to add that extra boolean. It only adds units that are alive. Unless Zwieb or DSG can comment on my post about Tranquility, it's fine.
Yes, I think I missed something when I was copying it just because of going fast, because I remembered your second condition "matching unit is alive". Tomorrow I'll let you know xD
 
Level 4
Joined
Aug 26, 2015
Messages
71
How does my trigger count corpses? You don't need to add that extra boolean. It only adds units that are alive. Unless Zwieb or DSG can comment on my post about Tranquility, it's fine.

Nope. I was right, i didn't forget anything. Your trigger, when is checking for number of units in "UnitGroup" it still count corpses.
So, for example, i have 1 footman and a rifleman. I kill them. With your trigger, it doesn't count as "less than / equal to 0" because their corpses are on the ground. So it counts 2 persons.
 
Level 4
Joined
Aug 26, 2015
Messages
71
Let me see the triggers.

It's the same as yours:

  • Events
    • Map initialization
  • Conditions
  • Actions
  • Set Group = (Units owned by Jugador 1 (rojo) matching ((((Matching unit) is Una estructura) Equal to False) and (((Matching unit) is alive) Equal to True)))
  • Events
    • Unit - A unit owned by Jugador 1 (rojo) Dies
  • Conditions
  • Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If: Condiciones
      • (Number of units in Group) Less than or equal to 0
    • Then: Acciones
      • Game - Victory Jugador 2 (azul) (Mostrar dialogs, Mostrar scores)
    • Otros: Acciones
      • Custom script: call DestroyGroup(udg_Group)
Why don't you try it on a test map? I'm not crazy or something (at least now xD)
 
Lmao that looks nothing like what I showed you. You aren't supposed to be doing that on Map Init. You enumerate through all the units everytime someone dies.

With your current setup, you check who is alive during loading screen, and then when the first unit dies, you destroy the group. That's it.

What you should be doing is check who is alive everytime the player's unit dies, and then count the number of units.
 
Level 4
Joined
Aug 26, 2015
Messages
71
Lmao that looks nothing like what I showed you. You aren't supposed to be doing that on Map Init. You enumerate through all the units everytime someone dies.

With your current setup, you check who is alive during loading screen, and then when the first unit dies, you destroy the group. That's it.

What you should be doing is check who is alive everytime the player's unit dies, and then count the number of units.

:| I thought it wasn't only one trigger. Now it works. Thanks and sorry if I made you waste your time.
 
Level 4
Joined
Aug 26, 2015
Messages
71
You didn't. It was a very minor issue, so it can easily be overlooked. Could you post the new triggers?

Yes:

  • Check If Dead
    • Events
      • Unit - A unit owned by Jugador 1 (rojo) Muere
    • Conditions
    • Actions
      • Set Group = (Units owned by Jugador 1 (rojo) matching ((((Matching unit) is Una estructura) Equal to False) and (((Matching unit) is alive) Equal to True)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If: Conditions
          • (Number of units in Group) less than or equal to 0
        • Then: Acciones
          • Partida - Victory Jugador 2 (azul) (Mostrar dialogs, Mostrar scores)
        • Else: Acciones
          • Custom script: call DestroyGroup(udg_Group)
PD: What's the problem of using Matching unit xD?
 
Status
Not open for further replies.
Top