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

AIs and Cyborgs can now change their camera size #11287

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
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_y - 1, aicamera.picture_size_y - 1)
mystery3525 marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -1055,7 +1055,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 @@ -1074,3 +1073,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
Loading