Fixes ooze eating (#61029)

Oozes now properly communicates with the edible component to be able to eat objects.
This commit is contained in:
AMonkeyThatCodes
2021-09-24 13:39:46 +01:00
committed by GitHub
parent f13dd0695d
commit 1126f22073
3 changed files with 26 additions and 34 deletions
@@ -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("<span class='warning>[src] eats [eaten_atom]!</span>", span_notice("You eat [eaten_atom]."))
playsound(loc,'sound/items/eatfood.ogg', rand(30,50), TRUE)
qdel(eaten_atom)
/mob/living/simple_animal/hostile/ooze/proc/eat_atom(atom/eat_target, silent)
if(SEND_SIGNAL(eat_target, COMSIG_OOZE_EAT_ATOM, src, edible_food_types) & COMPONENT_ATOM_EATEN)
return
if(silent || !isitem(eat_target)) //Don't bother reporting it for everything
return
to_chat(src, span_warning("[eat_target] cannot be eaten!"))
///Updates the display that shows the mobs nutrition
/mob/living/simple_animal/hostile/ooze/proc/updateNutritionDisplay()
@@ -289,6 +275,7 @@
melee_damage_upper = 12
obj_damage = 15
deathmessage = "deflates and spills its vital juices!"
edible_food_types = MEAT | VEGETABLES
///The ability lets you envelop a carbon in a healing cocoon. Useful for saving critical carbons.
var/datum/action/cooldown/gel_cocoon/gel_cocoon
///The ability to shoot a mending globule, a sticky projectile that heals over time.
@@ -306,15 +293,6 @@
QDEL_NULL(gel_cocoon)
QDEL_NULL(globules)
/mob/living/simple_animal/hostile/ooze/grapes/check_edible(atom/movable/potential_food)
if(ismob(potential_food))
return FALSE
var/foodtype
if(istype(potential_food, /obj/item/reagent_containers/food))
var/obj/item/reagent_containers/food/meal = potential_food
foodtype = meal.foodtype
return foodtype & MEAT || foodtype & VEGETABLES //Dont forget to add edible component compat here later
/mob/living/simple_animal/hostile/ooze/grapes/add_cell_sample()
AddElement(/datum/element/swabable, CELL_LINE_TABLE_GRAPE, CELL_VIRUS_TABLE_GENERIC_MOB, 1, 5)