[MIRROR] Fixes a hard del in monkey AI [MDB IGNORE] (#25713)

* Fixes a hard del in monkey AI (#80425)

## About The Pull Request

![firefox_KI4H4wxvN3](https://github.com/tgstation/tgstation/assets/13398309/6e8c18f3-2413-4eaf-8436-15fd7aea9c51)

Fixes this hard del, caused by a del-on-death mob being qdeleted after
being victim to the monkey's attack. When a mob gets qdeleted, they
remove themselves from the blackboard.

Monkey code was then adding it back immediately after, resulting in the
hard del. Adds safeties to ensure that won't happen.

## Why It's Good For The Game

Less annoying CI failures

## Changelog

🆑
fix: monkeys will no longer cause other monkeys to get angry at the mobs
they just poofed by attacking
/🆑

* Fixes a hard del in monkey AI

---------

Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-12-18 13:01:05 -06:00
committed by GitHub
co-authored by Bloop
parent ec17d8462d
commit 0a609c34d4
3 changed files with 14 additions and 4 deletions
+1 -1
View File
@@ -340,7 +340,7 @@ multiple modular subtrees with behaviors
set_ai_status(AI_STATUS_ON) //Can't do anything while player is connected
RegisterSignal(pawn, COMSIG_MOB_LOGIN, PROC_REF(on_sentience_gained))
// Turn the controller off the controller if the pawn has been qdeleted
// Turn the controller off if the pawn has been qdeleted
/datum/ai_controller/proc/on_pawn_qdeleted()
SIGNAL_HANDLER
set_ai_status(AI_STATUS_OFF)
+7 -1
View File
@@ -221,6 +221,12 @@
// note they might immediately reduce threat and drop from the list.
// this is fine, we're just giving them a love tap then leaving them alone.
// unless they fight back, then we retaliate
// Some mobs delete on death. If the target is no longer alive, go back to idle
if(QDELETED(target))
finish_action(controller, TRUE)
return
if(isnull(controller.blackboard[BB_MONKEY_ENEMIES][target]))
controller.set_blackboard_key_assoc(BB_MONKEY_ENEMIES, target, 1)
@@ -298,7 +304,7 @@
var/mob/living/living_pawn = controller.pawn
for(var/mob/living/nearby_monkey in view(living_pawn, MONKEY_ENEMY_VISION))
if(!HAS_AI_CONTROLLER_TYPE(nearby_monkey, /datum/ai_controller/monkey))
if(QDELETED(nearby_monkey) || !HAS_AI_CONTROLLER_TYPE(nearby_monkey, /datum/ai_controller/monkey))
continue
if(!SPT_PROB(MONKEY_RECRUIT_PROB, seconds_per_tick))
continue
+6 -2
View File
@@ -147,8 +147,12 @@ have ways of interacting with a specific mob and control it.
return TRUE
///Reactive events to being hit
/datum/ai_controller/monkey/proc/retaliate(mob/living/L)
add_blackboard_key_assoc(BB_MONKEY_ENEMIES, L, MONKEY_HATRED_AMOUNT)
/datum/ai_controller/monkey/proc/retaliate(mob/living/living_mob)
// just to be safe
if(QDELETED(living_mob))
return
add_blackboard_key_assoc(BB_MONKEY_ENEMIES, living_mob, MONKEY_HATRED_AMOUNT)
/datum/ai_controller/monkey/proc/on_attacked(datum/source, mob/attacker)
SIGNAL_HANDLER