Garry's Mod

Garry's Mod

Not enough ratings
[TTT2] Prosecutor [ROLE]
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Server content
Addon Tags: Fun
File Size
Posted
Updated
390.804 KB
22 Nov, 2021 @ 6:50pm
1 Jun @ 12:05pm
6 Change Notes ( view )

Subscribe to download
[TTT2] Prosecutor [ROLE]

Description
Once the detective has determined the killer, it's your time to deliver justice!

You have to use TTT2 in order to use this role.



The Prosecutor is an innocent with an instant kill magnum! Their role is kept secret so they can stay in the shadows waiting for the time to deliver justice, or reveal their role to use their gun as an active threat. If they shoot a non-traitor or non-neutral team(configurable), they face punishment! (Instant death! Configurable)

They are unable to kill people via any other means besides their magnum, only able to reduce health to a certain amount(25 by default, configurable) before damage is ineffective. They also have a shop and start with 1 credit. They can only buy damage resistances and immunities to ensure they last long enough to deliver instant justice!

Plays best with:



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_prosec_enabled [0/1] (default: 1) # the percentage of players that are spawned as this role ttt_prosec_pct [0.0..1.0] (default: 0.15) # the limit of players that spawn as this role each round, this overwrites the percentage ttt_prosec_max [0..n] (default: 1) # the probability each round of this role being spawned at all ttt_prosec_random [0..100] (default: 15) # the amount of players needed for this role to spawn ttt_prosec_min_players: [0..n] (default: 5) # the amount of credits this role starts with ttt_prosec_credits_starting: [0..1] (default: 1)

Rolespecific Convars:

# What is the lowest the Prosecutor can lower someones health without their magnum? ttt_prosecutor_damage_hp_cutoff [0..100] (default: 25) # What method is used to determine if the Prosecutor shot a terrorist/evil person? # 0 - Traitors Team # 1 - All Non-Innocent Teams # 2 - Traitor Team + Neutral Team # 3 - None(Always Punish) ttt_prosecutor_detection_method [0-3] (default: 1) # What punishment should the Prosecutor go through if they shot an innocent? # 0 - Death # 1 - Half Max Health(+Resign) # 2 - Quarter Max Health(+Resign) # 3 - Resign Only # 4 - None ttt_prosecutor_punishment [0-4] (default: 0)

For modders/people familiar with lua

The mod adds two hooks, ShouldProsecutorBePunished(prosecutor, target) and DoProsecutorPunishment(prosecutor).

Returning false or a non-nil value on DoProsecutorPunishment cancels the standard prosecutor punishment.

And for role mods, you really shouldn't hook and change the return value for ShouldProsecutorBePunished unless you absolutely need to, and if you do, please respect the convar. (Unless you are a server owner specifically programming custom Prosecutor behavior, then ignore this warning, lol.)

TODOS:
  • Implement special code if Swapper role is installed so the prosecutor doesn't die.
  • Reload animation after the gun is fired to make it more clear it has a 5 second cooldown.

Credits
Murder, where this role idea came from. (I thought it'd interesting to port a sheriff role from an entirely different game into TTT2)

Person who created the silent role, which I used to create the thumbnail for this addon.

My friends who play tested this role.
2 Comments
MissingTextureMan101  [author] 30 May @ 8:08am 
There may be a bug where ttt_prosec_max isn't defaulting to 1, atleast in my test environment. I suggest making sure it is 1
Bacon The Protogen 22 Nov, 2021 @ 6:54pm 
First addon lets go!