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
🆑
code: animals' food hunting behavior has been refactored, please report
any bugs
/🆑
This commit is contained in:
Ben10Omintrix
2024-10-15 13:18:37 +13:00
committed by GitHub
parent 3b6305acee
commit a99a1e6383
18 changed files with 96 additions and 60 deletions
@@ -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