Skip to content

Commit

Permalink
AIs and Cyborgs can now change their camera size (#11287)
Browse files Browse the repository at this point in the history
* camera buff

* Empty commit to restart tests

* shit
  • Loading branch information
mystery3525 authored Aug 8, 2024
1 parent 3af1a93 commit c8ba35e
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 5 deletions.
2 changes: 1 addition & 1 deletion code/_onclick/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

if(aicamera.in_camera_mode)
aicamera.camera_mode_off()
aicamera.captureimage(pixel_turf, usr)
aicamera.captureimage(pixel_turf, usr, null, aicamera.picture_size_x - 1, aicamera.picture_size_y - 1)
return
if(waypoint_mode)
waypoint_mode = 0
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/cyborg.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

if(aicamera.in_camera_mode) //Cyborg picture taking
aicamera.camera_mode_off()
aicamera.captureimage(A, usr)
aicamera.captureimage(A, usr, null, aicamera.picture_size_x - 1, aicamera.picture_size_y - 1)
return

var/obj/item/W = get_active_held_item()
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/pai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
..()
if(aicamera.in_camera_mode) //pAI picture taking
aicamera.camera_mode_off()
aicamera.captureimage(A, usr, null, aicamera.picture_size_x, aicamera.picture_size_y)
aicamera.captureimage(A, usr, null, aicamera.picture_size_x - 1, aicamera.picture_size_y - 1)
return
14 changes: 13 additions & 1 deletion code/modules/mob/living/silicon/ai/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,6 @@
/mob/living/silicon/ai/zMove(dir, feedback = FALSE, feedback_to = src)
. = eyeobj.zMove(dir, feedback, feedback_to)


/// Proc to hook behavior to the changes of the value of [aiRestorePowerRoutine].
/mob/living/silicon/ai/proc/setAiRestorePowerRoutine(new_value)
if(new_value == aiRestorePowerRoutine)
Expand All @@ -1073,3 +1072,16 @@

/mob/living/silicon/on_handsblocked_end()
return // AIs have no hands

/mob/living/silicon/ai/verb/change_photo_camera_radius()
set category = "AI Commands"
set name = "Adjust Camera Zoom"
set desc = "Change the zoom of your builtin camera."

if(incapacitated())
return
if(isnull(aicamera))
to_chat(usr, "<span class='warning'>You don't have a built-in camera!</span>")
return

aicamera.adjust_zoom(src)
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
data["printerPictures"] = borgo.connected_ai ? length(borgo.connected_ai.aicamera?.stored) : length(borgo.aicamera?.stored) //Number of pictures taken, synced to AI if available
data["printerToner"] = borgo.toner //amount of toner
data["printerTonerMax"] = borgo.tonermax //It's a variable, might as well use it
data["cameraRadius"] = isnull(borgo.aicamera) ? 1 : borgo.aicamera.picture_size_x // picture_size_x and picture_size_y should always be the same.
data["thrustersInstalled"] = borgo.ionpulse //If we have a thruster uprade
data["thrustersStatus"] = "[borgo.ionpulse_on?"ACTIVE":"DISABLED"]" //Feedback for thruster status
data["selfDestructAble"] = (borgo.emagged || istype(borgo, /mob/living/silicon/robot/modules/syndicate))
Expand Down Expand Up @@ -133,6 +134,20 @@
borgo.lamp_intensity = clamp(text2num(params["ref"]), 1, 5)
borgo.toggle_headlamp(FALSE, TRUE)

if("cameraRadius")
var/obj/item/camera/siliconcam/robot_camera/borgcam = borgo.aicamera
if(isnull(borgcam))
CRASH("Cyborg embedded AI camera is null somehow, was it qdeleted?")
var/desired_radius = text2num(params["ref"])
if(isnull(desired_radius))
return
// respect the limits
if(desired_radius > borgcam.picture_size_x_max || desired_radius < borgcam.picture_size_x_min)
log_href_exploit(usr, " attempted to select an invalid borg camera size '[desired_radius]'.")
return
borgcam.picture_size_x = desired_radius
borgcam.picture_size_y = desired_radius

if("selfDestruct")
if(borgo.stat || borgo.lockcharge) //No detonation while stunned or locked down
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@
computer.saved_image = null
photo_path = null
return TRUE
if("PDA_viewPhotos")
if(!issilicon(usr))
return
var/mob/living/silicon/user = usr
var/obj/item/camera/siliconcam/aicamera = user.aicamera
if(isnull(aicamera))
return
aicamera.viewpictures(user)
if("PDA_selectPhoto")
if(!issilicon(usr))
return
Expand Down
15 changes: 15 additions & 0 deletions tgui/packages/tgui/interfaces/NtosCyborgSelfMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const NtosCyborgSelfMonitorContent = (_, context) => {
printerPictures,
printerToner,
printerTonerMax,
cameraRadius,
thrustersInstalled,
thrustersStatus,
selfDestructAble,
Expand Down Expand Up @@ -139,6 +140,20 @@ export const NtosCyborgSelfMonitorContent = (_, context) => {
<LabeledList.Item label="Printer Toner">
<ProgressBar value={printerToner / printerTonerMax} />
</LabeledList.Item>
<LabeledList.Item label="Camera Radius">
<Slider
value={cameraRadius}
step={1}
stepPixelSize={25}
maxValue={4}
minValue={1}
onChange={(e, value) =>
act('cameraRadius', {
ref: value,
})
}
/>
</LabeledList.Item>
{!!thrustersInstalled && (
<LabeledList.Item label="Toggle Thrusters">
<Button content={thrustersStatus} onClick={() => act('toggleThrusters')} />
Expand Down
7 changes: 6 additions & 1 deletion tgui/packages/tgui/interfaces/NtosMessenger.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ const ContactsScreen = (props, context) => {
<Button icon="bell" content="Set Ringtone" onClick={() => act('PDA_ringSet')} />
<Button icon="comment" content="View Messages" onClick={() => act('PDA_viewMessages')} />
<Button icon="sort" content={`Sort by: ${sortByJob ? 'Job' : 'Name'}`} onClick={() => act('PDA_changeSortStyle')} />
{!!isSilicon && <Button icon="camera" content="Attach Photo" onClick={() => act('PDA_selectPhoto')} />}
{!!virus_attach && (
<Button
icon="bug"
Expand All @@ -138,6 +137,12 @@ const ContactsScreen = (props, context) => {
/>
)}
</Box>
{!!isSilicon && (
<Box>
<Button icon="camera" content="View Photos" onClick={() => act('PDA_viewPhotos')} />
<Button icon="camera" content="Attach Photo" onClick={() => act('PDA_selectPhoto')} />
</Box>
)}
</Section>
</Stack>
{!!photo && (
Expand Down

0 comments on commit c8ba35e

Please sign in to comment.