From 53647ec98012ebecbf52b264cd77a60dd43499f2 Mon Sep 17 00:00:00 2001 From: Mechoid Date: Fri, 12 Apr 2019 13:42:46 -0700 Subject: [PATCH] Airlock short-circuit --- .../gamemaster/actions/electrified_door.dm | 70 +++++++++++++++++++ polaris.dme | 1 + 2 files changed, 71 insertions(+) create mode 100644 code/modules/gamemaster/actions/electrified_door.dm diff --git a/code/modules/gamemaster/actions/electrified_door.dm b/code/modules/gamemaster/actions/electrified_door.dm new file mode 100644 index 0000000000..bc5bf35ae0 --- /dev/null +++ b/code/modules/gamemaster/actions/electrified_door.dm @@ -0,0 +1,70 @@ +/datum/gm_action/electrified_door + name = "airlock short-circuit" + departments = list(ROLE_ENGINEERING, ROLE_MEDICAL) + chaotic = 10 + var/obj/machinery/door/airlock/chosen_door + var/list/area/excluded = list( + /area/shuttle, + /area/crew_quarters + ) + var/severity + +/datum/gm_action/electrified_door/set_up() + var/list/area/grand_list_of_areas = get_station_areas(excluded) + + severity = pickweight(EVENT_LEVEL_MUNDANE = 10, + EVENT_LEVEL_MODERATE = 5, + EVENT_LEVEL_MAJOR = 1 + ) + + //try 10 times + for(var/i in 1 to 10) + var/area/A = pick(grand_list_of_areas) + var/list/obj/machinery/door/airlock/target_doors = list() + for(var/obj/machinery/door/airlock/target_door in A.contents) + target_doors += target_door + target_doors = shuffle(target_doors) + + for(var/obj/machinery/door/airlock/target_door in target_doors) + if(!target_door.isElectrified() && target_door.arePowerSystemsOn() && target_door.maxhealth == target_door.health) + chosen_door = target_door + return + +/datum/gm_action/electrified_door/start() + ..() + if(!chosen_door) + return + if(prob(33)) + chosen_door.visible_message("\The [chosen_door]'s panel sparks!") + chosen_door.set_safeties(0) + if(severity >= EVENT_LEVEL_MODERATE) + chosen_door.electrify(-1) + + if(severity >= EVENT_LEVEL_MAJOR) // New Major effect. Hydraulic boom. + spawn() + chosen_door.visible_message("\The [chosen_door] buzzes.") + playsound(get_turf(chosen_door), 'sound/machines/buzz-sigh.ogg', 50, 1) + sleep(rand(10 SECONDS, 3 MINUTES)) + if(!chosen_door || !chosen_door.arePowerSystemsOn()) + return + chosen_door.visible_message("\The [chosen_door]'s hydraulics creak.") + playsound(get_turf(chosen_door), 'sound/machines/airlock_creaking.ogg', 50, 1) + sleep(rand(30 SECONDS, 10 MINUTES)) + if(!chosen_door || !chosen_door.arePowerSystemsOn()) + return + chosen_door.visible_message("\The [chosen_door] emits a hydraulic shriek!") + playsound(get_turf(chosen_door), 'sound/machines/airlock.ogg', 80, 1) + spawn(rand(5 SECONDS, 30 SECONDS)) + if(!chosen_door || !chosen_door.arePowerSystemsOn()) + return + chosen_door.visible_message("\The [chosen_door]'s hydraulics detonate!") + chosen_door.fragmentate(get_turf(chosen_door), rand(5, 10), rand(3, 5), list(/obj/item/projectile/bullet/pellet/fragment/tank/small)) + explosion(get_turf(chosen_door),-1,-1,2,3) + + chosen_door.lock() + chosen_door.health = chosen_door.maxhealth / 6 + chosen_door.aiControlDisabled = 1 + chosen_door.update_icon() + +/datum/gm_action/electrified_door/get_weight() + return 10 + (metric.count_people_in_department(ROLE_ENGINEERING) * 5 + metric.count_people_in_department(ROLE_MEDICAL) * 10) diff --git a/polaris.dme b/polaris.dme index 7a53f0085b..06f8a6615b 100644 --- a/polaris.dme +++ b/polaris.dme @@ -1665,6 +1665,7 @@ #include "code\modules\gamemaster\actions\comms_blackout.dm" #include "code\modules\gamemaster\actions\dust.dm" #include "code\modules\gamemaster\actions\electrical_storm.dm" +#include "code\modules\gamemaster\actions\electrified_door.dm" #include "code\modules\gamemaster\actions\gravity.dm" #include "code\modules\gamemaster\actions\grid_check.dm" #include "code\modules\gamemaster\actions\ion_storm.dm"