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 00000000000..1616f746323 --- /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 893f08960bd..c3da448f1a6 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1167,22 +1167,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 bb74a469308..d450dc1c30f 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/traits/neutral.dm b/code/modules/mob/living/carbon/human/species/station/traits/neutral.dm index 85c12622f9c..9adfdf8c976 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 @@ -1692,3 +1692,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 = TRUE //Disabled on Virgo + 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 = TRUE //Disabled on Virgo + added_component_path = /datum/component/nutrition_size_change/shrinking diff --git a/vorestation.dme b/vorestation.dme index 7768e176b03..cd7ebbf910b 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -517,6 +517,7 @@ #include "code\datums\components\disabilities\tourettes.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\waddle.dm" #include "code\datums\components\traits\weaver.dm"