#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 resistance_flags = FIRE_PROOF armor = list(melee = 50, bullet = 20, laser = 20, energy = 20, bomb = 0, bio = 0, rad = 0, fire = 90, acid = 50) obj_integrity = 100 max_integrity = 100 integrity_failure = 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/structure/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/Initialize(mapload) . = ..() assembly = new(src) assembly.state = 4 GLOB.cameranet.cameras += src GLOB.cameranet.addCamera(src) proximity_monitor = new(src, 1) if(mapload && z == ZLEVEL_STATION && prob(3) && !start_active) toggle_cam() /obj/machinery/camera/Destroy() toggle_cam(null, 0) //kick anyone viewing out if(assembly) qdel(assembly) assembly = null if(bug) bug.bugged_cameras -= src.c_tag if(bug.current == src) bug.current = null bug = null GLOB.cameranet.removeCamera(src) //Will handle removal from the camera network and the chunks, so we don't need to worry about that GLOB.cameranet.cameras -= src GLOB.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() GLOB.cameranet.removeCamera(src) stat |= EMPED set_light(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()) GLOB.cameranet.addCamera(src) emped = 0 //Resets the consecutive EMP count addtimer(CALLBACK(src, .proc/cancelCameraAlarm), 100) for(var/mob/O in GLOB.mob_list) if (O.client && O.client.eye == src) O.unset_machine() O.reset_perspective(null) to_chat(O, "The screen bursts into static.") ..() /obj/machinery/camera/tesla_act(var/power)//EMP proof upgrade also makes it tesla immune if(isEmpProof()) return ..() qdel(src)//to prevent bomb testing camera from exploding over and over forever /obj/machinery/camera/ex_act(severity, target) if(invuln) return ..() /obj/machinery/camera/proc/setViewRange(num = 7) src.view_range = num GLOB.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/item/W, mob/living/user, params) var/msg = "You attach [W] into the assembly's inner circuits." var/msg2 = "[src] already has that upgrade!" // DECONSTRUCTION if(istype(W, /obj/item/weapon/screwdriver)) panel_open = !panel_open to_chat(user, "You screw the camera's panel [panel_open ? "open" : "closed"].") playsound(src.loc, W.usesound, 50, 1) return if(panel_open) if(istype(W, /obj/item/weapon/wirecutters)) //enable/disable the camera toggle_cam(user, 1) obj_integrity = max_integrity //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)) to_chat(user, "You [(view_range == initial(view_range)) ? "restore" : "mess up"] the camera's focus.") return else if(istype(W, /obj/item/weapon/weldingtool)) if(weld(W, user)) visible_message("[user] unwelds [src], leaving it as just a frame bolted to the wall.", "You unweld [src], leaving it as just a frame bolted to the wall") deconstruct(TRUE) return else if(istype(W, /obj/item/device/analyzer)) if(!isXRay()) if(!user.drop_item(W)) return upgradeXRay() qdel(W) to_chat(user, "[msg]") else to_chat(user, "[msg2]") return else if(istype(W, /obj/item/stack/sheet/mineral/plasma)) if(!isEmpProof()) upgradeEmpProof() to_chat(user, "[msg]") qdel(W) else to_chat(user, "[msg2]") return else if(istype(W, /obj/item/device/assembly/prox_sensor)) if(!isMotion()) upgradeMotion() to_chat(user, "[msg]") qdel(W) else to_chat(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 to_chat(U, "You hold \the [itemname] up to the camera...") U.changeNext_move(CLICK_CD_MELEE) for(var/mob/O in GLOB.player_list) if(isAI(O)) var/mob/living/silicon/ai/AI = O if(AI.control_disabled || (AI.stat == DEAD)) return if(U.name == "Unknown") to_chat(AI, "[U] holds \a [itemname] up to one of your cameras ...") else to_chat(AI, "[U] holds \a [itemname] up to one of your cameras ...") AI.last_paper_seen = "