diff --git a/code/datums/ai/_ai_controller.dm b/code/datums/ai/_ai_controller.dm index 06a4aac8358..6bbdabfc50d 100644 --- a/code/datums/ai/_ai_controller.dm +++ b/code/datums/ai/_ai_controller.dm @@ -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) diff --git a/code/datums/ai/monkey/monkey_behaviors.dm b/code/datums/ai/monkey/monkey_behaviors.dm index b041ec763a8..d16110cd702 100644 --- a/code/datums/ai/monkey/monkey_behaviors.dm +++ b/code/datums/ai/monkey/monkey_behaviors.dm @@ -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 diff --git a/code/datums/ai/monkey/monkey_controller.dm b/code/datums/ai/monkey/monkey_controller.dm index 951147007f9..781bfb70a85 100644 --- a/code/datums/ai/monkey/monkey_controller.dm +++ b/code/datums/ai/monkey/monkey_controller.dm @@ -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