Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Simple Defeat Condition

Discussion in 'Triggers & Scripts' started by Goron2222, Nov 12, 2018.

  1. Goron2222

    Goron2222

    Joined:
    Aug 3, 2006
    Messages:
    84
    Resources:
    2
    Maps:
    2
    Resources:
    2
    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
     
  2. Warseeker

    Warseeker

    Joined:
    Feb 18, 2014
    Messages:
    3,104
    Resources:
    2
    Maps:
    2
    Resources:
    2
    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: Nov 12, 2018
  3. Goron2222

    Goron2222

    Joined:
    Aug 3, 2006
    Messages:
    84
    Resources:
    2
    Maps:
    2
    Resources:
    2
    I tried changing it to a periodic event and still no dice, is there any reason why that condition wont fire?
     
  4. Warseeker

    Warseeker

    Joined:
    Feb 18, 2014
    Messages:
    3,104
    Resources:
    2
    Maps:
    2
    Resources:
    2
    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: Nov 12, 2018
  5. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,128
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    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.
     
  6. doom_sheep

    doom_sheep

    Joined:
    Oct 18, 2008
    Messages:
    786
    Resources:
    0
    Resources:
    0
    well, almost ever. I believe units dying from finger of death or artillery attacks disappear immediately.
     
  7. Wrda

    Wrda

    Joined:
    Nov 18, 2012
    Messages:
    1,309
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    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
     
  8. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,691
    Resources:
    37
    Tools:
    2
    Maps:
    3
    Spells:
    11
    Tutorials:
    20
    JASS:
    1
    Resources:
    37
    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: Nov 12, 2018