From 78530a0ceb0c5bdef233916b7559e25e230e9e42 Mon Sep 17 00:00:00 2001 From: Joan Lung Date: Sun, 30 Jul 2017 23:31:38 -0400 Subject: [PATCH 1/3] The AI's internal camera functions better --- code/datums/wires/robot.dm | 14 ++-- code/game/machinery/camera/camera.dm | 14 ---- code/game/machinery/camera/tracking.dm | 6 +- code/modules/mob/living/silicon/ai/ai.dm | 4 +- .../modules/mob/living/silicon/robot/death.dm | 4 +- .../modules/mob/living/silicon/robot/robot.dm | 71 ++++++------------- code/modules/mob/living/silicon/silicon.dm | 3 + .../mob/living/silicon/silicon_movement.dm | 20 ++++++ tgstation.dme | 1 + 9 files changed, 59 insertions(+), 78 deletions(-) create mode 100644 code/modules/mob/living/silicon/silicon_movement.dm diff --git a/code/datums/wires/robot.dm b/code/datums/wires/robot.dm index d4eeb0cc39d..1107eccdfa2 100644 --- a/code/datums/wires/robot.dm +++ b/code/datums/wires/robot.dm @@ -21,7 +21,7 @@ var/list/status = list() status += "The law sync module is [R.lawupdate ? "on" : "off"]." status += "The intelligence link display shows [R.connected_ai ? R.connected_ai.name : "NULL"]." - status += "The camera light is [!isnull(R.camera) && R.camera.status ? "on" : "off"]." + status += "The camera light is [!isnull(R.builtInCamera) && R.builtInCamera.status ? "on" : "off"]." status += "The lockdown indicator is [R.lockcharge ? "on" : "off"]." status += "The reset module hardware light is [R.has_module() ? "on" : "off"]." return status @@ -45,8 +45,8 @@ else R.notify_ai(TRUE) if(WIRE_CAMERA) // Pulse to disable the camera. - if(!isnull(R.camera) && !R.scrambledcodes) - R.camera.toggle_cam(usr, 0) + if(!QDELETED(R.builtInCamera) && !R.scrambledcodes) + R.builtInCamera.toggle_cam(usr, 0) R.visible_message("[R]'s camera lense focuses loudly.", "Your camera lense focuses loudly.") if(WIRE_LAWSYNC) // Forces a law update if possible. if(R.lawupdate) @@ -75,10 +75,10 @@ else if(!R.deployed) //AI shells must always have the same laws as the AI R.lawupdate = FALSE if (WIRE_CAMERA) // Disable the camera. - if(!isnull(R.camera) && !R.scrambledcodes) - R.camera.status = mend - R.camera.toggle_cam(usr, 0) - R.visible_message("[R]'s camera lense focuses loudly.", "Your camera lense focuses loudly.") + if(!QDELETED(R.builtInCamera) && !R.scrambledcodes) + R.builtInCamera.status = mend + R.builtInCamera.toggle_cam(usr, 0) + R.visible_message("[R]'s camera lens focuses loudly.", "Your camera lens focuses loudly.") if(WIRE_LOCKDOWN) // Simple lockdown. R.SetLockdown(!mend) if(WIRE_RESET_MODULE) diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index cc756caf982..2ef95cfa6c2 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -373,20 +373,6 @@ else set_light(0) -/obj/machinery/camera/portable //Cameras which are placed inside of things, such as helmets. - var/turf/prev_turf - -/obj/machinery/camera/portable/Initialize() - . = ..() - assembly.state = 0 //These cameras are portable, and so shall be in the portable state if removed. - assembly.anchored = FALSE - assembly.update_icon() - -/obj/machinery/camera/portable/process() //Updates whenever the camera is moved. - if(GLOB.cameranet && get_turf(src) != prev_turf) - GLOB.cameranet.updatePortableCamera(src) - prev_turf = get_turf(src) - /obj/machinery/camera/get_remote_view_fullscreens(mob/user) if(view_range == short_range) //unfocused user.overlay_fullscreen("remote_view", /obj/screen/fullscreen/impaired, 2) diff --git a/code/game/machinery/camera/tracking.dm b/code/game/machinery/camera/tracking.dm index 14579824672..af954703857 100644 --- a/code/game/machinery/camera/tracking.dm +++ b/code/game/machinery/camera/tracking.dm @@ -136,9 +136,9 @@ /proc/near_camera(mob/living/M) if (!isturf(M.loc)) return 0 - if(iscyborg(M)) - var/mob/living/silicon/robot/R = M - if(!(R.camera && R.camera.can_use()) && !GLOB.cameranet.checkCameraVis(M)) + if(issilicon(M)) + var/mob/living/silicon/S = M + if((!QDELETED(S.builtInCamera) || !S.builtInCamera.can_use()) && !GLOB.cameranet.checkCameraVis(M)) return 0 else if(!GLOB.cameranet.checkCameraVis(M)) return 0 diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index f31b339bf5b..81959edcb40 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -79,8 +79,6 @@ var/cooldown = 0 var/acceleration = 1 - var/obj/machinery/camera/portable/builtInCamera - var/obj/structure/AIcore/deactivated/linked_core //For exosuit control var/mob/living/silicon/robot/deployed_shell = null //For shell control var/datum/action/innate/deploy_shell/deploy_action = new @@ -151,7 +149,7 @@ GLOB.ai_list += src GLOB.shuttle_caller_list += src - builtInCamera = new /obj/machinery/camera/portable(src) + builtInCamera = new (src) builtInCamera.network = list("SS13") diff --git a/code/modules/mob/living/silicon/robot/death.dm b/code/modules/mob/living/silicon/robot/death.dm index c8c57dc6028..7eb241e01fe 100644 --- a/code/modules/mob/living/silicon/robot/death.dm +++ b/code/modules/mob/living/silicon/robot/death.dm @@ -22,8 +22,8 @@ locked = FALSE //unlock cover update_canmove() - if(camera && camera.status) - camera.toggle_cam(src,0) + if(!QDELETED(builtInCamera) && builtInCamera.status) + builtInCamera.toggle_cam(src,0) update_headlamp(1) //So borg lights are disabled when killed. uneq_all() // particularly to ensure sight modes are cleared diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 049092b36a1..2a9030fc825 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -42,7 +42,6 @@ var/mob/living/silicon/ai/connected_ai = null var/obj/item/weapon/stock_parts/cell/cell = null - var/obj/machinery/camera/camera = null var/opened = 0 var/emagged = FALSE @@ -76,7 +75,6 @@ var/lamp_recharging = 0 //Flag for if the lamp is on cooldown after being forcibly disabled. var/sight_mode = 0 - var/updating = 0 //portable camera camerachunk update hud_possible = list(ANTAG_HUD, DIAG_STAT_HUD, DIAG_HUD, DIAG_BATT_HUD, DIAG_TRACK_HUD) var/list/upgrades = list() @@ -125,16 +123,16 @@ lawupdate = FALSE radio = new /obj/item/device/radio/borg(src) - if(!scrambledcodes && !camera) - camera = new /obj/machinery/camera(src) - camera.c_tag = real_name - camera.network = list("SS13") + if(!scrambledcodes && !builtInCamera) + builtInCamera = new (src) + builtInCamera.c_tag = real_name + builtInCamera.network = list("SS13") if(wires.is_cut(WIRE_CAMERA)) - camera.status = 0 + builtInCamera.status = 0 module = new /obj/item/weapon/robot_module(src) module.rebuild_modules() update_icons() - ..() + . = ..() //If this body is meant to be a borg controlled by the AI player if(shell) @@ -189,7 +187,6 @@ wires = null module = null eye_lights = null - camera = null cell = null return ..() @@ -233,8 +230,8 @@ real_name = changed_name name = real_name - if(camera) - camera.c_tag = real_name //update the camera name too + if(!QDELETED(builtInCamera)) + builtInCamera.c_tag = real_name //update the camera name too /mob/living/silicon/robot/proc/get_standard_name() return "[(designation ? "[designation] " : "")][mmi.braintype]-[ident]" @@ -615,29 +612,6 @@ add_overlay(head_overlay) update_fire() -#define BORG_CAMERA_BUFFER 30 - -/mob/living/silicon/robot/proc/do_camera_update(oldLoc) - if(oldLoc != src.loc) - GLOB.cameranet.updatePortableCamera(src.camera) - updating = 0 - -/mob/living/silicon/robot/Move(a, b, flag) - var/oldLoc = src.loc - . = ..() - if(.) - if(src.camera) - if(!updating) - updating = 1 - addtimer(CALLBACK(src, .proc/do_camera_update, oldLoc), BORG_CAMERA_BUFFER) - if(module) - if(istype(module, /obj/item/weapon/robot_module/miner)) - if(istype(loc, /turf/open/floor/plating/asteroid)) - for(var/obj/item/I in held_items) - if(istype(I, /obj/item/weapon/storage/bag/ore)) - loc.attackby(I, src) -#undef BORG_CAMERA_BUFFER - /mob/living/silicon/robot/proc/self_destruct() if(emagged) if(mmi) @@ -656,9 +630,8 @@ canmove = 1 scrambledcodes = 1 //Disconnect it's camera so it's not so easily tracked. - if(src.camera) - qdel(src.camera) - src.camera = null + if(!QDELETED(builtInCamera)) + QDEL_NULL(builtInCamera) // I'm trying to get the Cyborg to not be listed in the camera list // Instead of being listed as "deactivated". The downside is that I'm going // to have to check if every camera is null or not before doing anything, to prevent runtime errors. @@ -939,8 +912,8 @@ /mob/living/silicon/robot/revive(full_heal = 0, admin_revive = 0) if(..()) //successfully ressuscitated from death - if(camera && !wires.is_cut(WIRE_CAMERA)) - camera.toggle_cam(src,0) + if(!QDELETED(builtInCamera) && !wires.is_cut(WIRE_CAMERA)) + builtInCamera.toggle_cam(src,0) update_headlamp() if(admin_revive) locked = TRUE @@ -951,8 +924,8 @@ ..() if(oldname != real_name) notify_ai(RENAME, oldname, newname) - if(camera) - camera.c_tag = real_name + if(!QDELETED(builtInCamera)) + builtInCamera.c_tag = real_name custom_name = newname @@ -1016,8 +989,8 @@ name = "[designation] AI Shell [rand(100,999)]" real_name = name GLOB.available_ai_shells |= src - if(camera) - camera.c_tag = real_name //update the camera name too + if(!QDELETED(builtInCamera)) + builtInCamera.c_tag = real_name //update the camera name too diag_hud_set_aishell() notify_ai(AI_SHELL) @@ -1032,15 +1005,15 @@ GLOB.available_ai_shells -= src name = "Unformatted Cyborg [rand(100,999)]" real_name = name - if(camera) - camera.c_tag = real_name + if(!QDELETED(builtInCamera)) + builtInCamera.c_tag = real_name diag_hud_set_aishell() /mob/living/silicon/robot/proc/deploy_init(var/mob/living/silicon/ai/AI) real_name = "[AI.real_name] shell [rand(100, 999)] - [designation]" //Randomizing the name so it shows up seperately in the shells list name = real_name - if(camera) - camera.c_tag = real_name //update the camera name too + if(!QDELETED(builtInCamera)) + builtInCamera.c_tag = real_name //update the camera name too mainframe = AI deployed = TRUE connected_ai = mainframe @@ -1084,8 +1057,8 @@ undeployment_action.Remove(src) if(radio) //Return radio to normal radio.recalculateChannels() - if(camera) - camera.c_tag = real_name //update the camera name too + if(!QDELETED(builtInCamera)) + builtInCamera.c_tag = real_name //update the camera name too diag_hud_set_aishell() mainframe.diag_hud_set_deployed() if(mainframe.laws) diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index e5b7d8b4100..3e2cc172dd4 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -36,6 +36,8 @@ var/d_hud = DATA_HUD_DIAGNOSTIC //There is only one kind of diag hud var/law_change_counter = 0 + var/obj/machinery/camera/builtInCamera = null + var/updating = FALSE //portable camera camerachunk update /mob/living/silicon/Initialize() ..() @@ -54,6 +56,7 @@ /mob/living/silicon/Destroy() radio = null aicamera = null + QDEL_NULL(builtInCamera) GLOB.silicon_mobs -= src return ..() diff --git a/code/modules/mob/living/silicon/silicon_movement.dm b/code/modules/mob/living/silicon/silicon_movement.dm new file mode 100644 index 00000000000..c7267acf76d --- /dev/null +++ b/code/modules/mob/living/silicon/silicon_movement.dm @@ -0,0 +1,20 @@ +/mob/living/silicon/Moved(oldLoc, dir) + . = ..() + update_camera_location(oldLoc) + +/mob/living/silicon/forceMove(atom/destination) + . = ..() + update_camera_location(destination) + +/mob/living/silicon/proc/do_camera_update(oldLoc) + if(!QDELETED(builtInCamera) && oldLoc != get_turf(src)) + GLOB.cameranet.updatePortableCamera(builtInCamera) + updating = FALSE + +#define SILICON_CAMERA_BUFFER 10 +/mob/living/silicon/proc/update_camera_location(oldLoc) + oldLoc = get_turf(oldLoc) + if(!QDELETED(builtInCamera) && !updating && oldLoc != get_turf(src)) + updating = TRUE + addtimer(CALLBACK(src, .proc/do_camera_update, oldLoc), SILICON_CAMERA_BUFFER) +#undef SILICON_CAMERA_BUFFER diff --git a/tgstation.dme b/tgstation.dme index 3303a1d188b..1e371b2fd56 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1620,6 +1620,7 @@ #include "code\modules\mob\living\silicon\say.dm" #include "code\modules\mob\living\silicon\silicon.dm" #include "code\modules\mob\living\silicon\silicon_defense.dm" +#include "code\modules\mob\living\silicon\silicon_movement.dm" #include "code\modules\mob\living\silicon\ai\ai.dm" #include "code\modules\mob\living\silicon\ai\ai_defense.dm" #include "code\modules\mob\living\silicon\ai\death.dm" From cf0d0879459e22e2ead05ade7cff85e5b19c2f99 Mon Sep 17 00:00:00 2001 From: Joan Lung Date: Mon, 31 Jul 2017 09:31:08 -0400 Subject: [PATCH 2/3] since hey we handled that --- .../living/silicon/robot/robot_movement.dm | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/code/modules/mob/living/silicon/robot/robot_movement.dm b/code/modules/mob/living/silicon/robot/robot_movement.dm index 8c0dc1149e5..9352f5d66d0 100644 --- a/code/modules/mob/living/silicon/robot/robot_movement.dm +++ b/code/modules/mob/living/silicon/robot/robot_movement.dm @@ -1,24 +1,3 @@ -/mob/living/silicon/robot/Moved(oldLoc, dir) - . = ..() - update_camera_location(oldLoc) - -/mob/living/silicon/robot/forceMove(atom/destination) - . = ..() - update_camera_location(destination) - -/mob/living/silicon/robot/proc/do_camera_update(oldLoc) - if(!QDELETED(camera) && oldLoc != get_turf(src)) - GLOB.cameranet.updatePortableCamera(camera) - updating = FALSE - -#define BORG_CAMERA_BUFFER 30 -/mob/living/silicon/robot/proc/update_camera_location(oldLoc) - oldLoc = get_turf(oldLoc) - if(!QDELETED(camera) && !updating && oldLoc != get_turf(src)) - updating = TRUE - addtimer(CALLBACK(src, .proc/do_camera_update, oldLoc), BORG_CAMERA_BUFFER) -#undef BORG_CAMERA_BUFFER - /mob/living/silicon/robot/Process_Spacemove(movement_dir = 0) if(ionpulse()) return 1 From 3d0884490e5e553cf43cac30fb9dd912808a309d Mon Sep 17 00:00:00 2001 From: Joan Lung Date: Mon, 31 Jul 2017 09:37:27 -0400 Subject: [PATCH 3/3] lense is actually a misspelling of flense --- code/datums/wires/robot.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/datums/wires/robot.dm b/code/datums/wires/robot.dm index 1107eccdfa2..65438830a29 100644 --- a/code/datums/wires/robot.dm +++ b/code/datums/wires/robot.dm @@ -47,7 +47,7 @@ if(WIRE_CAMERA) // Pulse to disable the camera. if(!QDELETED(R.builtInCamera) && !R.scrambledcodes) R.builtInCamera.toggle_cam(usr, 0) - R.visible_message("[R]'s camera lense focuses loudly.", "Your camera lense focuses loudly.") + R.visible_message("[R]'s camera lens focuses loudly.", "Your camera lens focuses loudly.") if(WIRE_LAWSYNC) // Forces a law update if possible. if(R.lawupdate) R.visible_message("[R] gently chimes.", "LawSync protocol engaged.")