[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 <killer65311@gmail.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-05-19 07:36:17 +02:00
committed by GitHub
co-authored by Will Kashargul Cameron Lennox
parent 69609faf9e
commit 0f390c4e92
7 changed files with 71 additions and 62 deletions
@@ -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
@@ -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)
@@ -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.
@@ -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."))
@@ -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
@@ -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."
+1
View File
@@ -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"