From e2f43e53b9fa20af0d37a0766c1ec2912ba12c55 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 15 Mar 2023 01:51:52 +0100 Subject: [PATCH] [MIRROR] Gives The AI Hotkeys For Disconnecting From and Reconnecting To A Cyborg Shell [MDB IGNORE] (#19868) * Gives The AI Hotkeys For Disconnecting From and Reconnecting To A Cyborg Shell (#73871) ## About The Pull Request What it says on the tin. Gives the AI hotkeys to connect and disconnect from its shell. I'm open to suggestions for better default hotkeys, I made sure to choose out-of-the-way keys with no overlaps because I have a vague memory about code-side keybind conflicts leading to a threatened forkening and I don't want that. Also this is my first PR with more than 2 lines changed so I would appreciate a thorough and critical review of my code. ## Why It's Good For The Game Since there are so many AI player admins (Who are all universally gigachads btw) it would be convenient to them to have an aghost-hotkey analogue for the AI. This change was specifically requested of me by one of these admins in fact. I'm sure non-admin AIs would appreciate this convenience as well though. ## Changelog :cl: qol: The AI now has hotkeys for its shells, make sure to bind them to your preferred keys in your keybindings menu, under game preferences. /:cl: * Gives The AI Hotkeys For Disconnecting From and Reconnecting To A Cyborg Shell --------- Co-authored-by: Jackraxxus <60418544+Jackraxxus@users.noreply.github.com> --- code/__DEFINES/keybinding.dm | 2 ++ code/datums/keybinding/_defines.dm | 2 ++ .../keybinding/artificial_intelligence.dm | 21 +++++++++++++++++++ code/datums/keybinding/robot.dm | 19 +++++++++++++++++ tgstation.dme | 1 + 5 files changed, 45 insertions(+) create mode 100644 code/datums/keybinding/artificial_intelligence.dm diff --git a/code/__DEFINES/keybinding.dm b/code/__DEFINES/keybinding.dm index dbc8ef85b17..0f05c0fe12b 100644 --- a/code/__DEFINES/keybinding.dm +++ b/code/__DEFINES/keybinding.dm @@ -79,6 +79,8 @@ #define COMSIG_KB_SILICON_TOGGLEMODULETWO_DOWN "keybinding_silicon_togglemoduletwo_down" #define COMSIG_KB_SILICON_TOGGLEMODULETHREE_DOWN "keybinding_silicon_togglemodulethree_down" #define COMSIG_KB_SILICON_UNEQUIPMODULE_DOWN "keybinding_silicon_unequipmodule_down" +#define COMSIG_KB_SILION_UNDEPLOY_DOWN "keybinding_silicon_undeploy_down" +#define COMSIG_KB_SILICON_RECONNECT_DOWN "keybinding_silicon_reconnect_down" //Movement #define COMSIG_KB_MOVEMENT_NORTH_DOWN "keybinding_movement_north_down" diff --git a/code/datums/keybinding/_defines.dm b/code/datums/keybinding/_defines.dm index 7d4ae382227..5f0bbae164b 100644 --- a/code/datums/keybinding/_defines.dm +++ b/code/datums/keybinding/_defines.dm @@ -5,6 +5,7 @@ #define CATEGORY_CARBON "CARBON" #define CATEGORY_HUMAN "HUMAN" #define CATEGORY_ROBOT "ROBOT" +#define CATEGORY_AI "AI" #define CATEGORY_MISC "MISC" #define CATEGORY_MOVEMENT "MOVEMENT" #define CATEGORY_COMMUNICATION "COMMUNICATION" @@ -17,4 +18,5 @@ #define WEIGHT_LIVING 50 #define WEIGHT_DEAD 60 #define WEIGHT_EMOTE 70 +#define WEIGHT_AI 80 #define WEIGHT_LOWEST 999 diff --git a/code/datums/keybinding/artificial_intelligence.dm b/code/datums/keybinding/artificial_intelligence.dm new file mode 100644 index 00000000000..c7430c237c6 --- /dev/null +++ b/code/datums/keybinding/artificial_intelligence.dm @@ -0,0 +1,21 @@ +/datum/keybinding/artificial_intelligence + category = CATEGORY_AI + weight = WEIGHT_AI + +/datum/keybinding/artificial_intelligence/can_use(client/user) + return isAI(user.mob) + +/datum/keybinding/artificial_intelligence/reconnect + hotkey_keys = list("-") + name = "reconnect" + full_name = "Reconnect to shell" + description = "Reconnects you to your most recently used AI shell" + keybind_signal = COMSIG_KB_SILICON_RECONNECT_DOWN + +/datum/keybinding/artificial_intelligence/reconnect/down(client/user) + . = ..() + if(.) + return + var/mob/living/silicon/ai/our_ai = user.mob + our_ai.deploy_to_shell(our_ai.redeploy_action.last_used_shell) + return TRUE diff --git a/code/datums/keybinding/robot.dm b/code/datums/keybinding/robot.dm index de941732275..3aac0deac96 100644 --- a/code/datums/keybinding/robot.dm +++ b/code/datums/keybinding/robot.dm @@ -64,3 +64,22 @@ var/mob/living/silicon/robot/R = user.mob R.uneq_active() return TRUE + +/datum/keybinding/robot/undeploy + category = CATEGORY_AI + hotkey_keys = list("=") + name = "undeploy" + full_name = "Disconnect from shell" + description = "Returns you to your AI core" + keybind_signal = COMSIG_KB_SILION_UNDEPLOY_DOWN + +/datum/keybinding/robot/undeploy/down(client/user) + . = ..() + if(.) + return + var/mob/living/silicon/robot/shell/our_shell = user.mob + //We make sure our shell is actually a shell + if(our_shell.shell == FALSE) + return + our_shell.undeploy() + return TRUE diff --git a/tgstation.dme b/tgstation.dme index 17acf43b94a..a7ec88805ad 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1323,6 +1323,7 @@ #include "code\datums\keybinding\_defines.dm" #include "code\datums\keybinding\_keybindings.dm" #include "code\datums\keybinding\admin.dm" +#include "code\datums\keybinding\artificial_intelligence.dm" #include "code\datums\keybinding\carbon.dm" #include "code\datums\keybinding\client.dm" #include "code\datums\keybinding\communication.dm"