From df59d8cbc72c3f37d6a90f382edccec40ee1b33c Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Sun, 20 Jul 2014 19:20:24 +0200 Subject: [PATCH] Makes it possible for the AI to alt+left click turfs in camera view and grants ctrl/alt shortcuts to the turret control. AI can now alt+left click turfs in camera view to list and interact with objects in the status tab. For example allows for interacting with emergency shutters beneath grills. alt-clicking doors now notifies the AI when they are electrified/un-electrified as, unlike most other shortcuts, this doesn't have a visual cue. When interacting with doors and the AI-control is disabled hacking is now automatically initiated, as if the AI had attempted to open the door 'menu'. When borgs/AIs try to interact with an emagged door they now receive a feedback message that it's unresponsive. Parts of implementation done by porting code from tg-station. Conflicts: code/_onclick/ai.dm code/_onclick/click.dm code/modules/mob/living/silicon/ai/freelook/cameranet.dm code/modules/mob/mob.dm --- code/_onclick/ai.dm | 21 ++++++++- code/_onclick/click.dm | 7 ++- .../visibility_networks/visibility_network.dm | 9 ++-- code/game/machinery/doors/airlock.dm | 47 +++++++++++-------- code/modules/mob/mob.dm | 4 +- 5 files changed, 59 insertions(+), 29 deletions(-) diff --git a/code/_onclick/ai.dm b/code/_onclick/ai.dm index 29910ceaea9..bcef0703eef 100644 --- a/code/_onclick/ai.dm +++ b/code/_onclick/ai.dm @@ -79,6 +79,7 @@ than anything else in the game, atoms have separate procs for AI shift, ctrl, and alt clicking. */ + /mob/living/silicon/ai/ShiftClickOn(var/atom/A) A.AIShiftClick(src) /mob/living/silicon/ai/CtrlClickOn(var/atom/A) @@ -111,14 +112,19 @@ else Topic("aiDisable=4", list("aiDisable"="4"), 1) -/obj/machinery/power/apc/AICtrlClick() // turns off APCs. +/obj/machinery/power/apc/AICtrlClick() // turns off/on APCs. Topic("breaker=1", list("breaker"="1"), 0) // 0 meaning no window (consistency! wait...) +/obj/machinery/turretid/AICtrlClick() //turns off/on Turrets + src.enabled = !src.enabled + src.updateTurrets() /atom/proc/AIAltClick() return -/obj/machinery/door/airlock/AIAltClick() // Eletrifies doors. +/obj/machinery/door/airlock/AIAltClick() // Electrifies doors. + if(emagged) + return if(!secondsElectrified) // permenant shock Topic("aiEnable=6", list("aiEnable"="6"), 1) // 1 meaning no window (consistency!) @@ -126,3 +132,14 @@ // disable/6 is not in Topic; disable/5 disables both temporary and permenant shock Topic("aiDisable=5", list("aiDisable"="5"), 1) return + +/obj/machinery/turretid/AIAltClick() //toggles lethal on turrets + src.lethal = !src.lethal + src.updateTurrets() + +// +// Override AdjacentQuick for AltClicking +// + +/mob/living/silicon/ai/TurfAdjacent(var/turf/T) + return (cameranet && cameranet.checkTurfVis(T)) diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index 99d992639e1..821e4248f16 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -247,14 +247,17 @@ /atom/proc/AltClick(var/mob/user) var/turf/T = get_turf(src) - if(T && T.Adjacent(user)) - if(user.listed_turf == T) + if(T && user.TurfAdjacent(T)) + if(user. == T) user.listed_turf = null else user.listed_turf = T user.client.statpanel = T.name return +/mob/proc/TurfAdjacent(var/turf/T) + return T.AdjacentQuick(src) + /* Misc helpers diff --git a/code/datums/visibility_networks/visibility_network.dm b/code/datums/visibility_networks/visibility_network.dm index 225b6e3def6..f1bc24e771a 100644 --- a/code/datums/visibility_networks/visibility_network.dm +++ b/code/datums/visibility_networks/visibility_network.dm @@ -32,7 +32,7 @@ /datum/visibility_network/proc/visibility(var/mob/targetMob) - + // if we've got not visibility interface on the mob, we canot do this if (!targetMob.visibility_interface) return @@ -88,12 +88,12 @@ /datum/visibility_network/proc/getViewpointFromMob(var/mob/currentMob) return FALSE - + /datum/visibility_network/proc/updateMob(var/mob/currentMob) var/viewpoint = getViewpointFromMob(currentMob) if(viewpoint) updateViewpoint(viewpoint) - + /datum/visibility_network/proc/updateViewpoint(var/viewpoint) if(validViewpoint(viewpoint)) @@ -132,6 +132,9 @@ // checks if the network can see a particular atom /datum/visibility_network/proc/checkCanSee(var/atom/target) var/turf/position = get_turf(target) + return checkTurfVis(position) + +/datum/visibility_network/proc/checkTurfVis(var/turf/position) var/datum/visibility_chunk/chunk = getChunk(position.x, position.y, position.z) if(chunk) if(chunk.changed) diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index cf8ae5220d9..33042d95331 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -494,8 +494,8 @@ About the new airlock wires panel: /obj/machinery/door/airlock/proc/canAIControl() return ((src.aiControlDisabled!=1) && (!src.isAllPowerCut())); -/obj/machinery/door/airlock/proc/canAIHack() - return ((src.aiControlDisabled==1) && (!hackProof) && (!src.isAllPowerCut())); +/obj/machinery/door/airlock/proc/canAIHack(var/user as mob) + return (isAI(user) && src.aiControlDisabled==1 && !hackProof && !src.isAllPowerCut()); /obj/machinery/door/airlock/proc/arePowerSystemsOn() return (src.secondsMainPowerLost==0 || src.secondsBackupPowerLost==0) @@ -613,12 +613,8 @@ About the new airlock wires panel: return /obj/machinery/door/airlock/attack_ai(mob/user as mob) - if(!src.canAIControl()) - if(src.canAIHack()) - src.hack(user) - return - else - user << "Airlock AI control has been blocked with a firewall. Unable to hack." + if (!check_synth_access(user)) + return //Separate interface for the AI. user.set_machine(src) @@ -738,7 +734,7 @@ About the new airlock wires panel: user << "Alert cancelled. Airlock control has been restored without our assistance." src.aiHacking=0 return - else if(!src.canAIHack()) + else if(!src.canAIHack(user)) user << "We've lost our connection! Unable to hack airlock." src.aiHacking=0 return @@ -750,7 +746,7 @@ About the new airlock wires panel: user << "Alert cancelled. Airlock control has been restored without our assistance." src.aiHacking=0 return - else if(!src.canAIHack()) + else if(!src.canAIHack(user)) user << "We've lost our connection! Unable to hack airlock." src.aiHacking=0 return @@ -760,7 +756,7 @@ About the new airlock wires panel: user << "Alert cancelled. Airlock control has been restored without our assistance." src.aiHacking=0 return - else if(!src.canAIHack()) + else if(!src.canAIHack(user)) user << "We've lost our connection! Unable to hack airlock." src.aiHacking=0 return @@ -814,6 +810,17 @@ About the new airlock wires panel: ..(user) return +/obj/machinery/door/airlock/proc/check_synth_access(mob/user as mob) + if(emagged) + user << "Unable to interface: Airlock is unresponsive." + return 0 + if(!src.canAIControl()) + if(src.canAIHack(user)) + src.hack(user) + else + user << "Airlock AI control has been blocked with a firewall." + return 0 + return 1 /obj/machinery/door/airlock/Topic(href, href_list, var/nowindow = 0) // If you add an if(..()) check you must first remove the var/nowindow parameter. @@ -874,7 +881,10 @@ About the new airlock wires panel: - if(istype(usr, /mob/living/silicon) && src.canAIControl()) + if(istype(usr, /mob/living/silicon)) + if (!check_synth_access(usr)) + return + //AI //aiDisable - 1 idscan, 2 disrupt main power, 3 disrupt backup power, 4 drop door bolts, 5 un-electrify door, 7 close door, 8 door safties, 9 door speed //aiEnable - 1 idscan, 4 raise door bolts, 5 electrify door for 30 seconds, 6 electrify door indefinitely, 7 open door, 8 door safties, 9 door speed @@ -884,7 +894,7 @@ About the new airlock wires panel: if(1) //disable idscan if(src.isWireCut(AIRLOCK_WIRE_IDSCAN)) - usr << "The IdScan wire has been cut - So, you can't disable it, but it is already disabled anyways." + usr << "The IdScan wire has been cut - So, you can't disable it, but it is already disabled anyway." else if(src.aiDisabledIdScanner) usr << "You've already disabled the IdScan feature." else @@ -912,9 +922,8 @@ About the new airlock wires panel: //un-electrify door if(src.isWireCut(AIRLOCK_WIRE_ELECTRIFY)) usr << text("Can't un-electrify the airlock - The electrification wire is cut.") - else if(src.secondsElectrified==-1) - src.secondsElectrified = 0 - else if(src.secondsElectrified>0) + else if(src.secondsElectrified==-1 || src.secondsElectrified>0) + usr << "The door is now un-electrified." src.secondsElectrified = 0 if(8) @@ -926,8 +935,6 @@ About the new airlock wires panel: else usr << text("Firmware reports safeties already overriden.") - - if(9) // Door speed control if(src.isWireCut(AIRLOCK_WIRE_SPEED)) @@ -957,8 +964,6 @@ About the new airlock wires panel: else usr << text("Door bolt lights are already disabled!") - - else if(href_list["aiEnable"]) var/code = text2num(href_list["aiEnable"]) switch (code) @@ -990,6 +995,7 @@ About the new airlock wires panel: else shockedby += text("\[[time_stamp()]\][usr](ckey:[usr.ckey])") usr.attack_log += text("\[[time_stamp()]\] Electrified the [name] at [x] [y] [z]") + usr << "The door is now electrified for thirty seconds." src.secondsElectrified = 30 spawn(10) while (src.secondsElectrified>0) @@ -1009,6 +1015,7 @@ About the new airlock wires panel: else shockedby += text("\[[time_stamp()]\][usr](ckey:[usr.ckey])") usr.attack_log += text("\[[time_stamp()]\] Electrified the [name] at [x] [y] [z]") + usr << "The door is now electrified." src.secondsElectrified = -1 if (8) // Not in order >.> diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 2ae523e4878..6dcf67415ae 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -853,7 +853,7 @@ var/list/slot_equipment_priority = list( \ stat(null, "MasterController-ERROR") if(listed_turf && client) - if(get_dist(listed_turf,src) > 1) + if(!TurfAdjacent(listed_turf)) listed_turf = null else statpanel(listed_turf.name, null, listed_turf) @@ -1225,4 +1225,4 @@ mob/proc/yank_out_object() if(host) host.ckey = src.ckey - host << "You are now a mouse. Try to avoid interaction with players, and do not give hints away that you are more than a simple rodent." \ No newline at end of file + host << "You are now a mouse. Try to avoid interaction with players, and do not give hints away that you are more than a simple rodent."