initial commit - cross reference with 5th port - obviously has compile errors
This commit is contained in:
@@ -0,0 +1,422 @@
|
||||
#define CAMERA_UPGRADE_XRAY 1
|
||||
#define CAMERA_UPGRADE_EMP_PROOF 2
|
||||
#define CAMERA_UPGRADE_MOTION 4
|
||||
|
||||
/obj/machinery/camera
|
||||
name = "security camera"
|
||||
desc = "It's used to monitor rooms."
|
||||
icon = 'icons/obj/monitors.dmi'
|
||||
icon_state = "camera"
|
||||
use_power = 2
|
||||
idle_power_usage = 5
|
||||
active_power_usage = 10
|
||||
layer = WALL_OBJ_LAYER
|
||||
|
||||
var/health = 50
|
||||
var/list/network = list("SS13")
|
||||
var/c_tag = null
|
||||
var/c_tag_order = 999
|
||||
var/status = 1
|
||||
anchored = 1
|
||||
var/start_active = 0 //If it ignores the random chance to start broken on round start
|
||||
var/invuln = null
|
||||
var/obj/item/device/camera_bug/bug = null
|
||||
var/obj/machinery/camera_assembly/assembly = null
|
||||
|
||||
//OTHER
|
||||
|
||||
var/view_range = 7
|
||||
var/short_range = 2
|
||||
|
||||
var/alarm_on = 0
|
||||
var/busy = 0
|
||||
var/emped = 0 //Number of consecutive EMP's on this camera
|
||||
|
||||
// Upgrades bitflag
|
||||
var/upgrades = 0
|
||||
|
||||
/obj/machinery/camera/New()
|
||||
..()
|
||||
assembly = new(src)
|
||||
assembly.state = 4
|
||||
cameranet.cameras += src
|
||||
cameranet.addCamera(src)
|
||||
add_to_proximity_list(src, 1) //1 was default of everything
|
||||
/* // Use this to look for cameras that have the same c_tag.
|
||||
for(var/obj/machinery/camera/C in cameranet.cameras)
|
||||
var/list/tempnetwork = C.network&src.network
|
||||
if(C != src && C.c_tag == src.c_tag && tempnetwork.len)
|
||||
world.log << "[src.c_tag] [src.x] [src.y] [src.z] conflicts with [C.c_tag] [C.x] [C.y] [C.z]"
|
||||
*/
|
||||
|
||||
/obj/machinery/camera/initialize()
|
||||
if(z == 1 && prob(3) && !start_active)
|
||||
toggle_cam()
|
||||
|
||||
/obj/machinery/camera/Move()
|
||||
remove_from_proximity_list(src, 1)
|
||||
return ..()
|
||||
|
||||
/obj/machinery/camera/Destroy()
|
||||
toggle_cam(null, 0) //kick anyone viewing out
|
||||
remove_from_proximity_list(src, 1)
|
||||
if(assembly)
|
||||
qdel(assembly)
|
||||
assembly = null
|
||||
if(bug)
|
||||
bug.bugged_cameras -= src.c_tag
|
||||
if(bug.current == src)
|
||||
bug.current = null
|
||||
bug = null
|
||||
cameranet.removeCamera(src) //Will handle removal from the camera network and the chunks, so we don't need to worry about that
|
||||
cameranet.cameras -= src
|
||||
cameranet.removeCamera(src)
|
||||
return ..()
|
||||
|
||||
/obj/machinery/camera/emp_act(severity)
|
||||
if(!status)
|
||||
return
|
||||
if(!isEmpProof())
|
||||
if(prob(150/severity))
|
||||
update_icon()
|
||||
var/list/previous_network = network
|
||||
network = list()
|
||||
cameranet.removeCamera(src)
|
||||
stat |= EMPED
|
||||
SetLuminosity(0)
|
||||
emped = emped+1 //Increase the number of consecutive EMP's
|
||||
update_icon()
|
||||
var/thisemp = emped //Take note of which EMP this proc is for
|
||||
spawn(900)
|
||||
if(loc) //qdel limbo
|
||||
triggerCameraAlarm() //camera alarm triggers even if multiple EMPs are in effect.
|
||||
if(emped == thisemp) //Only fix it if the camera hasn't been EMP'd again
|
||||
network = previous_network
|
||||
stat &= ~EMPED
|
||||
update_icon()
|
||||
if(can_use())
|
||||
cameranet.addCamera(src)
|
||||
emped = 0 //Resets the consecutive EMP count
|
||||
addtimer(src, "cancelCameraAlarm", 100)
|
||||
for(var/mob/O in mob_list)
|
||||
if (O.client && O.client.eye == src)
|
||||
O.unset_machine()
|
||||
O.reset_perspective(null)
|
||||
O << "The screen bursts into static."
|
||||
..()
|
||||
|
||||
|
||||
/obj/machinery/camera/ex_act(severity, target)
|
||||
if(src.invuln)
|
||||
return
|
||||
switch(severity)
|
||||
if(1)
|
||||
qdel(src)
|
||||
if(2)
|
||||
take_damage(50, BRUTE, 0)
|
||||
else
|
||||
take_damage(rand(30,60), BRUTE, 0)
|
||||
|
||||
/obj/machinery/camera/proc/setViewRange(num = 7)
|
||||
src.view_range = num
|
||||
cameranet.updateVisibility(src, 0)
|
||||
|
||||
/obj/machinery/camera/proc/shock(mob/living/user)
|
||||
if(!istype(user))
|
||||
return
|
||||
user.electrocute_act(10, src)
|
||||
|
||||
/obj/machinery/camera/attackby(obj/W, mob/living/user, params)
|
||||
var/msg = "<span class='notice'>You attach [W] into the assembly's inner circuits.</span>"
|
||||
var/msg2 = "<span class='notice'>[src] already has that upgrade!</span>"
|
||||
|
||||
// DECONSTRUCTION
|
||||
if(istype(W, /obj/item/weapon/screwdriver))
|
||||
panel_open = !panel_open
|
||||
user << "<span class='notice'>You screw the camera's panel [panel_open ? "open" : "closed"].</span>"
|
||||
playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1)
|
||||
return
|
||||
|
||||
if(panel_open)
|
||||
if(istype(W, /obj/item/weapon/wirecutters)) //enable/disable the camera
|
||||
toggle_cam(user, 1)
|
||||
health = initial(health) //this is a pretty simplistic way to heal the camera, but there's no reason for this to be complex.
|
||||
return
|
||||
|
||||
else if(istype(W, /obj/item/device/multitool)) //change focus
|
||||
setViewRange((view_range == initial(view_range)) ? short_range : initial(view_range))
|
||||
user << "<span class='notice'>You [(view_range == initial(view_range)) ? "restore" : "mess up"] the camera's focus.</span>"
|
||||
return
|
||||
|
||||
else if(istype(W, /obj/item/weapon/weldingtool))
|
||||
if(weld(W, user))
|
||||
visible_message("<span class='warning'>[user] unwelds [src], leaving it as just a frame screwed to the wall.</span>", "<span class='warning'>You unweld [src], leaving it as just a frame screwed to the wall</span>")
|
||||
if(!assembly)
|
||||
assembly = new()
|
||||
assembly.loc = src.loc
|
||||
assembly.state = 1
|
||||
assembly.setDir(src.dir)
|
||||
assembly = null
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
else if(istype(W, /obj/item/device/analyzer))
|
||||
if(!isXRay())
|
||||
upgradeXRay()
|
||||
qdel(W)
|
||||
user << "[msg]"
|
||||
else
|
||||
user << "[msg2]"
|
||||
return
|
||||
|
||||
else if(istype(W, /obj/item/stack/sheet/mineral/plasma))
|
||||
if(!isEmpProof())
|
||||
upgradeEmpProof()
|
||||
user << "[msg]"
|
||||
qdel(W)
|
||||
else
|
||||
user << "[msg2]"
|
||||
return
|
||||
|
||||
else if(istype(W, /obj/item/device/assembly/prox_sensor))
|
||||
if(!isMotion())
|
||||
upgradeMotion()
|
||||
user << "[msg]"
|
||||
qdel(W)
|
||||
else
|
||||
user << "[msg2]"
|
||||
return
|
||||
|
||||
// OTHER
|
||||
if((istype(W, /obj/item/weapon/paper) || istype(W, /obj/item/device/pda)) && isliving(user))
|
||||
var/mob/living/U = user
|
||||
var/obj/item/weapon/paper/X = null
|
||||
var/obj/item/device/pda/P = null
|
||||
|
||||
var/itemname = ""
|
||||
var/info = ""
|
||||
if(istype(W, /obj/item/weapon/paper))
|
||||
X = W
|
||||
itemname = X.name
|
||||
info = X.info
|
||||
else
|
||||
P = W
|
||||
itemname = P.name
|
||||
info = P.notehtml
|
||||
U << "<span class='notice'>You hold \the [itemname] up to the camera...</span>"
|
||||
U.changeNext_move(CLICK_CD_MELEE)
|
||||
for(var/mob/O in player_list)
|
||||
if(istype(O, /mob/living/silicon/ai))
|
||||
var/mob/living/silicon/ai/AI = O
|
||||
if(AI.control_disabled || (AI.stat == DEAD))
|
||||
return
|
||||
if(U.name == "Unknown")
|
||||
AI << "<b>[U]</b> holds <a href='?_src_=usr;show_paper=1;'>\a [itemname]</a> up to one of your cameras ..."
|
||||
else
|
||||
AI << "<b><a href='?src=\ref[AI];track=[html_encode(U.name)]'>[U]</a></b> holds <a href='?_src_=usr;show_paper=1;'>\a [itemname]</a> up to one of your cameras ..."
|
||||
AI.last_paper_seen = "<HTML><HEAD><TITLE>[itemname]</TITLE></HEAD><BODY><TT>[info]</TT></BODY></HTML>"
|
||||
else if (O.client && O.client.eye == src)
|
||||
O << "[U] holds \a [itemname] up to one of the cameras ..."
|
||||
O << browse(text("<HTML><HEAD><TITLE>[]</TITLE></HEAD><BODY><TT>[]</TT></BODY></HTML>", itemname, info), text("window=[]", itemname))
|
||||
return
|
||||
|
||||
else if(istype(W, /obj/item/device/camera_bug))
|
||||
if(!can_use())
|
||||
user << "<span class='notice'>Camera non-functional.</span>"
|
||||
return
|
||||
if(bug)
|
||||
user << "<span class='notice'>Camera bug removed.</span>"
|
||||
bug.bugged_cameras -= src.c_tag
|
||||
bug = null
|
||||
else
|
||||
user << "<span class='notice'>Camera bugged.</span>"
|
||||
bug = W
|
||||
bug.bugged_cameras[src.c_tag] = src
|
||||
return
|
||||
|
||||
else if(istype(W, /obj/item/weapon/pai_cable))
|
||||
var/obj/item/weapon/pai_cable/cable = W
|
||||
cable.plugin(src, user)
|
||||
return
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/machinery/camera/take_damage(damage, damage_type = BRUTE, sound_effect = 1)
|
||||
switch(damage_type)
|
||||
if(BRUTE)
|
||||
if(sound_effect)
|
||||
if(damage)
|
||||
playsound(src, 'sound/weapons/smash.ogg', 50, 1)
|
||||
else
|
||||
playsound(src, 'sound/weapons/tap.ogg', 50, 1)
|
||||
if(BURN)
|
||||
if(sound_effect)
|
||||
playsound(src.loc, 'sound/items/Welder.ogg', 100, 1)
|
||||
else
|
||||
return
|
||||
if(damage < 10) //camera has a damage resistance threshold
|
||||
return
|
||||
health = max(0, health - damage)
|
||||
if(!health && status)
|
||||
triggerCameraAlarm()
|
||||
toggle_cam(null, 0)
|
||||
|
||||
/obj/machinery/camera/update_icon()
|
||||
if(!status)
|
||||
icon_state = "[initial(icon_state)]1"
|
||||
else if (stat & EMPED)
|
||||
icon_state = "[initial(icon_state)]emp"
|
||||
else
|
||||
icon_state = "[initial(icon_state)]"
|
||||
|
||||
/obj/machinery/camera/proc/toggle_cam(mob/user, displaymessage = 1)
|
||||
status = !status
|
||||
if(can_use())
|
||||
cameranet.addCamera(src)
|
||||
else
|
||||
SetLuminosity(0)
|
||||
cameranet.removeCamera(src)
|
||||
cameranet.updateChunk(x, y, z)
|
||||
var/change_msg = "deactivates"
|
||||
if(status)
|
||||
change_msg = "reactivates"
|
||||
triggerCameraAlarm()
|
||||
addtimer(src, "cancelCameraAlarm", 100)
|
||||
if(displaymessage)
|
||||
if(user)
|
||||
visible_message("<span class='danger'>[user] [change_msg] [src]!</span>")
|
||||
add_hiddenprint(user)
|
||||
else
|
||||
visible_message("<span class='danger'>\The [src] [change_msg]!</span>")
|
||||
|
||||
playsound(src.loc, 'sound/items/Wirecutter.ogg', 100, 1)
|
||||
update_icon()
|
||||
|
||||
// now disconnect anyone using the camera
|
||||
//Apparently, this will disconnect anyone even if the camera was re-activated.
|
||||
//I guess that doesn't matter since they can't use it anyway?
|
||||
for(var/mob/O in player_list)
|
||||
if (O.client && O.client.eye == src)
|
||||
O.unset_machine()
|
||||
O.reset_perspective(null)
|
||||
O << "The screen bursts into static."
|
||||
|
||||
/obj/machinery/camera/proc/triggerCameraAlarm()
|
||||
alarm_on = 1
|
||||
for(var/mob/living/silicon/S in mob_list)
|
||||
S.triggerAlarm("Camera", get_area(src), list(src), src)
|
||||
|
||||
/obj/machinery/camera/proc/cancelCameraAlarm()
|
||||
alarm_on = 0
|
||||
for(var/mob/living/silicon/S in mob_list)
|
||||
S.cancelAlarm("Camera", get_area(src), src)
|
||||
|
||||
/obj/machinery/camera/proc/can_use()
|
||||
if(!status)
|
||||
return 0
|
||||
if(stat & EMPED)
|
||||
return 0
|
||||
return 1
|
||||
|
||||
/obj/machinery/camera/proc/can_see()
|
||||
var/list/see = null
|
||||
var/turf/pos = get_turf(src)
|
||||
if(isXRay())
|
||||
see = range(view_range, pos)
|
||||
else
|
||||
see = get_hear(view_range, pos)
|
||||
return see
|
||||
|
||||
/atom/proc/auto_turn()
|
||||
//Automatically turns based on nearby walls.
|
||||
var/turf/closed/wall/T = null
|
||||
for(var/i = 1, i <= 8; i += i)
|
||||
T = get_ranged_target_turf(src, i, 1)
|
||||
if(istype(T))
|
||||
//If someone knows a better way to do this, let me know. -Giacom
|
||||
switch(i)
|
||||
if(NORTH)
|
||||
src.setDir(SOUTH)
|
||||
if(SOUTH)
|
||||
src.setDir(NORTH)
|
||||
if(WEST)
|
||||
src.setDir(EAST)
|
||||
if(EAST)
|
||||
src.setDir(WEST)
|
||||
break
|
||||
|
||||
//Return a working camera that can see a given mob
|
||||
//or null if none
|
||||
/proc/seen_by_camera(var/mob/M)
|
||||
for(var/obj/machinery/camera/C in oview(4, M))
|
||||
if(C.can_use()) // check if camera disabled
|
||||
return C
|
||||
break
|
||||
return null
|
||||
|
||||
/proc/near_range_camera(var/mob/M)
|
||||
for(var/obj/machinery/camera/C in range(4, M))
|
||||
if(C.can_use()) // check if camera disabled
|
||||
return C
|
||||
break
|
||||
|
||||
return null
|
||||
|
||||
/obj/machinery/camera/proc/weld(obj/item/weapon/weldingtool/WT, mob/living/user)
|
||||
if(busy)
|
||||
return 0
|
||||
if(!WT.remove_fuel(0, user))
|
||||
return 0
|
||||
|
||||
user << "<span class='notice'>You start to weld [src]...</span>"
|
||||
playsound(src.loc, 'sound/items/Welder.ogg', 50, 1)
|
||||
busy = 1
|
||||
if(do_after(user, 100, target = src))
|
||||
busy = 0
|
||||
if(!WT.isOn())
|
||||
return 0
|
||||
return 1
|
||||
busy = 0
|
||||
return 0
|
||||
|
||||
/obj/machinery/camera/proc/Togglelight(on=0)
|
||||
for(var/mob/living/silicon/ai/A in ai_list)
|
||||
for(var/obj/machinery/camera/cam in A.lit_cameras)
|
||||
if(cam == src)
|
||||
return
|
||||
if(on)
|
||||
src.SetLuminosity(AI_CAMERA_LUMINOSITY)
|
||||
else
|
||||
src.SetLuminosity(0)
|
||||
|
||||
/obj/machinery/camera/bullet_act(obj/item/projectile/P)
|
||||
. = ..()
|
||||
take_damage(P.damage, P.damage_type, 0)
|
||||
|
||||
/obj/machinery/camera/portable //Cameras which are placed inside of things, such as helmets.
|
||||
var/turf/prev_turf
|
||||
|
||||
/obj/machinery/camera/portable/New()
|
||||
..()
|
||||
assembly.state = 0 //These cameras are portable, and so shall be in the portable state if removed.
|
||||
assembly.anchored = 0
|
||||
assembly.update_icon()
|
||||
|
||||
/obj/machinery/camera/portable/process() //Updates whenever the camera is moved.
|
||||
if(cameranet && get_turf(src) != prev_turf)
|
||||
cameranet.updatePortableCamera(src)
|
||||
prev_turf = get_turf(src)
|
||||
|
||||
/obj/machinery/camera/get_remote_view_fullscreens(mob/user)
|
||||
if(view_range == short_range) //unfocused
|
||||
user.overlay_fullscreen("remote_view", /obj/screen/fullscreen/impaired, 2)
|
||||
|
||||
/obj/machinery/camera/update_remote_sight(mob/living/user)
|
||||
user.see_invisible = SEE_INVISIBLE_LIVING //can't see ghosts through cameras
|
||||
if(isXRay())
|
||||
user.sight |= (SEE_TURFS|SEE_MOBS|SEE_OBJS)
|
||||
user.see_in_dark = max(user.see_in_dark, 8)
|
||||
else
|
||||
user.sight = 0
|
||||
user.see_in_dark = 2
|
||||
return 1
|
||||
@@ -0,0 +1,140 @@
|
||||
/obj/item/wallframe/camera
|
||||
name = "camera assembly"
|
||||
desc = "The basic construction for Nanotrasen-Always-Watching-You cameras."
|
||||
icon = 'icons/obj/monitors.dmi'
|
||||
icon_state = "cameracase"
|
||||
materials = list(MAT_METAL=400, MAT_GLASS=250)
|
||||
result_path = /obj/machinery/camera_assembly
|
||||
|
||||
|
||||
/obj/machinery/camera_assembly
|
||||
name = "camera assembly"
|
||||
desc = "The basic construction for Nanotrasen-Always-Watching-You cameras."
|
||||
icon = 'icons/obj/monitors.dmi'
|
||||
icon_state = "camera1"
|
||||
// Motion, EMP-Proof, X-Ray
|
||||
var/list/obj/item/possible_upgrades = list(/obj/item/device/assembly/prox_sensor, /obj/item/stack/sheet/mineral/plasma, /obj/item/device/analyzer)
|
||||
var/list/upgrades = list()
|
||||
var/state = 1
|
||||
var/busy = 0
|
||||
/*
|
||||
1 = Wrenched in place
|
||||
2 = Welded in place
|
||||
3 = Wires attached to it (you can now attach/dettach upgrades)
|
||||
4 = Screwdriver panel closed and is fully built (you cannot attach upgrades)
|
||||
*/
|
||||
|
||||
/obj/machinery/camera_assembly/New(loc, ndir, building)
|
||||
..()
|
||||
if(building)
|
||||
setDir(ndir)
|
||||
|
||||
/obj/machinery/camera_assembly/attackby(obj/item/W, mob/living/user, params)
|
||||
switch(state)
|
||||
if(1)
|
||||
// State 1
|
||||
if(istype(W, /obj/item/weapon/weldingtool))
|
||||
if(weld(W, user))
|
||||
user << "<span class='notice'>You weld the assembly securely into place.</span>"
|
||||
anchored = 1
|
||||
state = 2
|
||||
return
|
||||
|
||||
else if(istype(W, /obj/item/weapon/wrench))
|
||||
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
|
||||
user << "<span class='notice'>You unattach the assembly from its place.</span>"
|
||||
new /obj/item/wallframe/camera(get_turf(src))
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
if(2)
|
||||
// State 2
|
||||
if(istype(W, /obj/item/stack/cable_coil))
|
||||
var/obj/item/stack/cable_coil/C = W
|
||||
if(C.use(2))
|
||||
user << "<span class='notice'>You add wires to the assembly.</span>"
|
||||
state = 3
|
||||
else
|
||||
user << "<span class='warning'>You need two lengths of cable to wire a camera!</span>"
|
||||
return
|
||||
return
|
||||
|
||||
else if(istype(W, /obj/item/weapon/weldingtool))
|
||||
|
||||
if(weld(W, user))
|
||||
user << "<span class='notice'>You unweld the assembly from its place.</span>"
|
||||
state = 1
|
||||
anchored = 1
|
||||
return
|
||||
|
||||
|
||||
if(3)
|
||||
// State 3
|
||||
if(istype(W, /obj/item/weapon/screwdriver))
|
||||
playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1)
|
||||
|
||||
var/input = stripped_input(usr, "Which networks would you like to connect this camera to? Seperate networks with a comma. No Spaces!\nFor example: SS13,Security,Secret ", "Set Network", "SS13")
|
||||
if(!input)
|
||||
usr << "<span class='warning'>No input found, please hang up and try your call again!</span>"
|
||||
return
|
||||
|
||||
var/list/tempnetwork = splittext(input, ",")
|
||||
if(tempnetwork.len < 1)
|
||||
usr << "<span class='warning'>No network found, please hang up and try your call again!</span>"
|
||||
return
|
||||
|
||||
state = 4
|
||||
var/obj/machinery/camera/C = new(src.loc)
|
||||
src.loc = C
|
||||
C.assembly = src
|
||||
C.setDir(src.dir)
|
||||
|
||||
C.network = tempnetwork
|
||||
var/area/A = get_area_master(src)
|
||||
C.c_tag = "[A.name] ([rand(1, 999)])"
|
||||
|
||||
|
||||
else if(istype(W, /obj/item/weapon/wirecutters))
|
||||
new/obj/item/stack/cable_coil(get_turf(src), 2)
|
||||
playsound(src.loc, 'sound/items/Wirecutter.ogg', 50, 1)
|
||||
user << "<span class='notice'>You cut the wires from the circuits.</span>"
|
||||
state = 2
|
||||
return
|
||||
|
||||
// Upgrades!
|
||||
if(is_type_in_list(W, possible_upgrades) && !is_type_in_list(W, upgrades)) // Is a possible upgrade and isn't in the camera already.
|
||||
if(!user.unEquip(W))
|
||||
return
|
||||
user << "<span class='notice'>You attach \the [W] into the assembly inner circuits.</span>"
|
||||
upgrades += W
|
||||
W.loc = src
|
||||
return
|
||||
|
||||
// Taking out upgrades
|
||||
else if(istype(W, /obj/item/weapon/crowbar) && upgrades.len)
|
||||
var/obj/U = locate(/obj) in upgrades
|
||||
if(U)
|
||||
user << "<span class='notice'>You unattach an upgrade from the assembly.</span>"
|
||||
playsound(src.loc, 'sound/items/Crowbar.ogg', 50, 1)
|
||||
U.loc = get_turf(src)
|
||||
upgrades -= U
|
||||
return
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/machinery/camera_assembly/proc/weld(obj/item/weapon/weldingtool/WT, mob/living/user)
|
||||
if(busy)
|
||||
return 0
|
||||
if(!WT.remove_fuel(0, user))
|
||||
return 0
|
||||
|
||||
user << "<span class='notice'>You start to weld \the [src]...</span>"
|
||||
playsound(src.loc, 'sound/items/Welder.ogg', 50, 1)
|
||||
busy = 1
|
||||
if(do_after(user, 20, target = src))
|
||||
busy = 0
|
||||
if(!WT.isOn())
|
||||
return 0
|
||||
return 1
|
||||
busy = 0
|
||||
return 0
|
||||
@@ -0,0 +1,62 @@
|
||||
/obj/machinery/camera
|
||||
|
||||
var/list/motionTargets = list()
|
||||
var/detectTime = 0
|
||||
var/area/ai_monitored/area_motion = null
|
||||
var/alarm_delay = 30 // Don't forget, there's another 3 seconds in queueAlarm()
|
||||
|
||||
/obj/machinery/camera/process()
|
||||
// motion camera event loop
|
||||
if(!isMotion())
|
||||
. = PROCESS_KILL
|
||||
return
|
||||
if (detectTime > 0)
|
||||
var/elapsed = world.time - detectTime
|
||||
if (elapsed > alarm_delay)
|
||||
triggerAlarm()
|
||||
else if (detectTime == -1)
|
||||
for (var/mob/target in motionTargets)
|
||||
if (target.stat == 2) lostTarget(target)
|
||||
// If not detecting with motion camera...
|
||||
if (!area_motion)
|
||||
// See if the camera is still in range
|
||||
if(!in_range(src, target))
|
||||
// If they aren't in range, lose the target.
|
||||
lostTarget(target)
|
||||
|
||||
/obj/machinery/camera/proc/newTarget(mob/target)
|
||||
if (istype(target, /mob/living/silicon/ai)) return 0
|
||||
if (detectTime == 0)
|
||||
detectTime = world.time // start the clock
|
||||
if (!(target in motionTargets))
|
||||
motionTargets += target
|
||||
return 1
|
||||
|
||||
/obj/machinery/camera/proc/lostTarget(mob/target)
|
||||
if (target in motionTargets)
|
||||
motionTargets -= target
|
||||
if (motionTargets.len == 0)
|
||||
cancelAlarm()
|
||||
|
||||
/obj/machinery/camera/proc/cancelAlarm()
|
||||
if (detectTime == -1)
|
||||
for (var/mob/living/silicon/aiPlayer in player_list)
|
||||
if (status)
|
||||
aiPlayer.cancelAlarm("Motion", get_area(src), src)
|
||||
detectTime = 0
|
||||
return 1
|
||||
|
||||
/obj/machinery/camera/proc/triggerAlarm()
|
||||
if (!detectTime) return 0
|
||||
for (var/mob/living/silicon/aiPlayer in player_list)
|
||||
if (status)
|
||||
aiPlayer.triggerAlarm("Motion", get_area(src), list(src), src)
|
||||
detectTime = -1
|
||||
return 1
|
||||
|
||||
/obj/machinery/camera/HasProximity(atom/movable/AM as mob|obj)
|
||||
// Motion cameras outside of an "ai monitored" area will use this to detect stuff.
|
||||
if (!area_motion)
|
||||
if(isliving(AM))
|
||||
newTarget(AM)
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
// PRESETS
|
||||
|
||||
// EMP
|
||||
/obj/machinery/camera/emp_proof
|
||||
start_active = 1
|
||||
|
||||
/obj/machinery/camera/emp_proof/New()
|
||||
..()
|
||||
upgradeEmpProof()
|
||||
|
||||
// X-RAY
|
||||
|
||||
/obj/machinery/camera/xray
|
||||
start_active = 1
|
||||
icon_state = "xraycam" // Thanks to Krutchen for the icons.
|
||||
|
||||
/obj/machinery/camera/xray/New()
|
||||
..()
|
||||
upgradeXRay()
|
||||
|
||||
// MOTION
|
||||
/obj/machinery/camera/motion
|
||||
start_active = 1
|
||||
name = "motion-sensitive security camera"
|
||||
|
||||
/obj/machinery/camera/motion/New()
|
||||
..()
|
||||
upgradeMotion()
|
||||
|
||||
// ALL UPGRADES
|
||||
/obj/machinery/camera/all
|
||||
start_active = 1
|
||||
|
||||
/obj/machinery/camera/all/New()
|
||||
..()
|
||||
upgradeEmpProof()
|
||||
upgradeXRay()
|
||||
upgradeMotion()
|
||||
|
||||
// AUTONAME
|
||||
|
||||
/obj/machinery/camera/autoname
|
||||
var/number = 0 //camera number in area
|
||||
|
||||
//This camera type automatically sets it's name to whatever the area that it's in is called.
|
||||
/obj/machinery/camera/autoname/New()
|
||||
..()
|
||||
spawn(10)
|
||||
number = 1
|
||||
var/area/A = get_area(src)
|
||||
if(A)
|
||||
for(var/obj/machinery/camera/autoname/C in machines)
|
||||
if(C == src) continue
|
||||
var/area/CA = get_area(C)
|
||||
if(CA.type == A.type)
|
||||
if(C.number)
|
||||
number = max(number, C.number+1)
|
||||
c_tag = "[A.name] #[number]"
|
||||
|
||||
|
||||
// CHECKS
|
||||
|
||||
/obj/machinery/camera/proc/isEmpProof()
|
||||
return upgrades & CAMERA_UPGRADE_EMP_PROOF
|
||||
|
||||
/obj/machinery/camera/proc/isXRay()
|
||||
return upgrades & CAMERA_UPGRADE_XRAY
|
||||
|
||||
/obj/machinery/camera/proc/isMotion()
|
||||
return upgrades & CAMERA_UPGRADE_MOTION
|
||||
|
||||
// UPGRADE PROCS
|
||||
|
||||
/obj/machinery/camera/proc/upgradeEmpProof()
|
||||
assembly.upgrades.Add(new /obj/item/stack/sheet/mineral/plasma(assembly))
|
||||
upgrades |= CAMERA_UPGRADE_EMP_PROOF
|
||||
|
||||
/obj/machinery/camera/proc/upgradeXRay()
|
||||
assembly.upgrades.Add(new /obj/item/device/analyzer(assembly))
|
||||
upgrades |= CAMERA_UPGRADE_XRAY
|
||||
|
||||
// If you are upgrading Motion, and it isn't in the camera's New(), add it to the machines list.
|
||||
/obj/machinery/camera/proc/upgradeMotion()
|
||||
assembly.upgrades.Add(new /obj/item/device/assembly/prox_sensor(assembly))
|
||||
upgrades |= CAMERA_UPGRADE_MOTION
|
||||
@@ -0,0 +1,172 @@
|
||||
/mob/living/silicon/ai/proc/get_camera_list()
|
||||
|
||||
track.cameras.Cut()
|
||||
|
||||
if(src.stat == 2)
|
||||
return
|
||||
|
||||
var/list/L = list()
|
||||
for (var/obj/machinery/camera/C in cameranet.cameras)
|
||||
L.Add(C)
|
||||
|
||||
camera_sort(L)
|
||||
|
||||
var/list/T = list()
|
||||
|
||||
for (var/obj/machinery/camera/C in L)
|
||||
var/list/tempnetwork = C.network&src.network
|
||||
if (tempnetwork.len)
|
||||
T[text("[][]", C.c_tag, (C.can_use() ? null : " (Deactivated)"))] = C
|
||||
|
||||
track.cameras = T
|
||||
return T
|
||||
|
||||
|
||||
/mob/living/silicon/ai/proc/ai_camera_list(camera)
|
||||
if (!camera)
|
||||
return 0
|
||||
|
||||
var/obj/machinery/camera/C = track.cameras[camera]
|
||||
src.eyeobj.setLoc(C)
|
||||
|
||||
return
|
||||
|
||||
/datum/trackable
|
||||
var/list/names = list()
|
||||
var/list/namecounts = list()
|
||||
var/list/humans = list()
|
||||
var/list/others = list()
|
||||
var/list/cameras = list()
|
||||
|
||||
/mob/living/silicon/ai/proc/trackable_mobs()
|
||||
|
||||
track.names.Cut()
|
||||
track.namecounts.Cut()
|
||||
track.humans.Cut()
|
||||
track.others.Cut()
|
||||
|
||||
if(usr.stat == 2)
|
||||
return list()
|
||||
|
||||
for(var/mob/living/M in mob_list)
|
||||
if(!M.can_track(usr))
|
||||
continue
|
||||
|
||||
// Human check
|
||||
var/human = 0
|
||||
if(istype(M, /mob/living/carbon/human))
|
||||
human = 1
|
||||
|
||||
var/name = M.name
|
||||
if (name in track.names)
|
||||
track.namecounts[name]++
|
||||
name = text("[] ([])", name, track.namecounts[name])
|
||||
else
|
||||
track.names.Add(name)
|
||||
track.namecounts[name] = 1
|
||||
if(human)
|
||||
track.humans[name] = M
|
||||
else
|
||||
track.others[name] = M
|
||||
|
||||
var/list/targets = sortList(track.humans) + sortList(track.others)
|
||||
|
||||
return targets
|
||||
|
||||
/mob/living/silicon/ai/verb/ai_camera_track(target_name in trackable_mobs())
|
||||
set name = "track"
|
||||
set hidden = 1 //Don't display it on the verb lists. This verb exists purely so you can type "track Oldman Robustin" and follow his ass
|
||||
|
||||
if(!target_name)
|
||||
return
|
||||
|
||||
var/mob/target = (isnull(track.humans[target_name]) ? track.others[target_name] : track.humans[target_name])
|
||||
|
||||
ai_actual_track(target)
|
||||
|
||||
/mob/living/silicon/ai/proc/ai_actual_track(mob/living/target)
|
||||
if(!istype(target))
|
||||
return
|
||||
var/mob/living/silicon/ai/U = usr
|
||||
|
||||
U.cameraFollow = target
|
||||
U.tracking = 1
|
||||
|
||||
if(!target || !target.can_track(usr))
|
||||
U << "<span class='warning'>Target is not near any active cameras.</span>"
|
||||
U.cameraFollow = null
|
||||
return
|
||||
|
||||
U << "<span class='notice'>Now tracking [target.get_visible_name()] on camera.</span>"
|
||||
|
||||
var/cameraticks = 0
|
||||
spawn(0)
|
||||
while(U.cameraFollow == target)
|
||||
if(U.cameraFollow == null)
|
||||
return
|
||||
|
||||
if(!target.can_track(usr))
|
||||
U.tracking = 1
|
||||
if(!cameraticks)
|
||||
U << "<span class='warning'>Target is not near any active cameras. Attempting to reacquire...</span>"
|
||||
cameraticks++
|
||||
if(cameraticks > 9)
|
||||
U.cameraFollow = null
|
||||
U << "<span class='warning'>Unable to reacquire, cancelling track...</span>"
|
||||
tracking = 0
|
||||
return
|
||||
else
|
||||
sleep(10)
|
||||
continue
|
||||
|
||||
else
|
||||
cameraticks = 0
|
||||
U.tracking = 0
|
||||
|
||||
if(U.eyeobj)
|
||||
U.eyeobj.setLoc(get_turf(target))
|
||||
|
||||
else
|
||||
view_core()
|
||||
U.cameraFollow = null
|
||||
return
|
||||
|
||||
sleep(10)
|
||||
|
||||
/proc/near_camera(mob/living/M)
|
||||
if (!isturf(M.loc))
|
||||
return 0
|
||||
if(isrobot(M))
|
||||
var/mob/living/silicon/robot/R = M
|
||||
if(!(R.camera && R.camera.can_use()) && !cameranet.checkCameraVis(M))
|
||||
return 0
|
||||
else if(!cameranet.checkCameraVis(M))
|
||||
return 0
|
||||
return 1
|
||||
|
||||
/obj/machinery/camera/attack_ai(mob/living/silicon/ai/user)
|
||||
if (!istype(user))
|
||||
return
|
||||
if (!src.can_use())
|
||||
return
|
||||
user.eyeobj.setLoc(get_turf(src))
|
||||
|
||||
|
||||
/mob/living/silicon/ai/attack_ai(mob/user)
|
||||
ai_camera_list()
|
||||
|
||||
/proc/camera_sort(list/L)
|
||||
var/obj/machinery/camera/a
|
||||
var/obj/machinery/camera/b
|
||||
|
||||
for (var/i = L.len, i > 0, i--)
|
||||
for (var/j = 1 to i - 1)
|
||||
a = L[j]
|
||||
b = L[j + 1]
|
||||
if (a.c_tag_order != b.c_tag_order)
|
||||
if (a.c_tag_order > b.c_tag_order)
|
||||
L.Swap(j, j + 1)
|
||||
else
|
||||
if (sorttext(a.c_tag, b.c_tag) < 0)
|
||||
L.Swap(j, j + 1)
|
||||
return L
|
||||
Reference in New Issue
Block a user