Merge pull request #27 from tigercat2000/ai_eye_refactors

A handful of aiEye refactors
This commit is contained in:
Aurorablade
2018-06-05 00:38:41 -04:00
committed by GitHub
11 changed files with 131 additions and 75 deletions
+14 -4
View File
@@ -87,11 +87,12 @@ var/list/ai_verbs_default = list(
var/mob/living/simple_animal/bot/Bot
var/turf/waypoint //Holds the turf of the currently selected waypoint.
var/waypoint_mode = 0 //Waypoint mode is for selecting a turf via clicking.
var/apc_override = FALSE //hack for letting the AI use its APC even when visionless
var/nuking = 0
var/obj/machinery/doomsday_device/doomsday_device
var/obj/machinery/hologram/holopad/holo = null
var/mob/camera/aiEye/eyeobj = new()
var/mob/camera/aiEye/eyeobj
var/sprint = 10
var/cooldown = 0
var/acceleration = 1
@@ -191,9 +192,7 @@ var/list/ai_verbs_default = list(
spawn(5)
new /obj/machinery/ai_powersupply(src)
eyeobj.ai = src
eyeobj.name = "[src.name] (AI Eye)" // Give it a name
eyeobj.loc = src.loc
create_eye()
builtInCamera = new /obj/machinery/camera/portable(src)
builtInCamera.c_tag = name
@@ -1163,6 +1162,17 @@ var/list/ai_verbs_default = list(
client.eye = eyeobj
return TRUE
/mob/living/silicon/ai/proc/can_see(atom/A)
if(isturf(loc)) //AI in core, check if on cameras
//get_turf_pixel() is because APCs in maint aren't actually in view of the inner camera
//apc_override is needed here because AIs use their own APC when depowered
return (cameranet && cameranet.checkTurfVis(get_turf_pixel(A))) || apc_override
//AI is carded/shunted
//view(src) returns nothing for carded/shunted AIs and they have x-ray vision so just use get_dist
var/list/viewscale = getviewsize(client.view)
return get_dist(src, A) <= max(viewscale[1]*0.5,viewscale[2]*0.5)
/mob/living/silicon/ai/proc/relay_speech(mob/living/M, text, verb, datum/language/speaking)
if(!say_understands(M, speaking))//The AI will be able to understand most mobs talking through the holopad.
if(speaking)
@@ -28,7 +28,7 @@
eye.visibleCameraChunks += src
visible++
seenby += eye
if(changed && !updating)
if(changed)
update()
// Remove an AI eye from the chunk, then update if changed.
@@ -20,7 +20,6 @@
// It will also stream the chunk that the new loc is in.
/mob/camera/aiEye/setLoc(T)
if(ai)
if(!isturf(ai.loc))
return
@@ -42,8 +41,22 @@
return ai.client
return null
/mob/camera/aiEye/proc/RemoveImages()
var/client/C = GetViewerClient()
if(C)
for(var/V in visibleCameraChunks)
var/datum/camerachunk/chunk = V
C.images -= chunk.obscured
/mob/camera/aiEye/Destroy()
ai = null
if(ai)
//ai.all_eyes -= src
ai = null
for(var/V in visibleCameraChunks)
var/datum/camerachunk/chunk = V
chunk.remove(src)
return ..()
/atom/proc/move_camera_by_click()
@@ -103,12 +116,18 @@
src.eyeobj.loc = src.loc
else
to_chat(src, "ERROR: Eyeobj not found. Creating new eye...")
src.eyeobj = new(src.loc)
src.eyeobj.ai = src
src.eyeobj.name = "[src.name] (AI Eye)" // Give it a name
create_eye()
eyeobj.setLoc(loc)
/mob/living/silicon/ai/proc/create_eye()
if(eyeobj)
return
eyeobj = new /mob/camera/aiEye()
eyeobj.ai = src
eyeobj.setLoc(loc)
eyeobj.name = "[name] (AI Eye)"
/mob/living/silicon/ai/proc/toggle_acceleration()
set category = "AI Commands"
set name = "Toggle Camera Acceleration"
+3 -1
View File
@@ -129,8 +129,10 @@
to_chat(src, "Receiving control information from APC.")
sleep(2)
//bring up APC dialog
aiRestorePowerRoutine = 3
apc_override = 1
theAPC.attack_ai(src)
apc_override = 0
aiRestorePowerRoutine = 3
to_chat(src, "Here are your current laws:")
src.show_laws() //WHY THE FUCK IS THIS HERE
sleep(50)