• 🏆 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] Victory/Defeat Triggers are hard...

Status
Not open for further replies.
Level 12
Joined
May 20, 2009
Messages
822
Sorry to post another thread today, but every time I come to try and make a Victory/Defeat Trigger, I can never successfully do it. It's extremely difficult...

Here's what I have so far (THIS IS NOT COMPLETE):

  • Victory Conditions
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Count structures controlled by (Triggering player) (Include incomplete structures)) Equal to 0
    • Actions
      • Set Players = (All Players)
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering player) is giving (Picked player) Alliance (non-aggression)) Equal to True
              • ((Picked player) is giving (Triggering player) Alliance (non-aggression)) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Count structures controlled by (Picked player) (Include incomplete structures)) Equal to 0
                • Then - Actions
                  • Player Group - Remove (Picked player) from Players
                  • Player Group - Remove (Triggering player) from Players
                  • Game - Defeat (Triggering player) with the message: Defeat!
                  • Game - Defeat (Picked player) with the message: Defeat!
                • Else - Actions
            • Else - Actions
              • Player Group - Remove (Triggering player) from Players
              • Game - Defeat (Triggering player) with the message: Defeat!
I've got the Defeat part done. But now how would I go about the giving Victory to the last players standing that are all allied? I have to do this because I'm using a custom race. (I also get the joy of making a reveal trigger for the player that uses the custom race...Yaaaay)

EDIT: There needs to be a generic link/tutorial that people can link to people for this, if there isn't one already.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,197
You keep track of each player on player hostility in a counter. When a player is defeated you decrement the counter by all the hostilities he was involved in. If the hostility counter becomes 0 (there is no more player on player hostility) you know the remaining players have won (the players who have not been defeated).

This solves the age old diplo problem of having a "neutral" player winning once his allies have resolved their conflicts.
 
Level 12
Joined
May 20, 2009
Messages
822
You keep track of each player on player hostility in a counter. When a player is defeated you decrement the counter by all the hostilities he was involved in. If the hostility counter becomes 0 (there is no more player on player hostility) you know the remaining players have won (the players who have not been defeated).

This solves the age old diplo problem of having a "neutral" player winning once his allies have resolved their conflicts.

If you don't mind me asking, could you provide an example? =)
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,197
What you say you are after is that you win once all enemy players have been defeated. However this alone is not enough since there may exist players who are enemies to no one (allied everyone) so under that meaning they would instantly win (as soon as they ally everyone).

So what you actually need is two stages to the victory process.
1. Defeating players as they lose.
2. Winning all players once everyone is allied (no hostility exists).
Aka, allied victory from all the RTS games like AoE and EE.

To do this you need to track the number (an integer variable to count) of hostile relationships between players that exist at any given time. You could either re-build this from scratch each test (slow) or cache the result and only apply the changes to it (fast but more complicated/bug prone).

When this counter is 0 then there are no longer any hostile relationships in the game and as such victory can be rewarded to the survivors.

To build the counter, for every player remaining (not neutral (AI, not part of game) and not defeated) then for every player who is not that player if outer loop player is hostile with inner loop player than add 1 to the counter. This will technically count each player on player hostility relationship twice (once for each player) but that is of no concern as you only care if it is 0 (no hostility exists).
 
Level 12
Joined
May 20, 2009
Messages
822
I'm really sorry, but that only made more questions then it answered. xD

I'm going to check some maps, though, and see if the method you are saying is implemented. Like Some Diplos.

EDIT: Do you know any maps that aren't Protected so I actually CAN take a look at the Victory/Defeat Trigger...? (NOT asking for deprotectors or anything, just maps that aren't initially protected.)
 
Last edited:
Level 13
Joined
Jul 16, 2012
Messages
679
Sorry to post another thread today, but every time I come to try and make a Victory/Defeat Trigger, I can never successfully do it. It's extremely difficult...

Here's what I have so far (THIS IS NOT COMPLETE):

  • Victory Conditions
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Count structures controlled by (Triggering player) (Include incomplete structures)) Equal to 0
    • Actions
      • Set Players = (All Players)
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering player) is giving (Picked player) Alliance (non-aggression)) Equal to True
              • ((Picked player) is giving (Triggering player) Alliance (non-aggression)) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Count structures controlled by (Picked player) (Include incomplete structures)) Equal to 0
                • Then - Actions
                  • Player Group - Remove (Picked player) from Players
                  • Player Group - Remove (Triggering player) from Players
                  • Game - Defeat (Triggering player) with the message: Defeat!
                  • Game - Defeat (Picked player) with the message: Defeat!
                • Else - Actions
            • Else - Actions
              • Player Group - Remove (Triggering player) from Players
              • Game - Defeat (Triggering player) with the message: Defeat!
I've got the Defeat part done. But now how would I go about the giving Victory to the last players standing that are all allied? I have to do this because I'm using a custom race. (I also get the joy of making a reveal trigger for the player that uses the custom race...Yaaaay)

EDIT: There needs to be a generic link/tutorial that people can link to people for this, if there isn't one already.

Look this if work or not
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Number of units in (Units owned by (Triggering player))) Equal to 0
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units owned by (Triggering player))) Equal to 0
            • Then - Actions
            • Else - Actions
              • Set PlayerGroup = (Player group((Player((Integer A)))))
      • Player Group - Pick every player in PlayerGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering player) is giving (Picked player) Alliance (non-aggression)) Equal to True
              • ((Picked player) is giving (Triggering player) Alliance (non-aggression)) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in (Units owned by (Picked player))) Equal to 0
                • Then - Actions
                  • Player Group - Remove (Triggering player) from PlayerGroup
                  • Player Group - Remove (Picked player) from PlayerGroup
                  • Game - Defeat (Triggering player) with the message: Defeat!
                  • Game - Defeat (Matching player) with the message: Defeat!
                • Else - Actions
            • Else - Actions
              • Player Group - Remove (Triggering player) from PlayerGroup
              • Game - Defeat (Triggering player) with the message: Defeat!
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,197
It would be under integer comparison I imagine. Additionally you could do the pure JASS approach and test if the first of the group is equal to null (group is empty).

Remember to destroy the group after you are done with it as WC3 has very bad (virtually non-existent?) garbage collection. Not destroying the group will result in an object leak that can cause degraded performance. Groups are especially bad for this as they are often one of the largest objects (especially if they feature a large subset of all units).
 
Level 12
Joined
May 20, 2009
Messages
822
Nothing here is helping me...I need a more detailed explanation then just "keep track of each player on player hostility in a counter"

Sorry...

I'm still EXTREMELY new to GUI, I know I've barely learned anything from it and THEN I have to learn JASS which will be especially difficult because I've never really done a whole lot with any kind of coding...
 
Status
Not open for further replies.
Top