forked from Skyrat-SS13/Skyrat-tg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIRROR] Turns Deer into Basic Mob - They Freeze At The Sight of Vehi…
…cles [MDB IGNORE] (Skyrat-SS13#20711) * 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 :cl: 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. /:cl: --------- Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> * Turns Deer into Basic Mob - They Freeze At The Sight of Vehicles --------- Co-authored-by: san7890 <the@san7890.com> Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>
- Loading branch information
1 parent
7ffa98e
commit 8164175
Showing
12 changed files
with
151 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
code/datums/ai/basic_mobs/basic_ai_behaviors/stop_and_stare.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
code/datums/ai/basic_mobs/basic_subtrees/stare_at_thing.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/// Come to a complete stop for a set amount of time. | ||
/datum/ai_movement/complete_stop | ||
max_pathing_attempts = INFINITE // path all you want, you can not escape your fate | ||
|
||
/datum/ai_movement/complete_stop/start_moving_towards(datum/ai_controller/controller, atom/current_movement_target, min_distance) | ||
. = ..() | ||
var/atom/movable/moving = controller.pawn | ||
var/stopping_time = controller.blackboard[BB_STATIONARY_SECONDS] | ||
var/delay_time = (stopping_time * 0.5) // no real reason to fire any more often than this really | ||
// assume that the current_movement_target is our location | ||
var/datum/move_loop/loop = SSmove_manager.freeze(moving, current_movement_target, delay = delay_time, timeout = stopping_time, subsystem = SSai_movement, extra_info = controller) | ||
RegisterSignal(loop, COMSIG_MOVELOOP_PREPROCESS_CHECK, PROC_REF(pre_move)) | ||
|
||
/datum/ai_movement/complete_stop/allowed_to_move(datum/move_loop/source) | ||
return // no movement allowed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/mob/living/basic/deer | ||
name = "doe" | ||
desc = "A gentle, peaceful forest animal. How did this get into space?" | ||
icon_state = "deer-doe" | ||
icon_living = "deer-doe" | ||
icon_dead = "deer-doe-dead" | ||
gender = FEMALE | ||
mob_biotypes = MOB_ORGANIC|MOB_BEAST | ||
speak_emote = list("grunts", "grunts lowly") | ||
butcher_results = list(/obj/item/food/meat/slab = 3) | ||
response_help_continuous = "pets" | ||
response_help_simple = "pet" | ||
response_disarm_continuous = "gently nudges" | ||
response_disarm_simple = "gently nudges aside" | ||
response_harm_continuous = "kicks" | ||
response_harm_simple = "kick" | ||
attack_verb_continuous = "bucks" | ||
attack_verb_simple = "buck" | ||
attack_sound = 'sound/weapons/punch1.ogg' | ||
health = 75 | ||
maxHealth = 75 | ||
blood_volume = BLOOD_VOLUME_NORMAL | ||
ai_controller = /datum/ai_controller/basic_controller/deer | ||
/// Things that will scare us into being stationary. Vehicles are scary to deers because they might have headlights. | ||
var/static/list/stationary_scary_things = list(/obj/vehicle) | ||
|
||
/mob/living/basic/deer/Initialize(mapload) | ||
. = ..() | ||
AddElement(/datum/element/footstep, footstep_type = FOOTSTEP_MOB_SHOE) | ||
var/time_to_freeze_for = (rand(5, 10) SECONDS) | ||
ai_controller.blackboard[BB_STATIONARY_SECONDS] = time_to_freeze_for | ||
ai_controller.blackboard[BB_STATIONARY_COOLDOWN] = (time_to_freeze_for * (rand(3, 5))) | ||
ai_controller.blackboard[BB_STATIONARY_TARGETS] = stationary_scary_things | ||
|
||
/datum/ai_controller/basic_controller/deer | ||
blackboard = list( | ||
BB_BASIC_MOB_FLEEING = TRUE, | ||
BB_STATIONARY_MOVE_TO_TARGET = TRUE, | ||
BB_TARGETTING_DATUM = new /datum/targetting_datum/basic/ignore_faction, | ||
) | ||
ai_traits = STOP_MOVING_WHEN_PULLED | ||
ai_movement = /datum/ai_movement/basic_avoidance | ||
idle_behavior = /datum/idle_behavior/idle_random_walk | ||
planning_subtrees = list( | ||
/datum/ai_planning_subtree/random_speech/deer, | ||
/datum/ai_planning_subtree/stare_at_thing, | ||
/datum/ai_planning_subtree/find_nearest_thing_which_attacked_me_to_flee, | ||
/datum/ai_planning_subtree/flee_target, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters