From 4af06e18a9acfad24e6a84ea34c4da1b62ed71ff Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sun, 20 Sep 2020 17:33:07 +0200 Subject: [PATCH] [MIRROR] Fixes TRAIT_NOHUNGER on digestion and fat species that never stop being fat (#898) * Fixes TRAIT_NOHUNGER on digestion and fat species that never stop being fat (#53764) Issue was encountered during a Manuel round when a fatass became an Android. Incorrect check for TRAIT_NOHUNGER in handle_digestion meant it was ignored and digestion code would always run. Androids don't hunger, don't metabolise, don't eat. When a player turns into an android, if they were fat, they become a fat anrdroid. It then becomes incredibly difficult and annoying for admins to restore them back to normal. Admins trying to fix this manually can also create excess screen alerts, traits and moodlets as they triage the issue alongside the TRAIT_NOHUNGER bug that will constantly restore negative moodlets and throw screen alerts unless they set the status JUST RIGHT. As a result, as well as fixing TRAIT_NOHUNGER I'm also hitting TRAIT_NOHUNGER species. I created a new proc to set hunger values to safe levels and call it on_species_gain for every TRAIT_NOHUNGER species. Thanks to the Eric Fatsby who let me experiment on him to identify as many problem areas as I could. * Fixes TRAIT_NOHUNGER on digestion and fat species that never stop being fat Co-authored-by: Timberpoes --- .../mob/living/carbon/human/species.dm | 2 +- .../carbon/human/species_types/abductors.dm | 2 ++ .../carbon/human/species_types/android.dm | 3 +++ .../carbon/human/species_types/dullahan.dm | 1 + .../carbon/human/species_types/ethereal.dm | 2 +- .../carbon/human/species_types/plasmamen.dm | 4 ++++ .../human/species_types/shadowpeople.dm | 1 + .../carbon/human/species_types/skeletons.dm | 4 ++++ .../carbon/human/species_types/synths.dm | 1 + .../carbon/human/species_types/vampire.dm | 4 +--- code/modules/mob/living/living.dm | 20 +++++++++++++++++++ 11 files changed, 39 insertions(+), 5 deletions(-) diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index 53044c99b42..50a62aa2446 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -1099,7 +1099,7 @@ GLOBAL_LIST_EMPTY(roundstart_races) //LIFE// //////// /datum/species/proc/handle_digestion(mob/living/carbon/human/H) - if(HAS_TRAIT(src, TRAIT_NOHUNGER)) + if(HAS_TRAIT(H, TRAIT_NOHUNGER)) return //hunger is for BABIES //The fucking TRAIT_FAT mutation is the dumbest shit ever. It makes the code so difficult to work with diff --git a/code/modules/mob/living/carbon/human/species_types/abductors.dm b/code/modules/mob/living/carbon/human/species_types/abductors.dm index 8e560d7c1aa..6bbf5c041cd 100644 --- a/code/modules/mob/living/carbon/human/species_types/abductors.dm +++ b/code/modules/mob/living/carbon/human/species_types/abductors.dm @@ -13,6 +13,8 @@ var/datum/atom_hud/abductor_hud = GLOB.huds[DATA_HUD_ABDUCTOR] abductor_hud.add_hud_to(C) + C.set_safe_hunger_level() + /datum/species/abductor/on_species_loss(mob/living/carbon/C) . = ..() var/datum/atom_hud/abductor_hud = GLOB.huds[DATA_HUD_ABDUCTOR] diff --git a/code/modules/mob/living/carbon/human/species_types/android.dm b/code/modules/mob/living/carbon/human/species_types/android.dm index fd6dd45a67c..73e27f55f63 100644 --- a/code/modules/mob/living/carbon/human/species_types/android.dm +++ b/code/modules/mob/living/carbon/human/species_types/android.dm @@ -20,6 +20,9 @@ O.brute_reduction = 5 O.burn_reduction = 4 + // Androids don't eat, hunger or metabolise foods. Let's do some cleanup. + C.set_safe_hunger_level() + /datum/species/android/on_species_loss(mob/living/carbon/C) . = ..() for(var/X in C.bodyparts) diff --git a/code/modules/mob/living/carbon/human/species_types/dullahan.dm b/code/modules/mob/living/carbon/human/species_types/dullahan.dm index f977dd0c4aa..fcd97492e47 100644 --- a/code/modules/mob/living/carbon/human/species_types/dullahan.dm +++ b/code/modules/mob/living/carbon/human/species_types/dullahan.dm @@ -35,6 +35,7 @@ var/obj/item/organ/eyes/E = H.getorganslot(ORGAN_SLOT_EYES) var/datum/action/item_action/organ_action/dullahan/D = locate() in E?.actions D?.Trigger() + H.set_safe_hunger_level() /datum/species/dullahan/on_species_loss(mob/living/carbon/human/H) H.flags_1 |= HEAR_1 diff --git a/code/modules/mob/living/carbon/human/species_types/ethereal.dm b/code/modules/mob/living/carbon/human/species_types/ethereal.dm index 47ace68b131..04204c21712 100644 --- a/code/modules/mob/living/carbon/human/species_types/ethereal.dm +++ b/code/modules/mob/living/carbon/human/species_types/ethereal.dm @@ -61,7 +61,7 @@ RegisterSignal(ethereal, COMSIG_ATOM_EMP_ACT, .proc/on_emp_act) ethereal_light = ethereal.mob_light() spec_updatehealth(ethereal) - + C.set_safe_hunger_level() /datum/species/ethereal/on_species_loss(mob/living/carbon/human/C, datum/species/new_species, pref_load) UnregisterSignal(C, COMSIG_ATOM_EMAG_ACT) diff --git a/code/modules/mob/living/carbon/human/species_types/plasmamen.dm b/code/modules/mob/living/carbon/human/species_types/plasmamen.dm index 726c58ff371..67fa9c481ef 100644 --- a/code/modules/mob/living/carbon/human/species_types/plasmamen.dm +++ b/code/modules/mob/living/carbon/human/species_types/plasmamen.dm @@ -34,6 +34,10 @@ // This effects how fast body temp stabilizes, also if cold resit is lost on the mob bodytemp_cold_damage_limit = (BODYTEMP_COLD_DAMAGE_LIMIT - 50) // about -50c +/datum/species/plasmaman/on_species_gain(mob/living/carbon/C, datum/species/old_species, pref_load) + . = ..() + C.set_safe_hunger_level() + /datum/species/plasmaman/spec_life(mob/living/carbon/human/H) var/atmos_sealed = CanIgniteMob(H) && (isclothing(H.wear_suit) && H.wear_suit.clothing_flags & STOPSPRESSUREDAMAGE) && (isclothing(H.head) && H.head.clothing_flags & STOPSPRESSUREDAMAGE) if(!atmos_sealed && (!istype(H.w_uniform, /obj/item/clothing/under/plasmaman) || !istype(H.head, /obj/item/clothing/head/helmet/space/plasmaman) || !istype(H.gloves, /obj/item/clothing/gloves))) diff --git a/code/modules/mob/living/carbon/human/species_types/shadowpeople.dm b/code/modules/mob/living/carbon/human/species_types/shadowpeople.dm index 0de6c827db1..462f5ab27c0 100644 --- a/code/modules/mob/living/carbon/human/species_types/shadowpeople.dm +++ b/code/modules/mob/living/carbon/human/species_types/shadowpeople.dm @@ -50,6 +50,7 @@ to_chat(C, "[info_text]") C.fully_replace_character_name(null, pick(GLOB.nightmare_names)) + C.set_safe_hunger_level() /datum/species/shadow/nightmare/bullet_act(obj/projectile/P, mob/living/carbon/human/H) var/turf/T = H.loc diff --git a/code/modules/mob/living/carbon/human/species_types/skeletons.dm b/code/modules/mob/living/carbon/human/species_types/skeletons.dm index d7663e777eb..7922ba18f55 100644 --- a/code/modules/mob/living/carbon/human/species_types/skeletons.dm +++ b/code/modules/mob/living/carbon/human/species_types/skeletons.dm @@ -18,6 +18,10 @@ changesource_flags = MIRROR_BADMIN | WABBAJACK | ERT_SPAWN species_language_holder = /datum/language_holder/skeleton +/datum/species/skeleton/on_species_gain(mob/living/carbon/C, datum/species/old_species, pref_load) + . = ..() + C.set_safe_hunger_level() + /datum/species/skeleton/check_roundstart_eligible() if(SSevents.holidays && SSevents.holidays[HALLOWEEN]) return TRUE diff --git a/code/modules/mob/living/carbon/human/species_types/synths.dm b/code/modules/mob/living/carbon/human/species_types/synths.dm index ee181800ef3..c8477d2fbc9 100644 --- a/code/modules/mob/living/carbon/human/species_types/synths.dm +++ b/code/modules/mob/living/carbon/human/species_types/synths.dm @@ -36,6 +36,7 @@ ..() assume_disguise(old_species, H) RegisterSignal(H, COMSIG_MOB_SAY, .proc/handle_speech) + H.set_safe_hunger_level() /datum/species/synth/on_species_loss(mob/living/carbon/human/H) . = ..() diff --git a/code/modules/mob/living/carbon/human/species_types/vampire.dm b/code/modules/mob/living/carbon/human/species_types/vampire.dm index b6a25d5ac7e..cb62182fd4e 100644 --- a/code/modules/mob/living/carbon/human/species_types/vampire.dm +++ b/code/modules/mob/living/carbon/human/species_types/vampire.dm @@ -16,9 +16,6 @@ var/info_text = "You are a Vampire. You will slowly but constantly lose blood if outside of a coffin. If inside a coffin, you will slowly heal. You may gain more blood by grabbing a live victim and using your drain ability." var/obj/effect/proc_holder/spell/targeted/shapeshift/bat/batform //attached to the datum itself to avoid cloning memes, and other duplicates - - - /datum/species/vampire/check_roundstart_eligible() if(SSevents.holidays && SSevents.holidays[HALLOWEEN]) return TRUE @@ -32,6 +29,7 @@ if(isnull(batform)) batform = new C.AddSpell(batform) + C.set_safe_hunger_level() /datum/species/vampire/on_species_loss(mob/living/carbon/C) . = ..() diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 38aea4ee178..085d121debd 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -1778,3 +1778,23 @@ /// Whether or not this mob will escape from storages while being picked up/held. /mob/living/proc/will_escape_storage() return FALSE + +/// Sets the mob's hunger levels to a safe overall level. Useful for TRAIT_NOHUNGER species changes. +/mob/living/proc/set_safe_hunger_level() + // Nutrition reset and alert clearing. + nutrition = NUTRITION_LEVEL_FED + clear_alert("nutrition") + satiety = 0 + + // Trait removal if obese + if(HAS_TRAIT_FROM(src, TRAIT_FAT, OBESITY)) + if(overeatduration >= 100) + to_chat(src, "Your transformation restores your body's natural fitness!") + + REMOVE_TRAIT(src, TRAIT_FAT, OBESITY) + remove_movespeed_modifier(/datum/movespeed_modifier/obesity) + update_inv_w_uniform() + update_inv_wear_suit() + + // Reset overeat duration. + overeatduration = 0