Skip to content

Commit

Permalink
Oh, but we are not done yet! (must fix more!)
Browse files Browse the repository at this point in the history
  • Loading branch information
Syndicat-Meow committed Dec 26, 2024
1 parent c0fcaec commit 573ce7b
Show file tree
Hide file tree
Showing 24 changed files with 271 additions and 295 deletions.
22 changes: 22 additions & 0 deletions code/__DEFINES/dcs/signals/signals_atom/signals_atom_x_act.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@
///from obj/machinery/bsa/full/proc/fire(): ()
#define COMSIG_ATOM_BSA_BEAM "atom_bsa_beam_pass"
#define COMSIG_ATOM_BLOCKS_BSA_BEAM (1<<0)

/// Sent from [atom/proc/item_interaction], when this atom is left-clicked on by a mob with an item
/// Sent from the very beginning of the click chain, intended for generic atom-item interactions
/// Args: (mob/living/user, obj/item/tool, list/modifiers)
/// Return any ITEM_INTERACT_ flags as relevant (see tools.dm)
#define COMSIG_ATOM_ITEM_INTERACTION "atom_item_interaction"
/// Sent from [atom/proc/item_interaction], when this atom is right-clicked on by a mob with an item
/// Sent from the very beginning of the click chain, intended for generic atom-item interactions
/// Args: (mob/living/user, obj/item/tool, list/modifiers)
/// Return any ITEM_INTERACT_ flags as relevant (see tools.dm)
#define COMSIG_ATOM_ITEM_INTERACTION_SECONDARY "atom_item_interaction_secondary"
/// Sent from [atom/proc/item_interaction], to a mob clicking on an atom with an item
#define COMSIG_USER_ITEM_INTERACTION "user_item_interaction"
/// Sent from [atom/proc/item_interaction], to an item clicking on an atom
/// Args: (mob/living/user, atom/interacting_with, list/modifiers)
/// Return any ITEM_INTERACT_ flags as relevant (see tools.dm)
#define COMSIG_ITEM_INTERACTING_WITH_ATOM "item_interacting_with_atom"
/// Sent from [atom/proc/item_interaction], to an item right-clicking on an atom
/// Args: (mob/living/user, atom/interacting_with, list/modifiers)
/// Return any ITEM_INTERACT_ flags as relevant (see tools.dm)
#define COMSIG_ITEM_INTERACTING_WITH_ATOM_SECONDARY "item_interacting_with_atom_secondary"

/// from base of atom/Exited(): (mob/user, obj/item/extrapolator/E, scan = TRUE)
#define COMSIG_ATOM_EXTRAPOLATOR_ACT "atom_extrapolator_act"
///for any tool behaviors: (mob/living/user, obj/item/I, list/recipes)
Expand Down
5 changes: 5 additions & 0 deletions code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,8 @@
#define HOMEOSTASIS_HANDLED (1<<0)
/// Return to not reduce hunger at all
#define HOMEOSTASIS_NO_HUNGER (1<<1)

/// From /datum/element/basic_eating/finish_eating()
#define COMSIG_MOB_ATE "mob_ate"
///cancel post eating
#define COMSIG_MOB_TERMINATE_EAT (1<<0)
4 changes: 2 additions & 2 deletions code/__DEFINES/traits/declarations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
/* #define TRAIT_ALWAYS_WANTED "always_wanted" */

/// Trait given to mobs that have the basic eating element
/* #define TRAIT_MOB_EATER "mob_eater" */
#define TRAIT_MOB_EATER "mob_eater"
/// Trait which means whatever has this is dancing by a dance machine
/* #define TRAIT_DISCO_DANCER "disco_dancer" */

Expand All @@ -1261,7 +1261,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
/* #define TRAIT_EXPERT_FISHER "expert_fisher" */ // fishing is easier
/* #define TRAIT_ROUGHRIDER "roughrider" */ // you can improve speed on mounted animals with a good mood
/* #define TRAIT_STUBBY_BODY "stubby_body" */ // you have a stubby body that lessens your agility
/* #define TRAIT_BEAST_EMPATHY "beast_empathy" */ // you're good with animals, such as with taming them
#define TRAIT_BEAST_EMPATHY "beast_empathy" // you're good with animals, such as with taming them
/* #define TRAIT_STURDY_FRAME "sturdy_frame" */ // you suffer much lesser effects from equipment that slows you down

/// This item cannot be selected for or used by a theft objective (Spies, Traitors, etc.)
Expand Down
4 changes: 2 additions & 2 deletions code/_globalvars/traits/_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ GLOBAL_LIST_INIT(traits_by_type, list(
/* "TRAIT_ALWAYS_WANTED" = TRAIT_ALWAYS_WANTED, */
/* "TRAIT_ANOSMIA" = TRAIT_ANOSMIA, */
/* "TRAIT_BALLOON_SUTRA" = TRAIT_BALLOON_SUTRA, */
/* "TRAIT_BEAST_EMPATHY" = TRAIT_BEAST_EMPATHY, */
"TRAIT_BEAST_EMPATHY" = TRAIT_BEAST_EMPATHY,
/* "TRAIT_BIRTHDAY_BOY" = TRAIT_BIRTHDAY_BOY, */
/* "TRAIT_BLOCK_SHUTTLE_MOVEMENT" = TRAIT_BLOCK_SHUTTLE_MOVEMENT, */
/* "TRAIT_BLOOD_CLANS" = TRAIT_BLOOD_CLANS, */
Expand Down Expand Up @@ -564,7 +564,7 @@ GLOBAL_LIST_INIT(traits_by_type, list(
/* "TRAIT_MEDIBOTCOMINGTHROUGH" = TRAIT_MEDIBOTCOMINGTHROUGH, */
/* "TRAIT_MIND_READER" = TRAIT_MIND_READER, */
/* "TRAIT_MINING_PARRYING" = TRAIT_MINING_PARRYING, */
/* "TRAIT_MOB_EATER" = TRAIT_MOB_EATER, */
"TRAIT_MOB_EATER" = TRAIT_MOB_EATER,
/* "TRAIT_MOB_HATCHED" = TRAIT_MOB_HATCHED, */
/* "TRAIT_MOB_HIDE_HAPPINESS" = TRAIT_MOB_HIDE_HAPPINESS, */
/* "TRAIT_MOB_TIPPED" = TRAIT_MOB_TIPPED, */
Expand Down
39 changes: 17 additions & 22 deletions code/datums/components/tameable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
/datum/component/tameable
///If true, this atom can only be domesticated by one person
var/unique
///What the mob eats, typically used for taming or animal husbandry.
var/list/food_types
///Starting success chance for taming.
var/tame_chance
///Added success chance after every failed tame attempt.
Expand All @@ -17,8 +15,6 @@
if(!isatom(parent)) //yes, you could make a tameable toolbox.
return COMPONENT_INCOMPATIBLE

if(food_types)
src.food_types = food_types
if(tame_chance)
src.tame_chance = tame_chance
src.current_tame_chance = tame_chance
Expand All @@ -28,34 +24,33 @@
src.after_tame = after_tame
src.unique = unique

RegisterSignal(parent, COMSIG_ATOM_ATTACKBY, PROC_REF(try_tame))
if(food_types && !HAS_TRAIT(parent, TRAIT_MOB_EATER))
parent.AddElement(/datum/element/basic_eating, food_types = food_types)

RegisterSignal(parent, COMSIG_MOB_ATE, PROC_REF(try_tame))
RegisterSignal(parent, COMSIG_SIMPLEMOB_SENTIENCEPOTION, PROC_REF(on_tame)) //Instantly succeeds
RegisterSignal(parent, COMSIG_SIMPLEMOB_TRANSFERPOTION, PROC_REF(on_tame)) //Instantly succeeds

/datum/component/tameable/Destroy(force)
after_tame = null
return ..()

/datum/component/tameable/proc/try_tame(datum/source, obj/item/food, mob/living/attacker, params)
/datum/component/tameable/proc/try_tame(atom/source, obj/item/food, mob/living/attacker)
SIGNAL_HANDLER
if(!is_type_in_list(food, food_types))
return
if(isliving(source))
var/mob/living/potentially_dead_horse = source
if(potentially_dead_horse.stat == DEAD)
to_chat(attacker, span_warning("[parent] is dead!"))
return COMPONENT_CANCEL_ATTACK_CHAIN

var/atom/atom_parent = source
atom_parent.balloon_alert(attacker, "fed")
if(unique || !already_friends(attacker))
if(prob(current_tame_chance)) //note: lack of feedback message is deliberate, keep them guessing!
on_tame(source, attacker, food)
else
current_tame_chance += bonus_tame_chance
if(isnull(attacker) || already_friends(attacker))
return

qdel(food)
return COMPONENT_CANCEL_ATTACK_CHAIN
var/inform_tamer = FALSE
var/modified_tame_chance = current_tame_chance
if(HAS_TRAIT(attacker, TRAIT_BEAST_EMPATHY))
modified_tame_chance += 50
inform_tamer = TRUE
source.balloon_alert(attacker, "eats from your hand")
if(prob(modified_tame_chance)) //note: lack of feedback message is deliberate, keep them guessing unless they're an expert!
on_tame(source, attacker, food, inform_tamer)
else
current_tame_chance += bonus_tame_chance

/// Check if the passed mob is already considered one of our friends
/datum/component/tameable/proc/already_friends(mob/living/potential_friend)
Expand Down
37 changes: 23 additions & 14 deletions code/datums/elements/basic_eating.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,33 @@
src.drinking = drinking
src.food_types = food_types

//this lets players eat
RegisterSignal(target, COMSIG_ATOM_ITEM_INTERACTION, PROC_REF(try_feed))
RegisterSignal(target, COMSIG_LIVING_UNARMED_ATTACK, PROC_REF(on_unarm_attack))
//this lets ai eat. yes, i'm serious
RegisterSignal(target, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(on_pre_attackingtarget))

/datum/element/basic_eating/Detach(datum/target)
UnregisterSignal(target, list(COMSIG_LIVING_UNARMED_ATTACK, COMSIG_HOSTILE_PRE_ATTACKINGTARGET))

UnregisterSignal(target, list(
COMSIG_LIVING_UNARMED_ATTACK,
COMSIG_ATOM_ITEM_INTERACTION,
))
return ..()

/datum/element/basic_eating/proc/on_unarm_attack(mob/living/eater, atom/target, proximity, modifiers)
/datum/element/basic_eating/proc/try_feed(atom/source, mob/living/user, atom/possible_food)
SIGNAL_HANDLER
try_eating(eater, target)
if(user.combat_mode || !is_type_in_list(possible_food, food_types))
return NONE

/datum/element/basic_eating/proc/on_pre_attackingtarget(mob/living/eater, atom/target)
try_eating(source, possible_food, user)

/datum/element/basic_eating/proc/on_unarm_attack(mob/living/eater, atom/target, proximity, modifiers)
SIGNAL_HANDLER
try_eating(eater, target)

/datum/element/basic_eating/proc/try_eating(mob/living/eater, atom/target)
/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)

Check failure on line 57 in code/datums/elements/basic_eating.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "COMSIG_MOB_PRE_EAT"

Check failure on line 57 in code/datums/elements/basic_eating.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "COMSIG_MOB_PRE_EAT"

Check failure on line 57 in code/datums/elements/basic_eating.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "COMSIG_MOB_CANCEL_EAT"

Check failure on line 57 in code/datums/elements/basic_eating.dm

View workflow job for this annotation

GitHub Actions / Run Linters

OD0404: Unknown identifier "COMSIG_MOB_CANCEL_EAT"
return FALSE
var/eat_verb
if(drinking)
eat_verb = pick("slurp","sip","guzzle","drink","quaff","suck")
Expand All @@ -61,25 +68,27 @@
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" : ""]."))
finish_eating(eater, target)
return
return TRUE

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."))
finish_eating(eater, target)
return
finish_eating(eater, target, feeder)
return TRUE

eater.visible_message(span_notice("[eater] [eat_verb]s [target]."), span_notice("You [eat_verb] [target]."))
finish_eating(eater, target)
finish_eating(eater, target, feeder)
return TRUE

/datum/element/basic_eating/proc/finish_eating(mob/living/eater, atom/target)
/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) // monkestation edit original
playsound(eater.loc,get_drink_sound(eater), rand(10,50), TRUE) // monkestation edit: synthesized drink sounds
else
playsound(eater.loc,'sound/items/eatfood.ogg', rand(10,50), TRUE)
SEND_SIGNAL(eater, COMSIG_LIVING_ATE, target)
if(SEND_SIGNAL(eater, COMSIG_MOB_ATE, final_target, feeder) & COMSIG_MOB_TERMINATE_EAT)

Check failure on line 90 in code/datums/elements/basic_eating.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "final_target"

Check failure on line 90 in code/datums/elements/basic_eating.dm

View workflow job for this annotation

GitHub Actions / Run Linters

OD0404: Unknown identifier "final_target"
return
SEND_SIGNAL(eater, COMSIG_EMOTION_STORE, null, EMOTION_HAPPY, "I ate [target], I really like [target].")
var/atom/final_target = target
if(isstack(target)) //if stack, only consume 1
Expand Down
6 changes: 5 additions & 1 deletion code/modules/mob/living/basic/clown/clown.dm
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,11 @@
spit.Grant(src)

AddElement(/datum/element/swabable, CELL_LINE_TABLE_GLUTTON, CELL_VIRUS_TABLE_GENERIC_MOB, 1, 5)
AddComponent(/datum/component/tameable, food_types = list(/obj/item/food/cheesiehonkers, /obj/item/food/cornchips), tame_chance = 30, bonus_tame_chance = 0, after_tame = CALLBACK(src, PROC_REF(tamed)))
var/static/list/food_types = list(
/obj/item/food/cheesiehonkers,
/obj/item/food/cornchips,
)
AddComponent(/datum/component/tameable, food_types = food_types, tame_chance = 30, bonus_tame_chance = 0)


/mob/living/basic/clown/mutant/glutton/attacked_by(obj/item/item, mob/living/user)
Expand Down
1 change: 0 additions & 1 deletion code/modules/mob/living/basic/farm_animals/cow/_cow.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
if(!food_types)
food_types = src.food_types.Copy()
AddComponent(/datum/component/tameable, food_types = food_types, tame_chance = 25, bonus_tame_chance = 15, after_tame = CALLBACK(src, PROC_REF(tamed)))
AddElement(/datum/element/basic_eating, food_types = food_types)

/mob/living/basic/cow/proc/tamed(mob/living/tamer)
buckle_lying = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
var/static/list/food_types
if(!food_types)
food_types = src.food_types.Copy()
AddElement(/datum/element/basic_eating, food_types = food_types)
AddComponent(/datum/component/tameable, food_types = food_types, tame_chance = 25, bonus_tame_chance = 15, after_tame = CALLBACK(src, PROC_REF(tamed)))

/mob/living/basic/cow/moonicorn/tamed(mob/living/tamer)
Expand Down
3 changes: 2 additions & 1 deletion code/modules/mob/living/basic/farm_animals/pig.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@

///wrapper for the tameable component addition so you can have non tamable cow subtypes
/mob/living/basic/pig/proc/make_tameable()
AddComponent(/datum/component/tameable, food_types = list(/obj/item/food/grown/carrot), tame_chance = 25, bonus_tame_chance = 15, after_tame = CALLBACK(src, PROC_REF(tamed)))
var/list/food_types = string_list(list(/obj/item/food/grown/carrot))
AddComponent(/datum/component/tameable, food_types = food_types, tame_chance = 25, bonus_tame_chance = 15)

/mob/living/basic/pig/proc/tamed(mob/living/tamer)
can_buckle = TRUE
Expand Down
8 changes: 6 additions & 2 deletions code/modules/mob/living/basic/farm_animals/pony.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
AddElement(/datum/element/ai_retaliate)
AddElement(/datum/element/ai_flee_while_injured)
AddElement(/datum/element/waddling)
AddComponent(/datum/component/tameable, food_types = list(/obj/item/food/grown/apple), tame_chance = 25, bonus_tame_chance = 15, after_tame = CALLBACK(src, PROC_REF(tamed)), unique = unique_tamer)
var/static/list/food_types = list(
/obj/item/food/grown/apple,
)
AddComponent(/datum/component/tameable, food_types = food_types, tame_chance = 25, bonus_tame_chance = 15, unique = unique_tamer)

/mob/living/basic/pony/proc/tamed(mob/living/tamer)
can_buckle = TRUE
Expand Down Expand Up @@ -151,4 +154,5 @@
ponycolors = list("#5d566f", pick_weight(mane_colors))
name = pick("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
// Only one person can tame these fellas, and they only need one apple
AddComponent(/datum/component/tameable, food_types = list(/obj/item/food/grown/apple), tame_chance = 100, bonus_tame_chance = 15, after_tame = CALLBACK(src, PROC_REF(tamed)), unique = unique_tamer)
var/static/list/food_types = list(/obj/item/food/grown/apple)
AddComponent(/datum/component/tameable, food_types = food_types, tame_chance = 100, bonus_tame_chance = 15, unique = unique_tamer)
4 changes: 4 additions & 0 deletions code/modules/mob/living/basic/icemoon/wolf/wolf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
)

/mob/living/basic/mining/wolf/proc/tame_wolf()
var/static/list/food_types = list(/obj/item/food/meat/slab)
AddComponent(/datum/component/tameable, food_types = food_types, tame_chance = 15, bonus_tame_chance = 5)

/mob/living/basic/mining/wolf/tamed(mob/living/tamer, atom/food)
new /obj/effect/temp_visual/heart(src.loc)
// ride wolf, life good
AddElement(/datum/element/ridable, /datum/component/riding/creature/wolf)
Expand Down
17 changes: 9 additions & 8 deletions code/modules/mob/living/basic/lavaland/goldgrub/goldgrub.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
make_egg_layer()

RegisterSignal(src, COMSIG_ATOM_PRE_BULLET_ACT, PROC_REF(block_bullets))
RegisterSignal(src, COMSIG_MOB_ATE, PROC_REF(on_eat))

/mob/living/basic/mining/goldgrub/proc/block_bullets(datum/source, obj/projectile/hitting_projectile)
SIGNAL_HANDLER
Expand Down Expand Up @@ -97,13 +98,8 @@
return ..()

/mob/living/basic/mining/goldgrub/proc/make_tameable()
AddComponent(\
/datum/component/tameable,\
food_types = list(/obj/item/stack/ore),\
tame_chance = 25,\
bonus_tame_chance = 5,\
after_tame = CALLBACK(src, PROC_REF(tame_grub)),\
)
var/list/food_types = string_list(list(/obj/item/stack/ore))
AddComponent(/datum/component/tameable, food_types = food_types, tame_chance = 25, bonus_tame_chance = 5)

/mob/living/basic/mining/goldgrub/proc/tame_grub()
new /obj/effect/temp_visual/heart(src.loc)
Expand All @@ -128,13 +124,18 @@
. = ..()
if(!istype(arrived, /obj/item/stack/ore))
return
playsound(src,'sound/items/eatfood.ogg', rand(10,50), TRUE)
if(!can_lay_eggs)
return
if(!istype(arrived, /obj/item/stack/ore/bluespace_crystal) || prob(60))
return
new /obj/item/food/egg/green/grub_egg(get_turf(src))

/mob/living/basic/mining/goldgrub/proc/on_eat(atom/source, atom/movable/food, mob/feeder)
SIGNAL_HANDLER

food.forceMove(src)
return COMSIG_MOB_TERMINATE_EAT

/mob/living/basic/mining/goldgrub/baby
icon = 'icons/mob/simple/lavaland/lavaland_monsters.dmi'
name = "goldgrub baby"
Expand Down
9 changes: 2 additions & 7 deletions code/modules/mob/living/basic/lavaland/goliath/goliath.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,8 @@
AddComponent(/datum/component/basic_mob_attack_telegraph)
AddComponentFrom(INNATE_TRAIT, /datum/component/shovel_hands)
if (tameable)
AddComponent(\
/datum/component/tameable,\
food_types = list(/obj/item/food/grown/ash_flora),\
tame_chance = 10,\
bonus_tame_chance = 5,\
after_tame = CALLBACK(src, PROC_REF(tamed)),\
)
var/static/list/food_types = list(/obj/item/food/grown/ash_flora)
AddComponent(/datum/component/tameable, food_types = food_types, tame_chance = 10, bonus_tame_chance = 5)

tentacles = new (src)
tentacles.Grant(src)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/basic/pets/cat/cat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@
mob_type_allowed_typecache = /mob/living/basic/pet/cat
mob_type_blacklist_typecache = list()

/datum/emote/living/basic/pet/cat/meow
/datum/emote/cat/meow
key = "meow"
key_third_person = "meows"
message = "meows!"
emote_type = EMOTE_VISIBLE | EMOTE_AUDIBLE
vary = TRUE
sound = SFX_CAT_MEOW

/datum/emote/living/basic/pet/cat/purr
/datum/emote/cat/purr
key = "purr"
key_third_person = "purrs"
message = "purrs."
Expand Down
Loading

0 comments on commit 573ce7b

Please sign in to comment.