mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-12 10:42:37 +00:00
* Goats will randomly attack you (#78930) ## About The Pull Request We accidentally lost this behaviour when we converted goats to basic mobs. _Formerly_ (and now again) goats had a 0.5% chance per second to simply decide to attack you for no reason at all. While attacking you they also have a 10% chance per second to get bored of doing that and stop. Additionally, we were outputting a fluff message every time you attacked a goat which would spam chat if you were trying to fist fight each other. I added a 20 second cooldown onto it. As is often the case, implementing this led me down a bit of a rabbit hole. We were previously bypassing faction checks via a mixture of flags on AI behaviours and blackboard keys. I have moved this _entirely_ to the blackboard now, rather than making targetting subtypes just to skip faction checks. This entails having one blackboard key which is "by default do we care about factions?" and another which is "are we currently ignoring factions for some other reason?" Retaliatory AI will generally enable the second flag, so you can get pissed off at someone you would usually not mind hanging out with if they start something with you. Certain mobs which want to hunt other mobs but not be hunted in return just ignore factions entirely all the time and use the former. The upshot of this is that the default behaviour for expected default retaliatory AI shouldn't require you to set any specific kind of targetting datum and will Just Work. In a similar vein because I was touching largely the same mobs I made the "flee when injured" component apply its "don't flee because not injured" flag instantly upon application rather than needing to manually set it in the blackboard definition, so that also Just Works. ## Changelog 🆑 fix: Pete's anger management training has worn off, and he will once again sometimes pick a fight with you for absolutely no reason. qol: Attacking a goat will not spam messages so frequently. /🆑 --------- Co-authored-by: san7890 <the@ san7890.com> * Goats will randomly attack you --------- Co-authored-by: Jacquerel <hnevard@gmail.com> Co-authored-by: san7890 <the@ san7890.com>
40 lines
1.5 KiB
Plaintext
40 lines
1.5 KiB
Plaintext
/**
|
|
* 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)
|
|
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
|