• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Simple Defeat Condition

Status
Not open for further replies.
Level 7
Joined
Aug 3, 2006
Messages
88
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
 
Level 28
Joined
Feb 18, 2014
Messages
3,580
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:
Level 28
Joined
Feb 18, 2014
Messages
3,580
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:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
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.
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,887
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.
Top