Fixes an issue where toggling camera lights would disconnect the AI from an active holopad while keeping the pad online.

This commit is contained in:
PsiOmega
2014-08-26 16:20:02 +02:00
parent cbf3d79ea1
commit 0090efb210
5 changed files with 31 additions and 33 deletions

View File

@@ -101,7 +101,7 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/
hologram.SetLuminosity(2) //hologram lighting hologram.SetLuminosity(2) //hologram lighting
SetLuminosity(2) //pad lighting SetLuminosity(2) //pad lighting
icon_state = "holopad1" icon_state = "holopad1"
A.current = src A.holo = src
master = A//AI is the master. master = A//AI is the master.
use_power = 2//Active power usage. use_power = 2//Active power usage.
return 1 return 1
@@ -109,8 +109,8 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/
/obj/machinery/hologram/holopad/proc/clear_holo() /obj/machinery/hologram/holopad/proc/clear_holo()
// hologram.SetLuminosity(0)//Clear lighting. //handled by the lighting controller when its ower is deleted // hologram.SetLuminosity(0)//Clear lighting. //handled by the lighting controller when its ower is deleted
del(hologram)//Get rid of hologram. del(hologram)//Get rid of hologram.
if(master.current == src) if(master.holo == src)
master.current = null master.holo = null
master = null//Null the master, since no-one is using it now. master = null//Null the master, since no-one is using it now.
SetLuminosity(0) //pad lighting (hologram lighting will be handled automatically since its owner was deleted) SetLuminosity(0) //pad lighting (hologram lighting will be handled automatically since its owner was deleted)
icon_state = "holopad0" icon_state = "holopad0"

View File

@@ -20,7 +20,7 @@ var/list/ai_list = list()
density = 1 density = 1
status_flags = CANSTUN|CANPARALYSE status_flags = CANSTUN|CANPARALYSE
var/list/network = list("SS13") var/list/network = list("SS13")
var/obj/machinery/camera/current = null var/obj/machinery/camera/camera = null
var/list/connected_robots = list() var/list/connected_robots = list()
var/aiRestorePowerRoutine = 0 var/aiRestorePowerRoutine = 0
//var/list/laws = list() //var/list/laws = list()
@@ -311,9 +311,9 @@ var/list/ai_list = list()
return return
/mob/living/silicon/ai/check_eye(var/mob/user as mob) /mob/living/silicon/ai/check_eye(var/mob/user as mob)
if (!current) if (!camera)
return null return null
user.reset_view(current) user.reset_view(camera)
return 1 return 1
/mob/living/silicon/ai/blob_act() /mob/living/silicon/ai/blob_act()
@@ -490,10 +490,10 @@ var/list/ai_list = list()
updatehealth() updatehealth()
/mob/living/silicon/ai/reset_view(atom/A) /mob/living/silicon/ai/reset_view(atom/A)
if(current) if(camera)
current.SetLuminosity(0) camera.SetLuminosity(0)
if(istype(A,/obj/machinery/camera)) if(istype(A,/obj/machinery/camera))
current = A camera = A
..() ..()
if(istype(A,/obj/machinery/camera)) if(istype(A,/obj/machinery/camera))
if(camera_light_on) A.SetLuminosity(AI_CAMERA_LUMINOSITY) if(camera_light_on) A.SetLuminosity(AI_CAMERA_LUMINOSITY)
@@ -677,9 +677,9 @@ var/list/ai_list = list()
camera_light_on = !camera_light_on camera_light_on = !camera_light_on
src << "Camera lights [camera_light_on ? "activated" : "deactivated"]." src << "Camera lights [camera_light_on ? "activated" : "deactivated"]."
if(!camera_light_on) if(!camera_light_on)
if(current) if(camera)
current.SetLuminosity(0) camera.SetLuminosity(0)
current = null camera = null
else else
lightNearbyCamera() lightNearbyCamera()
@@ -690,23 +690,23 @@ var/list/ai_list = list()
/mob/living/silicon/ai/proc/lightNearbyCamera() /mob/living/silicon/ai/proc/lightNearbyCamera()
if(camera_light_on && camera_light_on < world.timeofday) if(camera_light_on && camera_light_on < world.timeofday)
if(src.current) if(src.camera)
var/obj/machinery/camera/camera = near_range_camera(src.eyeobj) var/obj/machinery/camera/camera = near_range_camera(src.eyeobj)
if(camera && src.current != camera) if(camera && src.camera != camera)
src.current.SetLuminosity(0) src.camera.SetLuminosity(0)
if(!camera.light_disabled) if(!camera.light_disabled)
src.current = camera src.camera = camera
src.current.SetLuminosity(AI_CAMERA_LUMINOSITY) src.camera.SetLuminosity(AI_CAMERA_LUMINOSITY)
else else
src.current = null src.camera = null
else if(isnull(camera)) else if(isnull(camera))
src.current.SetLuminosity(0) src.camera.SetLuminosity(0)
src.current = null src.camera = null
else else
var/obj/machinery/camera/camera = near_range_camera(src.eyeobj) var/obj/machinery/camera/camera = near_range_camera(src.eyeobj)
if(camera && !camera.light_disabled) if(camera && !camera.light_disabled)
src.current = camera src.camera = camera
src.current.SetLuminosity(AI_CAMERA_LUMINOSITY) src.camera.SetLuminosity(AI_CAMERA_LUMINOSITY)
camera_light_on = world.timeofday + 1 * 20 // Update the light every 2 seconds. camera_light_on = world.timeofday + 1 * 20 // Update the light every 2 seconds.

View File

@@ -47,9 +47,8 @@
if(ai.client) if(ai.client)
ai.client.eye = src ai.client.eye = src
//Holopad //Holopad
if(istype(ai.current, /obj/machinery/hologram/holopad)) if(ai.holo)
var/obj/machinery/hologram/holopad/H = ai.current ai.holo.move_hologram()
H.move_hologram()
// AI MOVEMENT // AI MOVEMENT
@@ -61,7 +60,7 @@
var/sprint = 10 var/sprint = 10
var/cooldown = 0 var/cooldown = 0
var/acceleration = 1 var/acceleration = 1
var/obj/machinery/hologram/holopad/holo = null
// Intiliaze the eye by assigning it's "ai" variable to us. Then set it's loc to us. // Intiliaze the eye by assigning it's "ai" variable to us. Then set it's loc to us.
/mob/living/silicon/ai/New() /mob/living/silicon/ai/New()
@@ -121,8 +120,7 @@
/mob/living/silicon/ai/proc/view_core() /mob/living/silicon/ai/proc/view_core()
camera = null
current = null
cameraFollow = null cameraFollow = null
unset_machine() unset_machine()

View File

@@ -144,8 +144,8 @@
if (!message) if (!message)
return return
var/obj/machinery/hologram/holopad/T = src.current var/obj/machinery/hologram/holopad/T = src.holo
if(istype(T) && T.hologram && T.master == src)//If there is a hologram and its master is the user. if(T && T.hologram && T.master == src)//If there is a hologram and its master is the user.
var/verb = say_quote(message) var/verb = say_quote(message)
//Human-like, sorta, heard by those who understand humans. //Human-like, sorta, heard by those who understand humans.

View File

@@ -96,8 +96,8 @@
/obj/item/weapon/paper/attack_ai(var/mob/living/silicon/ai/user as mob) /obj/item/weapon/paper/attack_ai(var/mob/living/silicon/ai/user as mob)
var/dist var/dist
if(istype(user) && user.current) //is AI if(istype(user) && user.camera) //is AI
dist = get_dist(src, user.current) dist = get_dist(src, user.camera)
else //cyborg or AI not seeing through a camera else //cyborg or AI not seeing through a camera
dist = get_dist(src, user) dist = get_dist(src, user)
if(dist < 2) if(dist < 2)