From eb69f11a1b836da18ef979e33b6620612a78a86e Mon Sep 17 00:00:00 2001
From: JimKil3 <47290811+JimKil3@users.noreply.github.com>
Date: Sat, 12 Aug 2023 12:38:10 -0500
Subject: [PATCH] Adds RTS-like camera controls to AI (#21625)
* REMOVES sillycons (their keybinds)
* adds the feature
* comment fix
* mech fix
* lewcc review
---
code/__DEFINES/keybindings_defines.dm | 2 +-
code/_globalvars/lists/keybindings_lists.dm | 4 +-
code/datums/keybindings/ai_keybinds.dm | 86 ++++++++++++++++++++
code/datums/keybindings/robot_keybinds.dm | 9 ++
code/datums/keybindings/silicon_keybinds.dm | 14 ----
code/game/machinery/camera/tracking.dm | 57 -------------
code/modules/mob/living/silicon/ai/ai_mob.dm | 19 ++++-
paradise.dme | 2 +-
8 files changed, 115 insertions(+), 78 deletions(-)
create mode 100644 code/datums/keybindings/ai_keybinds.dm
delete mode 100644 code/datums/keybindings/silicon_keybinds.dm
diff --git a/code/__DEFINES/keybindings_defines.dm b/code/__DEFINES/keybindings_defines.dm
index 5523006b0f9..cc1c80d83c5 100644
--- a/code/__DEFINES/keybindings_defines.dm
+++ b/code/__DEFINES/keybindings_defines.dm
@@ -3,7 +3,7 @@
#define KB_CATEGORY_LIVING 3
#define KB_CATEGORY_CARBON 4
#define KB_CATEGORY_HUMAN 5
-#define KB_CATEGORY_SILICON 6
+#define KB_CATEGORY_AI 6
#define KB_CATEGORY_ROBOT 7
#define KB_CATEGORY_ADMIN 8
#define KB_CATEGORY_EMOTE_GENERIC 9
diff --git a/code/_globalvars/lists/keybindings_lists.dm b/code/_globalvars/lists/keybindings_lists.dm
index 45a90536abc..350c5c3ec75 100644
--- a/code/_globalvars/lists/keybindings_lists.dm
+++ b/code/_globalvars/lists/keybindings_lists.dm
@@ -9,8 +9,8 @@ GLOBAL_LIST_INIT(keybindings_groups, list(
"Human Emotes" = KB_CATEGORY_EMOTE_HUMAN,
"Carbon" = KB_CATEGORY_CARBON,
"Carbon Emote" = KB_CATEGORY_EMOTE_CARBON,
- "Robot" = KB_CATEGORY_ROBOT,
- "Silicon" = KB_CATEGORY_SILICON,
+ "Cyborg" = KB_CATEGORY_ROBOT,
+ "AI" = KB_CATEGORY_AI,
"Silicon/IPC Emote" = KB_CATEGORY_EMOTE_SILICON,
"Animal Emote" = KB_CATEGORY_EMOTE_ANIMAL,
"Brain Emote" = KB_CATEGORY_EMOTE_BRAIN,
diff --git a/code/datums/keybindings/ai_keybinds.dm b/code/datums/keybindings/ai_keybinds.dm
new file mode 100644
index 00000000000..b1d04a23e81
--- /dev/null
+++ b/code/datums/keybindings/ai_keybinds.dm
@@ -0,0 +1,86 @@
+/datum/keybinding/ai
+ category = KB_CATEGORY_AI
+
+/datum/keybinding/ai/can_use(client/C, mob/M)
+ return isAI(M) && ..()
+
+/datum/keybinding/ai/to_core
+ name = "Jump to Core"
+ keys = list("1")
+
+/datum/keybinding/ai/to_core/down(client/C)
+ . = ..()
+ var/mob/living/silicon/ai/AI = C.mob
+ AI.view_core()
+
+/datum/keybinding/ai/store_location
+ //Which location we're storing.
+ var/location_number
+
+/datum/keybinding/ai/store_location/down(client/C)
+ . = ..()
+ var/mob/living/silicon/ai/AI = C.mob
+ if(AI.store_location(location_number))
+ to_chat(AI, "Successfully set location [location_number].")
+
+/datum/keybinding/ai/store_location/one
+ name = "Store Location One"
+ keys = list("Ctrl2")
+ location_number = 1
+
+/datum/keybinding/ai/store_location/two
+ name = "Store Location Two"
+ keys = list("Ctrl3")
+ location_number = 2
+
+/datum/keybinding/ai/store_location/three
+ name = "Store Location Three"
+ keys = list("Ctrl4")
+ location_number = 3
+
+/datum/keybinding/ai/store_location/four
+ name = "Store Location Four"
+ keys = list("Ctrl5")
+ location_number = 4
+
+/datum/keybinding/ai/to_location
+ var/location_number
+
+/datum/keybinding/ai/to_location/down(client/C)
+ . = ..()
+ var/mob/living/silicon/ai/AI = C.mob
+
+ if(AI.stored_locations[location_number] == "unset")
+ to_chat(AI, "You haven't set location [location_number] yet!")
+ return
+
+ AI.eyeobj.setLoc(AI.stored_locations[location_number])
+
+/datum/keybinding/ai/to_location/one
+ name = "Jump to Location One"
+ keys = list("2")
+ location_number = 1
+
+/datum/keybinding/ai/to_location/two
+ name = "Jump to Location Two"
+ keys = list("3")
+ location_number = 2
+
+/datum/keybinding/ai/to_location/three
+ name = "Jump to Location Three"
+ keys = list("4")
+ location_number = 3
+
+/datum/keybinding/ai/to_location/four
+ name = "Jump to Location Four"
+ keys = list("5")
+ location_number = 4
+
+/datum/keybinding/ai/switch_intent
+ name = "Switch Intents"
+ keys = list("6")
+
+/datum/keybinding/ai/switch_intent/down(client/C)
+ . = ..()
+ var/mob/living/silicon/ai/AI = C.mob
+ AI.a_intent_change(INTENT_HOTKEY_LEFT)
diff --git a/code/datums/keybindings/robot_keybinds.dm b/code/datums/keybindings/robot_keybinds.dm
index 64e4c10c519..e5e56e032e6 100644
--- a/code/datums/keybindings/robot_keybinds.dm
+++ b/code/datums/keybindings/robot_keybinds.dm
@@ -28,6 +28,15 @@
module_number = 3
keys = list("3")
+/datum/keybinding/robot/switch_intent
+ name = "Switch Intents"
+ keys = list("4")
+
+/datum/keybinding/robot/switch_intent/down(client/C)
+ . = ..()
+ var/mob/living/silicon/robot/M = C.mob
+ M.a_intent_change(INTENT_HOTKEY_LEFT)
+
/datum/keybinding/robot/cycle_modules
name = "Cycle Modules"
keys = list("X")
diff --git a/code/datums/keybindings/silicon_keybinds.dm b/code/datums/keybindings/silicon_keybinds.dm
deleted file mode 100644
index 4cf689e6f89..00000000000
--- a/code/datums/keybindings/silicon_keybinds.dm
+++ /dev/null
@@ -1,14 +0,0 @@
-/datum/keybinding/silicon
- category = KB_CATEGORY_SILICON
-
-/datum/keybinding/silicon/can_use(client/C, mob/M)
- return issilicon(M) && ..()
-
-/datum/keybinding/silicon/switch_intent
- name = "Switch Intents"
- keys = list("4")
-
-/datum/keybinding/silicon/switch_intent/down(client/C)
- . = ..()
- var/mob/living/silicon/M = C.mob
- M.a_intent_change(INTENT_HOTKEY_LEFT)
diff --git a/code/game/machinery/camera/tracking.dm b/code/game/machinery/camera/tracking.dm
index 3fd7f2ab21a..2ed707fc775 100644
--- a/code/game/machinery/camera/tracking.dm
+++ b/code/game/machinery/camera/tracking.dm
@@ -5,10 +5,6 @@
return 1
return 0
-
-/mob/living/silicon/ai/var/max_locations = 10
-/mob/living/silicon/ai/var/stored_locations[0]
-
/mob/living/silicon/ai/proc/get_camera_list()
track.cameras.Cut()
@@ -49,59 +45,6 @@
return
-/mob/living/silicon/ai/proc/ai_store_location(loc as text)
- set category = "AI Commands"
- set name = "Store Camera Location"
- set desc = "Stores your current camera location by the given name"
-
- loc = sanitize(copytext(loc, 1, MAX_MESSAGE_LEN))
- if(!loc)
- to_chat(src, "Must supply a location name")
- return
-
- if(stored_locations.len >= max_locations)
- to_chat(src, "Cannot store additional locations. Remove one first")
- return
-
- if(loc in stored_locations)
- to_chat(src, "There is already a stored location by this name")
- return
-
- var/L = get_turf(eyeobj)
- if(InvalidTurf(get_turf(L)))
- to_chat(src, "Unable to store this location")
- return
-
- stored_locations[loc] = L
- to_chat(src, "Location '[loc]' stored")
-
-/mob/living/silicon/ai/proc/sorted_stored_locations()
- return sortList(stored_locations)
-
-/mob/living/silicon/ai/proc/ai_goto_location(loc in sorted_stored_locations())
- set category = "AI Commands"
- set name = "Goto Camera Location"
- set desc = "Returns to the selected camera location"
-
- if(!(loc in stored_locations))
- to_chat(src, "Location [loc] not found")
- return
-
- var/L = stored_locations[loc]
- src.eyeobj.setLoc(L)
-
-/mob/living/silicon/ai/proc/ai_remove_location(loc in sorted_stored_locations())
- set category = "AI Commands"
- set name = "Delete Camera Location"
- set desc = "Deletes the selected camera location"
-
- if(!(loc in stored_locations))
- to_chat(src, "Location [loc] not found")
- return
-
- stored_locations.Remove(loc)
- to_chat(src, "Location [loc] removed")
-
// Used to allow the AI is write in mob names/camera name from the CMD line.
/datum/trackable
var/list/names = list()
diff --git a/code/modules/mob/living/silicon/ai/ai_mob.dm b/code/modules/mob/living/silicon/ai/ai_mob.dm
index 5ec2d304c0a..db9a7ea34dc 100644
--- a/code/modules/mob/living/silicon/ai/ai_mob.dm
+++ b/code/modules/mob/living/silicon/ai/ai_mob.dm
@@ -5,13 +5,10 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
/mob/living/silicon/ai/proc/ai_call_shuttle,
/mob/living/silicon/ai/proc/ai_camera_track,
/mob/living/silicon/ai/proc/ai_camera_list,
- /mob/living/silicon/ai/proc/ai_goto_location,
- /mob/living/silicon/ai/proc/ai_remove_location,
/mob/living/silicon/ai/proc/ai_hologram_change,
/mob/living/silicon/ai/proc/ai_network_change,
/mob/living/silicon/ai/proc/ai_roster,
/mob/living/silicon/ai/proc/ai_statuschange,
- /mob/living/silicon/ai/proc/ai_store_location,
/mob/living/silicon/ai/proc/control_integrated_radio,
/mob/living/silicon/ai/proc/core,
/mob/living/silicon/ai/proc/pick_icon,
@@ -118,6 +115,9 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
var/list/all_eyes = list()
var/next_text_announcement
+ //Used with the hotkeys on 2-5 to store locations.
+ var/list/stored_locations = list()
+
/mob/living/silicon/ai/proc/add_ai_verbs()
verbs |= GLOB.ai_verbs_default
verbs |= silicon_subsystems
@@ -218,6 +218,10 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
GLOB.ai_list += src
GLOB.shuttle_caller_list += src
+
+ for(var/I in 1 to 4)
+ stored_locations += "unset" //This is checked in ai_keybinds.dm.
+
..()
/mob/living/silicon/ai/Destroy()
@@ -1497,4 +1501,13 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
to_chat(src, "The tiny in built fan finally removes the tape!")
ducttapecomponent.remove_tape(card, src)
+//Stores the location of the AI to the value of stored_locations associated with location_number.
+/mob/living/silicon/ai/proc/store_location(location_number)
+ if(!isturf(eyeobj.loc)) //i.e., inside a mech or other shenanigans
+ to_chat(src, "You can't set a location here!")
+ return FALSE
+
+ stored_locations[location_number] = eyeobj.loc
+ return TRUE
+
#undef TEXT_ANNOUNCEMENT_COOLDOWN
diff --git a/paradise.dme b/paradise.dme
index 7e83083779f..ddcbd3a43db 100644
--- a/paradise.dme
+++ b/paradise.dme
@@ -451,6 +451,7 @@
#include "code\datums\helper_datums\topic_input.dm"
#include "code\datums\keybindings\_keybinding.dm"
#include "code\datums\keybindings\admin_keybinds.dm"
+#include "code\datums\keybindings\ai_keybinds.dm"
#include "code\datums\keybindings\carbon_keybinds.dm"
#include "code\datums\keybindings\client.dm"
#include "code\datums\keybindings\emote_keybinds.dm"
@@ -459,7 +460,6 @@
#include "code\datums\keybindings\mob_keybinds.dm"
#include "code\datums\keybindings\movement_keybinds.dm"
#include "code\datums\keybindings\robot_keybinds.dm"
-#include "code\datums\keybindings\silicon_keybinds.dm"
#include "code\datums\looping_sounds\item_sounds.dm"
#include "code\datums\looping_sounds\looping_sound.dm"
#include "code\datums\looping_sounds\machinery_sounds.dm"