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

Vote Counting System

Status
Not open for further replies.
Level 4
Joined
Aug 14, 2007
Messages
66
Im trying to make a map where players select their race before a game starts as a way of voting. I want it to find the top 2 races that were voted for on each team but im not sure how to go about approaching this. All I could think of doing was creating a long complicated list of if x greater than y then but I decided to look here before doing that.

If anyone could give me some ideas that would be great.
 
Level 13
Joined
Sep 14, 2008
Messages
1,408
You will need to learn about dialogs (try looking for a tutorial in the tutorial section)

Then you create 2 int arrays. 1 for each team and an entry (in the array) for every race.

So whenever a player presses the button of a certain race you just set the integer in the array of the team +1. At the end you go through the array and check which race has the most votes.
 
Level 4
Joined
Aug 14, 2007
Messages
66
You dont understand.

This isnt a dialog button voting system. Before you start the game you are in the game menu where you can select your race and which team your'e on. The race each player selects is there vote.

Im asking about the last thing you talked about.

At the end you go through the array and check which race has the most votes.

Thats what im trying to figure out how to do.

All I have so far is 2 integer variable arrays; Votes_team1[] and Votes_team2[]

Votes_team1[1] = # of players that voted human
Votes_team1[2] = # of players that voted orc
Votes_team1[3] = # of players that voted undead
Votes_team1[4] = # of players that voted night elf

Votes_team2[1] = # of players that voted human
Votes_team2[2] = # of players that voted orc
Votes_team2[3] = # of players that voted undead
Votes_team2[4] = # of players that voted night elf

I cant find any GUI for finding the largest number of a table of numbers all I see is greater than's, equals', or lesser than's.

Am I doomed to making a super complicated system of:


  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Vote_Team1[1] Greater than or equal to Vote_Team1[2]
        • Vote_Team1[1] Greater than or equal to Vote_Team1[3]
        • Vote_Team1[1] Greater than or equal to Vote_Team1[4]
        • Vote_Team1[1] Greater than or equal to Vote_Team1[5]
      • Then - Actions
      • Else - Actions

and im sure that way would be buggy so I dont know where to start.
 
Level 13
Joined
Sep 14, 2008
Messages
1,408
Hmm it's easy. You go like this:

Create an integer variable set default to 1. (i call it TempInt)

Then go like this:

For integer 1 - 4 do actions:
if(voteTeamX[tempInt] < voteTeamX[integer a])
then: set tempInt = integer a

In the end the tempInt should contain the place in the array where the largest number is.
But it will not work if there are several votes with the same number
 
Level 3
Joined
Apr 20, 2010
Messages
46
  • Vote Count
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Player Group - Add (Player((Integer A))) to TeamOne
      • For each (Integer A) from 6 to 10, do (Actions)
        • Loop - Actions
          • Player Group - Add (Player((Integer A))) to TeamTwo
      • Set RaceValConst[0] = Human
      • Set RaceValConst[1] = Orc
      • Set RaceValConst[2] = Undead
      • Set RaceValConst[3] = Night Elf
      • Set TeamOneVotes[0] = 0
      • Set TeamOneVotes[1] = 0
      • Set TeamOneVotes[2] = 0
      • Set TeamOneVotes[3] = 0
      • Set TeamTwoVotes[0] = 0
      • Set TeamTwoVotes[1] = 0
      • Set TeamTwoVotes[2] = 0
      • Set TeamTwoVotes[3] = 0
      • Player Group - Pick every player in TeamOne and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 0 to 3, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Race of (Picked player)) Equal to RaceValConst[(Integer A)]
                • Then - Actions
                  • Set TeamOneVotes[(Integer A)] = (TeamOneVotes[(Integer A)] + 1)
                • Else - Actions
                  • Do nothing
      • Player Group - Pick every player in TeamTwo and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 0 to 3, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Race of (Picked player)) Equal to RaceValConst[(Integer A)]
                • Then - Actions
                  • Set TeamTwoVotes[(Integer A)] = (TeamTwoVotes[(Integer A)] + 1)
                • Else - Actions
                  • Do nothing
This will, at Initialization, count the number of players of each race except Random (which I don't know the specifics of but it may affect the trigger depending on when this trigger is executed no doubt).

I haven't tried running this, and doing it at Initialization may have repercussions, but the main thing is the loops following the resetting of the vars.


As for comparing the vote, its a simple loop, as a previous post has stated.
 
Last edited:
Level 4
Joined
Aug 14, 2007
Messages
66
Yeah Levadam thats pretty much what I had. I took DarkAngelAzazel's advice for the loop and its working out although I havent had the chance to do more extensive testing. Let me know if you see any possible problems or a "cleaner" more efficient way to do it.


  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Cast Player Votes --------
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) slot status) Equal to Is playing
              • (Race of (Player((Integer A)))) Equal to Human
            • Then - Actions
              • Unit - Replace PlayerSelectionPM[(Integer A)] with a Altar of Kings (Player Selection System; Human) using The new unit's default life and mana
              • Set Vote_Team1[1] = (Vote_Team1[1] + 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Player((Integer A))) slot status) Equal to Is playing
                  • (Race of (Player((Integer A)))) Equal to Orc
                • Then - Actions
                  • Unit - Replace PlayerSelectionPM[(Integer A)] with a Altar of Storms (Player Selection System; Orc) using The new unit's default life and mana
                  • Set Vote_Team1[2] = (Vote_Team1[2] + 1)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Player((Integer A))) slot status) Equal to Is playing
                      • (Race of (Player((Integer A)))) Equal to Undead
                    • Then - Actions
                      • Unit - Replace PlayerSelectionPM[(Integer A)] with a Altar of Darkness (Player Selection System; Undead) using The new unit's default life and mana
                      • Set Vote_Team1[3] = (Vote_Team1[3] + 1)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Player((Integer A))) slot status) Equal to Is playing
                          • (Race of (Player((Integer A)))) Equal to Night Elf
                        • Then - Actions
                          • Unit - Replace PlayerSelectionPM[(Integer A)] with a Altar of Elders (Player Selection System; Night Elf) using The new unit's default life and mana
                          • Set Vote_Team1[4] = (Vote_Team1[4] + 1)
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • ((Player((Integer A))) slot status) Equal to Is playing
                              • (Race of (Player((Integer A)))) Equal to Demon
                            • Then - Actions
                              • Unit - Replace PlayerSelectionPM[(Integer A)] with a Altar of Depths (Player Selection System; Random) using The new unit's default life and mana
                              • Set Vote_Team1[0] = (Vote_Team1[0] + 1)
                            • Else - Actions
                              • Unit - Remove PlayerSelectionPM[(Integer A)] from the game
      • For each (Integer B) from 5 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer B))) slot status) Equal to Is playing
              • (Race of (Player((Integer B)))) Equal to Human
            • Then - Actions
              • Unit - Replace PlayerSelectionPM[(Integer B)] with a Altar of Kings (Player Selection System; Human) using The new unit's default life and mana
              • Set Vote_Team2[1] = (Vote_Team2[1] + 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Player((Integer B))) slot status) Equal to Is playing
                  • (Race of (Player((Integer B)))) Equal to Orc
                • Then - Actions
                  • Unit - Replace PlayerSelectionPM[(Integer B)] with a Altar of Storms (Player Selection System; Orc) using The new unit's default life and mana
                  • Set Vote_Team2[2] = (Vote_Team2[2] + 1)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Player((Integer B))) slot status) Equal to Is playing
                      • (Race of (Player((Integer B)))) Equal to Undead
                    • Then - Actions
                      • Unit - Replace PlayerSelectionPM[(Integer B)] with a Altar of Darkness (Player Selection System; Undead) using The new unit's default life and mana
                      • Set Vote_Team2[3] = (Vote_Team2[3] + 1)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Player((Integer B))) slot status) Equal to Is playing
                          • (Race of (Player((Integer B)))) Equal to Night Elf
                        • Then - Actions
                          • Unit - Replace PlayerSelectionPM[(Integer B)] with a Altar of Elders (Player Selection System; Night Elf) using The new unit's default life and mana
                          • Set Vote_Team2[4] = (Vote_Team2[4] + 1)
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • ((Player((Integer B))) slot status) Equal to Is playing
                              • (Race of (Player((Integer B)))) Equal to Demon
                            • Then - Actions
                              • Unit - Replace PlayerSelectionPM[(Integer B)] with a Altar of Depths (Player Selection System; Random) using The new unit's default life and mana
                              • Set Vote_Team2[0] = (Vote_Team2[0] + 1)
                            • Else - Actions
                              • Unit - Remove PlayerSelectionPM[(Integer B)] from the game
      • -------- ---------------------------- --------
      • Trigger - Run vote counter <gen> (checking conditions)
  • vote counter
    • Events
    • Conditions
    • Actions
      • For each (Integer votecounter) from 1 to 4, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Vote_Team1[votecounter] Greater than or equal to largestvote
            • Then - Actions
              • Set largestvote = votecounter
            • Else - Actions
              • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Vote_Team1[largestvote] Equal to 0
        • Then - Actions
          • Set Races_Team1[1] = Race[(Random integer number between 1 and 4)]
        • Else - Actions
          • Set Races_Team1[1] = Race[largestvote]
      • Set Vote_Team1[largestvote] = 0
      • Set largestvote = 0
      • For each (Integer votecounter) from 1 to 4, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Vote_Team1[votecounter] Greater than largestvote
            • Then - Actions
              • Set largestvote = votecounter
            • Else - Actions
              • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Vote_Team1[largestvote] Equal to 0
        • Then - Actions
          • Set Races_Team1[2] = Races_Team1[1]
        • Else - Actions
          • Set Races_Team1[2] = Race[largestvote]
      • Set largestvote = 0
      • For each (Integer votecounter) from 1 to 4, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Vote_Team2[votecounter] Greater than or equal to largestvote
            • Then - Actions
              • Set largestvote = votecounter
            • Else - Actions
              • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Vote_Team2[largestvote] Equal to 0
        • Then - Actions
          • Set Races_Team2[1] = Race[(Random integer number between 1 and 4)]
        • Else - Actions
          • Set Races_Team2[1] = Race[largestvote]
      • Set Vote_Team2[largestvote] = 0
      • Set largestvote = 0
      • For each (Integer votecounter) from 1 to 4, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Vote_Team2[votecounter] Greater than largestvote
            • Then - Actions
              • Set largestvote = votecounter
            • Else - Actions
              • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Vote_Team2[largestvote] Equal to 0
        • Then - Actions
          • Set Races_Team2[2] = Races_Team2[1]
        • Else - Actions
          • Set Races_Team2[2] = Race[largestvote]
      • Trigger - Run Team Setup <gen> (checking conditions)
I only threw in the Demon Race checker during Init because it was an option. Just in case I might be able to tweek that later on.
 
Status
Not open for further replies.
Top