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

Refactors AI / camera eyes and slows holopad holograms to walk speed #25078

Merged
merged 31 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f8cc798
Refactor/deduplicate camera eye code
asciodev Apr 7, 2024
fbf41cf
lets ff now
asciodev Apr 7, 2024
1398dc4
Merge branch 'master' into camera_eye_refactor
asciodev Apr 7, 2024
ccc4837
Camera Eye refactor fixes and finishing touches
asciodev Apr 11, 2024
bfe25fd
Merge branch 'master' into camera_eye_refactor_merge
asciodev Apr 11, 2024
dc9cdc8
Camera eye refactor: Fix AI acceleration toggle
asciodev Apr 11, 2024
b40e91f
Camera eye refactor: Fix syndicate cam visibility
asciodev Apr 11, 2024
7e5c025
Camera eye refactor: Convert spaces to tabs
asciodev Apr 11, 2024
f83609f
Camera eye refactor: Fix CRLF
asciodev Apr 11, 2024
8513590
Apply suggestions from code review
asciodev Apr 11, 2024
c320993
Apply suggestions from code review
asciodev Apr 11, 2024
8d290ac
Merge branch 'master' into camera_eye_refactor_merge
asciodev Apr 12, 2024
35588c8
Adds toggle to AI commands for fast holograms
asciodev Apr 12, 2024
a4fe28d
Merge branch 'master' into camera_eye_refactor_merge
asciodev Apr 13, 2024
1c70c2f
Merge branch 'master' into camera_eye_refactor_merge
asciodev May 5, 2024
173de47
Refactor ripped Hologram Eye relaymove
asciodev May 5, 2024
1fa7436
Remove unnecessary src access
asciodev May 5, 2024
e7b81a3
Merge branch 'master' into camera_eye_refactor_merge
asciodev May 12, 2024
266086c
Fix bug involving shuttle placement outlines
asciodev May 12, 2024
b0ef2e4
Merge branch 'master' into camera_eye_refactor_merge
asciodev May 30, 2024
a7bd333
Merge branch 'master' into camera_eye_refactor_merge
asciodev Jan 1, 2025
7cc4ab1
Unrevert some changes from #26306 lost in merge
asciodev Jan 1, 2025
3504757
Remove erroneous free xray vision on advanced cams
asciodev Jan 1, 2025
4982348
Autodoc camera acceleration vars
asciodev Jan 1, 2025
591e1f9
Merge branch 'master' into camera_eye_refactor_merge
asciodev Jan 1, 2025
930b330
Remove redundant null var initialization per code review
asciodev Jan 1, 2025
e13260b
Merge branch 'master' into camera_eye_refactor_merge
asciodev Jan 5, 2025
735135a
Changed variables to camel_case, autodocs, cleanup
asciodev Jan 9, 2025
2f5ee11
Merge branch 'master' into camera_eye_refactor_merge
asciodev Jan 9, 2025
4347593
Remove stray qdel(src) per code review
asciodev Jan 9, 2025
6526eba
Merge branch 'master' into camera_eye_refactor_merge
asciodev Jan 10, 2025
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
3 changes: 2 additions & 1 deletion code/__DEFINES/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@
#define isAutoAnnouncer(A) (istype((A), /mob/living/automatedannouncer))

#define iscameramob(A) (istype((A), /mob/camera))
#define isAIEye(A) (istype((A), /mob/camera/aiEye))
#define isAIEye(A) (istype((A), /mob/camera/eye))
#define isholo(A) (istype((A), /mob/camera/eye/hologram))
asciodev marked this conversation as resolved.
Show resolved Hide resolved
#define isovermind(A) (istype((A), /mob/camera/blob))

#define isSpirit(A) (istype((A), /mob/spirit))
Expand Down
20 changes: 2 additions & 18 deletions code/datums/holocall.dm
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
/mob/camera/aiEye/remote/holo/setLoc()
. = ..()
var/obj/machinery/hologram/holopad/H = origin
H.move_hologram(eye_user, loc)
ai_detector_visible = FALSE // Holocalls dont trigger the Ai Detector

//this datum manages it's own references

/datum/holocall
var/mob/living/user //the one that called
var/obj/machinery/hologram/holopad/calling_holopad //the one that sent the call
var/obj/machinery/hologram/holopad/connected_holopad //the one that answered the call (may be null)
var/list/dialed_holopads //all things called, will be cleared out to just connected_holopad once answered

var/mob/camera/aiEye/remote/holo/eye //user's eye, once connected
var/mob/camera/eye/eye //eye, once connected
asciodev marked this conversation as resolved.
Show resolved Hide resolved
var/obj/effect/overlay/holo_pad_hologram/hologram //user's hologram, once connected
var/datum/action/innate/end_holocall/hangup //hangup action

Expand Down Expand Up @@ -137,18 +129,10 @@
return

hologram = H.activate_holo(user)
eye = H.eye
hologram.HC = src

user.unset_machine(H)
//eyeobj code is horrid, this is the best copypasta I could make
eye = new()
eye.origin = H
eye.eye_initialized = TRUE
eye.eye_user = user
eye.name = "Camera Eye ([user.name])"
user.remote_control = eye
user.reset_perspective(eye)
eye.setLoc(get_turf(H))

hangup = new(eye,src)
hangup.Grant(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
return ..()

/obj/machinery/computer/camera_advanced/abductor/CreateEye()
..()
eyeobj = new /mob/camera/eye/abductor(loc, name, src, current_user)
give_eye_control(current_user)
eyeobj.visible_icon = 1
eyeobj.icon = 'icons/obj/abductor.dmi'
eyeobj.icon_state = "camera_target"
Expand Down Expand Up @@ -74,7 +75,7 @@
if(!target || !iscarbon(owner))
return
var/mob/living/carbon/human/C = owner
var/mob/camera/aiEye/remote/remote_eye = C.remote_control
var/mob/camera/eye/abductor/remote_eye = C.remote_control
var/obj/machinery/abductor/pad/P = target

if(GLOB.cameranet.checkTurfVis(remote_eye.loc))
Expand All @@ -101,7 +102,7 @@
if(!target || !iscarbon(owner))
return
var/mob/living/carbon/human/C = owner
var/mob/camera/aiEye/remote/remote_eye = C.remote_control
var/mob/camera/eye/abductor/remote_eye = C.remote_control
var/obj/machinery/abductor/pad/P = target

if(GLOB.cameranet.checkTurfVis(remote_eye.loc))
Expand Down Expand Up @@ -137,7 +138,7 @@
return

var/mob/living/carbon/human/C = owner
var/mob/camera/aiEye/remote/remote_eye = C.remote_control
var/mob/camera/eye/abductor/remote_eye = C.remote_control

var/obj/machinery/abductor/console/console = target
console.SetDroppoint(remote_eye.loc,owner)
115 changes: 14 additions & 101 deletions code/game/machinery/computer/camera_advanced.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
desc = "Used to access the various cameras on the station."
icon_screen = "cameras"
icon_keyboard = "security_key"
var/mob/camera/aiEye/remote/eyeobj
var/mob/camera/eye/eyeobj
var/mob/living/carbon/human/current_user = null
var/list/networks = list("SS13")
var/datum/action/innate/camera_off/off_action = new
var/datum/action/innate/camera_jump/jump_action = new
var/list/actions = list()

/obj/machinery/computer/camera_advanced/proc/CreateEye()
eyeobj = new()
eyeobj.origin = src
eyeobj = new /mob/camera/eye/syndicate(loc, name, src, current_user)
give_eye_control(current_user)

/obj/machinery/computer/camera_advanced/proc/GrantActions(mob/living/user)
if(off_action)
Expand All @@ -25,19 +25,17 @@
jump_action.Grant(user)
actions += jump_action

/obj/machinery/computer/camera_advanced/proc/remove_eye_control(mob/living/user)
if(!user)
/obj/machinery/computer/camera_advanced/proc/RemoveActions()
if(!istype(current_user))
return
for(var/V in actions)
var/datum/action/A = V
A.Remove(user)
A.Remove(current_user)
actions.Cut()
if(user.client)
user.reset_perspective(null)
eyeobj.RemoveImages()
eyeobj.eye_user = null
user.remote_control = null

/obj/machinery/computer/camera_advanced/proc/remove_eye_control(mob/living/user)
RemoveActions()
eyeobj.release_control()
current_user = null
user.unset_machine()
playsound(src, 'sound/machines/terminal_off.ogg', 25, 0)
Expand All @@ -54,7 +52,7 @@
return ..()

/obj/machinery/computer/camera_advanced/on_unset_machine(mob/M)
if(M == current_user)
if(istype(M) && M == current_user)
remove_eye_control(M)

/obj/machinery/computer/camera_advanced/attack_hand(mob/user)
Expand All @@ -66,102 +64,17 @@
if(..())
return
user.set_machine(src)
current_user = user

if(!eyeobj)
CreateEye()

if(!eyeobj.eye_initialized)
var/camera_location
for(var/obj/machinery/camera/C in GLOB.cameranet.cameras)
if(!C.can_use())
continue
if(length(C.network & networks))
camera_location = get_turf(C)
break
if(camera_location)
eyeobj.eye_initialized = 1
give_eye_control(user)
eyeobj.setLoc(camera_location)
else
// An abberant case - silent failure is obnoxious
to_chat(user, "<span class='warning'>ERROR: No linked and active camera network found.</span>")
user.unset_machine()
else
give_eye_control(user)
eyeobj.setLoc(eyeobj.loc)


/obj/machinery/computer/camera_advanced/proc/give_eye_control(mob/user)
eyeobj.give_control(user)
GrantActions(user)
current_user = user
eyeobj.eye_user = user
eyeobj.name = "Camera Eye ([user.name])"
user.remote_control = eyeobj
user.reset_perspective(eyeobj)

/mob/camera/aiEye/remote
name = "Inactive Camera Eye"
// Abductors dont trigger the Ai Detector
ai_detector_visible = FALSE
var/sprint = 10
var/cooldown = 0
var/acceleration = 1
var/mob/living/carbon/human/eye_user = null
var/obj/machinery/computer/camera_advanced/origin
var/eye_initialized = 0
var/visible_icon = 0
var/image/user_image = null

/mob/camera/aiEye/remote/Destroy()
eye_user = null
origin = null
return ..()

/mob/camera/aiEye/remote/RemoveImages()
..()
if(visible_icon)
var/client/C = GetViewerClient()
if(C)
C.images -= user_image

/mob/camera/aiEye/remote/GetViewerClient()
if(eye_user)
return eye_user.client
return null

/mob/camera/aiEye/remote/setLoc(T)
if(eye_user)
if(!isturf(eye_user.loc))
return
T = get_turf(T)
var/old_loc = loc
loc = T
Moved(old_loc, get_dir(old_loc, loc))
if(use_static)
GLOB.cameranet.visibility(src, GetViewerClient())
if(visible_icon)
if(eye_user.client)
eye_user.client.images -= user_image
user_image = image(icon,loc,icon_state,FLY_LAYER)
eye_user.client.images += user_image

/mob/camera/aiEye/remote/relaymove(mob/user,direct)
var/initial = initial(sprint)
var/max_sprint = 50

if(cooldown && cooldown < world.timeofday) // 3 seconds
sprint = initial

for(var/i = 0; i < max(sprint, initial); i += 20)
var/turf/step = get_turf(get_step(src, direct))
if(step)
src.setLoc(step)

cooldown = world.timeofday + 5
if(acceleration)
sprint = min(sprint + 0.5, max_sprint)
else
sprint = initial

/datum/action/innate/camera_off
name = "End Camera View"
Expand All @@ -171,7 +84,7 @@
if(!target || !iscarbon(target))
return
var/mob/living/carbon/C = target
var/mob/camera/aiEye/remote/remote_eye = C.remote_control
var/mob/camera/eye/remote_eye = C.remote_control
var/obj/machinery/computer/camera_advanced/console = remote_eye.origin
console.remove_eye_control(target)

Expand All @@ -183,7 +96,7 @@
if(!target || !iscarbon(target))
return
var/mob/living/carbon/C = target
var/mob/camera/aiEye/remote/remote_eye = C.remote_control
var/mob/camera/eye/remote_eye = C.remote_control
var/obj/machinery/computer/camera_advanced/origin = remote_eye.origin

var/list/L = list()
Expand Down
11 changes: 9 additions & 2 deletions code/game/machinery/hologram.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ GLOBAL_LIST_EMPTY(holopads)
var/obj/effect/overlay/holoray/ray
var/ringing = FALSE
var/dialling_input = FALSE //The user is currently selecting where to send their call
var/mob/camera/eye/hologram/eye = null
asciodev marked this conversation as resolved.
Show resolved Hide resolved

/obj/machinery/hologram/holopad/Initialize(mapload)
. = ..()
Expand Down Expand Up @@ -335,8 +336,8 @@ GLOBAL_LIST_EMPTY(holopads)

//Can we display holos there
//Area check instead of line of sight check because this is a called a lot if AI wants to move around.
/obj/machinery/hologram/holopad/proc/validate_location(turf/T,check_los = FALSE)
if(T.z == z && get_dist(T, src) <= holo_range && T.loc == get_area(src))
/obj/machinery/hologram/holopad/proc/validate_location(turf/T, extended_range = 0)
if(T.z == z && get_dist(T, src) <= holo_range + extended_range && T.loc == get_area(src))
asciodev marked this conversation as resolved.
Show resolved Hide resolved
return TRUE
return FALSE

Expand Down Expand Up @@ -385,6 +386,7 @@ GLOBAL_LIST_EMPTY(holopads)
hologram.set_light(2) //hologram lighting
move_hologram()

eye = new /mob/camera/eye/hologram(src, user.name, src, user)
set_holo(user, hologram)

if(!masters[user])//If there is not already a hologram.
Expand Down Expand Up @@ -437,6 +439,8 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/


/obj/machinery/hologram/holopad/proc/set_holo(mob/living/user, obj/effect/overlay/holo_pad_hologram/h)
eye = user.remote_control
eye.holopad = src
masters[user] = h
holorays[user] = new /obj/effect/overlay/holoray(loc)
var/mob/living/silicon/ai/AI = user
Expand All @@ -448,10 +452,13 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/

/obj/machinery/hologram/holopad/proc/clear_holo(mob/living/user)
qdel(masters[user]) // Get rid of user's hologram
if(!QDELETED(eye))
QDEL_NULL(eye)
unset_holo(user)
return TRUE

/obj/machinery/hologram/holopad/proc/unset_holo(mob/living/user)
eye = null
var/mob/living/silicon/ai/AI = user
if(istype(AI) && AI.current == src)
AI.current = null
Expand Down
7 changes: 6 additions & 1 deletion code/game/mecha/mecha.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@
AI.cancel_camera()
AI.controlled_mech = src
AI.remote_control = src
AI.reset_perspective(src)
AI.can_shunt = FALSE //ONE AI ENTERS. NO AI LEAVES.
to_chat(AI, "[AI.can_dominate_mechs ? "<span class='boldnotice'>Takeover of [name] complete! You are now permanently loaded onto the onboard computer. Do not attempt to leave the station sector!</span>" \
: "<span class='notice'>You have been uploaded to a mech's onboard computer."]")
Expand Down Expand Up @@ -1280,7 +1281,11 @@
return
to_chat(AI, "<span class='notice'>Returning to core...</span>")
AI.controlled_mech = null
AI.remote_control = null
if(istype(AI.eyeobj))
AI.remote_control = AI.eyeobj
AI.reset_perspective(AI.eyeobj)
else
AI.eyeobj = new /mob/camera/eye/ai(loc, AI.name, AI, AI)
RemoveActions(occupant, 1)
mob_container = AI
newloc = get_turf(AI.linked_core)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/tools/multitool.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
var/datum/camerachunk/chunk = GLOB.cameranet.getCameraChunk(our_turf.x, our_turf.y, our_turf.z)
if(chunk)
if(chunk.seenby.len)
for(var/mob/camera/aiEye/A in chunk.seenby)
for(var/mob/camera/eye/ai/A in chunk.seenby)
//Checks if the A is to be detected or not
if(!A.ai_detector_visible)
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,15 @@ GLOBAL_DATUM_INIT(cameranet, /datum/cameranet, new())

// Updates what the aiEye can see. It is recommended you use this when the aiEye moves or it's location is set.

/datum/cameranet/proc/visibility(list/moved_eyes, client/C, list/other_eyes)
/datum/cameranet/proc/visibility(list/moved_eyes, client/C)
if(!islist(moved_eyes))
moved_eyes = moved_eyes ? list(moved_eyes) : list()
if(islist(other_eyes))
other_eyes = (other_eyes - moved_eyes)
else
other_eyes = list()

var/list/chunks_pre_seen = list()
var/list/chunks_post_seen = list()

for(var/V in moved_eyes)
var/mob/camera/aiEye/eye = V
var/mob/camera/eye/eye = V
if(C)
chunks_pre_seen |= eye.visibleCameraChunks
// 0xf = 15
Expand Down Expand Up @@ -75,10 +71,6 @@ GLOBAL_DATUM_INIT(cameranet, /datum/cameranet, new())
chunks_post_seen |= eye.visibleCameraChunks

if(C)
for(var/V in other_eyes)
var/mob/camera/aiEye/eye = V
chunks_post_seen |= eye.visibleCameraChunks

var/list/remove = chunks_pre_seen - chunks_post_seen
var/list/add = chunks_post_seen - chunks_pre_seen

Expand Down
Loading