From 16e8e9d5d83a1c0cd693dea3430b2438c309d2a9 Mon Sep 17 00:00:00 2001 From: Yenwodyah Date: Wed, 16 Dec 2020 23:21:48 -0600 Subject: [PATCH] null AI transfers through transformations correctly (#55535) --- code/modules/mob/transform_procs.dm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/code/modules/mob/transform_procs.dm b/code/modules/mob/transform_procs.dm index ab8ddd6218e..982d297977b 100644 --- a/code/modules/mob/transform_procs.dm +++ b/code/modules/mob/transform_procs.dm @@ -151,8 +151,12 @@ if(tr_flags & TR_KEEPSTAMINADAMAGE) O.adjustStaminaLoss(getStaminaLoss()) + //if we have an AI, transfer it; if we don't, make sure the new thing doesn't either if(tr_flags & TR_KEEPAI) - ai_controller.PossessPawn(O) + if(ai_controller) + ai_controller.PossessPawn(O) + else if(O.ai_controller) + QDEL_NULL(O.ai_controller) if (tr_flags & TR_DEFAULTMSG) to_chat(O, "You are now a monkey.") @@ -327,8 +331,13 @@ changeling.purchasedpowers -= HF changeling.regain_powers() + //if we have an AI, transfer it; if we don't, make sure the new thing doesn't either if(tr_flags & TR_KEEPAI) - ai_controller.PossessPawn(O) + if(ai_controller) + ai_controller.PossessPawn(O) + else if(O.ai_controller) + QDEL_NULL(O.ai_controller) + O.a_intent = INTENT_HELP if (tr_flags & TR_DEFAULTMSG)