• 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] Faction Selection Issue

Status
Not open for further replies.
Level 7
Joined
Apr 5, 2013
Messages
243
I've made a dialog faction selection screen for my map allowing players to choose their civilization. Then, Player 1 can choose the civs for computer players. The problem is, I've made the selection dialog for each computer faction pop up after the previous one was selected, so if a computer player was unassigned, the dialog selection menu won't pop up for the following ones. I need a way to work around this, an easy one if possible as I'm nowhere near a trigger expert.
 
Level 7
Joined
Jan 22, 2013
Messages
293
I've made a dialog faction selection screen for my map allowing players to choose their civilization. Then, Player 1 can choose the civs for computer players. The problem is, I've made the selection dialog for each computer faction pop up after the previous one was selected, so if a computer player was unassigned, the dialog selection menu won't pop up for the following ones. I need a way to work around this, an easy one if possible as I'm nowhere near a trigger expert.

Please post your problem trigger otherwise you are making us guess, which doesn't help you much at all.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
You iterate through a dynamic structure containing the computer players instead of using hard-coded constants. A player group will be perfect for your requirements. Fill it with all un-assigned computer players during the selection process (when players select their own race).

Then when it is time to show it to red, you get the first player in the player group of un-assigned computers and remove him from that same player group. A dialog can then be made for player 1 representing the race of this player. After he chooses the race for that player, the next unit from the player group representing all un-assigned computers is chosen and the process repeats.

When the player group is empty (no more players in it) you can stop showing dialogs.
 
Level 7
Joined
Apr 5, 2013
Messages
243
I'm not sure if I got it correctly, but won't one or both of these help?
  • Conditions
    • (Player 1 (Red) slot status) Equal to Is playing
    • (Player 1 (Red) controller) Equal to Computer
Won't Help me solve it, I've done this but it won't skip to the next computer just by that (check my trigger bellow)

im not sure if this is what u want but u can assign computer slots forcefully in the player properties menu.
I don't want to do so, to allow both AI and human players in any combination of numbers.

Please post your problem trigger otherwise you are making us guess, which doesn't help you much at all.
Done!

You iterate through a dynamic structure containing the computer players instead of using hard-coded constants. A player group will be perfect for your requirements. Fill it with all un-assigned computer players during the selection process (when players select their own race).

Then when it is time to show it to red, you get the first player in the player group of un-assigned computers and remove him from that same player group. A dialog can then be made for player 1 representing the race of this player. After he chooses the race for that player, the next unit from the player group representing all un-assigned computers is chosen and the process repeats.

When the player group is empty (no more players in it) you can stop showing dialogs.
I think this is what I need but I don't completely understand how to do it.


Here's my first trigger, works for human players:
  • Selection
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Dialog - Clear FactionSelection
      • Dialog - Change the title of FactionSelection to Faction Selection
      • Dialog - Create a dialog button for FactionSelection labelled Romans
      • Set FSButton[0] = (Last created dialog Button)
      • Dialog - Create a dialog button for FactionSelection labelled Scythians
      • Set FSButton[1] = (Last created dialog Button)
      • Dialog - Create a dialog button for FactionSelection labelled Celts (Not Working ...
      • Set FSButton[2] = (Last created dialog Button)
      • Dialog - Create a dialog button for FactionSelection labelled Greeks (Not Working...
      • Set FSButton[3] = (Last created dialog Button)
      • Dialog - Create a dialog button for FactionSelection labelled Macedonians (Not Wo...
      • Set FSButton[4] = (Last created dialog Button)
      • Dialog - Create a dialog button for FactionSelection labelled Carthaginians (Not ...
      • Set FSButton[5] = (Last created dialog Button)
      • Dialog - Create a dialog button for FactionSelection labelled Persians (Not Worki...
      • Set FSButton[6] = (Last created dialog Button)
      • Player Group - Pick every player in (All players controlled by a User player) and do (Actions)
        • Loop - Actions
          • Dialog - Show FactionSelection for (Picked player)
Then, player 1 selects the computer races like this:
  • ComputerPlayer2
    • Events
      • Dialog - A dialog button is clicked for FactionSelection
    • Conditions
      • (Player 2 (Blue) controller) Equal to Computer
      • (Triggering player) Equal to Player 1 (Red)
    • Actions
      • Dialog - Clear FactionSelection2
      • Dialog - Change the title of FactionSelection2 to Choose Player 2 Civ
      • Dialog - Create a dialog button for FactionSelection2 labelled Romans
      • Set FSButton[0] = (Last created dialog Button)
      • Dialog - Create a dialog button for FactionSelection2 labelled Scythians
      • Set FSButton[1] = (Last created dialog Button)
      • Dialog - Create a dialog button for FactionSelection2 labelled Celts (Not Working ...
      • Set FSButton[2] = (Last created dialog Button)
      • Dialog - Create a dialog button for FactionSelection2 labelled Greeks (Not Working...
      • Set FSButton[3] = (Last created dialog Button)
      • Dialog - Create a dialog button for FactionSelection2 labelled Macedonians (Not Wo...
      • Set FSButton[4] = (Last created dialog Button)
      • Dialog - Create a dialog button for FactionSelection2 labelled Carthaginians (Not ...
      • Set FSButton[5] = (Last created dialog Button)
      • Dialog - Create a dialog button for FactionSelection2 labelled Persians (Not Worki...
      • Set FSButton[6] = (Last created dialog Button)
      • Player Group - Pick every player in Player Group - Player 1 (Red) and do (Actions)
        • Loop - Actions
          • Dialog - Show FactionSelection2 for (Picked player)
But, Say player 2 was unassigned, this way it won't show the next one for player 3 (that works accordingly on Events - Dialog - A dialog button is clicked for FactionSelection2), so no computer AI can be added.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
I think this will do it:
Create a player-group like variable. In my case, I named it CP_Group.
Add this line to your first trigger "Selection"
  • Set CP_Group = (All players controlled by a Computer player)
Then create a player-type variable. In my case I call it "Temp_Player". Now change your second trigger to this:
  • Triggers 2
    • Events
      • Dialog - A dialog button is clicked for FactionSelection
    • Conditions
      • (Triggering player) Equal to Player 1 (Red)
      • (Number of players in CP_Group) Greater than 0
    • Actions
      • Set Temp_Player = (Random player from CP_Group)
      • Player Group - Remove Temp_Player from CP_Group
      • -------- here go all the actions you have in your Computer Player Trigger 2 (dialog buttons, etc.) --------
The second condition checks if any player is in CP_Group. If not, then no player slots are used by Computer (so they're either empty or user-controlled)

Now create a last 3rd trigger and do this:
  • Comp Selection
    • Events
      • Dialog - A dialog button is clicked for FactionSelection2
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of players in CP_Group) Equal to 0
        • Then - Actions
          • Custom script: call DestroyForce(udg_CP_Group)
          • Skip remaining actions
        • Else - Actions
      • Set Temp_Player = (Random player from CP_Group)
      • Player Group - Remove Temp_Player from CP_Group
      • -------- here go once again all the actions you have in your Computer Player Trigger 2 (dialog buttons, etc.) --------
This trigger should use FactionSelection2 buttons as well. That way this trigger fires whenever FactionSelection2 button is selected and will eventually loop through all computer-controlled enemies.


There are possible problems I see with your selection:
1) you have set player 1 to choose civ for computer players. however this won't work if Player1 slot is computer or empty.
2) I'm not good with dialog buttons, but when player 1 selects dialog buttons, won't he rewrite them? (It seems you use same dialog buttons for all user-players and then, when player 1 selects civ, you rewrite them for Computer civ selection)
 
Level 7
Joined
Jan 22, 2013
Messages
293
Well, the guy above me mainly only suggest improvements for your speed, truly you don't need to even mess with pick all players in force. You can use PlayerID(0-16) :p

You place that in an Array in GUI with a custom integer for the array equal to the number of players.

You should be setting an Boolean so you can tell if a person alreadly has a dialog up, that way when you pick something the next will that is computer will pop up. If that slot is not equal to User & Isplaying or Computer then set that dialog Boolean to false that way it is then not opened for the player instead it will be none exsistant allowing you to continue to ones that are playing...

I'll be back soon, if you didn't understand what I said. Then I will give a better solution.
 
Level 7
Joined
Apr 5, 2013
Messages
243
I think this will do it:
Create a player-group like variable. In my case, I named it CP_Group.
Add this line to your first trigger "Selection"
  • Set CP_Group = (All players controlled by a Computer player)
Then create a player-type variable. In my case I call it "Temp_Player". Now change your second trigger to this:
  • Triggers 2
    • Events
      • Dialog - A dialog button is clicked for FactionSelection
    • Conditions
      • (Triggering player) Equal to Player 1 (Red)
      • (Number of players in CP_Group) Greater than 0
    • Actions
      • Set Temp_Player = (Random player from CP_Group)
      • Player Group - Remove Temp_Player from CP_Group
      • -------- here go all the actions you have in your Computer Player Trigger 2 (dialog buttons, etc.) --------
The second condition checks if any player is in CP_Group. If not, then no player slots are used by Computer (so they're either empty or user-controlled)

Now create a last 3rd trigger and do this:
  • Comp Selection
    • Events
      • Dialog - A dialog button is clicked for FactionSelection2
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of players in CP_Group) Equal to 0
        • Then - Actions
          • Custom script: call DestroyForce(udg_CP_Group)
          • Skip remaining actions
        • Else - Actions
      • Set Temp_Player = (Random player from CP_Group)
      • Player Group - Remove Temp_Player from CP_Group
      • -------- here go once again all the actions you have in your Computer Player Trigger 2 (dialog buttons, etc.) --------
This trigger should use FactionSelection2 buttons as well. That way this trigger fires whenever FactionSelection2 button is selected and will eventually loop through all computer-controlled enemies.


There are possible problems I see with your selection:
1) you have set player 1 to choose civ for computer players. however this won't work if Player1 slot is computer or empty.
2) I'm not good with dialog buttons, but when player 1 selects dialog buttons, won't he rewrite them? (It seems you use same dialog buttons for all user-players and then, when player 1 selects civ, you rewrite them for Computer civ selection)

An issue that comes up with this, correct me if I'm wrong, is that it brings up computer players in random order? If so how do you know for which one you select a race?

About the possible problems, if I'm getting you right:
1) I don't mind that much forcing player 1 to be the host. Unless there's an easy way around this.
2) I'm pretty certain that buttons work just fine for all players this way.

Well, the guy above me mainly only suggest improvements for your speed, truly you don't need to even mess with pick all players in force. You can use PlayerID(0-16) :p

You place that in an Array in GUI with a custom integer for the array equal to the number of players.

You should be setting an Boolean so you can tell if a person alreadly has a dialog up, that way when you pick something the next will that is computer will pop up. If that slot is not equal to User & Isplaying or Computer then set that dialog Boolean to false that way it is then not opened for the player instead it will be none exsistant allowing you to continue to ones that are playing...

I'll be back soon, if you didn't understand what I said. Then I will give a better solution.

Yes please I didn't quite get it.

Actually instead of messing with your time trying to explain, if either one of you could do it for me (map credits given ofc) It might be better (for the map check - link my sig - first post - progress). I'll then probably understand how it works and be able to readjust it for possible new faction additions/bigger player count.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Yes, random computer players will be selected from the group. You could find out which player it is through player ID or you could cycle through the group to pick up computer player with lowest player ID (by comparing player IDs)

Player 1 (red) has ID 1, Player 2 (blue) has ID 2, Player 7 (green) has ID 7, and so on.
So if you cycle through the computer group and pick the one with lowest ID, you can predict to which PC you assign civ.

Cycling through player group may also solve your issue with Player 1 being the host.
You could make the player with lowest ID to choose civ for computers.
---------
However if Orthane has better solution to this, I would try his way.
 
Level 7
Joined
Jan 22, 2013
Messages
293
Yes, random computer players will be selected from the group. You could find out which player it is through player ID or you could cycle through the group to pick up computer player with lowest player ID (by comparing player IDs)

Player 1 (red) has ID 1, Player 2 (blue) has ID 2, Player 7 (green) has ID 7, and so on.
So if you cycle through the computer group and pick the one with lowest ID, you can predict to which PC you assign civ.

Cycling through player group may also solve your issue with Player 1 being the host.
You could make the player with lowest ID to choose civ for computers.
---------
However if Orthane has better solution to this, I would try his way.

There are systems that allow you to find the host of the game (They aren't perfect but they work)

> Store Integer number travel it over to a loop for the host. run it every second checking to see if the Boolean(A True/False that involves if he alreadly has a dialog up) whent hat one is down, you remove a number fromt he index, allowing him to cycle through all of the computer players one by one, after all are picked the game starts, of if a "Timer runs out" it picks a random race for all who didn't pick "That way if people don't pick at all they don't ruin the game because it wont start until you do pick"
 
Status
Not open for further replies.
Top