Files
Bubberstation/code/datums/elements/basic_eating.dm
Jacquerel 940e2d31cf tgstation is back online and you are a horrible goose (#89204)
## About The Pull Request

Converts geese to basic mobs.
Nobody else did this one because two separate other developers have said
they started and then examining what the goose does made them feel
mildly ill, but I am stronger.

I will admit though I wasn't 100% committed to making it work exactly
the same way, I rewrote the entire system to use interfaces I like more
(read: I put all this shit in a status effect which means any mob can be
given the ability to vomit out everything in its contents) and if that
means the behaviour is only "inspired by" that didn't bother me that
much.

**Geese:**
- Wander randomly around.
- Peck people who attack them.
- Occasionally start pecking other nearby animals for absolutely no
reason.
- Eat any food they randomly wander within one tile of, but don't seek
it out further than that.
- Eat anything made of plastic that they randomly wander within one tile
of.
- Choke to death over 30 seconds if they eat anything made of plastic.
- Vomit out whatever it was that they choked on when they die.
- Honk (this is new).

The more famous subtype of goose is Birdboat. Birdboat is a unique goose
present on several maps with some additional behaviour.

**Birdboat:**
- Is chill and doesn't start pecking people for no reason.
- Is occasionally possessed by ghosts.
- Builds up an internal vomit-meter as he eats things. Moving around and
just sort of generally hanging will start rolling dice to find out when
Birdboat's tummy gets upset.
- May start vomiting instead of choking to death on plastic, thereby
saving his own life.
- Vomits out everything that he just ate while running around, making a
mess of the floor.
- Starts eating everything he just vomited out again.

Unlike regular geese who just eat your food and it's gone, Birdboat's
miraculous digestion preserves all of the food he eats so if he consumes
the entire kitchen counter it will eventually come back out again the
way it went in. Although you might not want to eat it any more.

The precise way in which this manifests may be slightly different, but
largely this is also what these animals did before.

Other stuff:

I noticed a bunch of find/set behaviours were not setting a search
range? I think that means they were never finding anything?
I did not actually test any of them to see if they were broken, but it's
possible that a bunch of broken AI behaviours like "climbing trees" may
now actually start triggering because they have a search radius greater
than an orange of 0.

I added "keep this in contents instead of deleting it" as a parameter
for generic eating and slapped it on the goldgrub, as it is used in two
places and may end up being used in more.

## Why It's Good For The Game

This kills off the last user of the `retaliate` subtype and makes our
list so so much closer to finish.
It's like... a couple of bots, a handful of oddballs (I'll probably
handle these soon), and then just the mining bosses and minibosses to
go.

If you give a human the vomit goose ability (now that I made it work on
any mob) they will eject all their organs and body parts via the mouth
until they die, if you don't do the brain or heart first you can vomit
your own head off.

## Changelog

🆑
refactor: Geese have been moved to the basic mob subsystem, please
report any unusual behaviour.
/🆑

---------

Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com>
2025-01-27 14:54:34 +02:00

114 lines
3.8 KiB
Plaintext

/**
* ## basic eating element!
*
* Small behavior for non-carbons to eat certain stuff they interact with
*/
/datum/element/basic_eating
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
/// Amount to heal
var/heal_amt
/// Amount to hurt
var/damage_amount
/// Type of hurt to apply
var/damage_type
/// Whether to flavor it as drinking rather than eating.
var/drinking
/// If true, we put food in our tummy instead of deleting it
var/add_to_contents
/// Types the animal can eat.
var/list/food_types
/datum/element/basic_eating/Attach(datum/target, heal_amt = 0, damage_amount = 0, damage_type = null, drinking = FALSE, add_to_contents = FALSE, food_types = list())
. = ..()
if(!isliving(target))
return ELEMENT_INCOMPATIBLE
ADD_TRAIT(target, TRAIT_MOB_EATER, REF(src))
src.heal_amt = heal_amt
src.damage_amount = damage_amount
src.damage_type = damage_type
src.drinking = drinking
src.add_to_contents = add_to_contents
src.food_types = food_types
RegisterSignal(target, COMSIG_ATOM_ITEM_INTERACTION, PROC_REF(try_feed))
RegisterSignal(target, COMSIG_LIVING_UNARMED_ATTACK, PROC_REF(on_unarm_attack))
/datum/element/basic_eating/Detach(datum/target)
REMOVE_TRAIT(target, TRAIT_MOB_EATER, REF(src))
UnregisterSignal(target, list(
COMSIG_LIVING_UNARMED_ATTACK,
COMSIG_ATOM_ITEM_INTERACTION,
))
return ..()
/datum/element/basic_eating/proc/try_feed(atom/source, mob/living/user, atom/possible_food)
SIGNAL_HANDLER
if(user.combat_mode || !is_type_in_list(possible_food, food_types))
return NONE
var/mob/living/living_source = source
if(living_source.stat != CONSCIOUS)
return NONE
return try_eating(source, possible_food, user) ? ITEM_INTERACT_SUCCESS : NONE
/datum/element/basic_eating/proc/on_unarm_attack(mob/living/eater, atom/target, proximity, modifiers)
SIGNAL_HANDLER
if(!proximity)
return NONE
if(try_eating(eater, target))
return COMPONENT_CANCEL_ATTACK_CHAIN
return NONE
/datum/element/basic_eating/proc/try_eating(mob/living/eater, atom/target, mob/living/feeder)
if(!is_type_in_list(target, food_types))
return FALSE
if(SEND_SIGNAL(eater, COMSIG_MOB_PRE_EAT, target, feeder) & COMSIG_MOB_CANCEL_EAT)
return FALSE
if(add_to_contents && !ismovable(target))
return FALSE
var/eat_verb
if(drinking)
eat_verb = pick("slurp","sip","guzzle","drink","quaff","suck")
else
eat_verb = pick("bite","chew","nibble","gnaw","gobble","chomp")
if (heal_amt > 0)
var/healed = heal_amt && eater.health < eater.maxHealth
eater.heal_overall_damage(heal_amt)
eater.visible_message(span_notice("[eater] [eat_verb]s [target]."), span_notice("You [eat_verb] [target][healed ? ", restoring some health" : ""]."))
else if (damage_amount > 0 && damage_type)
eater.apply_damage(damage_amount, damage_type)
eater.visible_message(span_notice("[eater] [eat_verb]s [target], and seems to hurt itself."), span_notice("You [eat_verb] [target], hurting yourself in the process."))
else
eater.visible_message(span_notice("[eater] [eat_verb]s [target]."), span_notice("You [eat_verb] [target]."))
finish_eating(eater, target, feeder)
return TRUE
/datum/element/basic_eating/proc/finish_eating(mob/living/eater, atom/target, mob/living/feeder)
set waitfor = FALSE
if(drinking)
playsound(eater.loc,'sound/items/drink.ogg', rand(10,50), TRUE)
else
playsound(eater.loc,'sound/items/eatfood.ogg', rand(10,50), TRUE)
var/atom/final_target = target
if(SEND_SIGNAL(eater, COMSIG_MOB_ATE, final_target, feeder) & COMSIG_MOB_TERMINATE_EAT)
return
if(isstack(target)) //if stack, only consume 1
var/obj/item/stack/food_stack = target
final_target = food_stack.split_stack(eater, 1)
eater.log_message("has eaten [target], [add_to_contents ? "swallowing it" : "destroying it"]!", LOG_ATTACK)
if (add_to_contents)
var/atom/movable/movable_target = final_target
movable_target.forceMove(eater)
else
qdel(final_target)