From 991f558472ecc6d29f80324cd07d91dc19c181ae Mon Sep 17 00:00:00 2001 From: CHOMPStation2StaffMirrorBot <94713762+CHOMPStation2StaffMirrorBot@users.noreply.github.com> Date: Tue, 3 Jun 2025 01:20:10 -0700 Subject: [PATCH] [MIRROR] Nutrition fix (#11001) Co-authored-by: Cameron Lennox Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com> --- .../traits/nutrition_size_change.dm | 30 +++++++++---------- code/modules/mob/living/carbon/human/life.dm | 13 ++++++++ tools/build/build.js | 2 +- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/code/datums/components/traits/nutrition_size_change.dm b/code/datums/components/traits/nutrition_size_change.dm index 35391365b5..77239e6890 100644 --- a/code/datums/components/traits/nutrition_size_change.dm +++ b/code/datums/components/traits/nutrition_size_change.dm @@ -1,6 +1,9 @@ #define GROWMODE_SHRINK 1 #define GROWMODE_GROW 2 +#define GROW_MULTIPLIER 5 +#define SHRINK_MULTIPLIER 0.3 + /datum/component/nutrition_size_change var/mob/living/owner var/grow_mode = 0 // Don't use base component @@ -28,24 +31,18 @@ owner.nutrition = 0.1 if(owner.nutrition <= 0) return - // Species controls hunger rate for humans, otherwise use defaults - var/nutrition_reduction = DEFAULT_HUNGER_FACTOR - if(ishuman(owner)) - var/mob/living/carbon/human/H = owner - nutrition_reduction = H.species.hunger_factor - // Modifiers can increase or decrease nutrition cost - for(var/datum/modifier/mod in owner.modifiers) - if(!isnull(mod.metabolism_percent)) - nutrition_reduction *= mod.metabolism_percent // Time to change size! - if(owner.nutrition > 1000 && grow_mode == GROWMODE_GROW) //Removing the strict check against normal max/min size to support dorms/VR oversizing - nutrition_reduction *= 5 + var/nutrition_multiplier = get_nutrition_multiplier() + if(nutrition_multiplier == GROW_MULTIPLIER) //Removing the strict check against normal max/min size to support dorms/VR oversizing owner.resize(owner.size_multiplier+0.01, animate = FALSE, uncapped = owner.has_large_resize_bounds()) //Bringing this code in line with micro and macro shrooms - if(owner.nutrition < 50 && grow_mode == GROWMODE_SHRINK) - nutrition_reduction *= 0.3 + if(nutrition_multiplier == SHRINK_MULTIPLIER) owner.resize(owner.size_multiplier-0.01, animate = FALSE, uncapped = owner.has_large_resize_bounds()) //Bringing this code in line with micro and macro shrooms - // Apply hunger costs - owner.adjust_nutrition(-nutrition_reduction) + +/datum/component/nutrition_size_change/proc/get_nutrition_multiplier() + if(owner.nutrition > 1000 && grow_mode == GROWMODE_GROW) //Removing the strict check against normal max/min size to support dorms/VR oversizing + return GROW_MULTIPLIER + else if(owner.nutrition < 50 && grow_mode == GROWMODE_SHRINK) + return SHRINK_MULTIPLIER /datum/component/nutrition_size_change/Destroy(force = FALSE) UnregisterSignal(owner, COMSIG_LIVING_LIFE) @@ -54,3 +51,6 @@ #undef GROWMODE_SHRINK #undef GROWMODE_GROW + +#undef GROW_MULTIPLIER +#undef SHRINK_MULTIPLIER diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index db97f0dd15..d6bc666b93 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1169,6 +1169,19 @@ return 0 //godmode // nutrition decrease + // Species controls hunger rate for humans, otherwise use defaults + if(nutrition > 0 && stat != DEAD) + var/nutrition_reduction = DEFAULT_HUNGER_FACTOR + nutrition_reduction = species.hunger_factor + // Modifiers can increase or decrease nutrition cost + for(var/datum/modifier/mod in modifiers) + if(!isnull(mod.metabolism_percent)) + nutrition_reduction *= mod.metabolism_percent + var/datum/component/nutrition_size_change/comp = GetComponent(/datum/component/nutrition_size_change) + if(comp) + nutrition_reduction *= comp.get_nutrition_multiplier() + adjust_nutrition(-nutrition_reduction) + if(noisy == TRUE && nutrition < 250 && prob(10)) var/sound/growlsound = sound(get_sfx("hunger_sounds")) var/growlmultiplier = 100 - (nutrition / 250 * 100) diff --git a/tools/build/build.js b/tools/build/build.js index 971837e63c..f2decaf3c8 100644 --- a/tools/build/build.js +++ b/tools/build/build.js @@ -483,7 +483,7 @@ export const ServerTarget = new Juke.Target({ const options = { dmbFile: `${DME_NAME}.dmb`, namedDmVersion: get(DmVersionParameter), - } + }; await DreamDaemon(options, port, "-trusted -invisible"); }, });