HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Poll - Vote - Multiple Choices

01-30-2005, 01:15 PM#1
QuakeII_best
I'm working on a map with a few dialog boxes and I need help with the option selection:

Things I CAN do
- Create, Show and Run Dialog boxes and their buttons (with 2, 3, 4, or more buttons)
- Allow the players to choose between two options (On/Off, or Up/Down).

Things I CAN'T figure out:
- Allow the player to choose between three or more options (easy/normal/hard, North/East/South/West).

Problem? I would like an efficient way to DETECT that two numbers are tied and which of the options got the most votes. If you can post an example of multiple choice poll it would be great. I use WEU

Side Question: In WEU there's an action called "multiplayer - voting"... how does it work?
01-30-2005, 01:51 PM#2
logik
you could use this trick.

goto Advanced>>Game Interface.

and edit the following "orc" "human" "undead" and "night elf"

to your 4 choices and allow the players to chose what race they wish to go.

then run a trigger that see what race they are and go from there.

additionally using this technique will allow a random choice for people who cant make up their minds.
01-30-2005, 03:16 PM#3
QuakeII_best
Quote:
Originally Posted by logik
you could use this trick.

goto Advanced>>Game Interface.

and edit the following "orc" "human" "undead" and "night elf"

to your 4 choices and allow the players to chose what race they wish to go.

then run a trigger that see what race they are and go from there.

additionally using this technique will allow a random choice for people who cant make up their minds.
That is a very clever idea... I like it... the downside is that it only allows you to pick one option, and you can't have any explaination text (well you can modify the team name... but still).

The problem is that they have to vote about difference things... like dificulty and gold income.
01-30-2005, 03:35 PM#4
Kalvorod
Well, the only thing I can think of is this. Each time a person votes for Difficulty add 1 to Variable (Difficulty), Array (Button number clicked). So the array would then have 3 array slots (1,2,3) and each would get +1 for each click.

Then have a trigger fun after all the votes are in, or after a certain time, that checks like so.
IF: (Difficulty, 1) = (Difficulty, 2)
>>>Then: IF (Difficulty, 1) = (Difficulty, 3)
>>>SET: *normal*
>>>ELSE: if (Difficulty, 1) < (Difficulty, 3)
>>>>>>then: Set: Hard
>>>>>>else: set *normal*

IF (Difficulty, 1) > (Difficulty, 2)
>>>THEN: IF (Difficulty, 1)>(Difficulty 3)
>>>Set EASY
>>>ELSE: If (Difficulty, 1) = (Difficulty, 3)
>>>>>> Then: set *Normal*
>>>>>>ELse: set hard

If (Difficulty, 2) > (Difficulty, 1)
>>> then: if (Difficulty, 2) > (Difficulty, 3)
>>>>>>Then: set Normal
>>>>>>else: if (Difficulty, 2) = (Difficulty, 3)
>>>>>>>>>then set *normal*
>>>>>>>>>Else: set normal


That should be all the combinations, i think. It's a little drawn out with the if/then/else commands, but it works. I've programed things like this.

NOTE: when it says *normal* that means that it sets the level of difficulty to normal when there is a tie. If you prefer to have it go to easy, then exchange those with easy.
01-30-2005, 03:44 PM#5
QuakeII_best
That's a decent way to do it... thanks for the input.

The problem is when you have 4-5 choices O.O Just imagine how big that trigger will be.

I know I can figure out a way but I'm lazy (lol) and I know someone already did it. Just for the kicks I'll work on it and post it later
01-30-2005, 05:41 PM#6
QuakeII_best
There... it is done at least for what I want to do it (pick a random option from the top voted choices if they tie).

What do you need?
-6 Variables (actually it is less but with this it is easier to follow):
----1 Array with Number of Votes for each choice, the casted votes (int)
----1 Array that corresponds to the different choices. This works with any kind of arrays... locations, units, integers, etc... You must store the choices in this array before the votes take place.
----2 Temporary variables that will hold a value for a small period of time. One for the Number of Votes (int) and one for the Choices.
----1 Counter Variable to see how many choices tie for the first place
----1 Final Variable which will store the final value/final choice to be used in the map.

After votes are in... you need to arrange the number of votes and choices so that the largest is the space [1] from the array and the smallest is [n] (n=number of choices). How do you do it?

Lets start with the nested loop to arrange the variables:
Code:
For each (Integer B) from 1 to (n-1), do (Actions)
    Loop - Actions
        For each (Integer A) from 1 to (n-1), do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Poll_VotesNumbers[((Integer A) + 1)] Greater than Poll_VotesNumbers[(Integer A)]
                    Then - Actions
                        Set Poll_VotesNumbersTemp = Poll_VotesNumbers[(Integer A)]
                        Set Poll_VotesNumbers[(Integer A)] = Poll_VotesNumbers[((Integer A) + 1)]
                        Set Poll_VotesNumbers[((Integer A) + 1)] = Poll_VotesNumbersTemp
                        Set Poll_VotesChoicesTemp = Poll_VotesChoices[(Integer A)]
                        Set Poll_VotesChoices[(Integer A)] = ((Integer A) + 1)
                        Set Poll_VotesChoices[((Integer A) + 1)] = Poll_VotesChoicesTemp
                    Else - Actions
That is enough to order the different choices in the Poll_VotesChoices array.

You must check how many have tied for first place... which is easy because they have the same number of votes and the first position of Poll_VotesNumber. Once we know how many have tied (if any) we simply run a random number between the choices and store it in the final place (the one we will use in game). Spawn_Time is the "winning" option that I'll use in my map.

Code:
Set Poll_VotesTiedForFirst = 0
For each (Integer A) from 1 to n, do (Actions)
    Loop - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Poll_VotesNumbers[(Integer A)] Equal to Poll_VotesNumbers[1]
            Then - Actions
                Set Poll_VotesTiedForFirst = (Poll_VotesTiedForFirst + 1)
            Else - Actions
Set Spawn_Time = Poll_VotesChoices[(Random integer number between 1 and Poll_VotesTiedForFirst)]
I think all this should work (in theory it should) but I haven't tested it yet. I'll let you know if I find any mistake when I'm done with the triggering for my map. This might look useless but if you have several choices (like 5 different units to be reproduced or the player that should be the captain) this will work. Technically it can work for an infinite amount of options and ti doesn't matter which options got a tie. Also the 5 variables used for voting (not the 6th one) can be used over and over again as long as there's no more than one voting process going on at the same time. Otherwise you will need duplicates of these variables.