Files
Bubberstation/code/datums/ai/basic_mobs/basic_subtrees/find_food.dm
Ben10Omintrix 8492ff7d69 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
/🆑
2024-11-16 00:42:55 -08:00

37 lines
1.5 KiB
Plaintext

/// similar to finding a target but looks for food types in the // the what?
/datum/ai_planning_subtree/find_food
///behavior we use to find the food
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[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
/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))