diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index 9c2adec4b12..1ca2d4af927 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -1339,7 +1339,9 @@ #define COMSIG_HUMAN_EARLY_UNARMED_ATTACK "human_early_unarmed_attack" ///from mob/living/carbon/human/UnarmedAttack(): (atom/target, proximity, modifiers) #define COMSIG_HUMAN_MELEE_UNARMED_ATTACK "human_melee_unarmed_attack" - +///FROM mob/living/simple_animal/hostile/ooze/eat_atom(): (atom/target, edible_flags) +#define COMSIG_OOZE_EAT_ATOM "ooze_eat_atom" + #define COMPONENT_ATOM_EATEN (1<<0) // Aquarium related signals diff --git a/code/datums/components/food/edible.dm b/code/datums/components/food/edible.dm index 9898a26d40e..bf7ae30a5e6 100644 --- a/code/datums/components/food/edible.dm +++ b/code/datums/components/food/edible.dm @@ -70,6 +70,7 @@ Behavior that's still missing from this component that original food items had t RegisterSignal(parent, COMSIG_ATOM_CREATEDBY_PROCESSING, .proc/OnProcessed) RegisterSignal(parent, COMSIG_ITEM_MICROWAVE_COOKED, .proc/OnMicrowaveCooked) RegisterSignal(parent, COMSIG_EDIBLE_INGREDIENT_ADDED, .proc/edible_ingredient_added) + RegisterSignal(parent, COMSIG_OOZE_EAT_ATOM, .proc/on_ooze_eat) var/static/list/loc_connections = list( COMSIG_ATOM_ENTERED = .proc/on_entered, @@ -485,3 +486,14 @@ Behavior that's still missing from this component that original food items had t tastes[t] += E.tastes[t] foodtypes |= E.foodtypes +/// Response to oozes trying to eat something edible +/datum/component/edible/proc/on_ooze_eat(datum/source, mob/eater, edible_flags) + SIGNAL_HANDLER + + if(foodtypes & edible_flags) + var/atom/eaten_food = parent + eaten_food.reagents.trans_to(eater, eaten_food.reagents.total_volume, transfered_by = eater) + eater.visible_message(span_warning("[src] eats [eaten_food]!"), span_notice("You eat [eaten_food].")) + playsound(get_turf(eater),'sound/items/eatfood.ogg', rand(30,50), TRUE) + qdel(eaten_food) + return COMPONENT_ATOM_EATEN diff --git a/code/modules/mob/living/simple_animal/hostile/ooze.dm b/code/modules/mob/living/simple_animal/hostile/ooze.dm index f57c2b1fbc5..b850e83f34b 100644 --- a/code/modules/mob/living/simple_animal/hostile/ooze.dm +++ b/code/modules/mob/living/simple_animal/hostile/ooze.dm @@ -31,6 +31,8 @@ var/ooze_nutrition = 50 var/ooze_nutrition_loss = -0.15 var/ooze_metabolism_modifier = 2 + ///Bitfield of edible food types + var/edible_food_types = MEAT /mob/living/simple_animal/hostile/ooze/Initialize() . = ..() @@ -39,21 +41,12 @@ ADD_TRAIT(src, TRAIT_VENTCRAWLER_ALWAYS, INNATE_TRAIT) /mob/living/simple_animal/hostile/ooze/attacked_by(obj/item/I, mob/living/user) - if(!check_edible(I)) + if(!eat_atom(I, TRUE)) return ..() - eat_atom(I) /mob/living/simple_animal/hostile/ooze/AttackingTarget(atom/attacked_target) - if(!check_edible(attacked_target)) + if(!eat_atom(attacked_target)) return ..() - eat_atom(attacked_target) - -/mob/living/simple_animal/hostile/ooze/UnarmedAttack(atom/A, proximity_flag, list/modifiers) - if(HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) - return - if(!check_edible(A)) - return ..() - eat_atom(A) ///Handles nutrition gain/loss of mob and also makes it take damage if it's too low on nutrition, only happens for sentient mobs. /mob/living/simple_animal/hostile/ooze/Life(delta_time = SSMOBS_DT, times_fired) @@ -77,25 +70,18 @@ if(ooze_nutrition <= 0) adjustBruteLoss(0.25 * delta_time) -///Returns whether or not the supplied movable atom is edible. -/mob/living/simple_animal/hostile/ooze/proc/check_edible(atom/movable/potential_food) - if(ismob(potential_food)) - return FALSE - if(istype(potential_food, /obj/item/reagent_containers/food)) - var/obj/item/reagent_containers/food/meal = potential_food - return (meal.foodtype & MEAT) //Dont forget to add edible component compat here later - ///Does ooze_nutrition + supplied amount and clamps it within 0 and 500 /mob/living/simple_animal/hostile/ooze/proc/adjust_ooze_nutrition(amount) ooze_nutrition = clamp(ooze_nutrition + amount, 0, 500) updateNutritionDisplay() ///Tries to transfer the atoms reagents then delete it -/mob/living/simple_animal/hostile/ooze/proc/eat_atom(obj/item/eaten_atom) - eaten_atom.reagents.trans_to(src, eaten_atom.reagents.total_volume, transfered_by = src) - src.visible_message("