From 05ebff4f546fa7d762b1357303da622554366531 Mon Sep 17 00:00:00 2001 From: "VivianFoxfoot@gmail.com" Date: Sun, 29 Apr 2012 00:00:54 +0000 Subject: [PATCH] AI can now track its cyborgs who speak on robotic talk. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3526 316c924e-a436-60f5-8080-3fe189b3f50e --- code/game/machinery/camera.dm | 57 +++++++++++++----------- code/modules/mob/living/say.dm | 9 ++-- code/modules/mob/living/silicon/ai/ai.dm | 24 ++++++++++ code/modules/mob/living/silicon/say.dm | 17 +++++-- 4 files changed, 75 insertions(+), 32 deletions(-) diff --git a/code/game/machinery/camera.dm b/code/game/machinery/camera.dm index d2be5a0e0ee..f65754f26e6 100644 --- a/code/game/machinery/camera.dm +++ b/code/game/machinery/camera.dm @@ -124,33 +124,38 @@ var/obj/machinery/camera/C = usr:current if ((C && istype(C, /obj/machinery/camera)) || C==null) - var/closestDist = -1 - if (C!=null) - if (C.status) - closestDist = get_dist(C, target) - //usr << text("Dist = [] for camera []", closestDist, C.name) - var/zmatched = 0 - if (closestDist > 7 || closestDist == -1) - //check other cameras - var/obj/machinery/camera/closest = C - for(var/obj/machinery/camera/C2 in world) - if (C2.network == src.network) - if (C2.z == target.z) - zmatched = 1 - if (C2.status) - var/dist = get_dist(C2, target) - if ((dist < closestDist) || (closestDist == -1)) - closestDist = dist - closest = C2 - //usr << text("Closest camera dist = [], for camera []", closestDist, closest.area.name) + if(isrobot(target)) + C = target:camera + usr:current = C + usr.reset_view(C) + else + var/closestDist = -1 + if (C!=null) + if (C.status) + closestDist = get_dist(C, target) + //usr << text("Dist = [] for camera []", closestDist, C.name) + var/zmatched = 0 + if (closestDist > 7 || closestDist == -1) + //check other cameras + var/obj/machinery/camera/closest = C + for(var/obj/machinery/camera/C2 in world) + if (C2.network == src.network) + if (C2.z == target.z) + zmatched = 1 + if (C2.status) + var/dist = get_dist(C2, target) + if ((dist < closestDist) || (closestDist == -1)) + closestDist = dist + closest = C2 + //usr << text("Closest camera dist = [], for camera []", closestDist, closest.area.name) - if (closest != C) - usr:current = closest - usr.reset_view(closest) - //use_power(50) - if (zmatched == 0) - usr << "Target is not on or near any active cameras on the station. We'll check again in 5 seconds (unless you use the cancel-camera verb)." - sleep(40) //because we're sleeping another second after this (a few lines down) + if (closest != C) + usr:current = closest + usr.reset_view(closest) + //use_power(50) + if (zmatched == 0) + usr << "Target is not on or near any active cameras on the station. We'll check again in 5 seconds (unless you use the cancel-camera verb)." + sleep(40) //because we're sleeping another second after this (a few lines down) else usr << "Follow camera mode ended." usr:cameraFollow = null diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm index 4214bb27b07..e3273c53aaa 100644 --- a/code/modules/mob/living/say.dm +++ b/code/modules/mob/living/say.dm @@ -1,7 +1,10 @@ /mob/living/proc/binarycheck() - if (istype(src, /mob/living/silicon/pai)) return - if (issilicon(src)) return 1 - if (!ishuman(src)) return + if (istype(src, /mob/living/silicon/pai)) + return + if (issilicon(src)) + return 1 + if (!ishuman(src)) + return var/mob/living/carbon/human/H = src if (H.ears) var/obj/item/device/radio/headset/dongle = H.ears diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index 585e4ce687a..0317a6d23b3 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -265,6 +265,30 @@ if (href_list["laws"]) // With how my law selection code works, I changed statelaws from a verb to a proc, and call it through my law selection panel. --NeoFite statelaws() + if (href_list["track"]) + var/mob/target = locate(href_list["track"]) + var/mob/living/silicon/ai/A = locate(href_list["track2"]) + if(A && target) + A.ai_actual_track(target) + return + + else if (href_list["faketrack"]) + var/mob/target = locate(href_list["track"]) + var/mob/living/silicon/ai/A = locate(href_list["track2"]) + if(A && target) + + A:cameraFollow = target + A << text("Now tracking [] on camera.", target.name) + if (usr.machine == null) + usr.machine = usr + + while (usr:cameraFollow == target) + usr << "Target is not on or near any active cameras on the station. We'll check again in 5 seconds (unless you use the cancel-camera verb)." + sleep(40) + continue + + return + return /mob/living/silicon/ai/meteorhit(obj/O as obj) diff --git a/code/modules/mob/living/silicon/say.dm b/code/modules/mob/living/silicon/say.dm index a9a86a4fb4a..069cb12d227 100644 --- a/code/modules/mob/living/silicon/say.dm +++ b/code/modules/mob/living/silicon/say.dm @@ -79,12 +79,23 @@ var/message_a = say_quote(message) var/rendered = "Robotic Talk, [name] [message_a]" + for (var/mob/living/S in world) if(!S.stat) - if(S.robot_talk_understand && (S.robot_talk_understand == robot_talk_understand)) - S.show_message(rendered, 2) + if(S.robot_talk_understand && (S.robot_talk_understand == robot_talk_understand)) // This SHOULD catch everything caught by the one below, but I'm not going to change it. + if(istype(S , /mob/living/silicon/ai)) + var/renderedAI = "Robotic Talk, [name] [message_a]" + S.show_message(renderedAI, 2) + else + S.show_message(rendered, 2) + + else if (S.binarycheck()) - S.show_message(rendered, 2) + if(istype(S , /mob/living/silicon/ai)) + var/renderedAI = "Robotic Talk, [name] [message_a]" + S.show_message(renderedAI, 2) + else + S.show_message(rendered, 2) var/list/listening = hearers(1, src) listening -= src