From 707bdc584bcaa2e3acaf8cf1b175d7d38e514925 Mon Sep 17 00:00:00 2001 From: Kyep Date: Mon, 30 Jan 2017 23:35:07 -0800 Subject: [PATCH 1/2] Enables AI hologram to move between holopads --- code/game/machinery/hologram.dm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/code/game/machinery/hologram.dm b/code/game/machinery/hologram.dm index 41952adf355..cd6cba323f9 100644 --- a/code/game/machinery/hologram.dm +++ b/code/game/machinery/hologram.dm @@ -28,6 +28,7 @@ Possible to do for anyone motivated enough: // 0 = RANGE BASED // 1 = AREA BASED var/const/HOLOPAD_MODE = 0 +var/list/holopads = list() /obj/machinery/hologram/holopad name = "\improper AI holopad" @@ -42,6 +43,7 @@ var/const/HOLOPAD_MODE = 0 /obj/machinery/hologram/holopad/New() ..() + holopads += src component_parts = list() component_parts += new /obj/item/weapon/circuitboard/holopad(null) component_parts += new /obj/item/weapon/stock_parts/capacitor(null) @@ -89,13 +91,15 @@ var/const/HOLOPAD_MODE = 0 if(user.eyeobj.loc != src.loc)//Set client eye on the object if it's not already. user.eyeobj.setLoc(get_turf(src)) else if(!hologram)//If there is no hologram, possibly make one. - activate_holo(user) + activate_holo(user, 0) else if(master == user)//If there is a hologram, remove it. But only if the user is the master. Otherwise do nothing. clear_holo() return -/obj/machinery/hologram/holopad/proc/activate_holo(mob/living/silicon/ai/user) - if(!(stat & NOPOWER) && user.eyeobj.loc == src.loc)//If the projector has power and client eye is on it. +/obj/machinery/hologram/holopad/proc/activate_holo(mob/living/silicon/ai/user, var/force = 0) + if(!force && user.eyeobj.loc != src.loc) // allows holopads to pass off holograms to the next holopad in the chain + to_chat(user, "ERROR: Unable to project hologram.") + else if(!(stat & NOPOWER))//If the projector has power if(user.holo) var/obj/machinery/hologram/holopad/current = user.holo current.clear_holo() @@ -163,7 +167,15 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/ if(eye_area != holo_area) return 1 + var/mob/living/silicon/ai/theai = master + var/turf/target_turf = get_turf(master.eyeobj) clear_holo()//If not, we want to get rid of the hologram. + var/obj/machinery/hologram/holopad/pad_close = get_closest_atom(/obj/machinery/hologram/holopad, holopads, theai.eyeobj) + if(get_dist(pad_close, theai.eyeobj) <= pad_close.holo_range) + if(!(pad_close.stat & NOPOWER) && !pad_close.hologram) + pad_close.activate_holo(theai, 1) + if(pad_close.hologram) + pad_close.hologram.forceMove(target_turf) return 1 /obj/machinery/hologram/holopad/proc/move_hologram() @@ -221,6 +233,7 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/ return /obj/machinery/hologram/holopad/Destroy() + holopads -= src if(hologram) clear_holo() return ..() From 0710a8262fd6b5aa7b81f32b4ca1b50ddda36479 Mon Sep 17 00:00:00 2001 From: Kyep Date: Mon, 30 Jan 2017 23:46:44 -0800 Subject: [PATCH 2/2] Also handles direction --- code/game/machinery/hologram.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/game/machinery/hologram.dm b/code/game/machinery/hologram.dm index cd6cba323f9..aa345e29643 100644 --- a/code/game/machinery/hologram.dm +++ b/code/game/machinery/hologram.dm @@ -169,6 +169,7 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/ var/mob/living/silicon/ai/theai = master var/turf/target_turf = get_turf(master.eyeobj) + var/newdir = hologram.dir clear_holo()//If not, we want to get rid of the hologram. var/obj/machinery/hologram/holopad/pad_close = get_closest_atom(/obj/machinery/hologram/holopad, holopads, theai.eyeobj) if(get_dist(pad_close, theai.eyeobj) <= pad_close.holo_range) @@ -176,6 +177,7 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/ pad_close.activate_holo(theai, 1) if(pad_close.hologram) pad_close.hologram.forceMove(target_turf) + pad_close.hologram.dir = newdir return 1 /obj/machinery/hologram/holopad/proc/move_hologram()