forked from Monkestation/Monkestation2.0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dogs now flee from mobs with tongs (tgstation#78797)
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
1 parent
1572170
commit 9e11b11
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
code/datums/ai/basic_mobs/targetting_datums/with_object.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,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 |
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