• 🏆 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!

Voting System for Terrain

Level 7
Joined
Feb 23, 2020
Messages
253
Hello, im making a voting system for different terrains the map will be played in.

Everything is working (i think, have not tested with multiple people yet). But the MapSelectionBoolean is messing with me a bit.

No matter what button is pressed, it will always choose every single one. Am i wrong doing this inside of the loop?

  • Map Selection Inst
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- --------
      • Set VariableSet MapSelectionBoolean[1] = False
      • Set VariableSet MapSelectionBoolean[2] = False
      • Set VariableSet MapSelectionBoolean[3] = False
      • Set VariableSet MapSelectionBoolean[4] = False
      • Set VariableSet MapSelectionBoolean[5] = False
      • Set VariableSet MapSelectionBoolean[6] = False
      • -------- --------
      • Set VariableSet MapTotalAreas = 6
      • -------- --------
      • Set VariableSet MapSelection_Name[1] = |cff008000Forest|r
      • Set VariableSet MapSelection_Name[2] = |cff00ffffOcean|r
      • Set VariableSet MapSelection_Name[3] = |cff8b4513Mountain|r
      • Set VariableSet MapSelection_Name[4] = |cfffffacdSavannah|r
      • Set VariableSet MapSelection_Name[5] = |cffc8c8ffWinter|r
      • Set VariableSet MapSelection_Name[6] = |cff800000Hell|r|cff800000Hell|r
      • -------- --------
      • Set VariableSet TotalPlayers = (All players matching ((((Matching player) slot status) Equal to Is playing) and (((Matching player) Not equal to Player 12 (Brown)) and ((Matching player) Not equal to Player 11 (Dark Green)))).)
      • -------- --------
  • Map Selection Dialog
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • -------- --------
      • -------- Will be used later --------
      • 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
              • (Player number of (Picked player)) Less than or equal to 4
              • ((Picked player) controller) Equal to User
              • ((Picked player) slot status) Equal to Is playing
            • Then - Actions
              • Player Group - Add (Picked player) to Team1
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Player number of (Picked player)) Greater than 4
                  • (Player number of (Picked player)) Less than or equal to 8
                  • ((Picked player) controller) Equal to User
                  • ((Picked player) slot status) Equal to Is playing
                • Then - Actions
                  • Player Group - Add (Picked player) to Team2
                • Else - Actions
      • -------- --------
      • Set VariableSet MapSelection_TotalPlayers = (Number of players in TotalPlayers)
      • Dialog - Clear MapSelection
      • Dialog - Change the title of MapSelection to Vote terrain
      • -------- --------
      • Dialog - Create a dialog button for MapSelection labelled |cff008000Forest|r
      • Set VariableSet MapSelctionButton[1] = (Last created dialog Button)
      • Set VariableSet MapVotingInteger[1] = 1
      • -------- --------
      • Dialog - Create a dialog button for MapSelection labelled |cff00ffffOcean|r
      • Set VariableSet MapSelctionButton[2] = (Last created dialog Button)
      • Set VariableSet MapVotingInteger[2] = 1
      • -------- --------
      • Dialog - Create a dialog button for MapSelection labelled |cff8b4513Mountain|r
      • Set VariableSet MapSelctionButton[3] = (Last created dialog Button)
      • Set VariableSet MapVotingInteger[3] = 1
      • -------- --------
      • Dialog - Create a dialog button for MapSelection labelled |cfffffacdSavannah|r
      • Set VariableSet MapSelctionButton[4] = (Last created dialog Button)
      • Set VariableSet MapVotingInteger[4] = 1
      • -------- --------
      • Dialog - Create a dialog button for MapSelection labelled |cffc8c8ffWinter|r
      • Set VariableSet MapSelctionButton[5] = (Last created dialog Button)
      • Set VariableSet MapVotingInteger[5] = 1
      • -------- --------
      • Dialog - Create a dialog button for MapSelection labelled |cff800000Hell|r
      • Set VariableSet MapSelctionButton[6] = (Last created dialog Button)
      • Set VariableSet MapVotingInteger[6] = 1
      • -------- --------
      • Player Group - Pick every player in TotalPlayers and do (Actions)
        • Loop - Actions
          • Dialog - Show MapSelection for (Picked player)
          • Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Visibility across Right Side Vision <gen>
          • Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Visibility across Left Side Vision <gen>
  • Map Selection Button
    • Events
      • Dialog - A dialog button is clicked for MapSelection
    • Conditions
    • Actions
      • -------- --------
      • Set VariableSet MapSelection_PlayerClicked = (MapSelection_PlayerClicked + 1)
      • Dialog - Hide MapSelection for (Triggering player)
      • -------- --------
      • For each (Integer MapSelection_Loop) from 1 to MapTotalAreas, do (Actions)
        • Loop - Actions
          • -------- --------
          • Set VariableSet MapVotingInteger[MapSelection_Loop] = (MapVotingInteger[MapSelection_Loop] + 1)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to MapSelctionButton[MapSelection_Loop]
            • Then - Actions
              • -------- --------
              • Player Group - Pick every player in (All players) and do (Actions)
                • Loop - Actions
                  • Game - Display to (Player group((Picked player))) for 30.00 seconds the text: ((Color_Text[(Player number of (Triggering player))] + ((Name of (Triggering player)) + |r)) + ( voted for + MapSelection_Name[MapSelection_Loop]))
              • -------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • MapSelection_PlayerClicked Equal to MapSelection_TotalPlayers
                • Then - Actions
                  • -------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • MapSelectionBoolean[MapSelection_Loop] Equal to True
                    • Then - Actions
                      • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Heavy)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • MapSelectionBoolean[MapSelection_Loop] Equal to True
                        • Then - Actions
                          • Environment - Create at (Playable map area) the weather effect Dungeon Green Fog (Light)
                        • Else - Actions
                  • -------- --------
                • Else - Actions
            • Else - Actions
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
I edited all three triggers and made fixes wherever I could:
  • Map Selection Init
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Set VariableSet MapTotalAreas = 6
      • -------- --------
      • Set VariableSet MapSelection_Name[1] = |cff008000Forest|r
      • Set VariableSet MapSelection_Name[2] = |cff00ffffOcean|r
      • Set VariableSet MapSelection_Name[3] = |cff8b4513Mountain|r
      • Set VariableSet MapSelection_Name[4] = |cfffffacdSavannah|r
      • Set VariableSet MapSelection_Name[5] = |cffc8c8ffWinter|r
      • Set VariableSet MapSelection_Name[6] = |cff800000Hell|r|cff800000Hell|r
      • -------- --------
      • Set VariableSet TotalPlayers = (All players matching ((((Matching player) slot status) Equal to Is playing) and (((Matching player) Not equal to Player 12 (Brown)) and ((Matching player) Not equal to Player 11 (Dark Green)))).)
  • Map Selection Dialog
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • -------- Will be used later --------
      • 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
              • (Player number of (Picked player)) Less than or equal to 4
              • ((Picked player) controller) Equal to User
              • ((Picked player) slot status) Equal to Is playing
            • Then - Actions
              • Player Group - Add (Picked player) to Team1
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Player number of (Picked player)) Greater than 4
                  • (Player number of (Picked player)) Less than or equal to 8
                  • ((Picked player) controller) Equal to User
                  • ((Picked player) slot status) Equal to Is playing
                • Then - Actions
                  • Player Group - Add (Picked player) to Team2
                • Else - Actions
      • -------- --------
      • Set VariableSet MapSelection_TotalPlayers = (Number of players in TotalPlayers)
      • Dialog - Clear MapSelection
      • Dialog - Change the title of MapSelection to Vote terrain
      • -------- --------
      • Dialog - Create a dialog button for MapSelection labelled |cff008000Forest|r
      • Set VariableSet MapSelctionButton[1] = (Last created dialog Button)
      • -------- --------
      • Dialog - Create a dialog button for MapSelection labelled |cff00ffffOcean|r
      • Set VariableSet MapSelctionButton[2] = (Last created dialog Button)
      • -------- --------
      • Dialog - Create a dialog button for MapSelection labelled |cff8b4513Mountain|r
      • Set VariableSet MapSelctionButton[3] = (Last created dialog Button)
      • -------- --------
      • Dialog - Create a dialog button for MapSelection labelled |cfffffacdSavannah|r
      • Set VariableSet MapSelctionButton[4] = (Last created dialog Button)
      • -------- --------
      • Dialog - Create a dialog button for MapSelection labelled |cffc8c8ffWinter|r
      • Set VariableSet MapSelctionButton[5] = (Last created dialog Button)
      • -------- --------
      • Dialog - Create a dialog button for MapSelection labelled |cff800000Hell|r
      • Set VariableSet MapSelctionButton[6] = (Last created dialog Button)
      • -------- --------
      • Player Group - Pick every player in TotalPlayers and do (Actions)
        • Loop - Actions
          • Dialog - Show MapSelection for (Picked player)
          • Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Visibility across Right Side Vision <gen>
          • Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Visibility across Left Side Vision <gen>
  • Map Selection Button
    • Events
      • Dialog - A dialog button is clicked for MapSelection
    • Conditions
    • Actions
      • Set VariableSet MapSelection_PlayerClicked = (MapSelection_PlayerClicked + 1)
      • Dialog - Hide MapSelection for (Triggering player)
      • -------- --------
      • For each (Integer MapSelection_Loop) from 1 to MapTotalAreas, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to MapSelctionButton[MapSelection_Loop]
            • Then - Actions
              • -------- --------
              • Set VariableSet MapVotingInteger[MapSelection_Loop] = (MapVotingInteger[MapSelection_Loop] + 1)
              • -------- --------
              • Game - Display to (All players) for 30.00 seconds the text: ((Color_Text[(Player number of (Triggering player))] + ((Name of (Triggering player)) + |r)) + ( voted for + MapSelection_Name[MapSelection_Loop]))
            • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MapSelection_PlayerClicked Greater than or equal to MapSelection_TotalPlayers
        • Then - Actions
          • // Here's where you tally the votes and pick the Terrain with the most votes (or pick one at random if there's a tie) //
        • Else - Actions
I don't see you setting MapSelectionBoolean to True anywhere in these triggers. Are they meant to be synced up with the type of Terrain that won? This can be done after you've tallied the votes and chosen a winner but it doesn't even look necessary to me.

If you need help tallying the votes, here's a very basic design:
  • Actions
    • Set VariableSet MapSelection_HighestVote = 0
    • For each (Integer MapSelection_Loop) from 1 to 6, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • MapVotingInteger[MapSelection_Loop] Greater than MapSelection_HighestVote
          • Then - Actions
            • Set VariableSet MapSelection_HighestVote = MapVotingInteger[MapSelection_Loop]
            • Set VariableSet MapSelection_Winner = MapSelection_Loop
          • Else - Actions
    • -------- --------
    • -------- MapSelection_Winner is now equal to the map with the highest votes (or tied for highest): --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • MapSelection_Winner Equal to 1
      • Then - Actions
        • -------- Do something... --------
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • MapSelection_Winner Equal to 2
          • Then - Actions
            • -------- Do something... --------
          • Else - Actions
            • -------- Etc... --------
Also, don't forget to Remove leaving players from the TotalPlayers player group and adjust MapSelection_TotalPlayers in response. You should also have a Timer as a failsafe that forces a Terrain to be chosen after X seconds if the users go afk or something.
 
Last edited:
Level 7
Joined
Feb 23, 2020
Messages
253
Alright i see, thank you very much! Are you using those actions in the same trigger, or a new one?
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Alright i see, thank you very much! Are you using those actions in the same trigger, or a new one?
Those Actions are for tallying the votes when voting is finished. So use them in the same trigger where I wrote this:
  • // Here's where you tally the votes and pick the Terrain with the most votes (or pick one at random if there's a tie) //
  • ...
Or put those Actions in a new trigger and Run it. This could serve useful in the future for your "out of time" Timer since it could Run this trigger as well:
  • // Here's where you tally the votes and pick the Terrain with the most votes (or pick one at random if there's a tie) //
  • Trigger - Run Choose Map Winner (ignoring conditions)
 
Last edited:
Level 7
Joined
Feb 23, 2020
Messages
253
Those Actions are for tallying the votes when voting is finished. So use them in the same trigger where I wrote this:
  • // Here's where you tally the votes and pick the Terrain with the most votes (or pick one at random if there's a tie) //
  • ...
Or put those Actions in a new trigger and Run it. This could serve useful in the future for your "out of time" Timer since it could Run this trigger as well:
  • // Here's where you tally the votes and pick the Terrain with the most votes (or pick one at random if there's a tie) //
  • Trigger - Run Choose Map Winner (ignoring conditions)

Oh i missed that part. It all works fine, but i have on question.

I tried this and put a debug text

  • Game - Display to (All players) the text: (String((Number of players in TotalPlayers)))
And it counts up too 2 players, so when i vote, i still have to wait for the countdown timer.
 
Level 7
Joined
Feb 23, 2020
Messages
253
It counts to 2 because there are 2 players inside of the Player Group. Remove the unwanted Player or adjust the Integer comparison to make it work how you want.
How do i know what player that is since its a computer, and all computers are already removed?

I did fix the issue. Just of curiosity.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
How do i know what player that is since its a computer, and all computers are already removed?

I did fix the issue. Just of curiosity.
  • Set VariableSet TotalPlayers = (All players matching ((((Matching player) slot status) Equal to Is playing) and (((Matching player) Not equal to Player 12 (Brown)) and ((Matching player) Not equal to Player 11 (Dark Green)))).)
It's a Player that "Is playing" and isn't Player 11/12.

But if you're still unsure, you can use the Pick Every Player action to loop through all of the Players in the Player Group. From there, you can do one of many things to determine who that Player is. Create a Footman for them, Display their name in a text message, etc...
 
Top