From 81012494d1da5f87a3acb2080be3a05d4382148f Mon Sep 17 00:00:00 2001 From: kawoppi <94711066+kawoppi@users.noreply.github.com> Date: Fri, 9 Dec 2022 19:27:09 +0100 Subject: [PATCH] Fixes many basic mobs not being vulnerable to extreme atmospheres and temperatures by making it the default (#71817) ## About The Pull Request **In short:** This PR causes cows, pigs, rabbits, sheep, cockroaches, mothroaches and mice to take damage in dangerous atmospheres and temperatures. **In long:** So simple mobs take damage from extreme atmospheres and temperatures by default, this is not the case with basic mobs however. Basic mobs can be given the `atmos_requirements` and `basic_body_temp_sensitive` elements to accomplish this, but these are missing on a number of basic mobs that probably shouldn't be able to survive in space. This PR gives basic mobs the `atmos_requirements` and `basic_body_temp_sensitive` elements by default, using the same values as default simple mobs do. These values have been overridden in the cases where this was done by the original simple mob (cockroaches and lavaland mobs) or where the basic mob already had one of the elements with different values (space bunnies and void puppies). Not every mob is vulnerable to temperature or atmosphere though. Setting `unsuitable_atmos_damage` to 0 will make it so the mob isn't given the `atmos_requirements` element. Setting both `minimum_survivable_temperature` and `maximum_survivable_temperature` to 0 will make it so the mob isn't given the `basic_body_temp_sensitive` element. I'm not sure if this is the best way of doing this. I don't know if mobs dying to extreme atmos/temp by default was left behind with simple mobs for a reason or if it was just forgotten about. ## Why It's Good For The Game Cows, pigs, rabbits, sheep, cockroaches, mothroaches and mice are probably not intended to be space-faring animals. Basic mobs matching the same default atmosphere and temperature vulnerabilities as simple mobs makes it harder to overlook that when porting them to basic mobs. ## Changelog :cl: fix: cows, pigs, rabbits, sheep, cockroaches, mothroaches and mice now take damage in hazardous atmospheres and temperatures /:cl: --- code/modules/mob/living/basic/basic.dm | 22 +++++++++++++++ .../mob/living/basic/farm_animals/rabbit.dm | 27 +++++-------------- .../mob/living/basic/lavaland/mining.dm | 4 ++- code/modules/mob/living/basic/pets/dog.dm | 6 ++--- code/modules/mob/living/basic/pets/pet.dm | 15 ----------- .../living/basic/ruin_defender/stickman.dm | 17 +++--------- .../mob/living/basic/vermin/axolotl.dm | 14 ---------- .../mob/living/basic/vermin/cockroach.dm | 4 +++ 8 files changed, 41 insertions(+), 68 deletions(-) diff --git a/code/modules/mob/living/basic/basic.dm b/code/modules/mob/living/basic/basic.dm index 232490128e0..1c08976beb0 100644 --- a/code/modules/mob/living/basic/basic.dm +++ b/code/modules/mob/living/basic/basic.dm @@ -85,6 +85,20 @@ ///Sentience type, for slime potions. SHOULD BE AN ELEMENT BUT I DONT CARE ABOUT IT FOR NOW var/sentience_type = SENTIENCE_ORGANIC + ///Leaving something at 0 means it's off - has no maximum. + var/list/habitable_atmos = list("min_oxy" = 5, "max_oxy" = 0, "min_plas" = 0, "max_plas" = 1, "min_co2" = 0, "max_co2" = 5, "min_n2" = 0, "max_n2" = 0) + ///This damage is taken when atmos doesn't fit all the requirements above. Set to 0 to avoid adding the atmos_requirements element. + var/unsuitable_atmos_damage = 1 + + ///Minimal body temperature without receiving damage + var/minimum_survivable_temperature = 250 + ///Maximal body temperature without receiving damage + var/maximum_survivable_temperature = 350 + ///This damage is taken when the body temp is too cold. Set both this and unsuitable_heat_damage to 0 to avoid adding the basic_body_temp_sensitive element. + var/unsuitable_cold_damage = 1 + ///This damage is taken when the body temp is too hot. Set both this and unsuitable_cold_damage to 0 to avoid adding the basic_body_temp_sensitive element. + var/unsuitable_heat_damage = 1 + /mob/living/basic/Initialize(mapload) . = ..() @@ -102,6 +116,14 @@ if(speak_emote) speak_emote = string_list(speak_emote) + if(unsuitable_atmos_damage != 0) + //String assoc list returns a cached list, so this is like a static list to pass into the element below. + habitable_atmos = string_assoc_list(habitable_atmos) + AddElement(/datum/element/atmos_requirements, habitable_atmos, unsuitable_atmos_damage) + + if(unsuitable_cold_damage != 0 && unsuitable_heat_damage != 0) + AddElement(/datum/element/basic_body_temp_sensitive, minimum_survivable_temperature, maximum_survivable_temperature, unsuitable_cold_damage, unsuitable_heat_damage) + /mob/living/basic/Life(delta_time = SSMOBS_DT, times_fired) . = ..() ///Automatic stamina re-gain diff --git a/code/modules/mob/living/basic/farm_animals/rabbit.dm b/code/modules/mob/living/basic/farm_animals/rabbit.dm index 78095d6f585..7677e6a98fd 100644 --- a/code/modules/mob/living/basic/farm_animals/rabbit.dm +++ b/code/modules/mob/living/basic/farm_animals/rabbit.dm @@ -31,6 +31,8 @@ attack_verb_continuous = "kicks" attack_verb_simple = "kick" butcher_results = list(/obj/item/food/meat/slab = 1) + unsuitable_cold_damage = 0.5 // Cold damage is 0.5 here to account for low health on the rabbit. + unsuitable_heat_damage = 0.5 // Heat damage is 0.5 here to account for low health on the rabbit. ai_controller = /datum/ai_controller/basic_controller/rabbit /// passed to animal_varity as the prefix icon. var/icon_prefix = "rabbit" @@ -85,27 +87,10 @@ icon_dead = "space_rabbit_white_dead" icon_prefix = "space_rabbit" ai_controller = /datum/ai_controller/basic_controller/rabbit/easter/space - // Minimum Allowable Body Temp, zero because we are meant to survive in space and we have a fucking RABBIT SPACE MASK. - var/minimum_survivable_temperature = 0 - // Maximum Allowable Body Temp, 1500 because we might overheat and die in said RABBIT SPACE MASK. - var/maximum_survivable_temperature = 1500 - -/mob/living/basic/rabbit/easter/space/Initialize(mapload) - . = ..() - // string_assoc_list returns a cached list, which we then use as a static list to pass into the below AddElement - var/list/habitable_atmos = string_assoc_list(list( - "min_oxy" = 0, - "max_oxy" = 0, - "min_plas" = 0, - "max_plas" = 0, - "min_co2" = 0, - "max_co2" = 0, - "min_n2" = 0, - "max_n2" = 0, - )) - AddElement(/datum/element/atmos_requirements, atmos_requirements = habitable_atmos, unsuitable_atmos_damage = 0) - // heat_damage is 0.5 here to account for low health on the rabbit. - AddElement(/datum/element/basic_body_temp_sensitive, min_body_temp = minimum_survivable_temperature, max_body_temp = maximum_survivable_temperature, cold_damage = 0, heat_damage = 0.5) + unsuitable_atmos_damage = 0 // Zero because we are meant to survive in space. + minimum_survivable_temperature = 0 // Minimum Allowable Body Temp, zero because we are meant to survive in space and we have a fucking RABBIT SPACE MASK. + maximum_survivable_temperature = 1500 // Maximum Allowable Body Temp, 1500 because we might overheat and die in said RABBIT SPACE MASK. + unsuitable_cold_damage = 0 // Zero because we are meant to survive in space. /datum/ai_controller/basic_controller/rabbit/easter/space planning_subtrees = list(/datum/ai_planning_subtree/random_speech/rabbit/easter/space) diff --git a/code/modules/mob/living/basic/lavaland/mining.dm b/code/modules/mob/living/basic/lavaland/mining.dm index 66900814b5d..c34c16d8545 100644 --- a/code/modules/mob/living/basic/lavaland/mining.dm +++ b/code/modules/mob/living/basic/lavaland/mining.dm @@ -3,10 +3,12 @@ combat_mode = TRUE faction = list("mining") + unsuitable_atmos_damage = 0 + minimum_survivable_temperature = 0 + maximum_survivable_temperature = INFINITY /mob/living/basic/mining/Initialize(mapload) . = ..() ADD_TRAIT(src, TRAIT_LAVA_IMMUNE, INNATE_TRAIT) ADD_TRAIT(src, TRAIT_ASHSTORM_IMMUNE, INNATE_TRAIT) AddElement(/datum/element/mob_killed_tally, "mobs_killed_mining") - AddElement(/datum/element/basic_body_temp_sensitive, max_body_temp = INFINITY) diff --git a/code/modules/mob/living/basic/pets/dog.dm b/code/modules/mob/living/basic/pets/dog.dm index 71f6c4a5e00..e8d7ee702e0 100644 --- a/code/modules/mob/living/basic/pets/dog.dm +++ b/code/modules/mob/living/basic/pets/dog.dm @@ -711,13 +711,13 @@ GLOBAL_LIST_INIT(strippable_corgi_items, create_strippable_list(list( icon_dead = "void_puppy_dead" nofur = TRUE held_state = "void_puppy" + unsuitable_atmos_damage = 0 + minimum_survivable_temperature = TCMB + maximum_survivable_temperature = T0C + 40 /mob/living/basic/pet/dog/corgi/puppy/void/Initialize(mapload) . = ..() ADD_TRAIT(src, TRAIT_AI_BAGATTACK, INNATE_TRAIT) - RemoveElement(/datum/element/atmos_requirements) - RemoveElement(/datum/element/basic_body_temp_sensitive) - AddElement(/datum/element/basic_body_temp_sensitive, TCMB, T0C + 40) /mob/living/basic/pet/dog/corgi/puppy/void/Process_Spacemove(movement_dir = 0, continuous_move = FALSE) return 1 //Void puppies can navigate space. diff --git a/code/modules/mob/living/basic/pets/pet.dm b/code/modules/mob/living/basic/pets/pet.dm index ea8181628b3..3f67e56f179 100644 --- a/code/modules/mob/living/basic/pets/pet.dm +++ b/code/modules/mob/living/basic/pets/pet.dm @@ -17,21 +17,6 @@ /mob/living/basic/pet/Initialize(mapload) . = ..() - // String assoc list returns a cached list, so this is like a static list to pass into the element below. - var/static/list/habitable_atmos = list( - "min_oxy" = 5, - "max_oxy" = 0, - "min_plas" = 0, - "max_plas" = 1, - "min_co2" = 0, - "max_co2" = 5, - "min_n2" = 0, - "max_n2" = 0, - ) - - AddElement(/datum/element/atmos_requirements, atmos_requirements = habitable_atmos, unsuitable_atmos_damage = 1) - AddElement(/datum/element/basic_body_temp_sensitive) - /// Can set the collar var beforehand to start the pet with a collar. if(collar) collar = new(src) diff --git a/code/modules/mob/living/basic/ruin_defender/stickman.dm b/code/modules/mob/living/basic/ruin_defender/stickman.dm index be3424105d0..68e2b50d1c7 100644 --- a/code/modules/mob/living/basic/ruin_defender/stickman.dm +++ b/code/modules/mob/living/basic/ruin_defender/stickman.dm @@ -16,26 +16,15 @@ attack_sound = 'sound/weapons/punch1.ogg' combat_mode = TRUE faction = list("stickman") + unsuitable_atmos_damage = 7.5 + unsuitable_cold_damage = 7.5 + unsuitable_heat_damage = 7.5 ai_controller = /datum/ai_controller/basic_controller/stickman /mob/living/basic/stickman/Initialize(mapload) . = ..() - // String assoc list returns a cached list, so this is like a static list to pass into the element below. - var/list/habitable_atmos = string_assoc_list(list( - "min_oxy" = 5, - "max_oxy" = 0, - "min_plas" = 0, - "max_plas" = 1, - "min_co2" = 0, - "max_co2" = 5, - "min_n2" = 0, - "max_n2" = 0, - )) - new /obj/effect/temp_visual/paper_scatter(get_turf(src)) - AddElement(/datum/element/basic_body_temp_sensitive, cold_damage = 7.5, heat_damage = 7.5) - AddElement(/datum/element/atmos_requirements, atmos_requirements = habitable_atmos, unsuitable_atmos_damage = 7.5) /datum/ai_controller/basic_controller/stickman blackboard = list( diff --git a/code/modules/mob/living/basic/vermin/axolotl.dm b/code/modules/mob/living/basic/vermin/axolotl.dm index 63fa841c622..a56f1df5909 100644 --- a/code/modules/mob/living/basic/vermin/axolotl.dm +++ b/code/modules/mob/living/basic/vermin/axolotl.dm @@ -35,20 +35,6 @@ . = ..() ADD_TRAIT(src, TRAIT_VENTCRAWLER_ALWAYS, INNATE_TRAIT) - var/list/habitable_atmos = string_assoc_list(list( - "min_oxy" = 5, - "max_oxy" = 0, - "min_plas" = 0, - "max_plas" = 1, - "min_co2" = 0, - "max_co2" = 5, - "min_n2" = 0, - "max_n2" = 0, - )) - - AddElement(/datum/element/atmos_requirements, habitable_atmos, unsuitable_atmos_damage = 1) - AddElement(/datum/element/basic_body_temp_sensitive) - /datum/ai_controller/basic_controller/axolotl ai_traits = STOP_MOVING_WHEN_PULLED ai_movement = /datum/ai_movement/basic_avoidance diff --git a/code/modules/mob/living/basic/vermin/cockroach.dm b/code/modules/mob/living/basic/vermin/cockroach.dm index 79d0d2e1c39..71b1fbf67f2 100644 --- a/code/modules/mob/living/basic/vermin/cockroach.dm +++ b/code/modules/mob/living/basic/vermin/cockroach.dm @@ -25,6 +25,10 @@ basic_mob_flags = DEL_ON_DEATH faction = list("hostile", FACTION_MAINT_CREATURES) + unsuitable_atmos_damage = 0 + minimum_survivable_temperature = 270 + maximum_survivable_temperature = INFINITY + ai_controller = /datum/ai_controller/basic_controller/cockroach var/cockroach_cell_line = CELL_LINE_TABLE_COCKROACH