From a39f70769b5de2b0fc3878bbcf96a0f4c5bde053 Mon Sep 17 00:00:00 2001 From: xTheLifex Date: Sat, 3 Aug 2024 21:35:48 -0300 Subject: [PATCH] Preferences Moment --- code/__SANDCODE/DEFINES/misc.dm | 2 + code/modules/client/preferences.dm | 8 ++ .../components/interaction_menu_granter.dm | 79 +++++++++---------- .../datums/interactions/lewd_definitions.dm | 14 ++-- .../modules/client/preferences_savefile.dm | 12 ++- .../interfaces/MobInteraction/InfoSection.tsx | 28 +++---- .../tabs/ContentPreferencesTab.tsx | 24 +++--- 7 files changed, 90 insertions(+), 77 deletions(-) diff --git a/code/__SANDCODE/DEFINES/misc.dm b/code/__SANDCODE/DEFINES/misc.dm index 83a266dac9..66c894e898 100644 --- a/code/__SANDCODE/DEFINES/misc.dm +++ b/code/__SANDCODE/DEFINES/misc.dm @@ -1,2 +1,4 @@ /// Adds an utf-8 header...? only ever used on circuitry so when wiremod arrives... #define UTF8HEADER "" +/// A shorthand for ternary operators to simulate a null-coalescing operator. Returns the first argument if its defined, otherwise, second. +#define NULL_COALESCE(var, default) ((var) ? (var) : (default)) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 8760ea172f..f535876f2b 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -124,6 +124,14 @@ GLOBAL_LIST_EMPTY(preferences_datums) var/list/alt_titles_preferences = list() var/lust_tolerance = 100 var/sexual_potency = 15 + /// Enable the 'arousal_multiplier' to be applied to lust amount + var/use_arousal_multiplier = FALSE + /// Enable the 'arousal_moaning' to be used as a % chance of moaning instead of default calculation. + var/use_moaning_multiplier = FALSE + /// A separate arousal multiplier that the user has control of (although we could just tap into lust or replace it.) + var/arousal_multiplier = 100 + /// Chance of moaning during an interaction + var/arousal_moaning = 5 //Sandstorm CHANGES END var/underwear = "Nude" //underwear type var/undie_color = "FFFFFF" diff --git a/modular_sand/code/datums/components/interaction_menu_granter.dm b/modular_sand/code/datums/components/interaction_menu_granter.dm index 454de38923..735948c494 100644 --- a/modular_sand/code/datums/components/interaction_menu_granter.dm +++ b/modular_sand/code/datums/components/interaction_menu_granter.dm @@ -390,40 +390,40 @@ var/datum/preferences/prefs = self?.client.prefs if(prefs) //Let's get their favorites! - .["favorite_interactions"] = SANITIZE_LIST(prefs.favorite_interactions) + .["favorite_interactions"] = SANITIZE_LIST(prefs.favorite_interactions) //Getting char prefs - .["erp_pref"] = pref_to_num(prefs.erppref) - .["noncon_pref"] = pref_to_num(prefs.nonconpref) - .["vore_pref"] = pref_to_num(prefs.vorepref) - .["extreme_pref"] = pref_to_num(prefs.extremepref) - .["extreme_harm"] = pref_to_num(prefs.extremeharm) + .["erp_pref"] = pref_to_num(prefs.erppref) + .["noncon_pref"] = pref_to_num(prefs.nonconpref) + .["vore_pref"] = pref_to_num(prefs.vorepref) + .["extreme_pref"] = pref_to_num(prefs.extremepref) + .["extreme_harm"] = pref_to_num(prefs.extremeharm) //Getting preferences - .["verb_consent"] = !!CHECK_BITFIELD(prefs.toggles, VERB_CONSENT) - .["lewd_verb_sounds"] = !!CHECK_BITFIELD(prefs.toggles, LEWD_VERB_SOUNDS) - .["arousable"] = prefs.arousable - .["genital_examine"] = !!CHECK_BITFIELD(prefs.cit_toggles, GENITAL_EXAMINE) - .["vore_examine"] = !!CHECK_BITFIELD(prefs.cit_toggles, VORE_EXAMINE) - .["medihound_sleeper"] = !!CHECK_BITFIELD(prefs.cit_toggles, MEDIHOUND_SLEEPER) - .["eating_noises"] = !!CHECK_BITFIELD(prefs.cit_toggles, EATING_NOISES) - .["digestion_noises"] = !!CHECK_BITFIELD(prefs.cit_toggles, DIGESTION_NOISES) - .["trash_forcefeed"] = !!CHECK_BITFIELD(prefs.cit_toggles, TRASH_FORCEFEED) - .["forced_fem"] = !!CHECK_BITFIELD(prefs.cit_toggles, FORCED_FEM) - .["forced_masc"] = !!CHECK_BITFIELD(prefs.cit_toggles, FORCED_MASC) - .["hypno"] = !!CHECK_BITFIELD(prefs.cit_toggles, HYPNO) - .["bimbofication"] = !!CHECK_BITFIELD(prefs.cit_toggles, BIMBOFICATION) - .["breast_enlargement"] = !!CHECK_BITFIELD(prefs.cit_toggles, BREAST_ENLARGEMENT) - .["penis_enlargement"] = !!CHECK_BITFIELD(prefs.cit_toggles, PENIS_ENLARGEMENT) - .["butt_enlargement"] = !!CHECK_BITFIELD(prefs.cit_toggles, BUTT_ENLARGEMENT) - .["never_hypno"] = !CHECK_BITFIELD(prefs.cit_toggles, NEVER_HYPNO) - .["no_aphro"] = !CHECK_BITFIELD(prefs.cit_toggles, NO_APHRO) - .["no_ass_slap"] = !CHECK_BITFIELD(prefs.cit_toggles, NO_ASS_SLAP) - .["no_auto_wag"] = !CHECK_BITFIELD(prefs.cit_toggles, NO_AUTO_WAG) - .["mood"] = self.arousal_multiplier - .["moan"] = self.arousal_moaning - .["enable_mood"] = self.use_arousal_multiplier - .["enable_moan"] = self.use_moaning_multiplier + .["verb_consent"] = !!CHECK_BITFIELD(prefs.toggles, VERB_CONSENT) + .["lewd_verb_sounds"] = !!CHECK_BITFIELD(prefs.toggles, LEWD_VERB_SOUNDS) + .["arousable"] = prefs.arousable + .["genital_examine"] = !!CHECK_BITFIELD(prefs.cit_toggles, GENITAL_EXAMINE) + .["vore_examine"] = !!CHECK_BITFIELD(prefs.cit_toggles, VORE_EXAMINE) + .["medihound_sleeper"] = !!CHECK_BITFIELD(prefs.cit_toggles, MEDIHOUND_SLEEPER) + .["eating_noises"] = !!CHECK_BITFIELD(prefs.cit_toggles, EATING_NOISES) + .["digestion_noises"] = !!CHECK_BITFIELD(prefs.cit_toggles, DIGESTION_NOISES) + .["trash_forcefeed"] = !!CHECK_BITFIELD(prefs.cit_toggles, TRASH_FORCEFEED) + .["forced_fem"] = !!CHECK_BITFIELD(prefs.cit_toggles, FORCED_FEM) + .["forced_masc"] = !!CHECK_BITFIELD(prefs.cit_toggles, FORCED_MASC) + .["hypno"] = !!CHECK_BITFIELD(prefs.cit_toggles, HYPNO) + .["bimbofication"] = !!CHECK_BITFIELD(prefs.cit_toggles, BIMBOFICATION) + .["breast_enlargement"] = !!CHECK_BITFIELD(prefs.cit_toggles, BREAST_ENLARGEMENT) + .["penis_enlargement"] = !!CHECK_BITFIELD(prefs.cit_toggles, PENIS_ENLARGEMENT) + .["butt_enlargement"] = !!CHECK_BITFIELD(prefs.cit_toggles, BUTT_ENLARGEMENT) + .["never_hypno"] = !CHECK_BITFIELD(prefs.cit_toggles, NEVER_HYPNO) + .["no_aphro"] = !CHECK_BITFIELD(prefs.cit_toggles, NO_APHRO) + .["no_ass_slap"] = !CHECK_BITFIELD(prefs.cit_toggles, NO_ASS_SLAP) + .["no_auto_wag"] = !CHECK_BITFIELD(prefs.cit_toggles, NO_AUTO_WAG) + .["arousal_multiplier"] = prefs.arousal_multiplier + .["arousal_moaning"] = prefs.arousal_moaning + .["use_arousal_multiplier"] = prefs.use_arousal_multiplier + .["use_moaning_multiplier"] = prefs.use_moaning_multiplier /datum/component/interaction_menu_granter/ui_static_data(mob/user) . = ..() @@ -475,17 +475,6 @@ return var/mob/living/parent_mob = parent switch(action) - if("dynamic") - var/mob/living/carbon/self = parent_mob - switch(params["type"]) - if("multiplier") - self.arousal_multiplier = params["amount"] - if("moan") - self.arousal_moaning = params["amount"] - if("enable_mood") - self.use_arousal_multiplier = !self.use_arousal_multiplier - if("enable_moan") - self.use_moaning_multiplier = !self.use_moaning_multiplier if("interact") var/datum/interaction/o = SSinteractions.interactions[params["interaction"]] if(o) @@ -622,6 +611,14 @@ TOGGLE_BITFIELD(prefs.cit_toggles, NO_ASS_SLAP) if("no_auto_wag") TOGGLE_BITFIELD(prefs.cit_toggles, NO_AUTO_WAG) + if("arousal_multiplier") + prefs.arousal_multiplier = params["amount"] + if("arousal_moaning") + prefs.arousal_moaning = params["amount"] + if("use_arousal_multiplier") + prefs.use_arousal_multiplier = !prefs.use_arousal_multiplier + if("use_moaning_multiplier") + prefs.use_moaning_multiplier = !prefs.use_moaning_multiplier else return FALSE prefs.save_preferences() diff --git a/modular_sand/code/datums/interactions/lewd_definitions.dm b/modular_sand/code/datums/interactions/lewd_definitions.dm index e8096bd580..e6247b8f2f 100644 --- a/modular_sand/code/datums/interactions/lewd_definitions.dm +++ b/modular_sand/code/datums/interactions/lewd_definitions.dm @@ -39,14 +39,6 @@ var/datum/interaction/lewd/last_lewd_datum //Recording our last lewd datum allows us to do stuff like custom cum messages. //Yes i feel like an idiot writing this. var/cleartimer //Timer for clearing the "last_lewd_datum". This prevents some oddities. - /// Enable the 'arousal_multiplier' for calculation instead of lust. - var/use_arousal_multiplier = FALSE - /// Enable the 'arousal_moaning' to be used as a % chance of moaning instead of default calculation. - var/use_moaning_multiplier = FALSE - /// A separate arousal multiplier that the user has control of (although we could just tap into lust or replace it.) - var/arousal_multiplier = 100 - /// Chance of moaning during an interaction - var/arousal_moaning = 5 /mob/living/proc/clear_lewd_datum() last_partner = null @@ -741,6 +733,12 @@ if(stat != CONSCIOUS) return FALSE + var/datum/preferences/prefs = client?.prefs + var/use_arousal_multiplier = NULL_COALESCE(prefs?.use_arousal_multiplier, FALSE) + var/use_moaning_multiplier = NULL_COALESCE(prefs?.use_moaning_multiplier, FALSE) + var/arousal_moaning = NULL_COALESCE(prefs?.arousal_moaning, 25) + var/arousal_multiplier = NULL_COALESCE(prefs?.arousal_multiplier, 100) + if(amount) if (use_arousal_multiplier) add_lust(amount * (arousal_multiplier/100)) diff --git a/modular_sand/code/modules/client/preferences_savefile.dm b/modular_sand/code/modules/client/preferences_savefile.dm index d89f7df70a..759fc249c2 100644 --- a/modular_sand/code/modules/client/preferences_savefile.dm +++ b/modular_sand/code/modules/client/preferences_savefile.dm @@ -29,13 +29,21 @@ . = ..() if(!istype(., /savefile)) return FALSE - WRITE_FILE(.["favorite_interactions"], favorite_interactions) + WRITE_FILE(.["favorite_interactions"], favorite_interactions) + WRITE_FILE(.["use_arousal_multiplier"], use_arousal_multiplier) + WRITE_FILE(.["use_moaning_multiplier"], use_moaning_multiplier) + WRITE_FILE(.["arousal_multiplier"], arousal_multiplier) + WRITE_FILE(.["arousal_moaning"], arousal_moaning) /datum/preferences/load_preferences(bypass_cooldown) . = ..() if(!istype(., /savefile)) return FALSE - .["favorite_interactions"] >> favorite_interactions + .["favorite_interactions"] >> favorite_interactions + .["use_arousal_multiplier"] >> use_arousal_multiplier + .["use_moaning_multiplier"] >> use_moaning_multiplier + .["arousal_multiplier"] >> arousal_multiplier + .["arousal_moaning"] >> arousal_moaning favorite_interactions = SANITIZE_LIST(favorite_interactions) diff --git a/tgui/packages/tgui/interfaces/MobInteraction/InfoSection.tsx b/tgui/packages/tgui/interfaces/MobInteraction/InfoSection.tsx index 2b3ecdfdcf..3abbbb363e 100644 --- a/tgui/packages/tgui/interfaces/MobInteraction/InfoSection.tsx +++ b/tgui/packages/tgui/interfaces/MobInteraction/InfoSection.tsx @@ -10,10 +10,10 @@ type HeaderInfo = { theirAttributes: string[]; theirLust: number; theirMaxLust: number; - moan: number; - mood: number; - enable_mood: boolean; - enable_moan: boolean; + arousal_moaning: number; + arousal_multiplier: number; + use_arousal_multiplier: boolean; + use_moaning_multiplier: boolean; } export const InfoSection = (props, context) => { @@ -27,10 +27,10 @@ export const InfoSection = (props, context) => { theirAttributes, theirLust, theirMaxLust, - moan, - mood, - enable_mood, - enable_moan, + arousal_moaning, + arousal_multiplier, + use_arousal_multiplier, + use_moaning_multiplier, } = data; return (
@@ -77,33 +77,33 @@ export const InfoSection = (props, context) => { - {(enable_mood ? ( + {(use_arousal_multiplier ? ( act("dynamic", {type: 'multiplier', amount: value})} + onChange={(_, value) => act("pref", {pref: 'arousal_multiplier', amount: value})} >Arousal Multiplier ) : (null))} - {(enable_moan ? ( + {(use_moaning_multiplier ? ( act("dynamic", {type: 'moan', amount: value})} + onChange={(_, value) => act("pref", {pref: 'arousal_moaning', amount: value})} >Moaning Chance ) : (null))} diff --git a/tgui/packages/tgui/interfaces/MobInteraction/tabs/ContentPreferencesTab.tsx b/tgui/packages/tgui/interfaces/MobInteraction/tabs/ContentPreferencesTab.tsx index e0cdc05673..84a4af8a29 100644 --- a/tgui/packages/tgui/interfaces/MobInteraction/tabs/ContentPreferencesTab.tsx +++ b/tgui/packages/tgui/interfaces/MobInteraction/tabs/ContentPreferencesTab.tsx @@ -22,8 +22,8 @@ type ContentPrefsInfo = { no_aphro: boolean, no_ass_slap: boolean, no_auto_wag: boolean, - enable_mood: boolean; - enable_moan: boolean; + use_arousal_multiplier: boolean; + use_moaning_multiplier: boolean; } export const ContentPreferencesTab = (props, context) => { @@ -49,8 +49,8 @@ export const ContentPreferencesTab = (props, context) => { no_aphro, no_ass_slap, no_auto_wag, - enable_mood, - enable_moan, + use_arousal_multiplier, + use_moaning_multiplier, } = data; return ( @@ -59,10 +59,10 @@ export const ContentPreferencesTab = (props, context) => { fluid mb={-0.7} content="Enable lust gain multiplier" - icon={enable_mood ? "toggle-on" : "toggle-off"} - selected={enable_mood} - onClick={() => act('dynamic', { - type: 'enable_mood', + icon={use_arousal_multiplier ? "toggle-on" : "toggle-off"} + selected={use_arousal_multiplier} + onClick={() => act('pref', { + pref: 'use_arousal_multiplier', })} /> @@ -71,10 +71,10 @@ export const ContentPreferencesTab = (props, context) => { fluid mb={-0.7} content="Enable moaning chance customizaton" - icon={enable_moan ? "toggle-on" : "toggle-off"} - selected={enable_moan} - onClick={() => act('dynamic', { - type: 'enable_moan', + icon={use_moaning_multiplier ? "toggle-on" : "toggle-off"} + selected={use_moaning_multiplier} + onClick={() => act('pref', { + pref: 'use_moaning_multiplier', })} />