From 2f3978773e2c328db67819293aacee8fd4451f4d Mon Sep 17 00:00:00 2001 From: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Date: Mon, 20 May 2024 06:29:59 +0300 Subject: [PATCH] [no gbp] raptors with the playful trait now play with their owners (#83294) ## About The Pull Request i forgot to add this behavior to playful raptors, currently this trait does nothing. raptors will now play with their owners and tease them if they are nearby ## Why It's Good For The Game adds more personality to raptors with the playful trait. also this behavior can now be given to any other tameable mobs ## Changelog :cl: fix: playful raptors now correctly play with owners /:cl: --- code/__DEFINES/ai/ai_blackboard.dm | 5 +++++ .../basic_subtrees/play_with_owners.dm | 21 +++++++++++++++++++ .../lavaland/raptor/raptor_ai_controller.dm | 9 +++++++- .../lavaland/raptor/raptor_ai_subtrees.dm | 4 ++++ tgstation.dme | 1 + 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 code/datums/ai/basic_mobs/basic_subtrees/play_with_owners.dm diff --git a/code/__DEFINES/ai/ai_blackboard.dm b/code/__DEFINES/ai/ai_blackboard.dm index 1a2b19740f6..a65b5ebd407 100644 --- a/code/__DEFINES/ai/ai_blackboard.dm +++ b/code/__DEFINES/ai/ai_blackboard.dm @@ -19,6 +19,11 @@ ///can this mob heal? #define BB_BASIC_MOB_HEALER "BB_basic_mob_healer" +///the owner we will try to play with +#define BB_OWNER_TARGET "BB_owner_target" +///the list of interactions we can have with the owner +#define BB_INTERACTIONS_WITH_OWNER "BB_interactions_with_owner" + /// Store a single or list of emotes at this key #define BB_EMOTE_KEY "BB_emotes" diff --git a/code/datums/ai/basic_mobs/basic_subtrees/play_with_owners.dm b/code/datums/ai/basic_mobs/basic_subtrees/play_with_owners.dm new file mode 100644 index 00000000000..e27e984e706 --- /dev/null +++ b/code/datums/ai/basic_mobs/basic_subtrees/play_with_owners.dm @@ -0,0 +1,21 @@ +/datum/ai_planning_subtree/find_and_hunt_target/play_with_owner + target_key = BB_OWNER_TARGET + hunting_behavior = /datum/ai_behavior/hunt_target/play_with_owner + finding_behavior = /datum/ai_behavior/find_hunt_target/find_owner + hunt_targets = list(/mob/living) + hunt_chance = 80 + hunt_range = 9 + +/datum/ai_behavior/find_hunt_target/find_owner + action_cooldown = 1 MINUTES + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/find_hunt_target/find_owner/valid_dinner(mob/living/source, atom/friend, radius, datum/ai_controller/controller, seconds_per_tick) + return (friend != source) && (source.faction.Find(REF(friend))) && can_see(source, friend, radius) + +/datum/ai_behavior/hunt_target/play_with_owner + +/datum/ai_behavior/hunt_target/play_with_owner/target_caught(mob/living/hunter, atom/hunted) + var/list/interactions_list = hunter.ai_controller.blackboard[BB_INTERACTIONS_WITH_OWNER] + var/interaction_message = length(interactions_list) ? pick(interactions_list) : "Plays with" + hunter.manual_emote("[interaction_message] [hunted]!") 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 40c2d836554..323f8422d2f 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 @@ -2,6 +2,12 @@ /datum/ai_controller/basic_controller/raptor blackboard = list( + BB_INTERACTIONS_WITH_OWNER = list( + "Pecks", + "Nuzzles", + "Wags tail against", + "Playfully leans against" + ), BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/raptor, BB_PET_TARGETING_STRATEGY = /datum/targeting_strategy/basic/raptor, BB_BABIES_PARTNER_TYPES = list(/mob/living/basic/mining/raptor), @@ -25,6 +31,7 @@ /datum/ai_planning_subtree/make_babies, /datum/ai_planning_subtree/find_and_hunt_target/raptor_start_trouble, /datum/ai_planning_subtree/express_happiness, + /datum/ai_planning_subtree/find_and_hunt_target/play_with_owner/raptor, ) /datum/ai_controller/basic_controller/raptor/TryPossessPawn(atom/new_pawn) @@ -39,7 +46,7 @@ /datum/targeting_strategy/basic/raptor -//dont attack anyone with the neutral faction. +//dont attack anyone with the neutral faction. /datum/targeting_strategy/basic/raptor/faction_check(datum/ai_controller/controller, mob/living/living_mob, mob/living/the_target) return (the_target.faction.Find(FACTION_NEUTRAL) || the_target.faction.Find(FACTION_RAPTOR)) 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 2d23268d35c..9dcb360c65d 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 @@ -60,3 +60,7 @@ return return ..() +/datum/ai_planning_subtree/find_and_hunt_target/play_with_owner/raptor/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + if(!controller.blackboard[BB_RAPTOR_PLAYFUL]) + return + return ..() diff --git a/tgstation.dme b/tgstation.dme index 2e7b8532db0..4cdb2cb1896 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -909,6 +909,7 @@ #include "code\datums\ai\basic_mobs\basic_subtrees\mine_walls.dm" #include "code\datums\ai\basic_mobs\basic_subtrees\move_to_cardinal.dm" #include "code\datums\ai\basic_mobs\basic_subtrees\opportunistic_ventcrawler.dm" +#include "code\datums\ai\basic_mobs\basic_subtrees\play_with_owners.dm" #include "code\datums\ai\basic_mobs\basic_subtrees\prepare_travel_to_destination.dm" #include "code\datums\ai\basic_mobs\basic_subtrees\ranged_skirmish.dm" #include "code\datums\ai\basic_mobs\basic_subtrees\run_emote.dm"