From a99a1e63834bdef8de7e394ebff648eaeeaa8a58 Mon Sep 17 00:00:00 2001 From: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Date: Tue, 15 Oct 2024 03:18:37 +0300 Subject: [PATCH] slightly redoes how animals hunt for food (#87166) ## About The Pull Request before, if u wanted to make ur animal hunt for food, u had to give them the find food subtree, the attacking subtree, and had to edit their targeting stratedgy to include items. this makes it so u only have to give them just 1 subtree which will handle everything it needs to. also makes it alot more customizable, u can now set a hunger cooldown for ur animals, and cute emotes for them to play after eating food ## Why It's Good For The Game makes it more convenient for future devs to include food hunting behaviors to their animals, while also making it more customizable ## Changelog :cl: code: animals' food hunting behavior has been refactored, please report any bugs /:cl: --- code/__DEFINES/ai/ai_blackboard.dm | 15 ++++++++-- code/__DEFINES/basic_mobs.dm | 3 ++ .../ai/basic_mobs/base_basic_controller.dm | 6 ++++ .../interact_with_target.dm | 27 +++++++++++++++++ .../ai/basic_mobs/basic_subtrees/find_food.dm | 30 ++++++++++++++++--- .../living/basic/farm_animals/cow/cow_ai.dm | 4 +-- .../basic/farm_animals/gorilla/gorilla_ai.dm | 4 +-- .../basic/lavaland/goliath/goliath_ai.dm | 2 +- .../lavaland/lobstrosity/lobstrosity_ai.dm | 4 +-- .../lavaland/raptor/raptor_ai_controller.dm | 13 +------- .../lavaland/raptor/raptor_ai_subtrees.dm | 2 +- .../mob/living/basic/pets/orbie/orbie_ai.dm | 3 +- .../living/basic/ruin_defender/skeleton.dm | 2 +- .../space_fauna/carp/carp_controllers.dm | 10 +++---- .../living/basic/space_fauna/snake/snake.dm | 4 +-- .../modules/mob/living/basic/vermin/lizard.dm | 3 +- .../basic/vermin/mothroach/mothroach_ai.dm | 23 ++------------ tgstation.dme | 1 + 18 files changed, 96 insertions(+), 60 deletions(-) create mode 100644 code/datums/ai/basic_mobs/basic_ai_behaviors/interact_with_target.dm diff --git a/code/__DEFINES/ai/ai_blackboard.dm b/code/__DEFINES/ai/ai_blackboard.dm index 0c682f7d411..2b25d0cfb31 100644 --- a/code/__DEFINES/ai/ai_blackboard.dm +++ b/code/__DEFINES/ai/ai_blackboard.dm @@ -123,6 +123,18 @@ ///list of foods this mob likes #define BB_BASIC_FOODS "BB_basic_foods" +///key holding any food we've found +#define BB_TARGET_FOOD "BB_TARGET_FOOD" + +///key holding emotes we play after eating +#define BB_EAT_EMOTES "BB_eat_emotes" + +///key holding the next time we eat +#define BB_NEXT_FOOD_EAT "BB_next_food_eat" + +///key holding our eating cooldown +#define BB_EAT_FOOD_COOLDOWN "BB_eat_food_cooldown" + /// Blackboard key for a held item #define BB_SIMPLE_CARRY_ITEM "BB_SIMPLE_CARRY_ITEM" @@ -168,5 +180,4 @@ /// For /datum/ai_behavior/find_potential_targets, what if any field are we using currently #define BB_FIND_TARGETS_FIELD(type) "bb_find_targets_field_[type]" -///mothroach next meal key! -#define BB_MOTHROACH_NEXT_EAT "mothroach_next_eat" + diff --git a/code/__DEFINES/basic_mobs.dm b/code/__DEFINES/basic_mobs.dm index 6696da857c8..12ddaa3a68a 100644 --- a/code/__DEFINES/basic_mobs.dm +++ b/code/__DEFINES/basic_mobs.dm @@ -24,6 +24,9 @@ /// Above this speed we stop gliding because it looks silly #define END_GLIDE_SPEED 10 +///hunger cooldown for basic mobs +#define EAT_FOOD_COOLDOWN 45 SECONDS + ///mook attack status flags #define MOOK_ATTACK_NEUTRAL 0 #define MOOK_ATTACK_WARMUP 1 diff --git a/code/datums/ai/basic_mobs/base_basic_controller.dm b/code/datums/ai/basic_mobs/base_basic_controller.dm index f21d31b0500..7ab15437f7d 100644 --- a/code/datums/ai/basic_mobs/base_basic_controller.dm +++ b/code/datums/ai/basic_mobs/base_basic_controller.dm @@ -9,6 +9,7 @@ update_speed(basic_mob) RegisterSignals(basic_mob, list(POST_BASIC_MOB_UPDATE_VARSPEED, COMSIG_MOB_MOVESPEED_UPDATED), PROC_REF(update_speed)) + RegisterSignal(basic_mob, COMSIG_MOB_ATE, PROC_REF(on_mob_eat)) return ..() //Run parent at end @@ -44,3 +45,8 @@ /datum/ai_controller/basic_controller/proc/update_speed(mob/living/basic/basic_mob) SIGNAL_HANDLER movement_delay = basic_mob.cached_multiplicative_slowdown + +/datum/ai_controller/basic_controller/proc/on_mob_eat() + SIGNAL_HANDLER + var/food_cooldown = blackboard[BB_EAT_FOOD_COOLDOWN] || EAT_FOOD_COOLDOWN + set_blackboard_key(BB_NEXT_FOOD_EAT, world.time + food_cooldown) diff --git a/code/datums/ai/basic_mobs/basic_ai_behaviors/interact_with_target.dm b/code/datums/ai/basic_mobs/basic_ai_behaviors/interact_with_target.dm new file mode 100644 index 00000000000..3b0c4245656 --- /dev/null +++ b/code/datums/ai/basic_mobs/basic_ai_behaviors/interact_with_target.dm @@ -0,0 +1,27 @@ +///behavior for general interactions with any targets +/datum/ai_behavior/interact_with_target + behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | AI_BEHAVIOR_REQUIRE_REACH + ///should we be clearing the target after the fact? + var/clear_target = TRUE + +/datum/ai_behavior/interact_with_target/setup(datum/ai_controller/controller, target_key) + . = ..() + var/atom/target = controller.blackboard[target_key] + if(QDELETED(target)) + return FALSE + set_movement_target(controller, target) + +/datum/ai_behavior/interact_with_target/perform(seconds_per_tick, datum/ai_controller/controller, target_key) + var/atom/target = controller.blackboard[target_key] + if(QDELETED(target) || !pre_interact(controller, target)) + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED + controller.ai_interact(target) + return AI_BEHAVIOR_SUCCEEDED | AI_BEHAVIOR_DELAY + +/datum/ai_behavior/interact_with_target/finish_action(datum/ai_controller/controller, succeeded, target_key) + . = ..() + if(clear_target || !succeeded) + controller.clear_blackboard_key(target_key) + +/datum/ai_behavior/interact_with_target/proc/pre_interact(datum/ai_controller/controller, target) + return TRUE diff --git a/code/datums/ai/basic_mobs/basic_subtrees/find_food.dm b/code/datums/ai/basic_mobs/basic_subtrees/find_food.dm index 9e3cd557b64..f05c357b1a8 100644 --- a/code/datums/ai/basic_mobs/basic_subtrees/find_food.dm +++ b/code/datums/ai/basic_mobs/basic_subtrees/find_food.dm @@ -4,11 +4,33 @@ var/datum/ai_behavior/finding_behavior = /datum/ai_behavior/find_and_set/in_list ///key of foods list var/food_list_key = BB_BASIC_FOODS + ///key where we store our food + var/found_food_key = BB_TARGET_FOOD + ///key holding any emotes we play after eating food + var/emotes_blackboard_list = BB_EAT_EMOTES /datum/ai_planning_subtree/find_food/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - . = ..() - if(controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) - // Busy with something + if(controller.blackboard[BB_NEXT_FOOD_EAT] > world.time) return + if(!controller.blackboard_key_exists(found_food_key)) + controller.queue_behavior(finding_behavior, found_food_key, controller.blackboard[food_list_key]) + return + controller.queue_behavior(/datum/ai_behavior/interact_with_target/eat_food, found_food_key, emotes_blackboard_list) + return SUBTREE_RETURN_FINISH_PLANNING - controller.queue_behavior(finding_behavior, BB_BASIC_MOB_CURRENT_TARGET, controller.blackboard[food_list_key]) +/datum/ai_behavior/interact_with_target/eat_food + ///default list of actions we take after eating + var/list/food_actions = list( + "eats up happily!", + "chomps with glee!", + ) + +/datum/ai_behavior/interact_with_target/eat_food/perform(seconds_per_tick, datum/ai_controller/controller, target_key, emotes_blackboard_list) + . = ..() + if(. & AI_BEHAVIOR_FAILED) + return + var/list/emotes_to_pick = controller.blackboard[emotes_blackboard_list] || food_actions + if(!length(emotes_to_pick)) + return + var/mob/living/living_pawn = controller.pawn + living_pawn.manual_emote(pick(emotes_to_pick)) diff --git a/code/modules/mob/living/basic/farm_animals/cow/cow_ai.dm b/code/modules/mob/living/basic/farm_animals/cow/cow_ai.dm index e1e611a28c2..cedc39f64f3 100644 --- a/code/modules/mob/living/basic/farm_animals/cow/cow_ai.dm +++ b/code/modules/mob/living/basic/farm_animals/cow/cow_ai.dm @@ -1,6 +1,6 @@ /datum/ai_controller/basic_controller/cow blackboard = list( - BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/allow_items, + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic, BB_BASIC_MOB_TIP_REACTING = FALSE, BB_BASIC_MOB_TIPPER = null, ) @@ -11,7 +11,5 @@ planning_subtrees = list( /datum/ai_planning_subtree/tip_reaction, /datum/ai_planning_subtree/find_food, - //attacking the food will eat it - /datum/ai_planning_subtree/basic_melee_attack_subtree, /datum/ai_planning_subtree/random_speech/cow, ) diff --git a/code/modules/mob/living/basic/farm_animals/gorilla/gorilla_ai.dm b/code/modules/mob/living/basic/farm_animals/gorilla/gorilla_ai.dm index 28a727fdb1b..de55865b5fa 100644 --- a/code/modules/mob/living/basic/farm_animals/gorilla/gorilla_ai.dm +++ b/code/modules/mob/living/basic/farm_animals/gorilla/gorilla_ai.dm @@ -1,7 +1,7 @@ /// Pretty basic, just click people to death. Also hunt and eat bananas. /datum/ai_controller/basic_controller/gorilla blackboard = list( - BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/allow_items, + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic, BB_TARGET_MINIMUM_STAT = UNCONSCIOUS, BB_EMOTE_KEY = "ooga", BB_EMOTE_CHANCE = 40, @@ -13,10 +13,10 @@ planning_subtrees = list( /datum/ai_planning_subtree/run_emote, - /datum/ai_planning_subtree/find_food, /datum/ai_planning_subtree/simple_find_target, /datum/ai_planning_subtree/attack_obstacle_in_path/gorilla, /datum/ai_planning_subtree/basic_melee_attack_subtree, + /datum/ai_planning_subtree/find_food, ) /datum/ai_planning_subtree/attack_obstacle_in_path/gorilla diff --git a/code/modules/mob/living/basic/lavaland/goliath/goliath_ai.dm b/code/modules/mob/living/basic/lavaland/goliath/goliath_ai.dm index 86ba1e00320..3bf9d1d8f33 100644 --- a/code/modules/mob/living/basic/lavaland/goliath/goliath_ai.dm +++ b/code/modules/mob/living/basic/lavaland/goliath/goliath_ai.dm @@ -3,7 +3,7 @@ /datum/ai_controller/basic_controller/goliath blackboard = list( - BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/allow_items, + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic, BB_TARGET_MINIMUM_STAT = HARD_CRIT, ) diff --git a/code/modules/mob/living/basic/lavaland/lobstrosity/lobstrosity_ai.dm b/code/modules/mob/living/basic/lavaland/lobstrosity/lobstrosity_ai.dm index de62b43e4a0..de6ca4a0cc1 100644 --- a/code/modules/mob/living/basic/lavaland/lobstrosity/lobstrosity_ai.dm +++ b/code/modules/mob/living/basic/lavaland/lobstrosity/lobstrosity_ai.dm @@ -7,7 +7,7 @@ /datum/ai_controller/basic_controller/lobstrosity blackboard = list( - BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/allow_items, + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic, BB_PET_TARGETING_STRATEGY = /datum/targeting_strategy/basic/not_friends, BB_TARGET_MINIMUM_STAT = HARD_CRIT, BB_LOBSTROSITY_EXPLOIT_TRAITS = list(TRAIT_INCAPACITATED, TRAIT_FLOORED, TRAIT_IMMOBILIZED, TRAIT_KNOCKEDOUT), @@ -45,7 +45,7 @@ ///Ensure that juveline lobstrosities witll charge at things they can reach. /datum/ai_controller/basic_controller/lobstrosity/juvenile blackboard = list( - BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/allow_items, + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic, BB_PET_TARGETING_STRATEGY = /datum/targeting_strategy/basic/not_friends, BB_TARGET_MINIMUM_STAT = SOFT_CRIT, BB_LOBSTROSITY_EXPLOIT_TRAITS = list(TRAIT_INCAPACITATED, TRAIT_FLOORED, TRAIT_IMMOBILIZED, TRAIT_KNOCKEDOUT), diff --git a/code/modules/mob/living/basic/lavaland/raptor/raptor_ai_controller.dm b/code/modules/mob/living/basic/lavaland/raptor/raptor_ai_controller.dm index 8178df7b78c..d9bada12ee8 100644 --- a/code/modules/mob/living/basic/lavaland/raptor/raptor_ai_controller.dm +++ b/code/modules/mob/living/basic/lavaland/raptor/raptor_ai_controller.dm @@ -1,5 +1,3 @@ -#define NEXT_EAT_COOLDOWN 45 SECONDS - /datum/ai_controller/basic_controller/raptor blackboard = list( BB_INTERACTIONS_WITH_OWNER = list( @@ -34,16 +32,9 @@ /datum/ai_planning_subtree/find_and_hunt_target/play_with_owner/raptor, ) -/datum/ai_controller/basic_controller/raptor/TryPossessPawn(atom/new_pawn) +/datum/ai_controller/basic_controller/raptor/on_mob_eat() . = ..() - if(. & AI_CONTROLLER_INCOMPATIBLE) - return - RegisterSignal(new_pawn, COMSIG_MOB_ATE, PROC_REF(post_eat)) - -/datum/ai_controller/basic_controller/raptor/proc/post_eat() - SIGNAL_HANDLER clear_blackboard_key(BB_RAPTOR_TROUGH_TARGET) - set_blackboard_key(BB_RAPTOR_EAT_COOLDOWN, world.time + NEXT_EAT_COOLDOWN) /datum/ai_controller/basic_controller/baby_raptor blackboard = list( @@ -62,5 +53,3 @@ /datum/ai_planning_subtree/express_happiness, /datum/ai_planning_subtree/look_for_adult, ) - -#undef NEXT_EAT_COOLDOWN diff --git a/code/modules/mob/living/basic/lavaland/raptor/raptor_ai_subtrees.dm b/code/modules/mob/living/basic/lavaland/raptor/raptor_ai_subtrees.dm index a8d91963ebf..2b88cc3282b 100644 --- a/code/modules/mob/living/basic/lavaland/raptor/raptor_ai_subtrees.dm +++ b/code/modules/mob/living/basic/lavaland/raptor/raptor_ai_subtrees.dm @@ -56,7 +56,7 @@ hunt_range = 9 /datum/ai_planning_subtree/find_and_hunt_target/raptor_trough/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - if(world.time < controller.blackboard[BB_RAPTOR_EAT_COOLDOWN]) + if(world.time < controller.blackboard[BB_NEXT_FOOD_EAT]) return return ..() diff --git a/code/modules/mob/living/basic/pets/orbie/orbie_ai.dm b/code/modules/mob/living/basic/pets/orbie/orbie_ai.dm index 1452dd18dee..a978b750d50 100644 --- a/code/modules/mob/living/basic/pets/orbie/orbie_ai.dm +++ b/code/modules/mob/living/basic/pets/orbie/orbie_ai.dm @@ -3,7 +3,7 @@ /datum/ai_controller/basic_controller/orbie blackboard = list( - BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/allow_items, + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic, BB_PET_TARGETING_STRATEGY = /datum/targeting_strategy/basic/not_friends, BB_TRICK_NAME = "Trick", ) @@ -13,7 +13,6 @@ planning_subtrees = list( /datum/ai_planning_subtree/find_food, /datum/ai_planning_subtree/find_playmates, - /datum/ai_planning_subtree/basic_melee_attack_subtree, /datum/ai_planning_subtree/relay_pda_message, /datum/ai_planning_subtree/pet_planning, ) diff --git a/code/modules/mob/living/basic/ruin_defender/skeleton.dm b/code/modules/mob/living/basic/ruin_defender/skeleton.dm index e6754a80a22..5eb8fda1523 100644 --- a/code/modules/mob/living/basic/ruin_defender/skeleton.dm +++ b/code/modules/mob/living/basic/ruin_defender/skeleton.dm @@ -162,7 +162,7 @@ /// Skeletons mostly just beat people to death, but they'll also find and drink milk. /datum/ai_controller/basic_controller/skeleton blackboard = list( - BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/allow_items, + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic, BB_TARGET_MINIMUM_STAT = HARD_CRIT, BB_EMOTE_KEY = "rattles", BB_EMOTE_CHANCE = 20, diff --git a/code/modules/mob/living/basic/space_fauna/carp/carp_controllers.dm b/code/modules/mob/living/basic/space_fauna/carp/carp_controllers.dm index ae011f5b14a..93ede010eb6 100644 --- a/code/modules/mob/living/basic/space_fauna/carp/carp_controllers.dm +++ b/code/modules/mob/living/basic/space_fauna/carp/carp_controllers.dm @@ -10,7 +10,7 @@ /datum/ai_controller/basic_controller/carp blackboard = list( BB_BASIC_MOB_STOP_FLEEING = TRUE, - BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/allow_items, + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic, BB_PET_TARGETING_STRATEGY = /datum/targeting_strategy/basic/not_friends, BB_TARGET_PRIORITY_TRAIT = TRAIT_SCARY_FISHERMAN, BB_CARPS_FEAR_FISHERMAN = TRUE, @@ -24,11 +24,11 @@ /datum/ai_planning_subtree/find_target_prioritize_traits, /datum/ai_planning_subtree/make_carp_rift/panic_teleport, /datum/ai_planning_subtree/flee_target/from_fisherman, - /datum/ai_planning_subtree/find_food, /datum/ai_planning_subtree/attack_obstacle_in_path/carp, /datum/ai_planning_subtree/shortcut_to_target_through_carp_rift, /datum/ai_planning_subtree/make_carp_rift/aggressive_teleport, /datum/ai_planning_subtree/basic_melee_attack_subtree/no_fisherman, + /datum/ai_planning_subtree/find_food, /datum/ai_planning_subtree/carp_migration, ) @@ -36,7 +36,7 @@ /datum/ai_controller/basic_controller/carp/mega blackboard = list( BB_BASIC_MOB_STOP_FLEEING = TRUE, - BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/allow_items, + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic, BB_PET_TARGETING_STRATEGY = /datum/targeting_strategy/basic/not_friends, BB_TARGET_PRIORITY_TRAIT = TRAIT_SCARY_FISHERMAN, BB_CARPS_FEAR_FISHERMAN = FALSE, @@ -46,12 +46,12 @@ /datum/ai_planning_subtree/simple_find_nearest_target_to_flee, /datum/ai_planning_subtree/make_carp_rift/panic_teleport, /datum/ai_planning_subtree/flee_target, - /datum/ai_planning_subtree/find_food, /datum/ai_planning_subtree/find_target_prioritize_traits, /datum/ai_planning_subtree/attack_obstacle_in_path/carp, /datum/ai_planning_subtree/shortcut_to_target_through_carp_rift, /datum/ai_planning_subtree/make_carp_rift/aggressive_teleport, /datum/ai_planning_subtree/basic_melee_attack_subtree, + /datum/ai_planning_subtree/find_food, /datum/ai_planning_subtree/carp_migration, ) /** @@ -90,13 +90,13 @@ /datum/ai_planning_subtree/find_target_prioritize_traits, /datum/ai_planning_subtree/make_carp_rift/panic_teleport, /datum/ai_planning_subtree/flee_target/from_fisherman, - /datum/ai_planning_subtree/find_food, /datum/ai_planning_subtree/find_nearest_magicarp_spell_target, /datum/ai_planning_subtree/targeted_mob_ability/magicarp, /datum/ai_planning_subtree/attack_obstacle_in_path/carp, /datum/ai_planning_subtree/shortcut_to_target_through_carp_rift, /datum/ai_planning_subtree/make_carp_rift/aggressive_teleport, /datum/ai_planning_subtree/basic_melee_attack_subtree/magicarp, + /datum/ai_planning_subtree/find_food, /datum/ai_planning_subtree/carp_migration, ) diff --git a/code/modules/mob/living/basic/space_fauna/snake/snake.dm b/code/modules/mob/living/basic/space_fauna/snake/snake.dm index 78f7d86e0db..3125ae9d323 100644 --- a/code/modules/mob/living/basic/space_fauna/snake/snake.dm +++ b/code/modules/mob/living/basic/space_fauna/snake/snake.dm @@ -73,7 +73,7 @@ /// Snakes are primarily concerned with getting those tasty, tasty mice, but aren't afraid to strike back at those who attack them /datum/ai_controller/basic_controller/snake blackboard = list( - BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/not_friends/allow_items, + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/not_friends, ) ai_traits = STOP_MOVING_WHEN_PULLED @@ -82,7 +82,7 @@ planning_subtrees = list( /datum/ai_planning_subtree/target_retaliate, - /datum/ai_planning_subtree/find_food, /datum/ai_planning_subtree/basic_melee_attack_subtree, + /datum/ai_planning_subtree/find_food, /datum/ai_planning_subtree/random_speech/snake, ) diff --git a/code/modules/mob/living/basic/vermin/lizard.dm b/code/modules/mob/living/basic/vermin/lizard.dm index c1c21850ee6..5e3a07094a9 100644 --- a/code/modules/mob/living/basic/vermin/lizard.dm +++ b/code/modules/mob/living/basic/vermin/lizard.dm @@ -64,7 +64,7 @@ /datum/ai_controller/basic_controller/lizard blackboard = list( - BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/allow_items, + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic, ) ai_traits = STOP_MOVING_WHEN_PULLED @@ -72,7 +72,6 @@ idle_behavior = /datum/idle_behavior/idle_random_walk planning_subtrees = list( /datum/ai_planning_subtree/find_food, - /datum/ai_planning_subtree/basic_melee_attack_subtree, /datum/ai_planning_subtree/random_speech/lizard, ) diff --git a/code/modules/mob/living/basic/vermin/mothroach/mothroach_ai.dm b/code/modules/mob/living/basic/vermin/mothroach/mothroach_ai.dm index bed72a98239..c9e8558ec5c 100644 --- a/code/modules/mob/living/basic/vermin/mothroach/mothroach_ai.dm +++ b/code/modules/mob/living/basic/vermin/mothroach/mothroach_ai.dm @@ -1,10 +1,9 @@ -#define MOTHROACH_EAT_TIMER 1 MINUTES - /datum/ai_controller/basic_controller/mothroach blackboard = list( BB_FLEE_TARGETING_STRATEGY = /datum/targeting_strategy/basic, BB_PET_TARGETING_STRATEGY = /datum/targeting_strategy/basic/not_friends, - BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/allow_items, + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic, + BB_EAT_FOOD_COOLDOWN = 1 MINUTES, ) ai_traits = STOP_MOVING_WHEN_PULLED @@ -15,28 +14,12 @@ /datum/ai_planning_subtree/find_food/mothroach, /datum/ai_planning_subtree/target_retaliate/to_flee, /datum/ai_planning_subtree/flee_target/from_flee_key, - /datum/ai_planning_subtree/basic_melee_attack_subtree, /datum/ai_planning_subtree/random_speech/mothroach, ) -/datum/ai_controller/basic_controller/mothroach/TryPossessPawn(atom/new_pawn) - . = ..() - if(. & AI_CONTROLLER_INCOMPATIBLE) - return - RegisterSignal(new_pawn, COMSIG_MOB_ATE, PROC_REF(on_eaten)) - -/datum/ai_controller/basic_controller/mothroach/proc/on_eaten(datum/source) - SIGNAL_HANDLER - set_blackboard_key(BB_MOTHROACH_NEXT_EAT, world.time + MOTHROACH_EAT_TIMER) - /datum/ai_planning_subtree/find_food/mothroach finding_behavior = /datum/ai_behavior/find_and_set/in_list/mothroach_food -/datum/ai_planning_subtree/find_food/mothroach/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - if(world.time < controller.blackboard[BB_MOTHROACH_NEXT_EAT]) - return - return ..() - /datum/ai_behavior/find_and_set/in_list/mothroach_food /datum/ai_behavior/find_and_set/in_list/mothroach_food/search_tactic(datum/ai_controller/controller, locate_paths, search_range) @@ -45,5 +28,3 @@ found -= living_pawn.loc if(length(found)) return pick(found) - -#undef MOTHROACH_EAT_TIMER diff --git a/tgstation.dme b/tgstation.dme index 544aa168100..f6ab0f39f88 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -901,6 +901,7 @@ #include "code\datums\ai\basic_mobs\basic_ai_behaviors\climb_tree.dm" #include "code\datums\ai\basic_mobs\basic_ai_behaviors\emote_with_target.dm" #include "code\datums\ai\basic_mobs\basic_ai_behaviors\find_parent.dm" +#include "code\datums\ai\basic_mobs\basic_ai_behaviors\interact_with_target.dm" #include "code\datums\ai\basic_mobs\basic_ai_behaviors\nearest_targeting.dm" #include "code\datums\ai\basic_mobs\basic_ai_behaviors\pick_up_item.dm" #include "code\datums\ai\basic_mobs\basic_ai_behaviors\pull_target.dm"