Skip to content

Commit

Permalink
[MIRROR] Add: 2 Quirks Configs (#1779)
Browse files Browse the repository at this point in the history
* [MIRROR] Add: 2 Quirks Configs (#549)

* Add: 2 Quirks Configs

* Conflicts

* Hotfix for Upstream Merge 81033 (#564)

* Add boolean quirk_points_enabled to LimbsPage, auto-hide quirk points balance on Augments page if false.

* Add boolean quirk_points_enabled to LimbsPage preferences middleware

* Nothing, Just forcing CI to run (hopefully)

---------

Co-authored-by: SomeRandomOwl <[email protected]>

* Silly Wabbit

* Removes Gifted

---------

Co-authored-by: Dani Glore <[email protected]>
Co-authored-by: Mal <[email protected]>
Co-authored-by: SomeRandomOwl <[email protected]>
Co-authored-by: Zergspower <[email protected]>

* conflicts resolved

* Delete gifted.dm

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: Dani Glore <[email protected]>
Co-authored-by: Mal <[email protected]>
Co-authored-by: SomeRandomOwl <[email protected]>
Co-authored-by: Zergspower <[email protected]>
Co-authored-by: Iajret <[email protected]>
  • Loading branch information
7 people authored Feb 28, 2024
1 parent 495fe08 commit 2e3426d
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 72 deletions.
4 changes: 0 additions & 4 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,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.
Expand Down
5 changes: 1 addition & 4 deletions code/__DEFINES/~nova_defines/traits/declarations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
/// Trait to spawn with a pet in a pet carrier (veteran only)
#define TRAIT_PET_OWNER "pet_owner"

/// adds -6 quirk to negative quirks for free points.
#define TRAIT_GIFTED "gifted"

//AdditionalEmotes *turf traits
#define TRAIT_WATER_ASPECT "water_aspect"
#define TRAIT_WEBBING_ASPECT "webbing_aspect"
Expand All @@ -44,7 +41,7 @@
#define TRAIT_SPARKLE_ASPECT "sparkle_aspect"

// Trait sources
#define TRAIT_GHOSTROLE "ghostrole" // NOVA EDIT ADDITION -- Ghost Cafe Traits
#define TRAIT_GHOSTROLE "ghostrole"

/// One can breath under water, you get me?
#define TRAIT_WATER_BREATHING "water_breathing"
Expand Down
2 changes: 1 addition & 1 deletion code/_globalvars/traits/_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ GLOBAL_LIST_INIT(traits_by_type, list(
"TRAIT_FLORAL_ASPECT" = TRAIT_FLORAL_ASPECT,
"TRAIT_FREE_GHOST" = TRAIT_FREE_GHOST,
"TRAIT_GHOSTROLE" = TRAIT_GHOSTROLE,
"TRAIT_GIFTED" = TRAIT_GIFTED,

"TRAIT_GLASSBLOWING" = TRAIT_GLASSBLOWING,
"TRAIT_GLOVES" = TRAIT_GLOVES,
"TRAIT_GLUED_ITEM" = TRAIT_GLUED_ITEM,
Expand Down
1 change: 0 additions & 1 deletion code/_globalvars/traits/admin_tooling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ GLOBAL_LIST_INIT(admin_visible_traits, list(
"TRAIT_FLORAL_ASPECT" = TRAIT_FLORAL_ASPECT,
"TRAIT_FREE_GHOST" = TRAIT_FREE_GHOST,
"TRAIT_GHOSTROLE" = TRAIT_GHOSTROLE,
"TRAIT_GIFTED" = TRAIT_GIFTED,
"TRAIT_GLASSBLOWING" = TRAIT_GLASSBLOWING,
"TRAIT_GLOVES" = TRAIT_GLOVES,
"TRAIT_GLUED_ITEM" = TRAIT_GLUED_ITEM,
Expand Down
9 changes: 9 additions & 0 deletions code/controllers/configuration/entries/game_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
40 changes: 24 additions & 16 deletions code/controllers/subsystem/processing/quirks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,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
Expand Down Expand Up @@ -158,19 +163,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
Expand All @@ -188,6 +194,8 @@ PROCESSING_SUBSYSTEM_DEF(quirks)
/datum/controller/subsystem/processing/quirks/proc/filter_invalid_quirks(list/quirks, list/augments) // NOVA 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()
Expand Down Expand Up @@ -224,15 +232,15 @@ 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

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)
Expand Down
3 changes: 3 additions & 0 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
//NOVA EDIT BEGIN
data["preview_selection"] = preview_pref

data["quirk_points_enabled"] = !CONFIG_GET(flag/disable_quirk_points)
data["quirks_balance"] = GetQuirkBalance()
data["positive_quirk_count"] = GetPositiveQuirkCount()
//NOVA EDIT END
Expand Down Expand Up @@ -540,6 +541,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()

Expand Down
8 changes: 7 additions & 1 deletion code/modules/client/preferences/middleware/quirks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -48,9 +53,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)
Expand Down
11 changes: 11 additions & 0 deletions config/game_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,17 @@ NEGATIVE_STATION_TRAITS 1 4
NEGATIVE_STATION_TRAITS 2 2
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

## FF CONFIGS
ROUNDSTART_RACES nabber
ROUNDSTART_RACES teshari_alt

This file was deleted.

1 change: 0 additions & 1 deletion tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -6240,7 +6240,6 @@
#include "modular_nova\master_files\code\datums\quirks\negative_quirks\all_nighter.dm"
#include "modular_nova\master_files\code\datums\quirks\negative_quirks\blooddeficiency.dm"
#include "modular_nova\master_files\code\datums\quirks\negative_quirks\brainproblems.dm"
#include "modular_nova\master_files\code\datums\quirks\negative_quirks\gifted.dm"
#include "modular_nova\master_files\code\datums\quirks\negative_quirks\heavy_sleeper.dm"
#include "modular_nova\master_files\code\datums\quirks\negative_quirks\narcolepsy.dm"
#include "modular_nova\master_files\code\datums\quirks\negative_quirks\nerve_staple.dm"
Expand Down
57 changes: 34 additions & 23 deletions tgui/packages/tgui/interfaces/PreferencesMenu/LimbsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ export const AugmentationPage = (props) => {
onSelected={(value) => {
// Since the costs are positive,
// it's added and not substracted
if (balance + props.limb.costs[value] > 0) {
if (
data.quirk_points_enabled &&
balance + props.limb.costs[value] > 0
) {
return;
}
act('set_limb_aug', {
Expand Down Expand Up @@ -198,7 +201,10 @@ export const OrganPage = (props) => {
displayText={props.organ.chosen_organ}
onSelected={(value) => {
// Since the costs are positive, it's added and not substracted
if (balance + props.organ.costs[value] > 0) {
if (
data.quirk_points_enabled &&
balance + props.organ.costs[value] > 0
) {
return;
}
act('set_organ_aug', {
Expand Down Expand Up @@ -245,27 +251,32 @@ export const LimbsPage = (props) => {
width="100%"
/>
<RotateCharacterButtons />
<Box
style={{
marginTop: '3em',
}}
>
<Section title="Quirk Points Balance" />
</Box>

<Box
backgroundColor="#eee"
bold
color="black"
fontSize="1.2em"
py={0.5}
style={{
width: '20%',
alignItems: 'center',
}}
>
{balance}
</Box>
{data.quirk_points_enabled ? (
<Section
fill
align="center"
title="Quirk Points Balance"
style={{ marginTop: '3em' }}
>
<Stack justify="center">
<Box
backgroundColor="#eee"
bold
color="black"
fontSize="1.2em"
py={0.5}
style={{
width: '20%',
alignItems: 'center',
}}
>
{balance}
</Box>
</Stack>
</Section>
) : (
''
)}
</Section>
</Stack.Item>
<Stack.Item minWidth="33%">
Expand Down
38 changes: 29 additions & 9 deletions tgui/packages/tgui/interfaces/PreferencesMenu/QuirksPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export function QuirksPage(props) {
max_positive_quirks: maxPositiveQuirks,
quirk_blacklist: quirkBlacklist,
quirk_info: quirkInfo,
points_enabled: pointsEnabled,
} = quirks_data.quirks; // NOVA EDIT - Quirks balance refactor

const quirks = Object.entries(quirkInfo);
Expand All @@ -342,9 +343,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!';
}
}
Expand Down Expand Up @@ -383,7 +387,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!';
}

Expand All @@ -395,13 +399,21 @@ export function QuirksPage(props) {
<Stack.Item basis="50%">
<Stack vertical fill align="center">
<Stack.Item>
<Box fontSize="1.3em">Positive Quirks</Box>
{maxPositiveQuirks > 0 ? (
<Box fontSize="1.3em">Positive Quirks</Box>
) : (
<Box mt={pointsEnabled ? 3.4 : 0} />
)}
</Stack.Item>

<Stack.Item>
<StatDisplay>
{positiveQuirks} / {maxPositiveQuirks}
</StatDisplay>
{maxPositiveQuirks > 0 ? (
<StatDisplay>
{positiveQuirks} / {maxPositiveQuirks}
</StatDisplay>
) : (
<Box mt={pointsEnabled ? 3.4 : 0} />
)}
</Stack.Item>

<Stack.Item>
Expand Down Expand Up @@ -449,11 +461,19 @@ export function QuirksPage(props) {
<Stack.Item basis="50%">
<Stack vertical fill align="center">
<Stack.Item>
<Box fontSize="1.3em">Quirk Balance</Box>
{pointsEnabled ? (
<Box fontSize="1.3em">Quirk Balance</Box>
) : (
<Box mt={maxPositiveQuirks > 0 ? 3.4 : 0} />
)}
</Stack.Item>

<Stack.Item>
<StatDisplay>{balance}</StatDisplay>
{pointsEnabled ? (
<StatDisplay>{balance}</StatDisplay>
) : (
<Box mt={maxPositiveQuirks > 0 ? 3.4 : 0} />
)}
</Stack.Item>

<Stack.Item>
Expand Down
2 changes: 2 additions & 0 deletions tgui/packages/tgui/interfaces/PreferencesMenu/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export type QuirkInfo = {
max_positive_quirks: number;
quirk_info: Record<string, Quirk>;
quirk_blacklist: string[][];
points_enabled: boolean;
};

export enum RandomSetting {
Expand Down Expand Up @@ -230,6 +231,7 @@ export type PreferencesMenuData = {
selected_languages: Language[];
unselected_languages: Language[];
total_language_points: number;
quirk_points_enabled: number;
quirks_balance: number;
positive_quirk_count: number;
species_restricted_jobs?: string[];
Expand Down

0 comments on commit 2e3426d

Please sign in to comment.