Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI Camera Tweaks #1234

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions code/__DEFINES/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,18 @@
#define ui_ai_core "SOUTH:6,WEST"
#define ui_ai_camera_list "SOUTH:6,WEST+1"
#define ui_ai_track_with_camera "SOUTH:6,WEST+2"
#define ui_ai_camera_light "SOUTH:6,WEST+3"
#define ui_ai_crew_monitor "SOUTH:6,WEST+4"
#define ui_ai_crew_manifest "SOUTH:6,WEST+5"
#define ui_ai_alerts "SOUTH:6,WEST+6"
#define ui_ai_announcement "SOUTH:6,WEST+7"
#define ui_ai_shuttle "SOUTH:6,WEST+8"
#define ui_ai_state_laws "SOUTH:6,WEST+9"
#define ui_ai_mod_int "SOUTH:6,WEST+10"
#define ui_ai_take_picture "SOUTH:6,WEST+11"
#define ui_ai_view_images "SOUTH:6,WEST+12"
#define ui_ai_sensor "SOUTH:6,WEST+13"
#define ui_ai_multicam "SOUTH+1:6,WEST+12"
#define ui_ai_add_multicam "SOUTH+1:6,WEST+13"
#define ui_ai_crew_monitor "SOUTH:6,WEST+3"
#define ui_ai_crew_manifest "SOUTH:6,WEST+4"
#define ui_ai_alerts "SOUTH:6,WEST+5"
#define ui_ai_announcement "SOUTH:6,WEST+6"
#define ui_ai_shuttle "SOUTH:6,WEST+7"
#define ui_ai_state_laws "SOUTH:6,WEST+8"
#define ui_ai_mod_int "SOUTH:6,WEST+9"
#define ui_ai_take_picture "SOUTH:6,WEST+10"
#define ui_ai_view_images "SOUTH:6,WEST+11"
#define ui_ai_sensor "SOUTH:6,WEST+12"
#define ui_ai_multicam "SOUTH+1:6,WEST+13"
#define ui_ai_add_multicam "SOUTH+1:6,WEST+14"
#define ui_ai_language_menu "SOUTH+1:8,WEST+11:30"

//pAI
Expand Down
15 changes: 0 additions & 15 deletions code/_onclick/hud/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@
return
AI.ai_camera_track(target_name)

/atom/movable/screen/ai/camera_light
name = "Toggle Camera Light"
icon_state = "camera_light"

/atom/movable/screen/ai/camera_light/Click()
if(..())
return
var/mob/living/silicon/ai/AI = usr
AI.toggle_camera_light()

/atom/movable/screen/ai/modpc
name = "Messenger"
icon_state = "pda_send"
Expand Down Expand Up @@ -206,11 +196,6 @@
using.screen_loc = ui_ai_track_with_camera
static_inventory += using

//Camera light
using = new /atom/movable/screen/ai/camera_light(null, src)
using.screen_loc = ui_ai_camera_light
static_inventory += using

//Crew Monitoring
using = new /atom/movable/screen/ai/crew_monitor(null, src)
using.screen_loc = ui_ai_crew_monitor
Expand Down
5 changes: 3 additions & 2 deletions code/game/machinery/camera/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -520,12 +520,13 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/camera/xray, 0)
see = get_hear(view_range, pos)
return see

/obj/machinery/camera/proc/Togglelight(on)
for(var/mob/living/silicon/ai/A in GLOB.ai_list)
/obj/machinery/camera/proc/set_ai_light(on, mob/living/silicon/ai/user)
for(var/mob/living/silicon/ai/A in GLOB.ai_list - user)
if(src in A.lit_cameras)
return

set_light(l_on = !!on)
visible_message(span_subtle("[src]'s light flicks [on ? "on" : "off"]."), vision_distance = COMBAT_MESSAGE_RANGE)

/obj/machinery/camera/get_remote_view_fullscreens(mob/user)
if(view_range == short_range) //unfocused
Expand Down
72 changes: 61 additions & 11 deletions code/modules/mob/living/silicon/ai/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@
var/explosive = FALSE //does the AI explode when it dies?

var/mob/living/silicon/ai/parent
var/camera_light_on = FALSE
/// If we are lighting cameras as our eye passes by.
var/camera_light_on = TRUE

/// Cameras that are lit by our presence.
var/list/obj/machinery/camera/lit_cameras = list()

var/datum/trackable/track = new
Expand Down Expand Up @@ -236,8 +239,52 @@
if(ai_voicechanger)
ai_voicechanger.owner = null
ai_voicechanger = null
lit_cameras = null
return ..()

/mob/living/silicon/ai/pre_examinate(atom/examinify)
if(client?.eye == src) // Not using a camera
return ..()

if(!isliving(examinify))
return ..()

if(!do_after(src, examinify, 1.5 SECONDS, DO_IGNORE_TARGET_LOC_CHANGE|DO_IGNORE_USER_LOC_CHANGE|DO_IGNORE_HELD_ITEM|DO_IGNORE_SLOWDOWNS|DO_IGNORE_INCAPACITATED))
return FALSE

if(!can_examinate(examinify))
return FALSE

if(!can_interact_with(examinify)) // Checks cameranet visibility
return FALSE

var/obj/machinery/camera/viewing_camera = get_nearest_lit_camera_to_mob(examinify)

if(viewing_camera)
viewing_camera.visible_message("[src]'s lens rotates and zooms into something.")
playsound(viewing_camera, 'sound/machines/camera_zoom.ogg', 50, FALSE, ignore_walls = FALSE)

var/mob/living/target_examined = examinify
if(target_examined.stats.cooldown_finished("ai_examine"))
var/datum/roll_result/result = target_examined.stat_roll(13, /datum/rpg_skill/extrasensory)
switch(result.outcome)
if(SUCCESS, CRIT_SUCCESS)
target_examined.stats.set_cooldown("ai_examine", 1 MINUTE)
result.do_skill_sound(target_examined)
to_chat(target_examined, result.create_tooltip("A nearby camera has fixated on you."))

return TRUE

/mob/living/silicon/ai/broadcast_examine(atom/examined)
return

/// Returns the nearest lit camera to a mob, as long as the camera can see that mob.
/mob/living/silicon/ai/proc/get_nearest_lit_camera_to_mob(mob/M)
var/smallest_dist = INFINITY
for(var/obj/machinery/camera/C as anything in lit_cameras)
if(get_dist(get_turf(M), get_turf(C)) < smallest_dist && (M in viewers(C)))
. = C

/// Removes all malfunction-related abilities from the AI
/mob/living/silicon/ai/proc/remove_malf_abilities()
QDEL_NULL(modules_action)
Expand Down Expand Up @@ -711,20 +758,22 @@

if (!camera_light_on)
to_chat(src, "Camera lights deactivated.")
var/list/old_cams = lit_cameras.Copy() //Togglelight will fail if the camera is in a lit_cameras list.
lit_cameras.Cut()
for (var/obj/machinery/camera/C in old_cams)
C.Togglelight(0)
for (var/obj/machinery/camera/C in lit_cameras)
C.set_ai_light(FALSE, src)

lit_cameras.Cut()
return

light_cameras()
update_lit_cameras()

to_chat(src, "Camera lights activated.")

//AI_CAMERA_LUMINOSITY

/mob/living/silicon/ai/proc/light_cameras()
/mob/living/silicon/ai/proc/update_lit_cameras()
if(isnull(eyeobj)) // Initialize
return

var/list/obj/machinery/camera/add = list()
var/list/obj/machinery/camera/remove = list()
var/list/obj/machinery/camera/visible = list()
Expand All @@ -738,10 +787,11 @@
remove = lit_cameras - visible

for (var/obj/machinery/camera/C in remove)
lit_cameras -= C //Removed from list before turning off the light so that it doesn't check the AI looking away.
C.Togglelight(0)
lit_cameras -= C
C.set_ai_light(FALSE, src)

for (var/obj/machinery/camera/C in add)
C.Togglelight(1)
C.set_ai_light(TRUE, src)
lit_cameras |= C

/mob/living/silicon/ai/proc/control_integrated_radio()
Expand Down Expand Up @@ -871,7 +921,7 @@

/mob/living/silicon/ai/reset_perspective(atom/new_eye)
if(camera_light_on)
light_cameras()
update_lit_cameras()

if(istype(new_eye, /obj/machinery/camera))
current = new_eye
Expand Down
10 changes: 6 additions & 4 deletions code/modules/mob/living/silicon/ai/freelook/cameranet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// The datum containing all the chunks.

#define CHUNK_SIZE 16 // Only chunk sizes that are to the power of 2. E.g: 2, 4, 8, 16, etc..
/// Takes a position, transforms it into a chunk bounded position. Indexes at 1 so it'll land on actual turfs always
#define GET_CHUNK_COORD(v) (max((FLOOR(v, CHUNK_SIZE)), 1))

GLOBAL_DATUM_INIT(cameranet, /datum/cameranet, new)

Expand All @@ -28,15 +30,15 @@ GLOBAL_DATUM_INIT(cameranet, /datum/cameranet, new)

/// Checks if a chunk has been Generated in x, y, z.
/datum/cameranet/proc/chunkGenerated(x, y, z)
x &= ~(CHUNK_SIZE - 1)
y &= ~(CHUNK_SIZE - 1)
x = GET_CHUNK_COORD(x)
y = GET_CHUNK_COORD(y)
return chunks["[x],[y],[z]"]

// Returns the chunk in the x, y, z.
// If there is no chunk, it creates a new chunk and returns that.
/datum/cameranet/proc/getCameraChunk(x, y, z)
x &= ~(CHUNK_SIZE - 1)
y &= ~(CHUNK_SIZE - 1)
x = GET_CHUNK_COORD(x)
y = GET_CHUNK_COORD(y)
var/key = "[x],[y],[z]"
. = chunks[key]
if(!.)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/silicon/ai/freelook/chunk.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@

/// Create a new camera chunk, since the chunks are made as they are needed.
/datum/camerachunk/New(x, y, z)
x &= ~(CHUNK_SIZE - 1)
y &= ~(CHUNK_SIZE - 1)
x = GET_CHUNK_COORD(x)
y = GET_CHUNK_COORD(y)

src.x = x
src.y = y
Expand Down
4 changes: 3 additions & 1 deletion code/modules/mob/living/silicon/ai/freelook/eye.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
hud_possible = list(
AI_DETECT_HUD = HUD_LIST_LIST
)

var/list/visibleCameraChunks = list()
var/mob/living/silicon/ai/ai = null
var/relay_speech = FALSE
var/use_static = TRUE
var/static_visibility_range = 16
var/ai_detector_visible = TRUE
var/ai_detector_color = COLOR_RED

interaction_range = null

/mob/camera/ai_eye/Initialize(mapload)
Expand Down Expand Up @@ -103,7 +105,7 @@
var/obj/machinery/holopad/H = ai.current
H.move_hologram(ai, destination)
if(ai.camera_light_on)
ai.light_cameras()
ai.update_lit_cameras()
if(ai.master_multicam)
ai.master_multicam.refresh_view()

Expand Down
22 changes: 19 additions & 3 deletions code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,21 @@
SEND_SIGNAL(src, COMSIG_MOB_RESET_PERSPECTIVE)
return TRUE

/// Can this mob examine the desired atom
/mob/proc/can_examinate(atom/examinify)
if(isturf(examinify) && !(sight & SEE_TURFS) && !(examinify in view(client ? client.view : world.view, src)))
// shift-click catcher may issue examinate() calls for out-of-sight turfs
return FALSE

if(is_blind() && !blind_examine_check(examinify)) //blind people see things differently (through touch)
return FALSE

return TRUE

/// Insert or change behavior prior to examine, after can_examine passes.
/mob/proc/pre_examinate(atom/examinify)
return TRUE

/**
* Examine a mob
*
Expand All @@ -571,15 +586,16 @@
DEFAULT_QUEUE_OR_CALL_VERB(VERB_CALLBACK(src, PROC_REF(run_examinate), examinify))

/mob/proc/run_examinate(atom/examinify)
set waitfor = FALSE

if(isturf(examinify) && !(sight & SEE_TURFS) && !(examinify in view(client ? client.view : world.view, src)))
// shift-click catcher may issue examinate() calls for out-of-sight turfs
if(!can_examinate(examinify))
return

if(is_blind() && !blind_examine_check(examinify)) //blind people see things differently (through touch)
if(!pre_examinate(examinify))
return

face_atom(examinify)

var/list/result
if(client)
LAZYINITLIST(client.recent_examines)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/three_dsix/skills/coordination.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/datum/rpg_skill/handicraft
name = "Handicraft"
name = "Coordination"
desc = "Control and manipulate, with style."

parent_stat_type = /datum/rpg_stat/kinesis
Expand Down
5 changes: 5 additions & 0 deletions code/modules/three_dsix/skills/extrasensory.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/datum/rpg_skill/extrasensory
name = "Extrasensory"
desc = "Perceive that which cannot be perceived."

parent_stat_type = /datum/rpg_stat/psyche
1 change: 1 addition & 0 deletions daedalus.dme
Original file line number Diff line number Diff line change
Expand Up @@ -4588,6 +4588,7 @@
#include "code\modules\three_dsix\skills\_skill.dm"
#include "code\modules\three_dsix\skills\anatomia.dm"
#include "code\modules\three_dsix\skills\coordination.dm"
#include "code\modules\three_dsix\skills\extrasensory.dm"
#include "code\modules\three_dsix\skills\forensics.dm"
#include "code\modules\three_dsix\skills\skirmish.dm"
#include "code\modules\three_dsix\skills\willpower.dm"
Expand Down
Binary file added sound/machines/camera_zoom.ogg
Binary file not shown.
2 changes: 2 additions & 0 deletions sound/machines/license.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
crate_close.ogg and crate_open.ogg are made by lawnjelly
(https://freesound.org/people/lawnjelly/sounds/156892/)
They have been licensed under CC-BY 3.0, which can be found at http://creativecommons.org/licenses/by/3.0/

camera_zoom.ogg by kwahmah_02 -- https://freesound.org/s/262896/ -- License: Attribution 3.0
Loading