From 9fe2ef7c991f3d125bae85b17ed4e695b98a02ef Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Mon, 29 Jan 2024 01:56:10 +0100 Subject: [PATCH] [MIRROR] Add: 2 Quirks Configs (#26206) * Add: 2 Quirks Configs (#81033) This PR adds two new config options for quirks: - *Flag* `DISABLE_QUIRK_POINTS` - When enabled, disables quirk points balancing. - When enabled, players can select positive quirks without first selecting negative ones. - When enabled, the quirk points balance visually hides itself on the Quirks page. - *Number* `MAX_POSITIVE_QUIRKS` - Limits the maximum quantity of positive quirks which players can select using the Character Preferences page. - I ported this from the old `MAX_QUIRKS` define. - When set to `0`, players won't be able to select any positive quirks, and they won't appear on the Quirks page. - When set to `-1`, players will be able to select any quantity of positive quirks. - When commented-out or undefined, the default is `6`. - When set to `0` or `-1`, the positive quirk balance visually hides itself on the Quirks page. There is some downstream repositories asking for the quirks system to be configurable. Additionally, I always find myself tweaking these values on my own private servers and I thought it would be nice to share my edits. Usually I was simply commenting-out sections of this code in order to get the same result, so it helps to have an official way to disable quirk points. :cl: A.C.M.O. config: Added two new config flags for quirks, DISABLE_QUIRK_POINTS and MAX_POSITIVE_QUIRKS. /:cl: * Oh come on --------- Co-authored-by: Dani Glore Co-authored-by: Useroth <37159550+Useroth@users.noreply.github.com> --- code/__DEFINES/mobs.dm | 4 -- .../configuration/entries/game_options.dm | 9 ++++ .../subsystem/processing/quirks.dm | 40 +++++++++------- code/modules/client/preferences.dm | 2 + .../client/preferences/middleware/quirks.dm | 8 +++- config/game_options.txt | 13 ++++- .../interfaces/PreferencesMenu/QuirksPage.tsx | 48 +++++++++++++------ .../tgui/interfaces/PreferencesMenu/data.ts | 1 + 8 files changed, 89 insertions(+), 36 deletions(-) diff --git a/code/__DEFINES/mobs.dm b/code/__DEFINES/mobs.dm index e4d7bc60502..8cdcc29bb47 100644 --- a/code/__DEFINES/mobs.dm +++ b/code/__DEFINES/mobs.dm @@ -487,10 +487,6 @@ #define FLASH_PROTECTION_FLASH 1 #define FLASH_PROTECTION_WELDER 2 -// Roundstart trait system - -#define MAX_QUIRKS 6 //The maximum amount of quirks one character can have at roundstart - // AI Toggles #define AI_CAMERA_LUMINOSITY 5 #define AI_VOX // Comment out if you don't want VOX to be enabled and have players download the voice sounds. diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index f377964700f..a5c88d97dc6 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -445,3 +445,12 @@ default = list("0" = 10, "1" = 10, "2" = 3, "2.5" = 1) key_mode = KEY_MODE_TEXT value_mode = VALUE_MODE_NUM + +// Configs for the Quirk system +/// Disables Quirk point balancing for the server and clients. +/datum/config_entry/flag/disable_quirk_points + +/// The maximum amount of positive quirks one character can have at roundstart. +/datum/config_entry/number/max_positive_quirks + default = 6 + min_val = -1 diff --git a/code/controllers/subsystem/processing/quirks.dm b/code/controllers/subsystem/processing/quirks.dm index 69c8cbd92dc..d4c785cc212 100644 --- a/code/controllers/subsystem/processing/quirks.dm +++ b/code/controllers/subsystem/processing/quirks.dm @@ -121,10 +121,15 @@ PROCESSING_SUBSYSTEM_DEF(quirks) var/bonus_quirks = max((length(user.quirks) + rand(-RANDOM_QUIRK_BONUS, RANDOM_QUIRK_BONUS)), MINIMUM_RANDOM_QUIRKS) var/added_quirk_count = 0 //How many we've added var/list/quirks_to_add = list() //Quirks we're adding - var/good_count = 0 //Maximum of 6 good perks + var/good_count = 0 var/score //What point score we're at ///Cached list of possible quirks var/list/possible_quirks = quirks.Copy() + + var/max_positive_quirks = CONFIG_GET(number/max_positive_quirks) + if(max_positive_quirks < 0) + max_positive_quirks = 6 + //Create a random list of stuff to start with while(bonus_quirks > added_quirk_count) var/quirk = pick(possible_quirks) //quirk is a string @@ -154,19 +159,20 @@ PROCESSING_SUBSYSTEM_DEF(quirks) quirks_to_add += quirk //And have benefits too - while(score < 0 && good_count <= MAX_QUIRKS) - if(!length(possible_quirks))//Lets not get stuck - break - var/quirk = pick(quirks) - if(quirk in GLOB.quirk_blacklist) //prevent blacklisted - possible_quirks -= quirk - continue - if(!quirk_points[quirk] > 0) //positive only - possible_quirks -= quirk - continue - good_count++ - score += quirk_points[quirk] - quirks_to_add += quirk + if(max_positive_quirks > 0) + while(score < 0 && good_count <= max_positive_quirks) + if(!length(possible_quirks))//Lets not get stuck + break + var/quirk = pick(quirks) + if(quirk in GLOB.quirk_blacklist) //prevent blacklisted + possible_quirks -= quirk + continue + if(!(quirk_points[quirk] > 0)) //positive only + possible_quirks -= quirk + continue + good_count++ + score += quirk_points[quirk] + quirks_to_add += quirk for(var/datum/quirk/quirk as anything in user.quirks) if(quirk.name in quirks_to_add) //Don't delete ones we keep @@ -184,6 +190,8 @@ PROCESSING_SUBSYSTEM_DEF(quirks) /datum/controller/subsystem/processing/quirks/proc/filter_invalid_quirks(list/quirks, list/augments) // SKYRAT EDIT - AUGMENTS+ var/list/new_quirks = list() var/list/positive_quirks = list() + var/points_enabled = !CONFIG_GET(flag/disable_quirk_points) + var/max_positive_quirks = CONFIG_GET(number/max_positive_quirks) var/balance = 0 var/list/all_quirks = get_quirks() @@ -220,7 +228,7 @@ PROCESSING_SUBSYSTEM_DEF(quirks) var/value = initial(quirk.value) if (value > 0) - if (positive_quirks.len == MAX_QUIRKS) + if (max_positive_quirks >= 0 && positive_quirks.len == max_positive_quirks) continue positive_quirks[quirk_name] = value @@ -228,7 +236,7 @@ PROCESSING_SUBSYSTEM_DEF(quirks) balance += value new_quirks += quirk_name - if (balance > 0) + if (points_enabled && balance > 0) var/balance_left_to_remove = balance for (var/positive_quirk in positive_quirks) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index ba610c347f3..f65964cd802 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -540,6 +540,8 @@ GLOBAL_LIST_EMPTY(preferences_datums) .++ /datum/preferences/proc/validate_quirks() + if(CONFIG_GET(flag/disable_quirk_points)) + return if(GetQuirkBalance() < 0) all_quirks = list() diff --git a/code/modules/client/preferences/middleware/quirks.dm b/code/modules/client/preferences/middleware/quirks.dm index c8a31c3f8a0..43b87c3a44e 100644 --- a/code/modules/client/preferences/middleware/quirks.dm +++ b/code/modules/client/preferences/middleware/quirks.dm @@ -31,8 +31,13 @@ var/list/quirks = SSquirks.get_quirks() + var/max_positive_quirks = CONFIG_GET(number/max_positive_quirks) + var/positive_quirks_disabled = max_positive_quirks == 0 for (var/quirk_name in quirks) var/datum/quirk/quirk = quirks[quirk_name] + if(positive_quirks_disabled && initial(quirk.value) > 0) + continue + var/datum/quirk_constant_data/constant_data = GLOB.all_quirk_constant_data[quirk] var/list/datum/preference/customization_options = constant_data?.get_customization_data() @@ -47,9 +52,10 @@ ) return list( - "max_positive_quirks" = MAX_QUIRKS, + "max_positive_quirks" = max_positive_quirks, "quirk_info" = quirk_info, "quirk_blacklist" = GLOB.quirk_string_blacklist, + "points_enabled" = !CONFIG_GET(flag/disable_quirk_points), ) /datum/preference_middleware/quirks/on_new_character(mob/user) diff --git a/config/game_options.txt b/config/game_options.txt index feb40f9f703..4441c54eb9c 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -580,4 +580,15 @@ NEUTRAL_STATION_TRAITS 2.5 1 NEGATIVE_STATION_TRAITS 0 8 NEGATIVE_STATION_TRAITS 1 4 NEGATIVE_STATION_TRAITS 2 2 -NEGATIVE_STATION_TRAITS 3 1 \ No newline at end of file +NEGATIVE_STATION_TRAITS 3 1 + +# Uncomment to disable Quirk point balancing for the server and clients. +# If enabled, players will be able to select positive quirks without first selecting negative quirks. +# If enabled, randomized Quirks will still use points internally, in order to maintain balance. +#DISABLE_QUIRK_POINTS + +# The maximum amount of positive quirks one character can have at roundstart. +# If set to -1, then players will be able to select any quantity of positive quirks. +# If set to 0, then players won't be able to select any positive quirks. +# If commented-out or undefined, the maximum default is 6. +MAX_POSITIVE_QUIRKS 6 diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/QuirksPage.tsx b/tgui/packages/tgui/interfaces/PreferencesMenu/QuirksPage.tsx index 5ebae22a2e9..8a8c81d3720 100644 --- a/tgui/packages/tgui/interfaces/PreferencesMenu/QuirksPage.tsx +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/QuirksPage.tsx @@ -308,8 +308,8 @@ export function QuirksPage(props) { return ( { - if (!quirks_data) { + render={(server_data) => { + if (!server_data) { // SKYRAT EDIT END return Loading quirks...; } @@ -318,7 +318,8 @@ export function QuirksPage(props) { max_positive_quirks: maxPositiveQuirks, quirk_blacklist: quirkBlacklist, quirk_info: quirkInfo, - } = quirks_data.quirks; // SKYRAT EDIT - Quirks balance refactor + points_enabled: pointsEnabled, + } = server_data.quirks; // SKYRAT EDIT - Quirks balance refactor const quirks = Object.entries(quirkInfo); quirks.sort(([_, quirkA], [__, quirkB]) => { @@ -338,9 +339,12 @@ export function QuirksPage(props) { const quirk = quirkInfo[quirkName]; if (quirk.value > 0) { - if (positiveQuirks >= maxPositiveQuirks) { + if ( + maxPositiveQuirks !== -1 && + positiveQuirks >= maxPositiveQuirks + ) { return "You can't have any more positive quirks!"; - } else if (balance + quirk.value > 0) { + } else if (pointsEnabled && balance + quirk.value > 0) { return 'You need a negative quirk to balance this out!'; } } @@ -376,7 +380,7 @@ export function QuirksPage(props) { const getReasonToNotRemove = (quirkName: string) => { const quirk = quirkInfo[quirkName]; - if (balance - quirk.value > 0) { + if (pointsEnabled && balance - quirk.value > 0) { return 'You need to remove a positive quirk first!'; } @@ -388,13 +392,21 @@ export function QuirksPage(props) { - Positive Quirks + {maxPositiveQuirks > 0 ? ( + Positive Quirks + ) : ( + + )} - - {positiveQuirks} / {maxPositiveQuirks} - + {maxPositiveQuirks > 0 ? ( + + {positiveQuirks} / {maxPositiveQuirks} + + ) : ( + + )} @@ -428,7 +440,7 @@ export function QuirksPage(props) { }, ]; })} - serverData={quirks_data} // SKYRAT EDIT CHANGE + serverData={server_data} // SKYRAT EDIT CHANGE randomBodyEnabled={randomBodyEnabled} /> @@ -442,11 +454,19 @@ export function QuirksPage(props) { - Quirk Balance + {pointsEnabled ? ( + Quirk Balance + ) : ( + 0 ? 3.4 : 0} /> + )} - {balance} + {pointsEnabled ? ( + {balance} + ) : ( + 0 ? 3.4 : 0} /> + )} @@ -484,7 +504,7 @@ export function QuirksPage(props) { }, ]; })} - serverData={quirks_data} // sKYRAT EDIT CHANGE + serverData={server_data} // sKYRAT EDIT CHANGE randomBodyEnabled={randomBodyEnabled} /> diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/data.ts b/tgui/packages/tgui/interfaces/PreferencesMenu/data.ts index d3570464af2..3d38daa520b 100644 --- a/tgui/packages/tgui/interfaces/PreferencesMenu/data.ts +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/data.ts @@ -137,6 +137,7 @@ export type QuirkInfo = { max_positive_quirks: number; quirk_info: Record; quirk_blacklist: string[][]; + points_enabled: boolean; }; export enum RandomSetting {