[MIRROR] The AI's internal camera functions better (#2219)

* The AI's internal camera functions better

* sync robot.dm and hopefully not break shit
This commit is contained in:
CitadelStationBot
2017-08-05 12:24:58 -05:00
committed by kevinz000
parent f8371a4fbe
commit 90a7ead961
10 changed files with 60 additions and 77 deletions
+8 -8
View File
@@ -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,9 +45,9 @@
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)
R.visible_message("[R]'s camera lense focuses loudly.", "Your camera lense focuses loudly.")
if(!QDELETED(R.builtInCamera) && !R.scrambledcodes)
R.builtInCamera.toggle_cam(usr, 0)
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.")
@@ -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)
-14
View File
@@ -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)
+3 -3
View File
@@ -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
+1 -3
View File
@@ -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")
@@ -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
+22 -26
View File
@@ -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()
@@ -127,16 +125,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)
@@ -191,7 +189,6 @@
wires = null
module = null
eye_lights = null
camera = null
cell = null
return ..()
@@ -238,8 +235,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]"
@@ -676,9 +673,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.
@@ -959,8 +955,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
@@ -971,8 +967,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
@@ -1036,8 +1032,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)
@@ -1052,15 +1048,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 separately 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
@@ -1105,8 +1101,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)
@@ -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
@@ -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 ..()
@@ -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
+1
View File
@@ -1677,6 +1677,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"