Simple Defeat Condition

Status
Not open for further replies.
Level 7
Joined
Aug 3, 2006
Messages
90
So I'm trying to make a seemingly simple trigger that defeats a player when they are all out of units, This is what I have now and I cant really figure out why its not working, any help would be appreciated.
upload_2018-11-11_20-44-37.png
 
You should use a periodic timer as an event. Also make sure you turn off the trigger so it won't overloop.
Another solution, is to remove the dying unit from the unit group and then check when the number of units in that unit group equal to 0
 
Last edited:
Unit group should work well with periodic timer, try the condition : All units of (Units owned by Player 2 (Bleu) are dead equal to True.
  • Defeat
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • (All units of (Units owned by Player 2 (Bleu)) are dead) Equal to TRUE
    • Actions
      • Trigger - Turn off (This trigger)
      • Game - Defeat Player 2 (Bleu) with the message: Defeat !
 
Last edited:
The reason the first trigger did not work is because the condition cannot ever be true under normal game mechanics. When a unit dies it goes into a decay state where it still exists as a unit as far as searches go but is mechanically treated as dead. As such the unit group would always have more than 1 unit.

In any case using a condition like that is not a good idea due to the unit group leak. You will need to run the test inside the trigger actions so one can destroy the group and prevent the leak.
 
In this context a periodic timer should be the last resort ever. Following what DSG said about dead units, you need to set a group variable: set Player2Group = All units of (Units owned by Player 2 (Blue)) matching condition (Matching unit is alive) Equal to True)
And then check the number of units in the group, if less than 1 = boom defeat
 
if your units are using food: one could use a player state event check for food used = 0.
  • Player - Player 1 (Red)'s Food used becomes Less than or equal to 0.00

use that
  • Deafed when all dead
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Count non-structure units controlled by (Triggering player) (Ausschließen incomplete units)) Equal to 0
    • Actions
      • Game - Display to (All players) the text: (Defeat Player: + (String((Player number of (Triggering player)))))
(Count non-structure units controlled by Player 2 (Blue) <- Integer, Player
 
Last edited:
Status
Not open for further replies.
Back
Top