Garry's Mod

Garry's Mod

Not enough ratings
[TTT2] Undecided [ROLE]
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Server content
Addon Tags: Fun, Roleplay
File Size
Posted
Updated
1.085 MB
7 Sep, 2021 @ 12:32pm
17 Jan @ 12:58am
12 Change Notes ( view )

Subscribe to download
[TTT2] Undecided [ROLE]

In 1 collection by blackmagicfine
TTT2 Mods For BMF's Server
95 items
Description
What do you mean that you haven't decided what your role is? You can't just sit on the fence when terrorism is involved!

You have to use TTT2 in order to use this role. Additionally using ULX for TTT2 is recommended. Report bugs concerning this role here[github.com] and submit new role ideas here[github.com]. A list of all currently available roles can be found here.

Discord: https://discord.gg/Npcbb4W
Source: https://github.com/AaronMcKenney/ttt2-role_undec




The Undecided is a Neutral role who is given 1 minute to "vote" for one of 3 randomly selected roles from a "ballot". They become the role that they vote for (they also get an "I VOTED" sticker, which offers no in-game benefit). If they do not vote within the allotted time, they become a Jester (or an Innocent if the Jester isn't installed) instead. The server owner can configure it so some other bad thing happens instead of becoming a Jester (ex. DEATH).

There is additionally an option to make the ballots re-occurring, such that the player will be constantly changing roles throughout the game. This is disabled by default.

How the Ballot is Generated
The ballot is generated by first separating the roles that the server has installed (and are valid for the current round) into 5 groups:
1. Innocents (excluding detectives)
2. Detectives
3. Traitors
4. Evil (roles with unique teams. Ex. Serial Killer, Jester, Infected, Marker, Doppelganger)
5. Neutral (Anything that doesn't fit the above 4 groups. Ex. Amnesiac, Drunk, Cursed, Medic)

Roles will only be present in the above groups if they could have been selected as starting roles.
Example 1: The Sidekick, Thrall, and Graverobber roles won't be present as they are secondary roles which only appear due to in-game events.
Example 2: The minimum number of players is considered. If 9 players are required for a player to be given the Medic role, but only 6 players are present on the server, then the Medic will not appear on the ballot.

Each group has a ConVar that determines its weight, which is used for random selection. The five weights do not have to add up to 100, but it will save you some headaches if they do. For example, if they add up to 100 and ttt2_undecided_weight_innocent is 35, then there is a 35% chance that an Innocent role will be chosen as a selectable option. These weights apply to each entry of the ballot, meaning that that if the ballot has 3 entries then it is possible for each entry to be an Innocent role.

A role cannot appear on the ballot multiple times.

This role offers support for the following roles that hide their true identity from the player: Shinigami, Wrath, and Lycanthrope. If the server has these roles installed, then they (along with the base Innocent role) will appear as "Innocent*". The player who selects "Innocent*" will probably become a special Innocent, but they can't know for certain. "Innocent*" can appear on the ballot multiple times, but each entry will correspond to a different role that has been obscured.

It is possible for the Undecided role to appear on the ballot. If the Undecided votes for their own role the ballot will be re-rolled and the timer reset.

Naturally, this role works best on servers that have numerous roles installed, but a miminalist server is supported. The ballot generation logic is semi-intelligent, and will adjust itself if one or more of the 5 groups is empty.



Convars are variables that are introduced to allow server owners to customize the gameplay without changing the code. There are always a handful of convars automatically created by TTT2, that define the spawn parameters of this role and are found in ULX. Additionally there might be some role specific convars, which have to be set in the server config file.

Normal Role Convars (also found in ULX):
# enable or disable this role ttt_undecided_enabled [0/1] (default: 1) # the percentage of players that are spawned as this role ttt_undecided_pct [0.0..1.0] (default: 0.13) # the limit of players that spawn as this role each round, this overwrites the percentage ttt_undecided_max [0..n] (default: 1) # the probability each round of this role being spawned at all ttt_undecided_random [0..100] (default: 30) # the amount of players needed for this role to spawn ttt_undecided_min_players: [0..n] (default: 6)

Rolespecific Convars:
# How many possible roles can the Undecided choose between? ttt2_undecided_num_choices [2..n] (default: 3) # How many seconds does the Undecided have to choose their role? ttt2_undecided_ballot_timer [0..n] (default: 60) # How many seconds after the voting period ends does the Undecided receive another ballot (<=0 to only receive one ballot per game)? ttt2_undecided_time_between_ballots [0..n] (default: 0) # If the Undecided fails to vote, what should happen to them? ttt2_undecided_no_vote_punishment_mode [0..3] (default: 3) # 0: D E A T H P E N A L T Y # 1: They get randomly assigned a role from the list of choices that they had. # 2: They become a regular old Innocent # 3: They become a Jester # What is the weight of the possibiilty for an innocent subrole (including base innocent) from being presented to the Undecided? ttt2_undecided_weight_innocent [0..n] (default: 35) # What is the weight of the possibiilty for a detective subrole (including base detective) from being presented to the Undecided? ttt2_undecided_weight_detective [0..n] (default: 5) # What is the weight of the possibiilty for a traitor subrole (including base traitor) from being presented to the Undecided? ttt2_undecided_weight_traitor [0..n] (default: 15) # What is the weight of the possibiilty for a role that has a team which isn't INNOCENT, TRAITOR, or NONE from being presented to the Undecided? ttt2_undecided_weight_evil [0..n] (default: 25) # What is the weight of the possibiilty for a role that has no discernable team (ex. Amnesiac, Drunk) from being presented to the Undecided? ttt2_undecided_weight_neutral [0..n] (default: 20) # Can the Undecided vote to be an Undecided? ttt2_undecided_can_vote_for_self [0/1] (default: 1) # For a role to appear on the ballot, it must be: ttt2_undecided_role_enable_mode [0..2] (default: 0) # 0: Enabled on the server # 1: Disabled on the server (The ballot will consist of roles no one else can have) # 2: Either enabled or disabled on the server

--
Credits:
BlackMagicFine: creator of this role addon
Smuggles: designer of the role icon
Mineotopia: designer of the role thumbnail
22 Comments
mexikoedi 17 Jan @ 4:44am 
@blackmagicfine
All right, thanks for the explanation and the quick fix.
blackmagicfine  [author] 17 Jan @ 12:59am 
@mexikoedi: I took a cursory glance. Presumably you are using the F1 menu to update the ttt2_undecided_ballot_timer ConVar from 60 to 20? There's a few things going on here.

Firstly, and most importantly, it seems that setting the ConVar via the F1 menu doesn't properly replicate and propagate the value to the client. So you still see the timer as 60 even if the server is interally using 20. Not entirely sure why that happened, I feel like this issue may be present on many roles. A quick workaround would be to update the client's ConVar manually via the terminal. Sometimes moving to a new map will also work. For now I have altered the logic to make it so that the client is fed the timer from the server directly, which seems to fix the issue.

Secondly, it seems like you've uncovered a bug, wherein I did not explicitly check that the client was responding to a ballot past its due date. I have fixed that issue.
mexikoedi 13 Jan @ 12:32pm 
I tried this role but I encountered an issue.
If I set the timer for example to 20 seconds and do nothing I will get the penalty but the popup with the choices is still there and I can pick a role there (which I also get).
There seems to be an issue with the timer (the timer at the popup is always 60 seconds).
blackmagicfine  [author] 4 Jan @ 10:59pm 
@we are number one: When you get this role, the left hand side will show a list of potential roles. If you hold the TAB key, you can move your cursor over to the role that you want and click it. This assumes that you use the same control scheme that I use, which I believe is the default PC settings.
we are number one 1 Jan @ 10:22pm 
How do you actually choose roles I cant figure it out
blackmagicfine  [author] 1 Jan, 2024 @ 2:01am 
@pawel99uk: Done. You can set "ttt2_undecided_role_enable_mode" to 1 so that it only picks disabled roles, or 2 so that it can any role regardless of whether it was enabled or disabled. I also took the liberty of extending ttt2_undecided_can_vote_for_self such that it overrides the added ConVar (in short: if this ConVar is true, then the Undecided will be able to vote for themselves even if ttt2_undecided_role_enable_mode is set to 1, and subsequently get a new ballot)
pawel99uk 30 Dec, 2023 @ 7:00am 
can you add a new convar for the role to allow it to only picked disabled roles or enabled and disabled roles on a server
Cpt.Haxray 29 Sep, 2021 @ 1:07pm 
Cheers. If its a a bad addon that's gonna be a pain to sort out, but thanks for the change regardless.
blackmagicfine  [author] 29 Sep, 2021 @ 12:50pm 
@Cpt.Haxray: ROLE_NONE showed up? I have no idea how that could possibly happen. You're certain that this player actually became the None role, not only according to the client but the server as well?

If you were to set num_choices to 99 on a server filled with many bots, the ballot will list out all roles that could possibly be chosen. Random chance won't play a factor here, as num_choices will exceed the amount of roles that you have installed on the server, and the ballot will end up just having all of the valid roles for the server's player count.

I have never seen ROLE_NONE appear on such a list, because I have a check early on that explicitly prevents its appearance. It is possible that your server has a bad addon or data corruption.

I went ahead and added an additional safety check for the Undecided. If a client somehow manages to vote for None or Sidekick or whatever invalid role, they'll now get an error message in the top right and the ballot will be regenerated.
Cpt.Haxray 28 Sep, 2021 @ 11:37pm 
Also, we increased the timer of the between Ballots to 180 seconds.