From c73f30c3e20eabfab3228165faa4986d4ce1c3be Mon Sep 17 00:00:00 2001 From: Ghom <42542238+Ghommie@users.noreply.github.com> Date: Sat, 12 Oct 2024 19:58:23 +0200 Subject: [PATCH] DNA Infusers now check for a datum trait instead of whether non-living objects are edible and have the GORE food type. (#87154) --- code/__DEFINES/traits/declarations.dm | 2 ++ code/_globalvars/traits/_traits.dm | 1 + code/datums/components/food/edible.dm | 9 +++++++++ code/game/machinery/dna_infuser/dna_infuser.dm | 8 ++------ code/modules/fishing/fish/_fish.dm | 3 +++ code/modules/fishing/fish/types/freshwater.dm | 2 +- code/modules/unit_tests/_unit_tests.dm | 2 +- .../{organ_set_bonus.dm => dna_infusion.dm} | 13 +++++++++++++ 8 files changed, 32 insertions(+), 8 deletions(-) rename code/modules/unit_tests/{organ_set_bonus.dm => dna_infusion.dm} (87%) diff --git a/code/__DEFINES/traits/declarations.dm b/code/__DEFINES/traits/declarations.dm index 08f87ac8d38..df85d95d86b 100644 --- a/code/__DEFINES/traits/declarations.dm +++ b/code/__DEFINES/traits/declarations.dm @@ -116,6 +116,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai #define TRAIT_RESISTHEAT "resist_heat" /// Trait for when you can no longer gain body heat #define TRAIT_HYPOTHERMIC "body_hypothermic" +/// This non-living object is valid to be used in dna infusers +#define TRAIT_VALID_DNA_INFUSION "valid_dna_infusion" ///For when you've gotten a power from a dna vault #define TRAIT_USED_DNA_VAULT "used_dna_vault" /// For when you want to be able to touch hot things, but still want fire to be an issue. diff --git a/code/_globalvars/traits/_traits.dm b/code/_globalvars/traits/_traits.dm index 84e9426fed0..ae9ca6ab4fb 100644 --- a/code/_globalvars/traits/_traits.dm +++ b/code/_globalvars/traits/_traits.dm @@ -43,6 +43,7 @@ GLOBAL_LIST_INIT(traits_by_type, list( "TRAIT_CHASM_STOPPER" = TRAIT_CHASM_STOPPER, "TRAIT_COMBAT_MODE_SKIP_INTERACTION" = TRAIT_COMBAT_MODE_SKIP_INTERACTION, "TRAIT_DEL_ON_SPACE_DUMP" = TRAIT_DEL_ON_SPACE_DUMP, + "TRAIT_VALID_DNA_INFUSION" = TRAIT_VALID_DNA_INFUSION, "TRAIT_FISH_CASE_COMPATIBILE" = TRAIT_FISH_CASE_COMPATIBILE, "TRAIT_FROZEN" = TRAIT_FROZEN, "TRAIT_HAS_LABEL" = TRAIT_HAS_LABEL, diff --git a/code/datums/components/food/edible.dm b/code/datums/components/food/edible.dm index 9e2964273fd..6651d923414 100644 --- a/code/datums/components/food/edible.dm +++ b/code/datums/components/food/edible.dm @@ -98,6 +98,9 @@ Behavior that's still missing from this component that original food items had t else if(isturf(parent) || isstructure(parent)) RegisterSignal(parent, COMSIG_ATOM_ATTACK_HAND, PROC_REF(TryToEatIt)) + if(foodtypes & GORE) + ADD_TRAIT(parent, TRAIT_VALID_DNA_INFUSION, REF(src)) + /datum/component/edible/UnregisterFromParent() UnregisterSignal(parent, list( COMSIG_ATOM_ATTACK_ANIMAL, @@ -114,6 +117,9 @@ Behavior that's still missing from this component that original food items had t qdel(GetComponent(/datum/component/connect_loc_behalf)) + if(foodtypes & GORE) + REMOVE_TRAIT(parent, TRAIT_VALID_DNA_INFUSION, REF(src)) + /datum/component/edible/InheritComponent( datum/component/edible/old_comp, i_am_original, @@ -138,6 +144,9 @@ Behavior that's still missing from this component that original food items had t tastes = old_comp.tastes eatverbs = old_comp.eatverbs + if(foodtypes & GORE) + ADD_TRAIT(parent, TRAIT_VALID_DNA_INFUSION, REF(src)) + // only edit if we're OG if(!i_am_original) return diff --git a/code/game/machinery/dna_infuser/dna_infuser.dm b/code/game/machinery/dna_infuser/dna_infuser.dm index 961092c635b..ccc24d44f6e 100644 --- a/code/game/machinery/dna_infuser/dna_infuser.dm +++ b/code/game/machinery/dna_infuser/dna_infuser.dm @@ -210,7 +210,6 @@ /// Verify that the given infusion source/mob is a dead creature. /obj/machinery/dna_infuser/proc/is_valid_infusion(atom/movable/target, mob/user) - var/datum/component/edible/food_comp = IS_EDIBLE(target) if(infusing_from) balloon_alert(user, "empty the machine first!") return FALSE @@ -219,11 +218,8 @@ if(living_target.stat != DEAD) balloon_alert(user, "only dead creatures!") return FALSE - else if(food_comp) - if(!(food_comp.foodtypes & GORE)) - balloon_alert(user, "only creatures!") - return FALSE - else + else if(!HAS_TRAIT(target, TRAIT_VALID_DNA_INFUSION)) + balloon_alert(user, "only creatures!") return FALSE return TRUE diff --git a/code/modules/fishing/fish/_fish.dm b/code/modules/fishing/fish/_fish.dm index c8f3cddc2f3..b3fbb91b468 100644 --- a/code/modules/fishing/fish/_fish.dm +++ b/code/modules/fishing/fish/_fish.dm @@ -173,6 +173,9 @@ ADD_TRAIT(src, TRAIT_UNCOMPOSTABLE, REF(src)) //Composting a food that is not real food wouldn't work anyway. START_PROCESSING(SSobj, src) + //Adding this because not all fish have the gore foodtype that makes them automatically eligible for dna infusion. + ADD_TRAIT(src, TRAIT_VALID_DNA_INFUSION, INNATE_TRAIT) + //stops new fish from being able to reproduce right away. breeding_wait = world.time + (breeding_timeout * NEW_FISH_BREEDING_TIMEOUT_MULT) last_feeding = world.time - (feeding_frequency * NEW_FISH_LAST_FEEDING_MULT) diff --git a/code/modules/fishing/fish/types/freshwater.dm b/code/modules/fishing/fish/types/freshwater.dm index fe0ff437c7d..75d4891b4f0 100644 --- a/code/modules/fishing/fish/types/freshwater.dm +++ b/code/modules/fishing/fish/types/freshwater.dm @@ -175,7 +175,7 @@ /obj/item/fish/tadpole/Initialize(mapload, apply_qualities = TRUE) . = ..() - AddComponent(/datum/component/fish_growth, /mob/living/basic/frog, rand(2.5, 3 MINUTES)) + AddComponent(/datum/component/fish_growth, /mob/living/basic/frog, rand(2 MINUTES, 3 MINUTES)) RegisterSignal(src, COMSIG_FISH_BEFORE_GROWING, PROC_REF(growth_checks)) RegisterSignal(src, COMSIG_FISH_FINISH_GROWING, PROC_REF(on_growth)) diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index bf218c12099..b1461334f06 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -135,6 +135,7 @@ #include "dcs_get_id_from_elements.dm" #include "designs.dm" #include "dismemberment.dm" +#include "dna_infusion.dm" #include "door_access.dm" #include "dragon_expiration.dm" #include "drink_icons.dm" @@ -211,7 +212,6 @@ #include "operating_table.dm" #include "orderable_items.dm" #include "organ_bodypart_shuffle.dm" -#include "organ_set_bonus.dm" #include "organs.dm" #include "orphaned_genturf.dm" #include "outfit_sanity.dm" diff --git a/code/modules/unit_tests/organ_set_bonus.dm b/code/modules/unit_tests/dna_infusion.dm similarity index 87% rename from code/modules/unit_tests/organ_set_bonus.dm rename to code/modules/unit_tests/dna_infusion.dm index 8e2c65270f7..0df63be644b 100644 --- a/code/modules/unit_tests/organ_set_bonus.dm +++ b/code/modules/unit_tests/dna_infusion.dm @@ -1,3 +1,16 @@ +///Check that input types that aren't living mobs have the TRAIT_VALID_DNA_INFUSION trait +/datum/unit_test/valid_dna_infusion + +/datum/unit_test/valid_dna_infusion/Run() + for(var/datum/infuser_entry/infuser_entry as anything in flatten_list(GLOB.infuser_entries)) + for(var/input_type as anything in infuser_entry.input_obj_or_mob) + if(ispath(input_type, /mob/living)) + continue + var/atom/movable/movable = allocate(input_type) + if(!HAS_TRAIT(movable, TRAIT_VALID_DNA_INFUSION)) + //TEST_FAIL() doesn't early return the unit test so we can keep checking. + TEST_FAIL("[input_type] is in the 'input_obj_or_mob' list for [infuser_entry.type] but doesn't have TRAIT_VALID_DNA_INFUSION.") + /// Checks that all "organ_set_bonus" status effects have unique "id" vars. /// Required to ensure that the status effects are treated as "unique". /datum/unit_test/organ_set_bonus_id