mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 13:10:02 +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:
@@ -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
|
||||
Reference in New Issue
Block a user