Merge pull request #9008 from PsiOmegaDelta/CameraPoff

Adds the APC & camera damage events.
This commit is contained in:
Chinsky
2015-04-28 13:49:50 +03:00
7 changed files with 104 additions and 4 deletions
+54
View File
@@ -0,0 +1,54 @@
/datum/event/apc_damage
var/apcSelectionRange = 25
/datum/event/apc_damage/start()
var/obj/machinery/power/apc/A = acquire_random_apc()
var/severity_range = 0
switch(severity)
if(EVENT_LEVEL_MUNDANE)
severity_range = 0
if(EVENT_LEVEL_MODERATE)
severity_range = 7
if(EVENT_LEVEL_MAJOR)
severity_range = 15
for(var/obj/machinery/power/apc/apc in range(severity_range,A))
if(is_valid_apc(apc))
apc.emagged = 1
apc.update_icon()
/datum/event/apc_damage/proc/acquire_random_apc()
var/list/possibleEpicentres = list()
var/list/apcs = list()
for(var/obj/effect/landmark/newEpicentre in landmarks_list)
if(newEpicentre.name == "lightsout")
possibleEpicentres += newEpicentre
if(!possibleEpicentres.len)
return
var/epicentre = pick(possibleEpicentres)
for(var/obj/machinery/power/apc/apc in range(epicentre,apcSelectionRange))
if(is_valid_apc(apc))
apcs += apc
// Greatly increase the chance for APCs in maintenance areas to be selected
var/area/A = get_area(apc)
if(istype(A,/area/maintenance))
apcs += apc
apcs += apc
if(!apcs.len)
return
return pick(apcs)
/datum/event/apc_damage/proc/is_valid_apc(var/obj/machinery/power/apc/apc)
// Type must be exactly a basic APC.
// This generally prevents affecting APCs in critical areas (AI core, engine room, etc.) as they often use higher capacity subtypes.
if(apc.type != /obj/machinery/power/apc)
return 0
var/turf/T = get_turf(apc)
return !apc.emagged && T && (T.z in config.player_levels)
+38
View File
@@ -0,0 +1,38 @@
/datum/event/camera_damage/start()
var/obj/machinery/camera/C = acquire_random_camera()
if(!C)
return
var/severity_range = 0
switch(severity)
if(EVENT_LEVEL_MUNDANE)
severity_range = 0
if(EVENT_LEVEL_MODERATE)
severity_range = 7
if(EVENT_LEVEL_MAJOR)
severity_range = 15
for(var/obj/machinery/camera/cam in range(severity_range,C))
if(is_valid_camera(cam))
if(prob(2*severity))
cam.destroy()
else
cam.wires.UpdateCut(CAMERA_WIRE_POWER, 0)
if(prob(5*severity))
cam.wires.UpdateCut(CAMERA_WIRE_ALARM, 0)
/datum/event/camera_damage/proc/acquire_random_camera(var/remaining_attempts = 5)
if(!cameranet.cameras.len)
return
if(!remaining_attempts)
return
var/obj/machinery/camera/C = pick(cameranet.cameras)
if(is_valid_camera(C))
return C
return acquire_random_camera(remaining_attempts--)
/datum/event/camera_damage/proc/is_valid_camera(var/obj/machinery/camera/C)
// Only return a functional camera, not installed in a silicon, and that exists somewhere players have access
var/turf/T = get_turf(C)
return T && C.can_use() && !istype(C.loc, /mob/living/silicon) && (T.z in config.player_levels)
@@ -12,9 +12,9 @@
A << "<br>"
if(prob(30)) //most of the time, we don't want an announcement, so as to allow AIs to fake blackouts.
command_announcement.Announce(alert, new_sound = sound('sound/misc/interference.ogg', volume=50))
command_announcement.Announce(alert, new_sound = sound('sound/misc/interference.ogg', volume=25))
/datum/event/communications_blackout/start()
for(var/obj/machinery/telecomms/T in telecomms_list)
T.emp_act(1)
T.emp_act(1)
+1 -1
View File
@@ -25,4 +25,4 @@
for(var/obj/effect/landmark/epicentre in epicentreList)
for(var/obj/machinery/power/apc/apc in range(epicentre,lightsoutRange))
apc.overload_lighting()
apc.overload_lighting()
+3 -1
View File
@@ -127,11 +127,13 @@ var/global/list/severity_to_string = list(EVENT_LEVEL_MUNDANE = "Mundane", EVENT
available_events = list(
// Severity level, event name, even type, base weight, role weights, one shot, min weight, max weight. Last two only used if set and non-zero
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Nothing", /datum/event/nothing, 100),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "APC Damage", /datum/event/apc_damage, 20, list(ASSIGNMENT_ENGINEER = 10)),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Brand Intelligence",/datum/event/brand_intelligence,20, list(ASSIGNMENT_JANITOR = 25), 1),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Camera Damage", /datum/event/camera_damage, 20, list(ASSIGNMENT_ENGINEER = 10)),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Economic News", /datum/event/economic_event, 300),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Lost Carp", /datum/event/carp_migration, 20, list(ASSIGNMENT_SECURITY = 10), 1),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Money Hacker", /datum/event/money_hacker, 0, list(ASSIGNMENT_ANY = 4), 1, 10, 25),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Money Lotto", /datum/event/money_lotto, 0, list(ASSIGNMENT_ANY = 1), 1, 5, 15),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Lost Carp", /datum/event/carp_migration, 20, list(ASSIGNMENT_SECURITY = 10), 1),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Mundane News", /datum/event/mundane_news, 300),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "PDA Spam", /datum/event/pda_spam, 0, list(ASSIGNMENT_ANY = 4), 0, 25, 50),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Space Dust", /datum/event/dust , 30, list(ASSIGNMENT_ENGINEER = 5), 0, 0, 50),