mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-22 11:38:12 +01:00
Merge pull request #1149 from VOREStation/vplk-canister-leak
New Event: Canister Leak
This commit is contained in:
@@ -43,6 +43,18 @@
|
||||
if (isarea(A))
|
||||
return A
|
||||
|
||||
|
||||
/** Checks if any living humans are in a given area. */
|
||||
/proc/area_is_occupied(var/area/myarea)
|
||||
// Testing suggests looping over human_mob_list is quicker than looping over area contents
|
||||
for(var/mob/living/carbon/human/H in human_mob_list)
|
||||
if(H.stat >= DEAD) //Conditions for exclusion here, like if disconnected people start blocking it.
|
||||
continue
|
||||
var/area/A = get_area(H)
|
||||
if(A == myarea) //The loc of a turf is the area it is in.
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/in_range(source, user)
|
||||
if(get_dist(source, user) <= 1)
|
||||
return 1
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// This event chooses a random canister on player levels and breaks it, releasing its contents!
|
||||
// On severity EVENT_LEVEL_MUNDANE or below it checks to make sure nobody is in the area, otherwise... good luck.
|
||||
//
|
||||
|
||||
/datum/event/canister_leak/start()
|
||||
// List of all non-destroyed canisters on station levels
|
||||
var/list/all_canisters = list()
|
||||
for(var/obj/machinery/portable_atmospherics/canister/C in machines)
|
||||
if(!C.destroyed && (C.z in using_map.station_levels))
|
||||
all_canisters += C
|
||||
|
||||
for(var/i in 1 to 10)
|
||||
var/obj/machinery/portable_atmospherics/canister/C = pick(all_canisters)
|
||||
if(severity <= EVENT_LEVEL_MUNDANE && area_is_occupied(get_area(C)))
|
||||
log_debug("canister_leak event: Rejecting canister [C] ([C.x],[C.y],[C.z]) because area is occupied")
|
||||
continue
|
||||
// Okay lets break it
|
||||
break_canister(C)
|
||||
return
|
||||
|
||||
// If we got to here we failed to find it
|
||||
log_debug("canister_leak event: Giving up after too many failures to pick target canister")
|
||||
kill()
|
||||
return
|
||||
|
||||
/datum/event/canister_leak/proc/break_canister(var/obj/machinery/portable_atmospherics/canister/C)
|
||||
log_debug("canister_leak event: Canister [C] ([C.x],[C.y],[C.z]) destroyed.")
|
||||
C.health = 0
|
||||
C.healthcheck()
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// This event chooses a random canister on player levels and breaks it, releasing its contents!
|
||||
//
|
||||
|
||||
/datum/gm_action/canister_leak
|
||||
name = "Canister Leak"
|
||||
departments = list(ROLE_ENGINEERING)
|
||||
chaotic = 20
|
||||
|
||||
/datum/gm_action/canister_leak/get_weight()
|
||||
return metric.count_people_in_department(ROLE_ENGINEERING) * 30
|
||||
|
||||
/datum/gm_action/canister_leak/start()
|
||||
..()
|
||||
// List of all non-destroyed canisters on station levels
|
||||
var/list/all_canisters = list()
|
||||
for(var/obj/machinery/portable_atmospherics/canister/C in machines)
|
||||
if(!C.destroyed && (C.z in using_map.station_levels))
|
||||
all_canisters += C
|
||||
var/obj/machinery/portable_atmospherics/canister/C = pick(all_canisters)
|
||||
log_debug("canister_leak event: Canister [C] ([C.x],[C.y],[C.z]) destroyed.")
|
||||
C.health = 0
|
||||
C.healthcheck()
|
||||
return
|
||||
@@ -1395,6 +1395,7 @@
|
||||
#include "code\modules\events\blob.dm"
|
||||
#include "code\modules\events\brand_intelligence.dm"
|
||||
#include "code\modules\events\camera_damage.dm"
|
||||
#include "code\modules\events\canister_leak.dm"
|
||||
#include "code\modules\events\carp_migration.dm"
|
||||
#include "code\modules\events\comms_blackout.dm"
|
||||
#include "code\modules\events\communications_blackout.dm"
|
||||
@@ -1454,6 +1455,7 @@
|
||||
#include "code\modules\gamemaster\game_master.dm"
|
||||
#include "code\modules\gamemaster\helpers.dm"
|
||||
#include "code\modules\gamemaster\actions\action.dm"
|
||||
#include "code\modules\gamemaster\actions\canister_leak.dm"
|
||||
#include "code\modules\gamemaster\actions\carp_migration.dm"
|
||||
#include "code\modules\gamemaster\actions\comms_blackout.dm"
|
||||
#include "code\modules\gamemaster\actions\dust.dm"
|
||||
|
||||
Reference in New Issue
Block a user