diff --git a/baystation12.dme b/baystation12.dme index 30966ac0f59..89e38f3910d 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -952,8 +952,10 @@ #include "code\modules\economy\Events.dm" #include "code\modules\economy\Events_Mundane.dm" #include "code\modules\economy\TradeDestinations.dm" +#include "code\modules\events\apc_damage.dm" #include "code\modules\events\blob.dm" #include "code\modules\events\brand_intelligence.dm" +#include "code\modules\events\camera_damage.dm" #include "code\modules\events\carp_migration.dm" #include "code\modules\events\comms_blackout.dm" #include "code\modules\events\communications_blackout.dm" diff --git a/code/modules/events/apc_damage.dm b/code/modules/events/apc_damage.dm new file mode 100644 index 00000000000..7eecfa6aeff --- /dev/null +++ b/code/modules/events/apc_damage.dm @@ -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) diff --git a/code/modules/events/camera_damage.dm b/code/modules/events/camera_damage.dm new file mode 100644 index 00000000000..3143b9585b3 --- /dev/null +++ b/code/modules/events/camera_damage.dm @@ -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) diff --git a/code/modules/events/communications_blackout.dm b/code/modules/events/communications_blackout.dm index fabfdd33365..68f60304251 100644 --- a/code/modules/events/communications_blackout.dm +++ b/code/modules/events/communications_blackout.dm @@ -12,9 +12,9 @@ A << "
" 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) \ No newline at end of file + T.emp_act(1) diff --git a/code/modules/events/electrical_storm.dm b/code/modules/events/electrical_storm.dm index 4a53cc696de..be405426873 100644 --- a/code/modules/events/electrical_storm.dm +++ b/code/modules/events/electrical_storm.dm @@ -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() \ No newline at end of file + apc.overload_lighting() diff --git a/code/modules/events/event_container.dm b/code/modules/events/event_container.dm index 900d6f76ec2..5cb256e500a 100644 --- a/code/modules/events/event_container.dm +++ b/code/modules/events/event_container.dm @@ -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), diff --git a/html/changelogs/PsiOmegaDelta-PR-9008.yml b/html/changelogs/PsiOmegaDelta-PR-9008.yml new file mode 100644 index 00000000000..298f0e4d68c --- /dev/null +++ b/html/changelogs/PsiOmegaDelta-PR-9008.yml @@ -0,0 +1,4 @@ +author: PsiOmegaDelta +delete-after: True +changes: + - rscadd: "Two new events which will cause damage to APCs or cameras when triggered."