From 0f390c4e92bf51f6512db7e13f0473b5d60c1ae3 Mon Sep 17 00:00:00 2001 From: CHOMPStation2StaffMirrorBot <94713762+CHOMPStation2StaffMirrorBot@users.noreply.github.com> Date: Sun, 18 May 2025 22:36:17 -0700 Subject: [PATCH] [MIRROR] Nutrition Resizing Component (#10904) Co-authored-by: Will <7099514+Willburd@users.noreply.github.com> Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com> Co-authored-by: Cameron Lennox --- .../traits/nutrition_size_change.dm | 54 +++++++++++++++++++ code/modules/mob/living/carbon/human/life.dm | 16 ------ .../living/carbon/human/species/species.dm | 2 - .../station/station_special_abilities_ch.dm | 24 --------- .../human/species/station/traits/neutral.dm | 16 ++++++ .../species/station/traits/neutral_ch.dm | 20 ------- vorestation.dme | 1 + 7 files changed, 71 insertions(+), 62 deletions(-) create mode 100644 code/datums/components/traits/nutrition_size_change.dm diff --git a/code/datums/components/traits/nutrition_size_change.dm b/code/datums/components/traits/nutrition_size_change.dm new file mode 100644 index 0000000000..1616f74632 --- /dev/null +++ b/code/datums/components/traits/nutrition_size_change.dm @@ -0,0 +1,54 @@ +#define GROWMODE_SHRINK 1 +#define GROWMODE_GROW 2 + +/datum/component/nutrition_size_change + var/mob/living/owner + var/grow_mode = 0 // Don't use base component + +/datum/component/nutrition_size_change/growing + grow_mode = GROWMODE_GROW + +/datum/component/nutrition_size_change/shrinking + grow_mode = GROWMODE_SHRINK + +/datum/component/nutrition_size_change/Initialize() + if(!isliving(parent)) + return COMPONENT_INCOMPATIBLE + owner = parent + RegisterSignal(owner, COMSIG_LIVING_LIFE, PROC_REF(process_component)) + +/datum/component/nutrition_size_change/proc/process_component() + if(QDELETED(parent)) + return + if(owner.stat == DEAD) + return + if(owner.nutrition <= 0 && grow_mode == GROWMODE_SHRINK && owner.size_multiplier > RESIZE_TINY) + 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 + 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 + 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/Destroy(force = FALSE) + UnregisterSignal(owner, COMSIG_LIVING_LIFE) + owner = null + . = ..() + +#undef GROWMODE_SHRINK +#undef GROWMODE_GROW diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index dea7865a26..a748d67c50 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1178,22 +1178,6 @@ else //heal in the dark heal_overall_damage(1,1) // nutrition decrease - if(nutrition <= 0 && species.shrinks && size_multiplier > RESIZE_TINY) - nutrition = 0.1 - if(nutrition > 0 && stat != DEAD) - var/nutrition_reduction = species.hunger_factor - - for(var/datum/modifier/mod in modifiers) - if(!isnull(mod.metabolism_percent)) - nutrition_reduction *= mod.metabolism_percent - if(nutrition > 1000 && species.grows) //Removing the strict check against normal max/min size to support dorms/VR oversizing - nutrition_reduction *= 5 - resize(size_multiplier+0.01, animate = FALSE, uncapped = has_large_resize_bounds()) //Bringing this code in line with micro and macro shrooms - if(nutrition < 50 && species.shrinks) - nutrition_reduction *= 0.3 - resize(size_multiplier-0.01, animate = FALSE, uncapped = has_large_resize_bounds()) //Bringing this code in line with micro and macro shrooms - 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/code/modules/mob/living/carbon/human/species/species.dm b/code/modules/mob/living/carbon/human/species/species.dm index 125a19cf52..b8f27d0446 100644 --- a/code/modules/mob/living/carbon/human/species/species.dm +++ b/code/modules/mob/living/carbon/human/species/species.dm @@ -244,8 +244,6 @@ var/gluttonous // Can eat some mobs. 1 for mice, 2 for monkeys, 3 for people. var/soft_landing = FALSE // Can fall down and land safely on small falls. - var/shrinks = FALSE // If we shrink when we have no nutrition. Not added but here for downstream's sake. - var/grows = FALSE // Same as above but if we grow when >1000 nutrition. var/crit_mod = 1 // Used for when we go unconscious. Used downstream. var/list/env_traits = list() var/pixel_offset_x = 0 // Used for offsetting 64x64 and up icons. diff --git a/code/modules/mob/living/carbon/human/species/station/station_special_abilities_ch.dm b/code/modules/mob/living/carbon/human/species/station/station_special_abilities_ch.dm index d8155105b6..1860414663 100644 --- a/code/modules/mob/living/carbon/human/species/station/station_special_abilities_ch.dm +++ b/code/modules/mob/living/carbon/human/species/station/station_special_abilities_ch.dm @@ -195,27 +195,3 @@ var/eggs = 0 src.visible_message(span_infoplain(span_red("[src] sinks their stinger into [T]!"))) T.bloodstr.add_reagent(REAGENT_ID_CONDENSEDCAPSAICINV,3) last_special = world.time + 50 // Many little jabs instead of one big one - -/mob/living/carbon/proc/toggle_growth() - set name = "Toggle Growth" - set desc = "Toggles whether excess nutrition will be used to grow you or not" - set category = "Abilities.General" - - species.grows = !species.grows - - if(species.grows) - to_chat(src, span_notice("You now grow with excess nutrition!")) - else - to_chat(src, span_notice("You no longer grow with excess nutrition.")) - -/mob/living/carbon/proc/toggle_shrinking() - set name = "Toggle Shrinking" - set desc = "Toggles whether a deficit of nutrition will cause you to shrink or not" - set category = "Abilities.General" - - species.shrinks = !species.shrinks - - if(species.shrinks) - to_chat(src, span_notice("You now shrink when not having enough nutrition!")) - else - to_chat(src, span_notice("You no longer shrink when not having enough nutrition.")) diff --git a/code/modules/mob/living/carbon/human/species/station/traits/neutral.dm b/code/modules/mob/living/carbon/human/species/station/traits/neutral.dm index 2011dda2ee..4e98bc565a 100644 --- a/code/modules/mob/living/carbon/human/species/station/traits/neutral.dm +++ b/code/modules/mob/living/carbon/human/species/station/traits/neutral.dm @@ -1697,3 +1697,19 @@ ..() var/datum/component/waddle_trait/G = H.GetComponent(added_component_path) G.waddling = trait_prefs["waddler"] + +/datum/trait/neutral/nutritiongrow + name = "Growing" + desc = "After you consume enough nutrition, you start to slowly grow while metabolizing nutrition faster." + excludes = list(/datum/trait/neutral/nutritionshrink) + cost = 0 + hidden = FALSE //Disabled on Virgo // CHOMPEdit + added_component_path = /datum/component/nutrition_size_change/growing + +/datum/trait/neutral/nutritionshrink + name = "Shrinking" + desc = "If you don't eat enough, your body starts shrinking to make up the difference!" + excludes = list(/datum/trait/neutral/nutritiongrow) + cost = 0 + hidden = FALSE //Disabled on Virgo // CHOMPEdit + added_component_path = /datum/component/nutrition_size_change/shrinking diff --git a/code/modules/mob/living/carbon/human/species/station/traits/neutral_ch.dm b/code/modules/mob/living/carbon/human/species/station/traits/neutral_ch.dm index 87a24f2d2c..cff1b3e3fb 100644 --- a/code/modules/mob/living/carbon/human/species/station/traits/neutral_ch.dm +++ b/code/modules/mob/living/carbon/human/species/station/traits/neutral_ch.dm @@ -17,26 +17,6 @@ ..() add_verb(H,/mob/living/proc/succubus_bite) //CHOMPEdit TGPanel -/datum/trait/neutral/nutritiongrow - name = "Growing" - desc = "After you consume enough nutrition, you start to slowly grow while metabolizing nutrition faster." - cost = 0 - var_changes = list("grows" = TRUE) - -/datum/trait/neutral/nutritiongrow/apply(var/datum/species/S,var/mob/living/carbon/human/H) - ..() - add_verb(H,/mob/living/carbon/proc/toggle_growth) //CHOMPEdit TGPanel - -/datum/trait/neutral/nutritionshrink - name = "Shrinking" - desc = "If you don't eat enough, your body starts shrinking to make up the difference!" - cost = 0 - var_changes = list("shrinks" = TRUE) - -/datum/trait/neutral/nutritiongrow/apply(var/datum/species/S,var/mob/living/carbon/human/H) - ..() - add_verb(H,/mob/living/carbon/proc/toggle_shrinking) //CHOMPEdit TGPanel - /datum/trait/neutral/singularity_metabolism name = "Metabolism, Singularity" desc = "You are insanely hungry. You can seemingly never get enough to eat. Perhaps you had a singularity as an ancestor, or maybe one is currently living inside of your gut." diff --git a/vorestation.dme b/vorestation.dme index eb5e7c3c3d..d65572abe5 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -548,6 +548,7 @@ #include "code\datums\components\species\xenochimera.dm" #include "code\datums\components\traits\drippy.dm" #include "code\datums\components\traits\gargoyle.dm" +#include "code\datums\components\traits\nutrition_size_change.dm" #include "code\datums\components\traits\photosynth.dm" #include "code\datums\components\traits\weaver.dm" #include "code\datums\diseases\_disease.dm"