lzinga / TTTWeightedTraitorSelection

A Garrys Mod TTT addon that improves the traitor selection process
Other
11 stars 6 forks source link
garrysmod garrysmod-addon in terrorist town trouble trouble-in-terroristtown ttt

TTT Weighted Traitor Selection

Description

This addon allows players to become traitors fairly and allow the entire server to enjoy being traitor more often. With this addon the longer you go with out being a traitor the higher chance you have at becoming traitor, this also includes between map changes. This may sound like you could determine who the traitor is; however, the algorithm is non-deterministic making it practically impossible to deduce who the current traitors may be.

To read more on how this addon works you can read the How does this work? in the wiki.

Prerequisites

Depending on your preferred server saving method, you may need additional libraries installed on your server in order for this to properly function. If you are planning on using one of the two SQL methods, you will need Mysqloo (https://github.com/FredyH/MySQLOO). The installation process has instructions for all.

Installation

  1. Copy the folder tttweightsystem into your addons folder.
  2. Open the file lua/autorun/weightsystem_autorun.lua, at the top of the file there is a variable named WeightSystem.StorageType, set this to mysql, sqlite, or json based on your preferred saving method.
  3. Setup
    • SQL - Complete the installation of MySQLoo, and set up a database on your server.
    • JSON - No setup needed.
  4. Starting your Server
    • SQL - Run your server once and it will generate a database-template.txt in garrysmod/data/weightsystem, copy and rename it to database.txt and edit the settings inside with your database connection info.
    • JSON - Run your server and start a round of TTT (Set minplayers to 1), the round will auto-complete and you are all set.

Console Commands

ttt_traitor_chance_command: Sets the command players can use to see their traitor chance. If ttt_show_traitor_chance is set to 0 this will not work. (default !TC)

ttt_karma_increase_weight: If you want people to get a slight increase in weight (0-2 weight) for good karma you have to enable this command. (Default 0)

ttt_karma_increase_weight_threshold: This is the minimum amount of karma needed to get the increased weight buff. If they are below it they will just get regular weight. (default 950, based off of the default max karma in regular TTT)

ttt_show_traitor_chance: At the beginning of every round it sends out a message stating what your chance is to become traitor in the next round, or in the next map.

ttt_weight_system_fun_mode: Allows the players weight to be portrayed onto their model. (default 0) would not suggest this to be on 24/7 more of a fun mode to have on every now and then (0% chance is normal model, 100% chance is much fatter model, everything else is in between)

Image of fat person

Admin Console Commands

ttt_weightlogs: (just typed into console) This allows admins to view all players weight and their chance to become traitor. Admins are also able to see a count of how many times each player has been a specific role. In the weight menu you can also get the players SteamID and set their weight back to default or set the weight to what ever you want, giving the player a higher chance or lower chance at becoming traitor in next round.

To gives users permission to ttt_weightlogs they must be in an allowed group. Any group you want to have access must be added to the data/weightsystem/groupperms.txt file which gets generated on first load of the script.

Admin menu

Group Extra Weight

This feature was requested by a user, with it you have the ability to give certain groups extra weight. For example you can have donators get 1 or 2 extra weight every round to increase their chances of being traitor more often. Like the database.txt file a groupweight-template.txt will be generated with an example (like below) that you can use. You can also just create the file yourself and name it groupweight.txt and make sure it is in /data/weightsystem/ folder.

As of 1.2.0, you can now also use this system to cap a player's percentage of being a traitor when assigned to a group as well.

{ "1":{ "MaxWeight":10, "GroupName":"[GroupName]", "MinWeight":0, "cappedWeight":10 }, "2":{ "MaxWeight":10, "GroupName":"[AnotherGroupName]", "MinWeight":5, "cappedWeight": 100 } }

In the above example, the first entry would grant a random weight gain of 0 to 10 each round, but the player would never be allowed to gain weight allowing them to go above a 10% chance to be a traitor in a round. In the second example, the weight gain is 5 to 10 points, but the player can go up to 100% chance.

If you would like to not have bonus weight gain, set both MinWeight and MaxWeight to 0.

If you do not want to use this feature simply don't have a file named groupweight.txt in the /data/weightsystem/ folder with a proper configuration.

The settings for the groupweight.txt are as follows -

Group Weight Settings

MinWeight: The minimum amount of weight you would want added to users in the group.

MaxWeight: The maximum amount of weight you would want added to users in the group.

GroupName: The group you wish for a random amount between MinWeight and MaxWeight to be added.

cappedWeight: The highest percentage chance a player in the group is allowed to attain for traitor chance.

As a note, users who are in a group and receive extra weight will be told they are getting extra weight because they are in said group.

Change Log

Contributors

The following users have helped this project with bug fixes and feature additions.