Announcement

Collapse
No announcement yet.

Random Class Selection

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Random Class Selection

    So I am brand new to visual scripting and im trying to work on a project simular to GMods TTT where you randomly get selected classes (trader, detective or innocent). How would I re-create that? Right now I have made bools for each "class" but I don't even know if that is correct. All I need is when you play and a round start you will be randomly selected either trader, detective or innocent. I would also need a limit so there is only one trader, one detective and the rest innocent.

    #2
    Maybe a random integer in range from 0 to 2 (if there are 3 options) and then do a branch that asks if it was a 0? If false do another branch that checks if it was a 1 and so on.
    If 1 = true set class detective for example and do a boolean variable "class taken".
    And the next time it runs and it is a 1 again do a branch before setting class where you plug in "class taken" and if it is true, then run the random integer again.

    Comment


      #3
      Say you want 3 detectives, after you set class you can make an array variable that is also integer and add 1 each time detective is selected. And before "class taken" branch you check if this array is longer than 2. If true > set class taken to true.

      Comment


        #4
        Create an Enum of Classes containing Trader, Detective and Innocent.
        Get a count of the total number of participants in the game.
        Fill an array with one Trader, one Detective and the rest Innocent.
        Have the game pick a random number from 0 to total number of participants (the size of the array).
        Assign participant that value in the array.
        Remove that value from the array.
        Repeat until complete.

        Comment

        Working...
        X