From 4aa8f73128d53445262fab2c3e3361f3be3f53c8 Mon Sep 17 00:00:00 2001 From: Miniature Date: Fri, 3 Feb 2012 20:28:43 +1030 Subject: [PATCH] AI freelook! I am no longer aware of any issues with it (other than one minor one involving it not removing the dim overlay sometimes, but that is very easy to ignore) If someone goes over the map and fixes the camera coverage, I suggest we force AIs to use this (and I'll be making a thread about it) --- code/WorkInProgress/AI_Visibility.dm | 35 ++++++++++++++++++++++++++++ code/defines/turf.dm | 1 + code/game/turf.dm | 7 ++++++ code/modules/mining/mine_turfs.dm | 1 + 4 files changed, 44 insertions(+) diff --git a/code/WorkInProgress/AI_Visibility.dm b/code/WorkInProgress/AI_Visibility.dm index 3d23f7c5026..a289c090029 100644 --- a/code/WorkInProgress/AI_Visibility.dm +++ b/code/WorkInProgress/AI_Visibility.dm @@ -7,6 +7,14 @@ /turf/proc/visibilityChanged() cameranet.updateVisibility(src) +/turf/New() + ..() + cameranet.updateVisibility(src) +/* +/turf/Del() + ..() + cameranet.updateVisibility(src) +*/ /datum/camerachunk var/list/obscuredTurfs = list() var/list/visibleTurfs = list() @@ -246,6 +254,21 @@ var/datum/cameranet/cameranet = new() chunk.cameras += c chunk.hasChanged() +/datum/cameranet/proc/removeCamera(obj/machinery/camera/c) + var/x1 = max(0, c.x - 16) & ~0xf + var/y1 = max(0, c.y - 16) & ~0xf + var/x2 = min(world.maxx, c.x + 16) & ~0xf + var/y2 = min(world.maxy, c.y + 16) & ~0xf + + for(var/x = x1; x <= x2; x += 16) + for(var/y = y1; y <= y2; y += 16) + if(chunkGenerated(x, y, c.z)) + var/datum/camerachunk/chunk = getCameraChunk(x, y, c.z) + if(!c) + chunk.hasChanged() + if(c in chunk.cameras) + chunk.cameras -= c + chunk.hasChanged() /mob/living/silicon/ai/var/mob/aiEye/eyeobj = new() @@ -318,6 +341,18 @@ var/datum/cameranet/cameranet = new() ..() cameranet.addCamera(src) +/obj/machinery/camera/Del() + cameranet.removeCamera(src) + ..() + +/obj/machinery/camera/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob) + . = ..(W, user) + if(istype(W, /obj/item/weapon/wirecutters)) + if(status) + cameranet.addCamera(src) + else + cameranet.removeCamera(src) + /proc/checkcameravis(atom/A) for(var/obj/machinery/camera/C in view(A,7)) if(!C.status || C.stat == 2) diff --git a/code/defines/turf.dm b/code/defines/turf.dm index 7ad19d4dab2..a91921f9567 100644 --- a/code/defines/turf.dm +++ b/code/defines/turf.dm @@ -46,6 +46,7 @@ /turf/space/New() // icon = 'space.dmi' + ..() icon_state = "[pick(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)]" /turf/simulated diff --git a/code/game/turf.dm b/code/game/turf.dm index 1382c9db3e4..d6e1036f332 100644 --- a/code/game/turf.dm +++ b/code/game/turf.dm @@ -132,6 +132,7 @@ for(var/obj/structure/lattice/L in locate(src.x, src.y, src.z)) del(L) var/turf/simulated/floor/W = new /turf/simulated/floor( locate(src.x, src.y, src.z) ) + W.New() W.dir = old_dir if(prior_icon) W.icon_state = prior_icon @@ -151,6 +152,7 @@ for(var/obj/structure/lattice/L in locate(src.x, src.y, src.z)) del(L) var/turf/simulated/floor/plating/W = new /turf/simulated/floor/plating( locate(src.x, src.y, src.z) ) + W.New() W.dir = old_dir if(prior_icon) W.icon_state = prior_icon @@ -166,6 +168,7 @@ for(var/obj/structure/lattice/L in locate(src.x, src.y, src.z)) del(L) var/turf/simulated/floor/engine/E = new /turf/simulated/floor/engine( locate(src.x, src.y, src.z) ) + E.New() E.dir = old_dir E.icon_state = "engine" @@ -228,12 +231,14 @@ /turf/proc/ReplaceWithSpace() var/old_dir = dir var/turf/space/S = new /turf/space( locate(src.x, src.y, src.z) ) + S.New() S.dir = old_dir return S /turf/proc/ReplaceWithLattice() var/old_dir = dir var/turf/space/S = new /turf/space( locate(src.x, src.y, src.z) ) + S.New() S.dir = old_dir new /obj/structure/lattice( locate(src.x, src.y, src.z) ) return S @@ -241,6 +246,7 @@ /turf/proc/ReplaceWithWall() var/old_icon = icon_state var/turf/simulated/wall/S = new /turf/simulated/wall( locate(src.x, src.y, src.z) ) + S.New() S.icon_old = old_icon S.opacity = 0 S.sd_NewOpacity(1) @@ -249,6 +255,7 @@ /turf/proc/ReplaceWithRWall() var/old_icon = icon_state var/turf/simulated/wall/r_wall/S = new /turf/simulated/wall/r_wall( locate(src.x, src.y, src.z) ) + S.New() S.icon_old = old_icon S.opacity = 0 S.sd_NewOpacity(1) diff --git a/code/modules/mining/mine_turfs.dm b/code/modules/mining/mine_turfs.dm index d44cded8637..48859e1ea06 100644 --- a/code/modules/mining/mine_turfs.dm +++ b/code/modules/mining/mine_turfs.dm @@ -194,6 +194,7 @@ shroom.pixel_y = 0 W = new /turf/simulated/floor/plating/airless/asteroid( locate(src.x, src.y, src.z) ) + W.New() W.dir = old_dir W.fullUpdateMineralOverlays()