• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Advanced Alliance System [GUI]

Status
Not open for further replies.
Level 9
Joined
Apr 23, 2010
Messages
312
So iv'e been working on an advanced alliance system where when (for example) Blue wants to ally Red he types "-ally red" and that brings up a dialog box for Red and another for Blue. Red's dialog box asks whether or not he/she would like to accept or decline the alliance, where as Blue's box just says Waiting for Red. My question is how do I make it so this DOESN'T happen? When Red has NOT accepted or declined the alliance request, and (for example) Teal wants an alliance with Purple, it will change my "Allying_Player" variable to teal instead of blue. Below are the triggers that make this work, and I do plan on adding a 10 second timer for the player to make a decision.

This is the trigger for what happens when a player types "-ally red", there are 7 others for the other players.

  • Ally Red
    • Events
      • Player - Player 2 (Blue) types a chat message containing -ally red as An exact match
      • Player - Player 3 (Teal) types a chat message containing -ally red as An exact match
      • Player - Player 4 (Purple) types a chat message containing -ally red as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -ally red as An exact match
      • Player - Player 6 (Orange) types a chat message containing -ally red as An exact match
      • Player - Player 7 (Green) types a chat message containing -ally red as An exact match
      • Player - Player 8 (Pink) types a chat message containing -ally red as An exact match
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Player 1 (Red) slot status) Equal to Is playing) and ((Player 1 (Red) controller) Equal to User)
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering player) is an ally of Player 1 (Red)) Equal to True
            • Then - Actions
              • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: You are already all...
            • Else - Actions
              • Set Allying_Player = (Triggering player)
              • Dialog - Clear Dialog_Box[0]
              • Dialog - Change the title of Dialog_Box[0] to ((Name of (Triggering player)) + would like to ally with you, would you like to form an alliance? You can always unally this player later.)
              • Dialog - Create a dialog button for Dialog_Box[0] labelled Accept
              • Set Dialog_Button[0] = (Last created dialog Button)
              • Dialog - Create a dialog button for Dialog_Box[0] labelled Decline
              • Set Dialog_Button[1] = (Last created dialog Button)
              • Dialog - Show Dialog_Box[0] for Player 1 (Red)
              • Dialog - Clear Dialog_Box[1]
              • Dialog - Change the title of Dialog_Box[1] to (Waiting for + ((Name of Player 1 (Red)) + to decide the alliance...))
              • Dialog - Show Dialog_Box[1] for (Triggering player)
              • Trigger - Turn on Red Ally Decision <gen>
        • Else - Actions
          • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: There is no one the...
Here's what happens when red makes a decision.

  • Red Ally Decision
    • Events
      • Dialog - A dialog button is clicked for Dialog_Box[0]
    • Conditions
      • (Triggering player) Equal to Player 1 (Red)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to Dialog_Button[0]
        • Then - Actions
          • Player - Make Player 1 (Red) treat Allying_Player as an Ally with shared vision
          • Player - Make Allying_Player treat Player 1 (Red) as an Ally with shared vision
          • Game - Display to (Player group(Allying_Player)) for 10.00 seconds the text: ((|cffffcc00 + (Name of Player 1 (Red))) + |r accepted your alliance!)
          • Game - Display to Player Group - Player 1 (Red) for 10.00 seconds the text: ((|cffffcc00 + (Name of (Triggering player))) + |r and you are now allies!)
        • Else - Actions
          • Game - Display to (Player group(Allying_Player)) for 10.00 seconds the text: ((|cffffcc00 + (Name of (Triggering player))) + |r declined the alliance!)
      • Dialog - Hide Dialog_Box[0] for Player 1 (Red)
      • Dialog - Hide Dialog_Box[1] for Allying_Player
      • Trigger - Turn off (This trigger)
I know I could make this work by making 7 different triggers for each player, but that would be very time consuming and I think there is a better way. So if anyone can please help me figure out how to fix this so it doesn't switch the allying players, I will give +rep and credits for helping fix this problem!
 
Level 9
Joined
Apr 23, 2010
Messages
312
@GangSpear, So I should just have 2 separate, non-array Dialog boxes or do you mean no arrays period when it comes to dialog actions? When i tested after i added a button to cancel the alliance request to make sure it worked, as I was the one messaging -ally (color) the dialog box did come up, however the button did not.

@Spinnaker, i don't see why "triggering player" wouldn't work for a dialog event, but i'll take your word for it. If I "set True_Player = (Triggering Player)" and then switched the actions that have triggering player out for the True_Player variable, would that work or should I just change triggering player to a specified player?

Oh, and I was also wondering for setting the Allying_Player variable if i changed it into an array and
  • Set Allying_Player[(Player number of (Triggering player))] = (Triggering player)
would that fix my problem?
 
Explanation for my statement.

I recommend setting player as variable when you use action - show dialog to given player. Then instead of Triggering player use this variable (guess with arrays, so you dont have to make multiple conditions/actions, just refer to player by the number in the array).

EDIT TRIGGERING PLAYER WORKS, my mistake!
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,243
@Spinnaker, array'd dialogs are not bugged, they just need to be initiated:
  • Tr
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • For each (Integer A) from 1 to 12, do (Actions)
      • Loop - Actions
        • Custom script: set udg_Dialogs[GetForLoopIndexA()] = DialogCreate()

You could use bj_forLoopAIndex instead of GetForLoopIndexA() :)

And as an alternative to this trigger, one could set the initial size of the initial array to 12.
 
Level 9
Joined
Apr 23, 2010
Messages
312
Thanks for all the help guys, I just have one more question. If I have this line of code
  • For each (Integer A) from 1 to 8, do (If ((Triggering player) Equal to True_Player[(Integer A)]) then do (Set Allying_Player[(Integer A)] = (Triggering player)) else do (Do nothing))
in one trigger and
  • Player - Make Allying_Player[(Integer A)] treat Player 1 (Red) as an Ally with shared vision
in another, does this save the player number from the first trigger to the second?
 
Level 9
Joined
Apr 23, 2010
Messages
312
Ok so I changed the triggers to what you guys said, but I think i'm doing something wrong.
  • Ally Red
    • Events
      • Player - Player 2 (Blue) types a chat message containing -ally red as An exact match
      • Player - Player 3 (Teal) types a chat message containing -ally red as An exact match
      • Player - Player 4 (Purple) types a chat message containing -ally red as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -ally red as An exact match
      • Player - Player 6 (Orange) types a chat message containing -ally red as An exact match
      • Player - Player 7 (Green) types a chat message containing -ally red as An exact match
      • Player - Player 8 (Pink) types a chat message containing -ally red as An exact match
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering player) is an ally of Player 1 (Red)) Equal to True
            • Then - Actions
              • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: You are already all...
            • Else - Actions
              • Set PlayerNumber_v = (Player number of (Triggering player))
              • Set Allying_Player[PlayerNumber_v] = (Triggering player)
              • Dialog - Clear Dialog_Box_A
              • Dialog - Change the title of Dialog_Box_A to ((Name of (Triggering player)) + would like to ally with you,|n would you like to form an alliance?|n You can always unally this player later.)
              • Dialog - Create a dialog button for Dialog_Box_A labelled Accept
              • Set Dialog_Button_A = (Last created dialog Button)
              • Dialog - Create a dialog button for Dialog_Box_A labelled Decline
              • Set Dialog_Button_B = (Last created dialog Button)
              • Dialog - Show Dialog_Box_A for Player 1 (Red)
              • Set Dialog_Button_C = (Last created dialog Button)
              • Dialog - Clear Dialog_Box_B
              • Dialog - Change the title of Dialog_Box_B to (Waiting for + ((Name of Player 1 (Red)) + |nto decide the alliance...))
              • Dialog - Create a dialog button for Dialog_Box_B labelled Cancel
              • Dialog - Show Dialog_Box_A for Player 1 (Red)
              • Dialog - Show Dialog_Box_B for Allying_Player[PlayerNumber_v]
              • Trigger - Turn on Red Ally Decision <gen>
        • Else - Actions
          • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: There is no one the...
In the above trigger it's setting Allying_Player to the triggering player but in the 2 trigger below the same player needs to be called so the dialog boxes are not stuck forever.
  • Red Ally Decision
    • Events
      • Dialog - A dialog button is clicked for Dialog_Box_A
    • Conditions
      • (Triggering player) Equal to Player 1 (Red)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to Dialog_Button_A
        • Then - Actions
          • Player - Make Player 1 (Red) treat Allying_Player[PlayerNumber_v] as an Ally with shared vision
          • Player - Make Allying_Player[PlayerNumber_v] treat Player 1 (Red) as an Ally with shared vision
          • Game - Display to (Player group(Allying_Player[PlayerNumber_v])) for 10.00 seconds the text: ((|cffffcc00 + (Name of Player 1 (Red))) + |r accepted your alliance!)
          • Game - Display to Player Group - Player 1 (Red) for 10.00 seconds the text: ((|cffffcc00 + (Name of Allying_Player[(Integer A)])) + |r and you are now allies!)
        • Else - Actions
          • Game - Display to (Player group(Allying_Player[PlayerNumber_v])) for 10.00 seconds the text: ((|cffffcc00 + (Name of Player 1 (Red))) + |r accepted your alliance!)
      • Dialog - Hide Dialog_Box_A for Player 1 (Red)
      • Dialog - Hide Dialog_Box_B for Allying_Player[PlayerNumber_v]
      • Trigger - Turn off (This trigger)
  • Red Cancel
    • Events
      • Dialog - A dialog button is clicked for Dialog_Box_B
    • Conditions
      • (Triggering player) Equal to Allying_Player[PlayerNumber_v]
    • Actions
      • Game - Display to (Player group(Allying_Player[PlayerNumber_v])) for 10.00 seconds the text: ((You canceled the alliance request with |cffffcc00 + (Name of Player 1 (Red))) + |r!)
      • Game - Display to Player Group - Player 1 (Red) for 10.00 seconds the text: ((|cffffcc00 + (Name of Allying_Player[(Integer A)])) + |r has canceled their alliance request with you!)
      • Dialog - Hide Dialog_Box_A for Player 1 (Red)
      • Dialog - Hide Dialog_Box_B for Allying_Player[PlayerNumber_v]
      • Trigger - Turn off Red Ally Decision <gen>
      • Trigger - Turn off (This trigger)
To clarify what i'm saying, I need to set the triggering player-A and be able to call that same player in a different trigger, but if someone else starts an the allying trigger, I can't have player-B be called in the allying trigger of player-A. If this is hard to understand it's because i'm confused on what needs to be done.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Explanation for my statement.

I recommend setting player as variable when you use action - show dialog to given player. Then instead of Triggering player use this variable (guess with arrays, so you dont have to make multiple conditions/actions, just refer to player by the number in the array).
See the post below yours in that thread (only the first line is good enough). It does work with "Triggering Player". I kind of lack the motivation to test it right now, but I am sure it works.
A player clicks the dialog button. Thus we have a triggering player (a player who triggered the event). Variables would only over-complicate things.



@13oot-me: try making 1 trigger for all players (so you don't need "Ally red", "Ally blue" and maybe 10 more of those triggers, but only one that works for all players). Well, try to do that once the system works as is.

What if 2 players ally at the same time? Then PlayerNumber_v will be messed up for the second trigger...
And for all I know, you're using "Allying_Player" in the same way as the already existing "Conversion - Convert Player Index To Player" (Allying_Player[PlayerNumber_v] is the same as Player(PlayerNumber_v)).
The title of the dialog is also very long, don't know how you can shorten it though :p

What I would do is set Allying_Player[1] to the triggering player, create a boolean (also arrayed), and set boolean[1] to true when someone is trying to ally red.
If boolean[1] is true, then you cannot try to ally red (to avoid bugs), and in the Red Ally Decision-trigger, you can safely use Allying_Player[1] to recall triggering player (and thus you kind-of rule out the need of "playerNumber_v" as well).

In the first trigger, what does "Set Dialog_Button_C = (Last created dialog Button)" do? That variable will be set to the same button as Button_B (because you did not create a dialog button in between these two actions).

That's about all I could find... try debugging the trigger if you still can't get it to work properly.
 
Level 9
Joined
Apr 23, 2010
Messages
312
Thank you Spinnaker and ap0calypse! + rep and credits for you guys.

@ap0calypse, Dialog_Button_C was misplaced and probably still would be if you didn't say anything. It's meant for the triggering players "cancel" button.

What if 2 players ally at the same time? Then PlayerNumber_v will be messed up for the second trigger...
This is what I was asking, just, better said hahaha.

By the way, has anyone seen any alliance system like this? Or am I the only one that's made something like this? I've looked for alliance systems and have only found the simple ones.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
About 99% of the ally systems I've seen, you just type "-ally {player}" and you ally him (the other player is still not allied to you then).
So your system beats that, once it's finished.

Did you try my suggestion of using red's player number instead of the triggering player's one?
I believe that makes it MPI.

To elaborate:

Teal wrote "-ally red"
Allying_Player[1] = teal
isAllying[1] = true (boolean check)

Red clicks "confirm":
Red allies Allying_Player[Player number of (Triggering Player)] --> Red allies Teal
isAllying[Player number of (Triggering Player)] = false --> isAllying[1] = false, red can get ally messages again.



Edit: just made such a system myself and it works (probably, not in the mood to test with multiple people :/).
So yeah, the idea works. You just need to execute it :D
 
Level 9
Joined
Apr 23, 2010
Messages
312
I did indeed use your suggestion. I believe the system is finished although i'm not quite sure how i would make one trigger for all the players that type "-ally (color)", I did get Ally Decision and Cancel triggers to work for all players. Here is the updated and working system.

  • Ally Red
    • Events
      • Player - Player 2 (Blue) types a chat message containing - as A substring
      • Player - Player 3 (Teal) types a chat message containing - as A substring
      • Player - Player 4 (Purple) types a chat message containing - as A substring
      • Player - Player 5 (Yellow) types a chat message containing - as A substring
      • Player - Player 6 (Orange) types a chat message containing - as A substring
      • Player - Player 7 (Green) types a chat message containing - as A substring
      • Player - Player 8 (Pink) types a chat message containing - as A substring
    • Conditions
      • (Entered chat string) Equal to -ally red
    • Actions
      • Set Player_v = Player 1 (Red)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AllyDecision_Boolean[1] Equal to True
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: An alliance is bein...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player_v slot status) Equal to Is playing) and ((Player_v controller) Equal to User)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Triggering player) is an ally of Player_v) Equal to True
                • Then - Actions
                  • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: You are already all...
                • Else - Actions
                  • Set AllyDecision_Boolean[1] = True
                  • Set Allying_Player[1] = (Triggering player)
                  • Dialog - Clear Dialog_Box_A
                  • Dialog - Change the title of Dialog_Box_A to ((Name of (Triggering player)) + would like to ally with you,|n would you like to form an alliance?|n You can always unally this player later.)
                  • Dialog - Create a dialog button for Dialog_Box_A labelled Accept
                  • Set Dialog_Button_A = (Last created dialog Button)
                  • Dialog - Create a dialog button for Dialog_Box_A labelled Decline
                  • Set Dialog_Button_B = (Last created dialog Button)
                  • Dialog - Show Dialog_Box_A for Player_v
                  • Dialog - Clear Dialog_Box_B
                  • Dialog - Change the title of Dialog_Box_B to (Waiting for + ((Name of Player_v) + |nto decide the alliance...))
                  • Dialog - Create a dialog button for Dialog_Box_B labelled Cancel
                  • Set Dialog_Button_C = (Last created dialog Button)
                  • Dialog - Show Dialog_Box_A for Player_v
                  • Dialog - Show Dialog_Box_B for Allying_Player[1]
                  • Trigger - Turn on Ally Decision <gen>
                  • Trigger - Turn on Cancel <gen>
            • Else - Actions
              • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: There is no one the...
  • Ally Decision
    • Events
      • Dialog - A dialog button is clicked for Dialog_Box_A
    • Conditions
      • (Triggering player) Equal to Player_v
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to Dialog_Button_A
        • Then - Actions
          • Player - Make Player_v treat Allying_Player[1] as an Ally with shared vision
          • Player - Make Allying_Player[1] treat Player_v as an Ally with shared vision
          • Game - Display to (Player group(Allying_Player[1])) for 10.00 seconds the text: ((|cffffcc00 + (Name of Player_v)) + |r accepted your alliance!)
          • Game - Display to (Player group(Player_v)) for 10.00 seconds the text: ((|cffffcc00 + (Name of Allying_Player[1])) + |r and you are now allies!)
        • Else - Actions
          • Game - Display to (Player group(Allying_Player[PlayerNumber_v])) for 10.00 seconds the text: ((|cffffcc00 + (Name of Player_v)) + |r accepted your alliance!)
      • Dialog - Hide Dialog_Box_A for Player_v
      • Dialog - Hide Dialog_Box_B for Allying_Player[1]
      • Set AllyDecision_Boolean[1] = False
      • Trigger - Turn off (This trigger)
  • Cancel
    • Events
      • Dialog - A dialog button is clicked for Dialog_Box_B
    • Conditions
      • (Triggering player) Equal to Allying_Player[1]
    • Actions
      • Game - Display to (Player group(Allying_Player[1])) for 10.00 seconds the text: ((You canceled the alliance request with |cffffcc00 + (Name of Player_v)) + |r!)
      • Game - Display to (Player group(Player_v)) for 10.00 seconds the text: ((|cffffcc00 + (Name of Allying_Player[1])) + |r has canceled their alliance request with you!)
      • Dialog - Hide Dialog_Box_A for Player_v
      • Dialog - Hide Dialog_Box_B for Allying_Player[1]
      • Set AllyDecision_Boolean[1] = False
      • Trigger - Turn off Ally Decision <gen>
      • Trigger - Turn off (This trigger)
 
Status
Not open for further replies.
Top