From 93b2aa082095773d5bf73ee28d91ffe4d35702d2 Mon Sep 17 00:00:00 2001 From: zxaber <37497534+zxaber@users.noreply.github.com> Date: Mon, 11 Jan 2021 01:37:48 -0800 Subject: [PATCH] Fixes removing AIs from mechs (#55986) Basically the old code attempted to use locate(AI), but the AI in this case is a ref that is supposed to be provided by the card. Since the card is initially empty when removing AIs from the mech, it couldn't find the null in the occupants list and thus failed with a report that there was no AI in the mech. Now it checks all occupants and makes a list of any AIs it finds, then gives the user the option to pick an AI (though since we don't have any multi-pilot mechs yet the most you can get is one AI, and input with one option just auto-chooses). --- code/modules/vehicles/mecha/_mecha.dm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/code/modules/vehicles/mecha/_mecha.dm b/code/modules/vehicles/mecha/_mecha.dm index 32cb46cf2c4..c606e031bc2 100644 --- a/code/modules/vehicles/mecha/_mecha.dm +++ b/code/modules/vehicles/mecha/_mecha.dm @@ -812,10 +812,21 @@ if(!construction_state) //Mech must be in maint mode to allow carding. to_chat(user, "[name] must have maintenance protocols active in order to allow a transfer.") return - if(!locate(AI) in occupants) //Mech does not have an AI for a pilot + var/list/ai_pilots = list() + for(var/mob/living/silicon/ai/aipilot in occupants) + ai_pilots += aipilot + if(!ai_pilots.len) //Mech does not have an AI for a pilot to_chat(user, "No AI detected in the [name] onboard computer.") return - for(var/mob/living/silicon/ai in occupants) + if(ai_pilots.len > 1) //Input box for multiple AIs, but if there's only one we'll default to them. + AI = input(user,"Which AI do you wish to card?", "AI Selection") as null|anything in sortList(ai_pilots) + else + AI = ai_pilots[1] + if(!AI) + return + if(!(AI in occupants) || !user.Adjacent(src)) + return //User sat on the selection window and things changed. + AI.ai_restore_power()//So the AI initially has power. AI.control_disabled = TRUE AI.radio_enabled = FALSE