Turns Deer into Basic Mob - They Freeze At The Sight of Vehicles (#74784)

## About The Pull Request

deers only show up in the BEPIS but i decided that they would be easy
enough to turn into a basic mob (they were). it was so easy in fact that
i decided to dip my toes into coding AI behavior, and made them freeze
up whenever they see a vehicle. this required a lot of code in a bunch
of places that i was quite unfamiliar with before starting this project,
so do let me know if i glonked up anywhere and i can work on smoothing
it out.
## Why It's Good For The Game

one less simple animal on the list. deers staring at headlights is
pretty cool i think, neato interaction for when you do get them beyond
the joke the bepis makes

i'm also amenable to dropping the whole "deer in headlights" code if you
don't like that for w/e reason- just wanted to make them basic at the
very least
## Changelog
🆑
add: If you ever happen upon a wild deer, try not to ride your fancy
vehicles too close to it as it'll freeze up like a... you know where I'm
going with this.
/🆑

---------

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
san7890
2023-04-23 11:31:03 -04:00
committed by GitHub
co-authored by Mothblocks
parent 2756965944
commit 43473a4dac
12 changed files with 151 additions and 32 deletions
@@ -0,0 +1,28 @@
/// Makes a mob simply stop and stare at a movable... yea...
/datum/ai_behavior/stop_and_stare
behavior_flags = AI_BEHAVIOR_MOVE_AND_PERFORM
/datum/ai_behavior/stop_and_stare/setup(datum/ai_controller/controller, target_key)
. = ..()
var/datum/weakref/weak_target = controller.blackboard[target_key]
var/atom/movable/target = weak_target?.resolve()
return ismovable(target) && isturf(target.loc) && ismob(controller.pawn)
/datum/ai_behavior/stop_and_stare/perform(seconds_per_tick, datum/ai_controller/controller, target_key)
// i don't really like doing this but we wanna make sure that the cooldown is pertinent to what we need for this specific controller before we invoke parent
action_cooldown = controller.blackboard[BB_STATIONARY_COOLDOWN]
. = ..()
var/datum/weakref/weak_target = controller.blackboard[target_key]
var/atom/movable/target = weak_target?.resolve()
if(!ismovable(target) || !isturf(target.loc)) // just to make sure that nothing funky happened between setup and perform
return
var/mob/pawn_mob = controller.pawn
var/turf/pawn_turf = get_turf(pawn_mob)
pawn_mob.face_atom(target)
pawn_mob.balloon_alert_to_viewers("stops and stares...")
set_movement_target(controller, pawn_turf, /datum/ai_movement/complete_stop)
if(controller.blackboard[BB_STATIONARY_MOVE_TO_TARGET])
addtimer(CALLBACK(src, PROC_REF(set_movement_target), controller, target, initial(controller.ai_movement)), (controller.blackboard[BB_STATIONARY_SECONDS] + 1 SECONDS))
@@ -101,6 +101,12 @@
speak = GLOB.wisdoms //Done here so it's setup properly
sound = list()
/datum/ai_planning_subtree/random_speech/deer
speech_chance = 1
speak = list("Weeeeeeee?", "Weeee", "WEOOOOOOOOOO")
emote_hear = list("brays.")
emote_see = list("shakes her head.")
/datum/ai_planning_subtree/random_speech/dog
speech_chance = 1
@@ -0,0 +1,14 @@
/// Locate a thing (practically any atom) to stop and stare at.
/datum/ai_planning_subtree/stare_at_thing
/datum/ai_planning_subtree/stare_at_thing/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick)
var/datum/weakref/weak_target = controller.blackboard[BB_STATIONARY_CAUSE]
var/atom/target = weak_target?.resolve()
if(isnull(target)) // No target? Time to locate one using the list we set in this mob's blackboard.
var/list/potential_scares = controller.blackboard[BB_STATIONARY_TARGETS]
controller.queue_behavior(/datum/ai_behavior/find_and_set/in_list, BB_STATIONARY_CAUSE, potential_scares)
return
controller.queue_behavior(/datum/ai_behavior/stop_and_stare, BB_STATIONARY_CAUSE)