Skip to content

Commit

Permalink
Dogs now flee from mobs with tongs (tgstation#78797)
Browse files Browse the repository at this point in the history
AI dogs with the dog controller behaviour will flee from a target with
tongs in hand.

Untested because I literally cannot play byond.

## Why It's Good For The Game
https://www.youtube.com/watch?v=cXIAZtwvgz0

## Changelog
:cl: oranges
add: Dogs now react to centrist grillers more realistically
/:cl:
  • Loading branch information
optimumtact authored and dwasint committed Nov 19, 2023
1 parent 1572170 commit 9e11b11
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
39 changes: 39 additions & 0 deletions code/datums/ai/basic_mobs/targetting_datums/with_object.dm
@@ -0,0 +1,39 @@
/**
* Find mobs who are holding the configurable object type
*
* This is an extension of basic targeting behaviour, that allows you to
* only target the mob if they have a specific item in their hand.
*
*/
/datum/targetting_datum/basic/holding_object
// We will find mobs who are holding this object in their hands
var/object_type_path = null

/**
* Create an instance of the holding object targeting datum
*
* * object_type_path Pass an object type path, this will be compared to the items
* in targets hands to filter the target list.
*/
/datum/targetting_datum/basic/holding_object/New(object_type_path)
if (!ispath(object_type_path))
stack_trace("trying to create an item targeting datum with no valid typepath")
// Leaving object type as null will make this basically a noop
return
src.object_type_path = object_type_path

///Returns true or false depending on if the target can be attacked by the mob
/datum/targetting_datum/basic/holding_object/can_attack(mob/living/living_mob, atom/target, vision_range, check_faction = FALSE)
if (object_type_path == null)
return FALSE // no op
if(!ismob(target))
return FALSE // no hands no problems

// Look at me, type casting like a grown up
var/mob/targetmob = target
// Check if our parent behaviour agrees we can attack this target (we ignore faction by default)
var/can_attack = ..()
if(can_attack && targetmob.is_holding_item_of_type(object_type_path))
return TRUE // they have the item
// No valid target
return FALSE
8 changes: 8 additions & 0 deletions code/datums/ai/dog/dog_controller.dm
Expand Up @@ -18,8 +18,12 @@
/datum/ai_controller/basic_controller/dog/corgi
blackboard = list(
BB_DOG_HARASS_HARM = TRUE,
// IF you dont have this fleeing behavviour will just refuse to work, isn't that funny ha ha
BB_BASIC_MOB_FLEEING = TRUE,
BB_VISION_RANGE = AI_DOG_VISION_RANGE,
BB_PET_TARGETTING_DATUM = new /datum/targetting_datum/not_friends(),
// Find nearby mobs with tongs in hand.
BB_TARGETTING_DATUM = new /datum/targetting_datum/basic/holding_object(/obj/item/kitchen/tongs),
BB_BABIES_PARTNER_TYPES = list(/mob/living/basic/pet/dog),
BB_BABIES_CHILD_TYPES = list(/mob/living/basic/pet/dog/corgi/puppy = 95, /mob/living/basic/pet/dog/corgi/puppy/void = 5),
)
Expand All @@ -29,6 +33,10 @@
/datum/ai_planning_subtree/make_babies, // Ian WILL prioritise sex over following your instructions
/datum/ai_planning_subtree/pet_planning,
/datum/ai_planning_subtree/dog_harassment,
// Find targets to run away from (uses the targetting datum from above)
/datum/ai_planning_subtree/simple_find_target,
// Flee from that target
/datum/ai_planning_subtree/flee_target,
)

/datum/ai_controller/basic_controller/dog/corgi/get_access()
Expand Down
1 change: 1 addition & 0 deletions tgstation.dme
Expand Up @@ -871,6 +871,7 @@
#include "code\datums\ai\basic_mobs\pet_commands\play_dead.dm"
#include "code\datums\ai\basic_mobs\targetting_datums\basic_targetting_datum.dm"
#include "code\datums\ai\basic_mobs\targetting_datums\dont_target_friends.dm"
#include "code\datums\ai\basic_mobs\targetting_datums\with_object.dm"
#include "code\datums\ai\cursed\cursed_behaviors.dm"
#include "code\datums\ai\cursed\cursed_controller.dm"
#include "code\datums\ai\cursed\cursed_subtrees.dm"
Expand Down

0 comments on commit 9e11b11

Please sign in to comment.