• 🏆 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!

Defeat Trigger Not Working

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
Hello, I am working on a map and finding it difficult to make my "defeat" trigger work. I want players to see a defeat message when everybody's peasent units die (like when all builders die in vampirism or island defence). Here is my trigger;

Defeat
Events
Unit - A unit Dies
Conditions
(Number of units in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Peasant (Staying Alive)))) Equal to 0
Actions
Trigger - Turn off Ghoul Timer <gen>
Trigger - Turn off Abominations Timer <gen>
Trigger - Turn off Knights Timer <gen>
Trigger - Turn off Undead Upgrade <gen>
Trigger - Turn off Necromancers Timer <gen>
Trigger - Turn off Undead King <gen>
Trigger - Turn off Ghouls Spawn <gen>
Trigger - Turn off Abominations Spawn <gen>
Trigger - Turn off Knights Spawn <gen>
Trigger - Turn off Necromancers Spawn <gen>
Trigger - Turn off Undead King <gen>
Trigger - Turn off Victory <gen>
Unit Group - Pick every unit in (Units in (Playable map area) matching ((Owner of (Matching unit)) Not equal to Player 12 (Brown))) and do (Actions)
Loop - Actions
Unit - Kill (Picked unit)
Sound - Stop music Immediately
Game - Display to (All players) for 30.00 seconds the text: Defeat...
Countdown Timer - Pause (Last started timer)
Countdown Timer - Destroy (Last created timer window)
Sound - Play Doom <gen>


When all the peasents die, the trigger does not fire. Does anyone have any ideas why this trigger isn't working?
 
Level 8
Joined
Sep 23, 2007
Messages
357
make the conditions "Dying Unit equal to Peasant "
and then in the actions put an If/Then/Else with the conditions for If being if the number of peasants in the playable map area is equal to 0 then (do all the actions) else (do nothing)
 
Level 11
Joined
Nov 15, 2007
Messages
781
Do your peasants leave corpses? Dead units still count as being on the map until they fully decay. Either set peasants' death type to "Can't raise, does not decay" in the object editor, or remove them via triggers when they die, or just add an "And" condition and check that there are any units on the map which are both alive and a peasant.
 
Level 17
Joined
Jan 21, 2010
Messages
2,111
  • Conditions
    • (Number of units in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Peasant (unit is alive)))) Equal to 0
  • Actions
Try this one
I forgot which is existed in the trigger editor, but i belive the (unit is alive) is the correct one
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
Thanks so much. I managed to fix it. I made a debug trigger which removed the unit, then used your line of code as the condition to the defeat trigger.

  • Debug
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Peasant (Staying Alive)
    • Actions
      • Unit - Remove (Dying unit) from the game
      • Trigger - Run Defeat <gen> (checking conditions)
  • Defeat
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Number of units in (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Peasant (Staying Alive)) and (((Dying unit) is alive) Equal to False)))) Equal to 0
    • Actions
      • Sound - Stop music Immediately
      • Sound - Play Doom <gen>
      • Game - Display to (All players) for 30.00 seconds the text: Defeat...
      • Countdown Timer - Destroy (Last created timer window)
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Owner of (Matching unit)) Not equal to Player 12 (Brown))) and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
      • Trigger - Turn off Ghoul Timer <gen>
      • Trigger - Turn off Abominations Timer <gen>
      • Trigger - Turn off Undead Upgrade <gen>
      • Trigger - Turn off Knights Timer <gen>
      • Trigger - Turn off Necromancers Timer <gen>
      • Trigger - Turn off Undead King <gen>
      • Trigger - Turn off Ghouls Spawn <gen>
      • Trigger - Turn off Abominations Spawn <gen>
      • Trigger - Turn off Necromancers Spawn <gen>
      • Trigger - Turn off Knights Spawn <gen>
      • Trigger - Turn off Undead King <gen>
      • Trigger - Turn off Victory <gen>
Thanks very much, + rep to all who helped :)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
You should only use one trigger. The unit group condition leaks.

->
  • Untitled Trigger 024
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Mortar Team
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Mortar Team) and (((Matching unit) is alive) Equal to True)))) Equal to 0
        • Then - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: 0
        • Else - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: not 0
 
Status
Not open for further replies.
Top