diff --git a/baystation12.dme b/baystation12.dme index ba02f28f659..0e8eb3aaeb8 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -1264,6 +1264,7 @@ #include "code\modules\mob\living\silicon\silicon.dm" #include "code\modules\mob\living\silicon\subystems.dm" #include "code\modules\mob\living\silicon\ai\ai.dm" +#include "code\modules\mob\living\silicon\ai\ai_movement.dm" #include "code\modules\mob\living\silicon\ai\death.dm" #include "code\modules\mob\living\silicon\ai\examine.dm" #include "code\modules\mob\living\silicon\ai\icons.dm" diff --git a/code/_helpers/unsorted.dm b/code/_helpers/unsorted.dm index e44a60ebc2b..94b23b2b162 100644 --- a/code/_helpers/unsorted.dm +++ b/code/_helpers/unsorted.dm @@ -579,10 +579,13 @@ proc/anim(turf/location as turf,target as mob|obj,a_icon,a_icon_state as text,fl return toReturn //Step-towards method of determining whether one atom can see another. Similar to viewers() -/proc/can_see(var/atom/source, var/atom/target, var/length=5) // I couldnt be arsed to do actual raycasting :I This is horribly inaccurate. +/proc/can_see(var/atom/source, var/atom/target, var/length=5) // I couldn't be arsed to do actual raycasting :I This is horribly inaccurate. var/turf/current = get_turf(source) var/turf/target_turf = get_turf(target) var/steps = 0 + + if(!current || !target_turf) + return 0 while(current != target_turf) if(steps > length) return 0 diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index 4be87495884..c5553d09b56 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -305,6 +305,9 @@ /obj/machinery/camera/proc/can_see() var/list/see = null var/turf/pos = get_turf(src) + if(!pos) + return list() + if(isXRay()) see = range(view_range, pos) else diff --git a/code/modules/mob/freelook/ai/chunk.dm b/code/modules/mob/freelook/ai/chunk.dm index 89a07bb465c..5d82f66d662 100644 --- a/code/modules/mob/freelook/ai/chunk.dm +++ b/code/modules/mob/freelook/ai/chunk.dm @@ -24,6 +24,10 @@ for(var/turf/t in c.can_see()) visible[t] = t + for(var/mob/living/silicon/ai/AI in living_mob_list) + for(var/turf/t in AI.seen_camera_turfs()) + visible[t] = t + // Create a new camera chunk, since the chunks are made as they are needed. /datum/chunk/camera/New(loc, x, y, z) @@ -31,3 +35,15 @@ if(c.can_use()) cameras += c ..() + +/mob/living/silicon/proc/provides_camera_vision() + return 0 + +/mob/living/silicon/ai/provides_camera_vision() + return stat != DEAD + +/mob/living/silicon/robot/provides_camera_vision() + return src.camera && src.camera.network.len + +/mob/living/silicon/ai/proc/seen_camera_turfs() + return seen_turfs_in_range(src, world.view) diff --git a/code/modules/mob/freelook/ai/update_triggers.dm b/code/modules/mob/freelook/ai/update_triggers.dm index 8a91d0540e6..f4fea0aa58f 100644 --- a/code/modules/mob/freelook/ai/update_triggers.dm +++ b/code/modules/mob/freelook/ai/update_triggers.dm @@ -4,13 +4,13 @@ // Update the portable camera everytime the Robot moves. // This might be laggy, comment it out if there are problems. -/mob/living/silicon/robot/var/updating = 0 +/mob/living/silicon/var/updating = 0 /mob/living/silicon/robot/Move() var/oldLoc = src.loc . = ..() if(.) - if(src.camera && src.camera.network.len) + if(provides_camera_vision()) if(!updating) updating = 1 spawn(BORG_CAMERA_BUFFER) @@ -18,6 +18,21 @@ cameranet.updatePortableCamera(src.camera) updating = 0 +/mob/living/silicon/AI/Move() + var/oldLoc = src.loc + . = ..() + if(.) + if(provides_camera_vision()) + if(!updating) + updating = 1 + spawn(BORG_CAMERA_BUFFER) + if(oldLoc != src.loc) + cameranet.updateVisibility(oldLoc, 0) + cameranet.updateVisibility(loc, 0) + updating = 0 + +#undef BORG_CAMERA_BUFFER + // CAMERA // An addition to deactivate which removes/adds the camera from the chunk list based on if it works or not. @@ -42,8 +57,19 @@ update_coverage(1) /obj/machinery/camera/Destroy() - cameranet.cameras -= src clear_all_networks() + cameranet.cameras -= src ..() -#undef BORG_CAMERA_BUFFER +// Mobs +/mob/living/silicon/ai/rejuvenate() + var/was_dead = stat == DEAD + ..() + if(was_dead && stat != DEAD) + // Arise! + cameranet.updateVisibility(src, 0) + +/mob/living/silicon/ai/death(gibbed) + if(..()) + // If true, the mob went from living to dead (assuming everyone has been overriding as they should...) + cameranet.updateVisibility(src, 0) diff --git a/code/modules/mob/freelook/eye.dm b/code/modules/mob/freelook/eye.dm index fb2b04a4348..437b2979dcc 100644 --- a/code/modules/mob/freelook/eye.dm +++ b/code/modules/mob/freelook/eye.dm @@ -41,12 +41,15 @@ mob/eye/Destroy() updateallghostimages() ..() -// Movement code. Returns 0 to stop air movement from moving it. /mob/eye/Move(n, direct) if(owner == src) - EyeMove(n, direct) + return EyeMove(n, direct) return 0 +/mob/eye/airflow_hit(atom/A) + airflow_speed = 0 + airflow_dest = null + /mob/eye/examinate() set popup_menu = 0 set src = usr.contents @@ -110,3 +113,4 @@ mob/eye/Destroy() sprint = min(sprint + 0.5, max_sprint) else sprint = initial + return 1 diff --git a/code/modules/mob/freelook/mask/chunk.dm b/code/modules/mob/freelook/mask/chunk.dm index b0973951cc2..f98a9b936bb 100644 --- a/code/modules/mob/freelook/mask/chunk.dm +++ b/code/modules/mob/freelook/mask/chunk.dm @@ -11,27 +11,24 @@ /datum/chunk/cult/acquireVisibleTurfs(var/list/visible) for(var/mob/living/L in living_mob_list) - for(var/turf/t in L.seen_turfs()) + for(var/turf/t in L.seen_cult_turfs()) visible[t] = t -/mob/living/proc/seen_turfs() +/mob/living/proc/seen_cult_turfs() return seen_turfs_in_range(src, 3) -/mob/living/carbon/human/seen_turfs() - /*if(src.isSynthetic()) - return list()*/ - +/mob/living/carbon/human/seen_cult_turfs() if(mind in cult.current_antagonists) - return seen_turfs_in_range(src, client ? client.view : 7) + return seen_turfs_in_range(src, world.view) return ..() -/mob/living/silicon/seen_turfs() +/mob/living/silicon/seen_cult_turfs() return list() -/mob/living/simple_animal/seen_turfs() +/mob/living/simple_animal/seen_cult_turfs() return seen_turfs_in_range(src, 1) -/mob/living/simple_animal/shade/narsie/seen_turfs() +/mob/living/simple_animal/shade/narsie/seen_cult_turfs() return view(2, src) /proc/seen_turfs_in_range(var/source, var/range) diff --git a/code/modules/mob/living/silicon/ai/ai_movement.dm b/code/modules/mob/living/silicon/ai/ai_movement.dm new file mode 100644 index 00000000000..456d11a9817 --- /dev/null +++ b/code/modules/mob/living/silicon/ai/ai_movement.dm @@ -0,0 +1,2 @@ +/mob/living/silicon/ai/SelfMove(turf/n, direct) + return 0