Adds a signal when an explosion happens (#48161)

This commit is contained in:
MrPerson
2019-12-09 02:26:51 -06:00
committed by Emmett Gaines
parent 6b5433eb23
commit 71a698c68e
4 changed files with 30 additions and 43 deletions

View File

@@ -17,7 +17,7 @@
#define ELEMENT_INCOMPATIBLE 1
// /datum/element flags
/// Causes the detach proc to be called when the host object is being deleted
/// Causes the detach proc to be called when the host object is being deleted
#define ELEMENT_DETACH (1 << 0)
/**
* Only elements created with the same arguments given after `id_arg_index` share an element instance
@@ -46,6 +46,8 @@
#define COMSIG_GLOB_NEW_Z "!new_z"
/// called after a successful var edit somewhere in the world: (list/args)
#define COMSIG_GLOB_VAR_EDIT "!var_edit"
/// called after an explosion happened : (epicenter, devastation_range, heavy_impact_range, light_impact_range, took, orig_dev_range, orig_heavy_range, orig_light_range)
#define COMSIG_GLOB_EXPLOSION "!explosion"
/// mob was created somewhere : (mob)
#define COMSIG_GLOB_MOB_CREATED "!mob_created"
/// mob died somewhere : (mob , gibbed)

View File

@@ -279,10 +279,7 @@ GLOBAL_LIST_EMPTY(explosions)
log_world("## DEBUG: Explosion([x0],[y0],[z0])(d[devastation_range],h[heavy_impact_range],l[light_impact_range]): Took [took] seconds.")
if(running) //if we aren't in a hurry
//Machines which report explosions.
for(var/array in GLOB.doppler_arrays)
var/obj/machinery/doppler_array/A = array
A.sense_explosion(epicenter, devastation_range, heavy_impact_range, light_impact_range, took,orig_dev_range, orig_heavy_range, orig_light_range)
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_EXPLOSION, epicenter, devastation_range, heavy_impact_range, light_impact_range, took, orig_dev_range, orig_heavy_range, orig_light_range)
++stopped
qdel(src)

View File

@@ -1,5 +1,3 @@
GLOBAL_LIST_EMPTY(doppler_arrays)
/obj/machinery/doppler_array
name = "tachyon-doppler array"
desc = "A highly precise directional sensor array which measures the release of quants from decaying tachyons. The doppler shifting of the mirror-image formed by these quants can reveal the size, location and temporal affects of energetic disturbances within a large radius ahead of the array.\n"
@@ -8,24 +6,18 @@ GLOBAL_LIST_EMPTY(doppler_arrays)
density = TRUE
var/cooldown = 10
var/next_announce = 0
var/integrated = FALSE
var/max_dist = 150
verb_say = "states coldly"
var/list/message_log = list()
/obj/machinery/doppler_array/Initialize()
. = ..()
GLOB.doppler_arrays += src
RegisterSignal(SSdcs, COMSIG_GLOB_EXPLOSION, .proc/sense_explosion)
/obj/machinery/doppler_array/ComponentInitialize()
. = ..()
AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE,null,null,CALLBACK(src,.proc/rot_message))
/obj/machinery/doppler_array/Destroy()
GLOB.doppler_arrays -= src
return ..()
/obj/machinery/doppler_array/ui_interact(mob/user)
. = ..()
if(stat)
@@ -72,8 +64,8 @@ GLOBAL_LIST_EMPTY(doppler_arrays)
to_chat(user, "<span class='notice'>You adjust [src]'s dish to face to the [dir2text(dir)].</span>")
playsound(src, 'sound/items/screwdriver2.ogg', 50, TRUE)
/obj/machinery/doppler_array/proc/sense_explosion(turf/epicenter,devastation_range,heavy_impact_range,light_impact_range,
took,orig_dev_range,orig_heavy_range,orig_light_range)
/obj/machinery/doppler_array/proc/sense_explosion(datum/source, turf/epicenter, devastation_range, heavy_impact_range, light_impact_range,
took, orig_dev_range, orig_heavy_range, orig_light_range)
if(stat & NOPOWER)
return FALSE
var/turf/zone = get_turf(src)
@@ -81,7 +73,7 @@ GLOBAL_LIST_EMPTY(doppler_arrays)
return FALSE
if(next_announce > world.time)
return
return FALSE
next_announce = world.time + cooldown
var/distance = get_dist(epicenter, zone)
@@ -89,26 +81,19 @@ GLOBAL_LIST_EMPTY(doppler_arrays)
if(distance > max_dist)
return FALSE
if(!(direct & dir) && !integrated)
if(!(direct & dir))
return FALSE
var/list/messages = list("Explosive disturbance detected.", \
"Epicenter at: grid ([epicenter.x],[epicenter.y]). Temporal displacement of tachyons: [took] seconds.", \
var/list/messages = list("Explosive disturbance detected.",
"Epicenter at: grid ([epicenter.x],[epicenter.y]). Temporal displacement of tachyons: [took] seconds.",
"Factual: Epicenter radius: [devastation_range]. Outer radius: [heavy_impact_range]. Shockwave radius: [light_impact_range].")
// If the bomb was capped, say its theoretical size.
if(devastation_range < orig_dev_range || heavy_impact_range < orig_heavy_range || light_impact_range < orig_light_range)
messages += "Theoretical: Epicenter radius: [orig_dev_range]. Outer radius: [orig_heavy_range]. Shockwave radius: [orig_light_range]."
if(integrated)
var/obj/item/clothing/head/helmet/space/hardsuit/helm = loc
if(!helm || !istype(helm, /obj/item/clothing/head/helmet/space/hardsuit))
return FALSE
helm.display_visor_message("Explosion detected! Epicenter: [devastation_range], Outer: [heavy_impact_range], Shock: [light_impact_range]")
else
for(var/message in messages)
say(message)
for(var/message in messages)
say(message)
LAZYADD(message_log, messages.Join(" "))
return TRUE
@@ -125,22 +110,16 @@ GLOBAL_LIST_EMPTY(doppler_arrays)
else
icon_state = "[initial(icon_state)]-off"
//Portable version, built into EOD equipment. It simply provides an explosion's three damage levels.
/obj/machinery/doppler_array/integrated
name = "integrated tachyon-doppler module"
integrated = TRUE
max_dist = 21 //Should detect most explosions in hearing range.
use_power = NO_POWER_USE
/obj/machinery/doppler_array/research
name = "tachyon-doppler research array"
desc = "A specialized tachyon-doppler bomb detection array that uses the results of the highest yield of explosions for research."
var/datum/techweb/linked_techweb
/obj/machinery/doppler_array/research/sense_explosion(turf/epicenter, dev, heavy, light, time, orig_dev, orig_heavy, orig_light) //probably needs a way to ignore admin explosives later on
/obj/machinery/doppler_array/research/sense_explosion(datum/source, turf/epicenter, devastation_range, heavy_impact_range, light_impact_range,
took, orig_dev_range, orig_heavy_range, orig_light_range) //probably needs a way to ignore admin explosives later on
. = ..()
if(!.)
return FALSE
return
if(!istype(linked_techweb))
say("Warning: No linked research system!")
return
@@ -149,11 +128,11 @@ GLOBAL_LIST_EMPTY(doppler_arrays)
/*****The Point Calculator*****/
if(orig_light < 10)
if(orig_light_range < 10)
say("Explosion not large enough for research calculations.")
return
else if(orig_light < 4500)
point_gain = (83300 * orig_light) / (orig_light + 3000)
else if(orig_light_range < 4500)
point_gain = (83300 * orig_light_range) / (orig_light_range + 3000)
else
point_gain = TECHWEB_BOMB_POINTCAP

View File

@@ -467,13 +467,13 @@
resistance_flags = ACID_PROOF | FIRE_PROOF
max_heat_protection_temperature = FIRE_SUIT_MAX_TEMP_PROTECT
armor = list("melee" = 30, "bullet" = 5, "laser" = 10, "energy" = 20, "bomb" = 100, "bio" = 100, "rad" = 60, "fire" = 60, "acid" = 80)
var/obj/machinery/doppler_array/integrated/bomb_radar
var/explosion_detection_dist = 21
clothing_flags = STOPSPRESSUREDAMAGE | THICKMATERIAL | SCAN_REAGENTS | SNUG_FIT
actions_types = list(/datum/action/item_action/toggle_helmet_light, /datum/action/item_action/toggle_research_scanner)
/obj/item/clothing/head/helmet/space/hardsuit/rd/Initialize()
. = ..()
bomb_radar = new /obj/machinery/doppler_array/integrated(src)
RegisterSignal(SSdcs, COMSIG_GLOB_EXPLOSION, .proc/sense_explosion)
/obj/item/clothing/head/helmet/space/hardsuit/rd/equipped(mob/living/carbon/human/user, slot)
..()
@@ -487,6 +487,15 @@
var/datum/atom_hud/DHUD = GLOB.huds[DATA_HUD_DIAGNOSTIC_BASIC]
DHUD.remove_hud_from(user)
/obj/item/clothing/head/helmet/space/hardsuit/rd/proc/sense_explosion(datum/source, turf/epicenter, devastation_range, heavy_impact_range,
light_impact_range, took, orig_dev_range, orig_heavy_range, orig_light_range)
var/turf/T = get_turf(src)
if(T.z != epicenter.z)
return
if(get_dist(epicenter, T) > explosion_detection_dist)
return
display_visor_message("Explosion detected! Epicenter: [devastation_range], Outer: [heavy_impact_range], Shock: [light_impact_range]")
/obj/item/clothing/suit/space/hardsuit/rd
name = "prototype hardsuit"
desc = "A prototype suit that protects against hazardous, low pressure environments. Fitted with extensive plating for handling explosives and dangerous research materials."