mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-27 22:17:32 +01:00
Expands the AI photo-camera so that it now has robot/cyborg support. Also implements DRY in practice.
Conflicts: code/modules/mob/living/silicon/ai/ai.dm code/modules/mob/living/silicon/robot/robot.dm code/modules/mob/living/silicon/robot/wires.dm code/modules/mob/transform_procs.dm code/modules/paperwork/photography.dm
This commit is contained in:
@@ -1,96 +0,0 @@
|
||||
/**************
|
||||
* AI-specific *
|
||||
**************/
|
||||
/datum/picture
|
||||
var/name = "image"
|
||||
var/list/fields = list()
|
||||
|
||||
obj/item/device/camera/ai_camera //camera AI can take pictures with
|
||||
name = "AI photo camera"
|
||||
var/in_camera_mode = 0
|
||||
var/list/aipictures = list()
|
||||
|
||||
/obj/item/device/camera/ai_camera/proc/injectaialbum(var/icon, var/img, var/desc, var/pixel_x, var/pixel_y) //stores image information to a list similar to that of the datacore
|
||||
var/numberer = 1
|
||||
for(var/datum/picture in src.aipictures)
|
||||
numberer++
|
||||
var/datum/picture/P = new()
|
||||
P.fields["name"] = "Image [numberer]"
|
||||
P.fields["icon"] = icon
|
||||
P.fields["img"] = img
|
||||
P.fields["desc"] = desc
|
||||
P.fields["pixel_x"] = pixel_x
|
||||
P.fields["pixel_y"] = pixel_y
|
||||
|
||||
aipictures += P
|
||||
usr << "<FONT COLOR=blue><B>Image recorded</B>"
|
||||
|
||||
/obj/item/device/camera/ai_camera/proc/viewpictures()
|
||||
var/list/nametemp = list()
|
||||
var/find
|
||||
var/datum/picture/selection
|
||||
if(src.aipictures.len == 0)
|
||||
usr << "<FONT COLOR=red><B>No images saved</B>"
|
||||
return
|
||||
for(var/datum/picture/t in src.aipictures)
|
||||
nametemp += t.fields["name"]
|
||||
find = input("Select image (numbered in order taken)") in nametemp
|
||||
var/obj/item/weapon/photo/P = new/obj/item/weapon/photo()
|
||||
for(var/datum/picture/q in src.aipictures)
|
||||
if(q.fields["name"] == find)
|
||||
selection = q
|
||||
break
|
||||
P.icon = selection.fields["icon"]
|
||||
P.img = selection.fields["img"]
|
||||
P.desc = selection.fields["desc"]
|
||||
P.pixel_x = selection.fields["pixel_x"]
|
||||
P.pixel_y = selection.fields["pixel_y"]
|
||||
|
||||
P.show(usr)
|
||||
usr << P.desc
|
||||
|
||||
// TG uses a special garbage collector.. qdel(P)
|
||||
del(P) //so 10 thousand pictures items are not left in memory should an AI take them and then view them all.
|
||||
|
||||
/obj/item/device/camera/ai_camera/printpicture(mob/user, icon/temp, mobs, flag)
|
||||
var/icon/small_img = icon(temp)
|
||||
var/icon/ic = icon('icons/obj/items.dmi',"photo")
|
||||
small_img.Scale(8, 8)
|
||||
ic.Blend(small_img,ICON_OVERLAY, 10, 13)
|
||||
var/icon = ic
|
||||
var/img = temp
|
||||
var/desc = mobs
|
||||
var/pixel_x = rand(-10, 10)
|
||||
var/pixel_y = rand(-10, 10)
|
||||
|
||||
injectaialbum(icon, img, desc, pixel_x, pixel_y)
|
||||
|
||||
/obj/item/device/camera/ai_camera/can_capture_turf(turf/T, mob/user)
|
||||
var/mob/living/silicon/ai = user
|
||||
return ai.TurfAdjacent(T)
|
||||
|
||||
/obj/item/device/camera/ai_camera/proc/toggle_camera_mode()
|
||||
if(in_camera_mode)
|
||||
camera_mode_off()
|
||||
else
|
||||
camera_mode_on()
|
||||
|
||||
/obj/item/device/camera/ai_camera/proc/camera_mode_off()
|
||||
src.in_camera_mode = 0
|
||||
usr << "<B>Camera Mode deactivated</B>"
|
||||
|
||||
/obj/item/device/camera/ai_camera/proc/camera_mode_on()
|
||||
src.in_camera_mode = 1
|
||||
usr << "<B>Camera Mode activated</B>"
|
||||
|
||||
/mob/living/silicon/ai/proc/ai_take_image()
|
||||
set category = "AI Commands"
|
||||
set name = "Take Image"
|
||||
set desc = "Takes an image"
|
||||
aicamera.toggle_camera_mode()
|
||||
|
||||
/mob/living/silicon/ai/proc/ai_view_images()
|
||||
set category = "AI Commands"
|
||||
set name = "View Images"
|
||||
set desc = "View images"
|
||||
aicamera.viewpictures()
|
||||
@@ -209,7 +209,6 @@
|
||||
mob_detail += "You can also see [A] on the photo[A:health < 75 ? " - [A] looks hurt":""].[holding ? " [holding]":"."]."
|
||||
return mob_detail
|
||||
|
||||
|
||||
/obj/item/device/camera/afterattack(atom/target as mob|obj|turf|area, mob/user as mob, flag)
|
||||
if(!on || !pictures_left || ismob(target.loc)) return
|
||||
captureimage(target, user, flag)
|
||||
@@ -256,13 +255,10 @@
|
||||
y_c--
|
||||
x_c = x_c - 3
|
||||
|
||||
printpicture(user, temp, mobs, flag)
|
||||
var/datum/picture/P = createpicture(user, temp, mobs, flag)
|
||||
printpicture(user, P)
|
||||
|
||||
/obj/item/device/camera/proc/printpicture(mob/user, icon/temp, mobs, flag)
|
||||
var/obj/item/weapon/photo/P = new/obj/item/weapon/photo()
|
||||
P.loc = user.loc
|
||||
if(!user.get_inactive_hand())
|
||||
user.put_in_inactive_hand(P)
|
||||
/obj/item/device/camera/proc/createpicture(mob/user, icon/temp, mobs, flag)
|
||||
var/icon/small_img = icon(temp)
|
||||
var/icon/tiny_img = icon(temp)
|
||||
var/icon/ic = icon('icons/obj/items.dmi',"photo")
|
||||
@@ -271,12 +267,32 @@
|
||||
tiny_img.Scale(4, 4)
|
||||
ic.Blend(small_img,ICON_OVERLAY, 10, 13)
|
||||
pc.Blend(tiny_img,ICON_OVERLAY, 12, 19)
|
||||
P.icon = ic
|
||||
P.tiny = pc
|
||||
P.img = temp
|
||||
P.desc = mobs
|
||||
P.pixel_x = rand(-10, 10)
|
||||
P.pixel_y = rand(-10, 10)
|
||||
|
||||
var/datum/picture/P = new()
|
||||
P.fields["author"] = user
|
||||
P.fields["icon"] = ic
|
||||
P.fields["tiny"] = pc
|
||||
P.fields["img"] = temp
|
||||
P.fields["desc"] = mobs
|
||||
P.fields["pixel_x"] = rand(-10, 10)
|
||||
P.fields["pixel_y"] = rand(-10, 10)
|
||||
|
||||
return P
|
||||
|
||||
/obj/item/device/camera/proc/printpicture(mob/user, var/datum/picture/P)
|
||||
var/obj/item/weapon/photo/Photo = new/obj/item/weapon/photo()
|
||||
Photo.loc = user.loc
|
||||
if(!user.get_inactive_hand())
|
||||
user.put_in_inactive_hand(Photo)
|
||||
Photo.construct(P)
|
||||
|
||||
/obj/item/weapon/photo/proc/construct(var/datum/picture/P)
|
||||
icon = P.fields["icon"]
|
||||
tiny = P.fields["tiny"]
|
||||
img = P.fields["img"]
|
||||
desc = P.fields["desc"]
|
||||
pixel_x = P.fields["pixel_x"]
|
||||
pixel_y = P.fields["pixel_y"]
|
||||
|
||||
/**************
|
||||
*video camera *
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/**************
|
||||
* AI-specific *
|
||||
**************/
|
||||
/datum/picture
|
||||
var/name = "image"
|
||||
var/list/fields = list()
|
||||
|
||||
/datum/inject
|
||||
var/name = "image"
|
||||
var/list/fields = list()
|
||||
|
||||
/obj/item/device/camera/siliconcam
|
||||
var/in_camera_mode = 0
|
||||
var/photos_taken = 0
|
||||
var/list/aipictures = list()
|
||||
|
||||
/obj/item/device/camera/siliconcam/ai_camera //camera AI can take pictures with
|
||||
name = "AI photo camera"
|
||||
|
||||
/obj/item/device/camera/siliconcam/robot_camera //camera cyborgs can take pictures with
|
||||
name = "Cyborg photo camera"
|
||||
|
||||
/obj/item/device/camera/siliconcam/proc/injectaialbum(var/datum/picture/P, var/sufix = "") //stores image information to a list similar to that of the datacore
|
||||
photos_taken++
|
||||
P.fields["name"] = "Image [photos_taken][sufix]"
|
||||
aipictures += P
|
||||
|
||||
/obj/item/device/camera/siliconcam/proc/injectmasteralbum(var/datum/picture/P) //stores image information to a list similar to that of the datacore
|
||||
var/mob/living/silicon/robot/C = src.loc
|
||||
if(C.connected_ai)
|
||||
var/mob/A = P.fields["author"]
|
||||
C.connected_ai.aiCamera.injectaialbum(P, " (taken by [A.name])")
|
||||
C.connected_ai << "<span class='unconscious'>Image recorded and saved by [name]</span>"
|
||||
usr << "<span class='unconscious'>Image recorded and saved to remote database</span>" //feedback to the Cyborg player that the picture was taken
|
||||
else
|
||||
injectaialbum(P)
|
||||
usr << "<span class='unconscious'>Image recorded</span>"
|
||||
|
||||
/obj/item/device/camera/siliconcam/proc/selectpicture(obj/item/device/camera/siliconcam/cam)
|
||||
var/list/nametemp = list()
|
||||
var/find
|
||||
if(cam.aipictures.len == 0)
|
||||
usr << "<span class='userdanger'>No images saved</span>"
|
||||
return
|
||||
for(var/datum/picture/t in cam.aipictures)
|
||||
nametemp += t.fields["name"]
|
||||
find = input("Select image (numbered in order taken)") in nametemp
|
||||
|
||||
for(var/datum/picture/q in cam.aipictures)
|
||||
if(q.fields["name"] == find)
|
||||
return q
|
||||
|
||||
/obj/item/device/camera/siliconcam/proc/viewpictures(obj/item/device/camera/siliconcam/cam)
|
||||
var/datum/picture/selection = selectpicture(cam)
|
||||
|
||||
if(!selection)
|
||||
return
|
||||
|
||||
var/obj/item/weapon/photo/P = new/obj/item/weapon/photo()
|
||||
P.construct(selection)
|
||||
P.show(usr)
|
||||
usr << P.desc
|
||||
|
||||
// TG uses a special garbage collector.. qdel(P)
|
||||
del(P) //so 10 thousand pictures items are not left in memory should an AI take them and then view them all.
|
||||
|
||||
/obj/item/device/camera/siliconcam/proc/deletepicture(obj/item/device/camera/siliconcam/cam)
|
||||
var/datum/picture/selection = selectpicture(cam)
|
||||
|
||||
if(!selection)
|
||||
return
|
||||
|
||||
cam.aipictures -= selection
|
||||
usr << "<span class='unconscious'>Image deleted</span>"
|
||||
|
||||
/obj/item/device/camera/siliconcam/ai_camera/can_capture_turf(turf/T, mob/user)
|
||||
var/mob/living/silicon/ai = user
|
||||
return ai.TurfAdjacent(T)
|
||||
|
||||
/obj/item/device/camera/siliconcam/proc/toggle_camera_mode()
|
||||
if(in_camera_mode)
|
||||
camera_mode_off()
|
||||
else
|
||||
camera_mode_on()
|
||||
|
||||
/obj/item/device/camera/siliconcam/proc/camera_mode_off()
|
||||
src.in_camera_mode = 0
|
||||
usr << "<B>Camera Mode deactivated</B>"
|
||||
|
||||
/obj/item/device/camera/siliconcam/proc/camera_mode_on()
|
||||
src.in_camera_mode = 1
|
||||
usr << "<B>Camera Mode activated</B>"
|
||||
|
||||
/obj/item/device/camera/siliconcam/ai_camera/printpicture(mob/user, datum/picture/P)
|
||||
injectaialbum(P)
|
||||
usr << "<span class='unconscious'>Image recorded</span>"
|
||||
|
||||
/obj/item/device/camera/siliconcam/robot_camera/printpicture(mob/user, datum/picture/P)
|
||||
injectmasteralbum(P)
|
||||
|
||||
/obj/item/device/camera/siliconcam/ai_camera/verb/take_image()
|
||||
set category = "AI Commands"
|
||||
set name = "Take Image"
|
||||
set desc = "Takes an image"
|
||||
set src in usr
|
||||
|
||||
toggle_camera_mode()
|
||||
|
||||
/obj/item/device/camera/siliconcam/ai_camera/verb/view_images()
|
||||
set category = "AI Commands"
|
||||
set name = "View Images"
|
||||
set desc = "View images"
|
||||
set src in usr
|
||||
|
||||
viewpictures(src)
|
||||
|
||||
/obj/item/device/camera/siliconcam/ai_camera/verb/delete_images()
|
||||
set category = "AI Commands"
|
||||
set name = "Delete Image"
|
||||
set desc = "Delete image"
|
||||
set src in usr
|
||||
|
||||
deletepicture(src)
|
||||
|
||||
/obj/item/device/camera/siliconcam/robot_camera/verb/take_image()
|
||||
set category ="Robot Commands"
|
||||
set name = "Take Image"
|
||||
set desc = "Takes an image"
|
||||
set src in usr
|
||||
|
||||
toggle_camera_mode()
|
||||
|
||||
/obj/item/device/camera/siliconcam/robot_camera/verb/view_images()
|
||||
set category ="Robot Commands"
|
||||
set name = "View Images"
|
||||
set desc = "View images"
|
||||
set src in usr
|
||||
|
||||
var/obj/item/device/camera/siliconcam/cam = getsource()
|
||||
viewpictures(cam)
|
||||
|
||||
/obj/item/device/camera/siliconcam/robot_camera/verb/delete_images()
|
||||
set category = "Robot Commands"
|
||||
set name = "Delete Image"
|
||||
set desc = "Delete a local image"
|
||||
set src in usr
|
||||
|
||||
deletepicture(src)
|
||||
|
||||
obj/item/device/camera/siliconcam/proc/getsource()
|
||||
var/mob/living/silicon/robot/C = src.loc
|
||||
var/obj/item/device/camera/siliconcam/Cinfo
|
||||
if(C.connected_ai)
|
||||
Cinfo = C.connected_ai.aiCamera
|
||||
else
|
||||
Cinfo = src
|
||||
return Cinfo
|
||||
Reference in New Issue
Block a user