mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-12 08:36:00 +01:00
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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user