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

[Trigger] defeat condition not working properly

Status
Not open for further replies.
Level 17
Joined
Aug 19, 2007
Messages
1,380
Hi all.

My defeat condition trigger does not always seem to work correctly. Sometimes a player is defeated after losing a building while he/she still has other buildings. This trigger is from/for my Starcraft Hybrids maps;

  • Defeat
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set Defeat_Group = (Units owned by (Owner of (Dying unit)) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) is A structure) Equal to True)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is A structure) Equal to True
          • (Number of units in Defeat_Group) Equal to 0
        • Then - Actions
          • Game - Display to (All players) the text: ((Player + (Name of (Owner of (Dying unit)))) + has been killed!)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Defeat_Group) Equal to 0
          • (Owner of (Dying unit)) Not equal to Neutral Hostile
          • (Owner of (Dying unit)) Not equal to Neutral Victim
          • (Owner of (Dying unit)) Not equal to Neutral Extra
          • (Owner of (Dying unit)) Not equal to Neutral Passive
        • Then - Actions
          • Game - Defeat (Owner of (Dying unit)) with the message: All your buildings ...
        • Else - Actions
      • Custom script: call DestroyGroup(udg_Defeat_Group)
Anyone know what the problem is? +rep ofcourse
 
Level 17
Joined
Aug 19, 2007
Messages
1,380
Thanks for the comments.

try use "triggering unit" instead of "dying unit"
since dying unit usually causes a problem when there's two unit die at the same time
, did not fixed it but usefull info nonetheless tnx.

You can try counting/picking all structures owned by x player. If a structure is destroyed/dead deduct one from the counted structures. If structures of x player reaches 0, defeat him.
Now, if x player finishes constructing a structure and he is not yet defeated, add 1 to the counted structures.
, interesting idea, gonna try that.

Post a replay of the game where bug happens.
, there's not much to see, I get the error e.g. after cancelling the building of a structure.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
There must be another trigger which causes defeats.Can you disable this trigger and test again?Because I tried with this same trigger but it is not defeating me nor displays message when I cancel building.

Btw I am using human type build but I don't think it matters.

  • Melee Initialization
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set Defeat_Group = (Units owned by (Owner of (Dying unit)) matching ((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is A structure) Equal to True
          • (Number of units in Defeat_Group) Equal to 0
        • Then - Actions
          • Game - Display to (All players) the text: killed
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Defeat_Group) Equal to 0
          • (Owner of (Dying unit)) Not equal to Neutral Hostile
          • (Owner of (Dying unit)) Not equal to Neutral Victim
          • (Owner of (Dying unit)) Not equal to Neutral Extra
          • (Owner of (Dying unit)) Not equal to Neutral Passive
        • Then - Actions
          • Game - Defeat Player 1 (Red) with the message: GG
        • Else - Actions
      • Custom script: call DestroyGroup(udg_Defeat_Group)

Edit: Oh wait...
Are you saying you are getting defeated when you cancel your FIRST building?You said player is getting defeated when player has other buildings.
 
Level 17
Joined
Aug 19, 2007
Messages
1,380
I do now the following as eubz suggested, which seems to work correctly (I run Count buildings init once in the beginning of the script):

  • Count buildings init
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 13, do (Actions)
        • Loop - Actions
          • Set DefeatGroup_new[(Integer A)] = (Count structures controlled by (Player((Integer A))) (Include incomplete structures))
  • Count buildings
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • ((Triggering unit) is A structure) Equal to True
    • Actions
      • Set DefeatGroup_new[(Player number of (Owner of (Triggering unit)))] = (DefeatGroup_new[(Player number of (Owner of (Triggering unit)))] + 1)
  • Defeat new
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A structure) Equal to True
      • (Owner of (Triggering unit)) Not equal to Neutral Hostile
      • (Owner of (Triggering unit)) Not equal to Neutral Victim
      • (Owner of (Triggering unit)) Not equal to Neutral Extra
      • (Owner of (Triggering unit)) Not equal to Neutral Passive
    • Actions
      • Set DefeatGroup_new[(Player number of (Owner of (Triggering unit)))] = (DefeatGroup_new[(Player number of (Owner of (Triggering unit)))] - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DefeatGroup_new[(Player number of (Owner of (Triggering unit)))] Less than or equal to 0
        • Then - Actions
          • Game - Display to (All players) the text: ((Player + (Name of (Owner of (Triggering unit)))) + has been killed!)
          • Game - Defeat (Owner of (Triggering unit)) with the message: All your buildings ...
        • Else - Actions
 
Level 12
Joined
Nov 3, 2013
Messages
989
Shouldn't you check if they cancel the buildings? Otherwise you could just cancel one building and now you can't lose because the integer will always be one more than how many buildings the opponent can destroy.

Edit: Aple seem to have struck gold.
 
Status
Not open for further replies.
Top