• 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.

Voting option

Status
Not open for further replies.
Level 7
Joined
May 30, 2018
Messages
290
Hey there :)

Iam currently working on a map, in which the players of a team are able to vote for a race to play (as team) at the beginning of the game.
I just wanted to ask how I could implement such a voting system. Furthermore after they voted for a race and the race got picked, how could I do it, that the players are then transfered to a character/hero selection, which is now specificly bound to the race they picked. E.g. So one team picked humans, how do I make it that they only can choose human heroes etc.

Thanks in advance :)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,286
Depends on how you want the vote system to work. Once vote results are in you push out a specific dialog for appropriate hero selection based on the results.

For more detail how to implement a vote system you will need to explain how you want the vote to work. There are dozens of ways a vote can work.

After the vote concludes and a selection is made, one can use an if then else if statement to choose which hero selection dialog to show. In GUI one could break these down into separate triggers for each vote result and then run the appropriate trigger after the vote concludes.
 
Level 13
Joined
Oct 12, 2016
Messages
769
What Dr. Super Good said.
No matter how you implement it though, be it through text commands or a dialog box with buttons, you will need a good grasp of variables, counting, and comparatives. Simplest way to compare these integers? If/then/else statements after a triggering event.
 
Level 7
Joined
May 30, 2018
Messages
290
Depends on how you want the vote system to work. Once vote results are in you push out a specific dialog for appropriate hero selection based on the results.

For more detail how to implement a vote system you will need to explain how you want the vote to work. There are dozens of ways a vote can work.

After the vote concludes and a selection is made, one can use an if then else if statement to choose which hero selection dialog to show. In GUI one could break these down into separate triggers for each vote result and then run the appropriate trigger after the vote concludes.

Okay you're right
So I want to use dialog boxes that show up after the game begins, they display the pickable races, each player from a team can give 1 Vote on which race to pick. The race with the majority of the votes is the one that get's picked.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,286
The race with the majority of the votes is the one that get's picked.
And the game just ends in defeat if no one votes or if there is a tie? This is what I mean about explaining what kind of vote you want...

I assume you know how dialogs work, so making a dialog with all the buttons for selectable races is a non-issue.

Each vote option is assigned an index in an integer array "ballot count". In response to a player pressing a button on the dialog it increments ballot count for that option by 1. When the vote ends a linear search is performed on ballot count to find the index which won the ballot. This index is then used to execute appropriate code for that selection, either by a massive if then else tree or by branching to run other triggers mapped using a trigger array to each option.

Vote end is determined when either all active players have cast a vote or a timer expires. A timeout of 30 seconds is pretty common for such votes. Votes left to cast is tracked using an integer variable which is set to the number of active players and decremented by 1 each time a player casts a vote. When votes left to cast is 0 then the vote has ended and the counting trigger can be run.

Technically one should track what each player votes for in order to remove their vote if they leave the game during the voting dialog. However this is a lot of hassle and can be ignored for now as the timer will prevent players dropping during the vote from causing a softlock.

The linear search needs some kind of bias for the case that 2 options have the most votes. If no votes are cast there should be some meaningful default, eg random.
 
Level 7
Joined
May 30, 2018
Messages
290
And the game just ends in defeat if no one votes or if there is a tie? This is what I mean about explaining what kind of vote you want...

I assume you know how dialogs work, so making a dialog with all the buttons for selectable races is a non-issue.

Each vote option is assigned an index in an integer array "ballot count". In response to a player pressing a button on the dialog it increments ballot count for that option by 1. When the vote ends a linear search is performed on ballot count to find the index which won the ballot. This index is then used to execute appropriate code for that selection, either by a massive if then else tree or by branching to run other triggers mapped using a trigger array to each option.

Vote end is determined when either all active players have cast a vote or a timer expires. A timeout of 30 seconds is pretty common for such votes. Votes left to cast is tracked using an integer variable which is set to the number of active players and decremented by 1 each time a player casts a vote. When votes left to cast is 0 then the vote has ended and the counting trigger can be run.

Technically one should track what each player votes for in order to remove their vote if they leave the game during the voting dialog. However this is a lot of hassle and can be ignored for now as the timer will prevent players dropping during the vote from causing a softlock.

The linear search needs some kind of bias for the case that 2 options have the most votes. If no votes are cast there should be some meaningful default, eg random.

I really appreciate your dedication towards the solution of this issue, but I have to disappoint you. I feel misrable for having to say this, but I dont understood a single thing you tried to explain. Iam sorry Im not that into coding and the editor in general. I know it's pathetic, but since I saw so many maps with voting systems, I imagined it to be more simple to realise for me :/ but now, that you explained it, I have to admit, I can't understand sh*t. Seems like I have to find an alternative now...:( Maybe I would get it if you explain it step by step / tutorial like, IF you would be willing to invest the time, which I dont expect, just asking.
 
Last edited:
Level 7
Joined
May 30, 2018
Messages
290
I'd know hot to make the basic dialoge boxes with each race, but what to do that they becomes a vote that leads to a pick of a race in conclusion?

In my map under triggers you can see at which point iam confunsed (basically everything)
 

Attachments

  • WC3 Team Survival.w3x
    18.6 KB · Views: 20
Last edited:
Level 9
Joined
Apr 23, 2011
Messages
527
Can't use the editor right now so can't look at your map, would be best if you posted the relevant triggers.

What DSG is saying is the entire logic of the system.
Say, there are several options for races:
  • 0 = Human
  • 1 = Orc
  • 2 = Undead
  • 3 = Night Elf
The dialog button variable must refer to each race, say, RaceDialog[0] (a dialog button variable) says "Human" on the button.
In an initialization trigger, add the players to their respective player group team and also set the number of players of the team to an integer.

When a player selects a dialog button, use multiple If-Then-Else statements to find out which one was pressed: (Functions may not be exact, exact trigger may not work)
  • dialog race
  • Events
    • A dialog box button is pressed
  • Conditions
  • Actions
  • For (Integer loop) from 0 to 1, Do (Actions)
    • Loop - Actions
      • If (All Conditions Are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player is in Team[loop]) Equal to True
        • Then - Actions
          • // Increase number of team votes, find out which race was selected
          • Set TotalVoteTeam[loop] = (TotalVoteTeam[loop] + 1)
          • For (Integer racecheck) from 0 to 3, do (Actions)
            • Loop - Actions
              • If (All Conditions Are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Selected dialog button) Equal to RaceDialog[racecheck]
                • Then - Actions
                  • Set RaceVote[racecheck[loop]] = (RaceVote[racecheck[loop] + 1)
                • Else - Actions
          • // Now to check if all players of a team have selected, then figure out the most votes
          • If (All Conditions Are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TotalVoteTeam[loop] Equal to maxplayersteam[loop]
            • Then - Actions
              • For (Integer racecheck) from 0 to 3, do (Actions)
                • Loop - Actions
                  • (linear search goes here)
        • Else - Actions
TotalVoteTeam counts how many players have voted per team (I'm assuming there are only 2 teams).
If player in team, increase vote for that team, increase vote of race for that team, check if all players of team have selected.

I'll let someone else do a linear search function, I'm a bit busy at the moment. Probably a bunch of stuff I've gotten wrong.
 
Last edited:
Level 7
Joined
May 30, 2018
Messages
290
Can't use the editor right now so can't look at your map, would be best if you posted the relevant triggers.

What DSG is saying is the entire logic of the system.
Say, there are several options for races:
  • 0 = Human
  • 1 = Orc
  • 2 = Undead
  • 3 = Night Elf
The dialog button variable must refer to each race, say, RaceDialog[0] (a dialog button variable) says "Human" on the button.
In an initialization trigger, add the players to their respective player group team and also set the number of players of the team to an integer.

When a player selects a dialog button, use multiple If-Then-Else statements to find out which one was pressed: (Functions may not be exact, exact trigger may not work)
  • dialog race
  • Events
    • A dialog box button is pressed
  • Conditions
  • Actions
  • For (Integer loop) from 0 to 1, Do (Actions)
    • Loop - Actions
      • If (All Conditions Are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player is in Team[loop]) Equal to True
        • Then - Actions
          • // Increase number of team votes, find out which race was selected
          • Set TotalVoteTeam[loop] = (TotalVoteTeam[loop] + 1)
          • For (Integer racecheck) from 0 to 3, do (Actions)
            • Loop - Actions
              • If (All Conditions Are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Selected dialog button) Equal to RaceDialog[racecheck]
                • Then - Actions
                  • Set RaceVote[racecheck[loop]] = (RaceVote[racecheck[loop] + 1)
                • Else - Actions
          • // Now to check if all players of a team have selected, then figure out the most votes
          • If (All Conditions Are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TotalVoteTeam[loop] Equal to maxplayersteam[loop]
            • Then - Actions
              • For (Integer racecheck) from 0 to 3, do (Actions)
                • Loop - Actions
                  • (linear search goes here)
        • Else - Actions
TotalVoteTeam counts how many players have voted per team (I'm assuming there are only 2 teams).
If player in team, increase vote for that team, increase vote of race for that team, check if all players of team have selected.

I'll let someone else do a linear search function, I'm a bit busy at the moment. Probably a bunch of stuff I've gotten wrong.

Wow thank you, Iam really thankful that you try to help me. Awesome thanks :)
 
Level 28
Joined
Nov 12, 2007
Messages
2,340
You said in a post above that you aren't familiar with coding. In case the dialog box feels overwhelming for you as an starter, you can do something simpler instead. If you understand variables and basic GUI triggers, I suggest to make a voting system by making units walk into regions, as shown in this map at the very start of the video.

Once you get the hang of how these things work the dialog box voting will suddenly be much easier/intuitive to make. Good luck!
 
Level 7
Joined
May 30, 2018
Messages
290
You said in a post above that you aren't familiar with coding. In case the dialog box feels overwhelming for you as an starter, you can do something simpler instead. If you understand variables and basic GUI triggers, I suggest to make a voting system by making units walk into regions, as shown in this map at the very start of the video.

Once you get the hang of how these things work the dialog box voting will suddenly be much easier/intuitive to make. Good luck!

That sounds handy :eek:2 cool idea
So I can realise my idea fully via unit region movement? Making a vote system via moving sounds more viable, but I guess still needs some triggers to make the "moving to an area" count as votes for a certain thing :bored:

Would it be like when "wisp" walks into zone x add +1 to x? etc
All in all it seems more approachable for me though, so thank you kind sir :)
 
Last edited:
Level 28
Joined
Nov 12, 2007
Messages
2,340
So I can realise my idea fully via unit region movement? Making a vote system via moving sounds more viable, but I guess still needs some triggers to make the "moving to an area" count as votes for a certain thing :bored:
Yes, it'll need triggers =P
We store data like "vote count", "kill count" , etc. in variables. They're simple to use, as seen in this tutorial: Variables
And you're welcome!
 
Status
Not open for further replies.
Top