mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-21 12:02:31 +01:00
Weather Warnings (#19934)
* Atmospheric probes will now relay changes in weather when deployed. Analog radios can be tuned into the weather broadcast and receive it, provided they're in the same sector / connected z-levels. * Fixed weather transitions to rainy / icy weather not working. * Changed rainy / icy weather to have a blue color, reducing eye strain.   
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#define WEATHER_RADIO_CHANNEL "Shortband Weather Broadcast"
|
||||
|
||||
/obj/item/lore_radio
|
||||
name = "analog radio"
|
||||
desc = "A portable radio capable of receiving radio waves from nearby space systems."
|
||||
@@ -11,8 +13,9 @@
|
||||
|
||||
/obj/item/lore_radio/Initialize()
|
||||
. = ..()
|
||||
if(!current_station && SSatlas.current_sector?.lore_radio_stations)
|
||||
current_station = pick(SSatlas.current_sector.lore_radio_stations)
|
||||
if(!current_station)
|
||||
var/list/possible_stations = get_possible_stations()
|
||||
current_station = pick(possible_stations)
|
||||
if(starts_on)
|
||||
toggle_receiving()
|
||||
RegisterSignal(SSdcs, COMSIG_GLOB_LORE_RADIO_BROADCAST, PROC_REF(relay_lore_radio))
|
||||
@@ -24,27 +27,33 @@
|
||||
to_chat(user, SPAN_NOTICE("\The [src] is listening to \the [current_station] radio station."))
|
||||
|
||||
/obj/item/lore_radio/attack_self(var/mob/user)
|
||||
if(SSatlas.current_sector?.lore_radio_stations)
|
||||
var/picked_station = tgui_input_list(user, "Select the radio frequency:", "Radio Station Selection", SSatlas.current_sector.lore_radio_stations, current_station)
|
||||
if(picked_station)
|
||||
current_station = picked_station
|
||||
if(!receiving)
|
||||
toggle_receiving(user)
|
||||
else
|
||||
audible_message("<b>[src]</b> only emits white noise...")
|
||||
var/list/possible_stations = get_possible_stations()
|
||||
var/picked_station = tgui_input_list(user, "Select the radio frequency:", "Radio Station Selection", possible_stations, current_station)
|
||||
if(picked_station)
|
||||
current_station = picked_station
|
||||
if(!receiving)
|
||||
toggle_receiving(user)
|
||||
|
||||
/obj/item/lore_radio/AltClick(var/mob/user)
|
||||
toggle_receiving(user)
|
||||
|
||||
/obj/item/lore_radio/proc/get_possible_stations()
|
||||
var/list/possible_stations = list(WEATHER_RADIO_CHANNEL)
|
||||
if(SSatlas.current_sector?.lore_radio_stations)
|
||||
possible_stations += SSatlas.current_sector.lore_radio_stations
|
||||
return possible_stations
|
||||
|
||||
/obj/item/lore_radio/proc/toggle_receiving(var/mob/user)
|
||||
if(!receiving)
|
||||
receiving = TRUE
|
||||
if(user)
|
||||
user.visible_message("<b>[user]</b> flicks \the [src] on.", SPAN_NOTICE("You flick \the [src] on."), range = 3)
|
||||
RegisterSignal(SSdcs, COMSIG_GLOB_Z_WEATHER_BROADCAST, PROC_REF(relay_weather_broadcast))
|
||||
else
|
||||
receiving = FALSE
|
||||
if(user)
|
||||
user.visible_message("<b>[user]</b> flicks \the [src] off.", SPAN_NOTICE("You flick \the [src] off."), range = 3)
|
||||
UnregisterSignal(SSdcs, COMSIG_GLOB_Z_WEATHER_BROADCAST, PROC_REF(relay_weather_broadcast))
|
||||
|
||||
/obj/item/lore_radio/proc/relay_lore_radio(var/datum/source, var/radio_station, var/radio_message)
|
||||
SIGNAL_HANDLER
|
||||
@@ -52,13 +61,23 @@
|
||||
if(!receiving || radio_station != current_station)
|
||||
return
|
||||
|
||||
var/displayed_message = radio_message ? "\The <b>[src.name]</b> transmits, \"[radio_message]\"" : "\The <b>[src]</b> only emits white noise..."
|
||||
audible_message(displayed_message)
|
||||
if(radio_message)
|
||||
var/list/hearers = get_hearers_in_view(7, src)
|
||||
var/list/clients_in_hearers = list()
|
||||
for(var/mob/mob in hearers)
|
||||
if(mob.client)
|
||||
clients_in_hearers += mob.client
|
||||
if(length(clients_in_hearers))
|
||||
INVOKE_ASYNC(src, TYPE_PROC_REF(/atom/movable, animate_chat), radio_message, null, FALSE, clients_in_hearers, 2 SECONDS)
|
||||
output_spoken_message(radio_message)
|
||||
else
|
||||
audible_message("The [SPAN_BOLD("[name]")] only emits white noise...") // using name instead of src so it doesn't add a bolded The or whatever, better control of what displays
|
||||
|
||||
/// Listens to when a weather change on this Z-level is broadcasted from a configured weather reader (survey probe), and reads it aloud
|
||||
/obj/item/lore_radio/proc/relay_weather_broadcast(var/datum/source, var/z_level, var/singleton/state_transition/weather/weather_transition, var/time_to_transition, var/broadcast_message)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(!receiving || current_station != WEATHER_RADIO_CHANNEL)
|
||||
return
|
||||
|
||||
var/turf/current_turf = get_turf(src)
|
||||
var/list/connected_z_levels = GetConnectedZlevels(current_turf.z)
|
||||
if(!(z_level in connected_z_levels))
|
||||
return
|
||||
|
||||
output_spoken_message(broadcast_message)
|
||||
|
||||
#undef WEATHER_RADIO_CHANNEL
|
||||
|
||||
@@ -309,3 +309,14 @@
|
||||
/obj/proc/clean()
|
||||
clean_blood()
|
||||
color = initial(color)
|
||||
|
||||
/obj/proc/output_spoken_message(var/message, var/message_verb = "transmits", var/display_overhead = TRUE, var/overhead_time = 2 SECONDS)
|
||||
audible_message("\The <b>[src.name]</b> [message_verb], \"[message]\"")
|
||||
if(display_overhead)
|
||||
var/list/hearers = get_hearers_in_view(7, src)
|
||||
var/list/clients_in_hearers = list()
|
||||
for(var/mob/mob in hearers)
|
||||
if(mob.client)
|
||||
clients_in_hearers += mob.client
|
||||
if(length(clients_in_hearers))
|
||||
INVOKE_ASYNC(src, TYPE_PROC_REF(/atom/movable, animate_chat), message, null, FALSE, clients_in_hearers, overhead_time)
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
#define SURVEY_TYPE_ATMOSPHERIC "atmospheric"
|
||||
#define SURVEY_TYPE_GROUND "ground"
|
||||
#define SURVEY_TYPE_GEOMAGNETIC "geomagnetic"
|
||||
|
||||
/obj/structure/survey_probe
|
||||
name = "atmosphere probe"
|
||||
desc = "\
|
||||
@@ -25,11 +29,13 @@
|
||||
var/start_deployed = FALSE
|
||||
///Extra information for variant types - manufacturer, faction, etc.
|
||||
var/desc_extra = "This probe was manufactured by Orion Express, but it is based on on older model designed by Hephaestus Industries."
|
||||
var/survey_type = "atmospheric"
|
||||
var/survey_type = SURVEY_TYPE_ATMOSPHERIC
|
||||
|
||||
/obj/structure/survey_probe/Initialize(mapload)
|
||||
. = ..()
|
||||
desc_extended += desc_extra
|
||||
if(survey_type == SURVEY_TYPE_ATMOSPHERIC)
|
||||
desc += " When deployed, this probe will read and relay weather data to compatible devices."
|
||||
if(start_deployed)
|
||||
deploy()
|
||||
|
||||
@@ -69,11 +75,49 @@
|
||||
anchored = TRUE
|
||||
density = TRUE
|
||||
icon_state = "[initial(icon_state)]_deployed"
|
||||
if(survey_type == SURVEY_TYPE_ATMOSPHERIC)
|
||||
RegisterSignal(SSdcs, COMSIG_GLOB_Z_WEATHER_CHANGE, PROC_REF(relay_weather_change))
|
||||
addtimer(CALLBACK(src, PROC_REF(read_initial_weather)), 2 SECONDS)
|
||||
output_spoken_message("Initializing weather detection subsystem...")
|
||||
|
||||
/// Reads the current weather status aloud when deployed on a planet with weather
|
||||
/obj/structure/survey_probe/proc/read_initial_weather()
|
||||
var/turf/current_turf = get_turf(src)
|
||||
|
||||
var/obj/abstract/weather_system/weather = current_turf.weather || SSweather.weather_by_z["[current_turf.z]"]
|
||||
if(!weather)
|
||||
output_spoken_message("No weather conditions detected.")
|
||||
return
|
||||
|
||||
var/singleton/state/weather/current_weather_state = weather.weather_system.current_state
|
||||
if(current_weather_state)
|
||||
output_spoken_message("Reading current weather conditions as \"[current_weather_state.name]\".")
|
||||
|
||||
/obj/structure/survey_probe/proc/undeploy()
|
||||
anchored = FALSE
|
||||
density = FALSE
|
||||
icon_state = initial(icon_state)
|
||||
if(survey_type == SURVEY_TYPE_ATMOSPHERIC)
|
||||
UnregisterSignal(SSdcs, COMSIG_GLOB_Z_WEATHER_CHANGE)
|
||||
|
||||
/// When a weather transition (see weather_fsm.dm) starts on this z_level, this will speak it aloud, and then broadcast it to any other devices listening to the broadcast global signal
|
||||
/obj/structure/survey_probe/proc/relay_weather_change(var/datum/source, var/z_level, var/singleton/state_transition/weather/weather_transition, var/time_to_transition)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
var/turf/current_turf = get_turf(src)
|
||||
var/list/connected_z_levels = GetConnectedZlevels(current_turf.z)
|
||||
if(!(z_level in connected_z_levels))
|
||||
return
|
||||
|
||||
var/singleton/state/weather/expected_weather_state = weather_transition.target
|
||||
var/broadcast_message = "Expecting shift to new weather condition, \"[expected_weather_state.name]\", in approximately [DisplayTimeText(time_to_transition)]."
|
||||
output_spoken_message(broadcast_message)
|
||||
|
||||
// received the message, now broadcast it to receivers
|
||||
// also send over other data, so unique receivers can have their own handling
|
||||
// think of it as the probe sending not just a radio message, but a broad band of data
|
||||
// yes, this does mean repeated messages if multiple atmospheric probes are set up
|
||||
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_Z_WEATHER_BROADCAST, z_level, weather_transition, time_to_transition, broadcast_message)
|
||||
|
||||
/obj/structure/survey_probe/proc/survey_end()
|
||||
if(timer_id)
|
||||
@@ -184,7 +228,7 @@
|
||||
The probe has to be deployed first before it is used. Wrench it to deploy, then click with empty hand to activate."
|
||||
|
||||
icon_state = "ground_probe"
|
||||
survey_type = "ground"
|
||||
survey_type = SURVEY_TYPE_GROUND
|
||||
|
||||
/obj/structure/survey_probe/ground/get_report(T, is_exoplanet, is_asteroid)
|
||||
// turf
|
||||
@@ -228,7 +272,7 @@
|
||||
The probe has to be deployed first before it is used. Wrench it to deploy, then click with empty hand to activate."
|
||||
|
||||
icon_state = "magnet_probe"
|
||||
survey_type = "geomagnetic"
|
||||
survey_type = SURVEY_TYPE_GEOMAGNETIC
|
||||
|
||||
/obj/structure/survey_probe/magnet/get_report(T, is_exoplanet, is_asteroid)
|
||||
. = "<b>Geomagnetic survey results:</b>"
|
||||
@@ -248,3 +292,7 @@
|
||||
. += "<br>No data available from geomagnetic analysis"
|
||||
else
|
||||
. += "<br>No data available from geomagnetic analysis"
|
||||
|
||||
#undef SURVEY_TYPE_ATMOSPHERIC
|
||||
#undef SURVEY_TYPE_GROUND
|
||||
#undef SURVEY_TYPE_GEOMAGNETIC
|
||||
|
||||
Reference in New Issue
Block a user