From 566f6a104e38f28e5c613c9a94a7048b46fa8485 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Tue, 3 Feb 2015 21:21:58 +0100 Subject: [PATCH] Carded AIs can no longer access cameras through camera consoles. Also includes fixes for hidden uplinks. --- code/game/machinery/computer/camera.dm | 4 ++ code/game/machinery/machinery.dm | 12 +---- code/game/objects/items/devices/uplinks.dm | 7 ++- code/game/objects/objs.dm | 11 +++-- code/modules/mob/living/silicon/ai/ai.dm | 3 ++ code/modules/nano/nanoui.dm | 53 +++++++++++----------- 6 files changed, 47 insertions(+), 43 deletions(-) diff --git a/code/game/machinery/computer/camera.dm b/code/game/machinery/computer/camera.dm index bb2d342bfc..e1e8021efb 100644 --- a/code/game/machinery/computer/camera.dm +++ b/code/game/machinery/computer/camera.dm @@ -128,6 +128,10 @@ //don't need to check if the camera works for AI because the AI jumps to the camera location and doesn't actually look through cameras. if(isAI(user)) var/mob/living/silicon/ai/A = user + // Only allow non-carded AIs to view because the interaction with the eye gets all wonky otherwise. + if(!A.is_in_chassis()) + return 0 + A.eyeobj.setLoc(get_turf(C)) A.client.eye = A.eyeobj return 1 diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index 53d6ce0295..c5eaf35497 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -187,17 +187,9 @@ Class Procs: /obj/machinery/Topic(href, href_list, var/nowindow = 0, var/checkrange = 1) if(..()) return 1 - if(!can_be_used_by(usr, be_close = checkrange)) - return 1 - add_fingerprint(usr) - return 0 - -/obj/machinery/proc/can_be_used_by(mob/user, be_close = 1) if(!interact_offline && stat & (NOPOWER|BROKEN)) - return 0 - if(user.can_interact_with_interface(src, be_close) != STATUS_INTERACTIVE) - return 0 - return 1 + return 1 + return 0 //////////////////////////////////////////////////////////////////////////////////////////// diff --git a/code/game/objects/items/devices/uplinks.dm b/code/game/objects/items/devices/uplinks.dm index cd2ff9b5fb..53efa61f96 100644 --- a/code/game/objects/items/devices/uplinks.dm +++ b/code/game/objects/items/devices/uplinks.dm @@ -108,6 +108,9 @@ datum/nano_item_lists return pick(random_items) /obj/item/device/uplink/Topic(href, href_list) + if(..()) + return 1 + if(href_list["buy_item"] == "random") var/datum/uplink_item/UI = chooseRandomItem() href_list["buy_item"] = UI.reference @@ -208,10 +211,10 @@ datum/nano_item_lists // The purchasing code. /obj/item/device/uplink/hidden/Topic(href, href_list) if (usr.stat || usr.restrained()) - return + return 1 if (!( istype(usr, /mob/living/carbon/human))) - return 0 + return 1 var/mob/user = usr var/datum/nanoui/ui = nanomanager.get_open_ui(user, src, "main") if ((usr.contents.Find(src.loc) || (in_range(src.loc, usr) && istype(src.loc.loc, /turf)))) diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm index 167794721b..bbcad347b5 100644 --- a/code/game/objects/objs.dm +++ b/code/game/objects/objs.dm @@ -16,11 +16,14 @@ var/damtype = "brute" var/force = 0 -/obj/Topic(href, href_list, var/nowindow = 0) +/obj/Topic(href, href_list, var/nowindow = 0, var/checkrange = 1) // Calling Topic without a corresponding window open causes runtime errors - if(nowindow) - return 0 - return ..() + if(!nowindow && ..()) + return 1 + if(usr.can_interact_with_interface(src, checkrange) != STATUS_INTERACTIVE) + return 1 + add_fingerprint(usr) + return 0 /obj/item/proc/is_used_on(obj/O, mob/user) diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index c25e833c08..5f7f79f1a0 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -766,5 +766,8 @@ var/list/ai_verbs_default = list( return 1 return 0 +/mob/living/silicon/ai/proc/is_in_chassis() + return istype(loc, /turf) + #undef AI_CHECK_WIRELESS #undef AI_CHECK_RADIO diff --git a/code/modules/nano/nanoui.dm b/code/modules/nano/nanoui.dm index 8d4922f52f..635896cca9 100644 --- a/code/modules/nano/nanoui.dm +++ b/code/modules/nano/nanoui.dm @@ -183,36 +183,37 @@ nanoui is used to open and update nano browser uis if(!T || !(z == T.z || (T.z in config.player_levels))) return STATUS_CLOSE - // If loc is a turf then we're an operational AI chassi - if(istype(loc, /turf)) + // If an object is in view then we can interact with it + if(src_object in view(client.view, src)) + return STATUS_INTERACTIVE + + // If we're installed in a chassi, rather than transfered to an inteliCard or other container, then check if we have camera view + if(is_in_chassis()) //stop AIs from leaving windows open and using then after they lose vision //apc_override is needed here because AIs use their own APC when powerless if(cameranet && !cameranet.checkTurfVis(get_turf(src_object))) return apc_override ? STATUS_INTERACTIVE : STATUS_CLOSE return STATUS_INTERACTIVE - // If the loc isn't a turf then the AI has been transfered to an inteliCard (or other container). Objects must now be in view to be interacted with. - if(src_object in view(client.view, src)) - return STATUS_INTERACTIVE return STATUS_CLOSE -/mob/living/proc/shared_living_nano_interaction(var/atom/movable/src_object) - if(!isturf(src_object.loc) && src_object.loc != src) - return STATUS_CLOSE - - var/dist = get_dist(src_object, src) - if (dist > 4) - return STATUS_CLOSE - +/mob/living/proc/shared_living_nano_interaction(var/src_object) if (src.stat != CONSCIOUS) return STATUS_CLOSE // no updates, close the interface else if (restrained() || lying || stat || stunned || weakened) return STATUS_UPDATE // update only (orange visibility) - else if (!(src_object in view(4, src))) // If the src object is not in visable, disable updates - return STATUS_DISABLED return STATUS_INTERACTIVE -/mob/living/proc/shared_living_nano_distance(var/src_object) +/mob/living/proc/shared_living_nano_distance(var/atom/movable/src_object) + if(!isturf(src_object.loc)) + if(src.contents.Find(src_object.loc)) // This is a hidden uplink + return STATUS_INTERACTIVE + if(src_object.loc != src) + return STATUS_CLOSE + + if (!(src_object in view(4, src))) // If the src object is not in visable, disable updates + return STATUS_CLOSE + var/dist = get_dist(src_object, src) if (dist <= 1) return STATUS_INTERACTIVE // interactive (green visibility) @@ -220,23 +221,21 @@ nanoui is used to open and update nano browser uis return STATUS_UPDATE // update only (orange visibility) else if (dist <= 4) return STATUS_DISABLED // no updates, completely disabled (red visibility) + return STATUS_CLOSE -/mob/living/can_interact_with_interface(var/src_object) +/mob/living/can_interact_with_interface(var/src_object, var/be_close = 1) . = shared_living_nano_interaction(src_object) - if(. == STATUS_INTERACTIVE) + if(. == STATUS_INTERACTIVE && be_close) . = shared_living_nano_distance(src_object) - if(STATUS_INTERACTIVE) - return STATUS_UPDATE + if(STATUS_INTERACTIVE) + return STATUS_UPDATE /mob/living/carbon/human/can_interact_with_interface(var/src_object, var/be_close = 1) . = shared_living_nano_interaction(src_object) - if(. == STATUS_INTERACTIVE) - if (istype(src_object, /obj/item/device/uplink/hidden)) // You know what if they have the uplink open let them use the UI - return STATUS_INTERACTIVE // Will build in distance checks on the topics for sanity. - if(be_close) - . = shared_living_nano_distance(src_object) - if(. == STATUS_DISABLED && (TK in mutations)) - return STATUS_INTERACTIVE + if(. == STATUS_INTERACTIVE && be_close) + . = shared_living_nano_distance(src_object) + if(. == STATUS_UPDATE && (TK in mutations)) // If we have telekinesis and remain close enough, allow interaction. + return STATUS_INTERACTIVE /** * Set the ui to auto update (every master_controller tick)