diff --git a/code/__defines/machinery.dm b/code/__defines/machinery.dm
index 0be4bc2a4d6..ed07f11c1e4 100644
--- a/code/__defines/machinery.dm
+++ b/code/__defines/machinery.dm
@@ -29,6 +29,11 @@ var/global/defer_powernet_rebuild = 0 // True if net rebuild will be called
#define MAINT 0x8 // Under maintenance.
#define EMPED 0x10 // Temporary broken by EMP pulse.
+// Remote control states
+#define RCON_NO 1
+#define RCON_AUTO 2
+#define RCON_YES 3
+
// Used by firelocks
#define FIREDOOR_OPEN 1
#define FIREDOOR_CLOSED 2
diff --git a/code/_helpers/_lists.dm b/code/_helpers/_lists.dm
index fdd6fc03a70..f60f113c692 100644
--- a/code/_helpers/_lists.dm
+++ b/code/_helpers/_lists.dm
@@ -843,3 +843,18 @@ proc/dd_sortedTextList(list/incoming)
if(L.len)
. = L[1]
L.Cut(1,2)
+
+//generates a list used to randomize transit animations so they aren't in lockstep
+/proc/get_cross_shift_list(var/size)
+ var/list/result = list()
+
+ result += rand(0, 14)
+ for(var/i in 2 to size)
+ var/shifts = list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
+ shifts -= result[i - 1] //consecutive shifts should not be equal
+ if(i == size)
+ shifts -= result[1] //because shift list is a ring buffer
+ result += pick(shifts)
+
+ return result
+
\ No newline at end of file
diff --git a/code/_helpers/global_lists.dm b/code/_helpers/global_lists.dm
index 854b02e3bff..ca862dbf3e1 100644
--- a/code/_helpers/global_lists.dm
+++ b/code/_helpers/global_lists.dm
@@ -19,8 +19,6 @@ var/global/list/side_effects = list() //list of all medical sideeffects types
var/global/list/mechas_list = list() //list of all mechs. Used by hostile mobs target tracking.
var/global/list/joblist = list() //list of all jobstypes, minus borg and AI
-var/global/list/turfs = list() //list of all turfs
-
#define all_genders_define_list list(MALE,FEMALE,PLURAL,NEUTER,HERM) //VOREStaton Edit
#define all_genders_text_list list("Male","Female","Plural","Neuter","Herm") //VOREStation Edit
diff --git a/code/controllers/subsystems/air.dm b/code/controllers/subsystems/air.dm
index 263e290968a..40d2cc3133a 100644
--- a/code/controllers/subsystems/air.dm
+++ b/code/controllers/subsystems/air.dm
@@ -38,7 +38,7 @@ SUBSYSTEM_DEF(air)
current_cycle = 0
var/simulated_turf_count = 0
- for(var/turf/simulated/S in turfs)
+ for(var/turf/simulated/S in world)
simulated_turf_count++
S.update_air_properties()
CHECK_TICK
diff --git a/code/controllers/subsystems/atoms.dm b/code/controllers/subsystems/atoms.dm
index 60fccf6dd30..4db490914ab 100644
--- a/code/controllers/subsystems/atoms.dm
+++ b/code/controllers/subsystems/atoms.dm
@@ -8,9 +8,9 @@ SUBSYSTEM_DEF(atoms)
init_order = INIT_ORDER_ATOMS
flags = SS_NO_FIRE
- var/initialized = INITIALIZATION_INSSATOMS
+ var/static/initialized = INITIALIZATION_INSSATOMS
// var/list/created_atoms // This is never used, so don't bother. ~Leshana
- var/old_initialized
+ var/static/old_initialized
var/list/late_loaders
var/list/created_atoms
diff --git a/code/controllers/subsystems/mapping.dm b/code/controllers/subsystems/mapping.dm
index cc69931426f..5e13e28e8f4 100644
--- a/code/controllers/subsystems/mapping.dm
+++ b/code/controllers/subsystems/mapping.dm
@@ -16,8 +16,7 @@ SUBSYSTEM_DEF(mapping)
if(config.generate_map)
// Map-gen is still very specific to the map, however putting it here should ensure it loads in the correct order.
- if(using_map.perform_map_generation())
- using_map.refresh_mining_turfs()
+ using_map.perform_map_generation()
/datum/controller/subsystem/mapping/proc/load_map_templates()
diff --git a/code/controllers/subsystems/mapping_vr.dm b/code/controllers/subsystems/mapping_vr.dm
index 8c18889f715..665f0e5756f 100644
--- a/code/controllers/subsystems/mapping_vr.dm
+++ b/code/controllers/subsystems/mapping_vr.dm
@@ -25,8 +25,7 @@ SUBSYSTEM_DEF(mapping)
if(config.generate_map)
// Map-gen is still very specific to the map, however putting it here should ensure it loads in the correct order.
- if(using_map.perform_map_generation())
- using_map.refresh_mining_turfs()
+ using_map.perform_map_generation()
loadEngine()
preloadShelterTemplates()
diff --git a/code/controllers/subsystems/skybox.dm b/code/controllers/subsystems/skybox.dm
index b876c6a2c8d..59e841ee52e 100644
--- a/code/controllers/subsystems/skybox.dm
+++ b/code/controllers/subsystems/skybox.dm
@@ -6,6 +6,38 @@ SUBSYSTEM_DEF(skybox)
flags = SS_NO_FIRE
var/list/skybox_cache = list()
+ var/list/dust_cache = list()
+ var/list/speedspace_cache = list()
+ var/list/phase_shift_by_x = list()
+ var/list/phase_shift_by_y = list()
+
+/datum/controller/subsystem/skybox/PreInit()
+ //Static
+ for (var/i in 0 to 25)
+ var/image/im = image('icons/turf/space_dust.dmi', "[i]")
+ im.plane = DUST_PLANE
+ im.alpha = 128 //80
+ im.blend_mode = BLEND_ADD
+ dust_cache["[i]"] = im
+ //Moving
+ for (var/i in 0 to 14)
+ // NORTH/SOUTH
+ var/image/im = image('icons/turf/space_dust_transit.dmi', "speedspace_ns_[i]")
+ im.plane = DUST_PLANE
+ im.blend_mode = BLEND_ADD
+ speedspace_cache["NS_[i]"] = im
+ // EAST/WEST
+ im = image('icons/turf/space_dust_transit.dmi', "speedspace_ew_[i]")
+ im.plane = DUST_PLANE
+ im.blend_mode = BLEND_ADD
+ speedspace_cache["EW_[i]"] = im
+
+ //Shuffle some lists
+ phase_shift_by_x = get_cross_shift_list(15)
+ phase_shift_by_y = get_cross_shift_list(15)
+
+ . = ..()
+
/datum/controller/subsystem/skybox/Initialize()
. = ..()
diff --git a/code/controllers/subsystems/xenoarch.dm b/code/controllers/subsystems/xenoarch.dm
index d863ad8269b..c8184d783e0 100644
--- a/code/controllers/subsystems/xenoarch.dm
+++ b/code/controllers/subsystems/xenoarch.dm
@@ -30,7 +30,7 @@ SUBSYSTEM_DEF(xenoarch)
. = ..()
/datum/controller/subsystem/xenoarch/proc/SetupXenoarch()
- for(var/turf/simulated/mineral/M in turfs)
+ for(var/turf/simulated/mineral/M in world)
if(!M.density || M.z in using_map.xenoarch_exempt_levels)
continue
diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm
index fc9f4b7826d..3482d5f3953 100644
--- a/code/game/area/areas.dm
+++ b/code/game/area/areas.dm
@@ -43,24 +43,17 @@
var/uid
/area/New()
- icon_state = ""
uid = ++global_uid
- all_areas += src
-
- if(!requires_power)
- power_light = 0
- power_equip = 0
- power_environ = 0
-
- if(dynamic_lighting)
- luminosity = 0
- else
- luminosity = 1
-
+ all_areas += src //Replace with /area in world? Byond optimizes X in world loops.
+
..()
/area/Initialize()
. = ..()
+
+ luminosity = !(dynamic_lighting)
+ icon_state = ""
+
return INITIALIZE_HINT_LATELOAD // Areas tradiationally are initialized AFTER other atoms.
/area/LateInitialize()
diff --git a/code/game/atoms.dm b/code/game/atoms.dm
index 6b206c6d020..35ff527da48 100644
--- a/code/game/atoms.dm
+++ b/code/game/atoms.dm
@@ -41,8 +41,7 @@
_preloader.load(src)
// Pass our arguments to InitAtom so they can be passed to initialize(), but replace 1st with if-we're-during-mapload.
- var/do_initialize = SSatoms && SSatoms.initialized // Workaround our non-ideal initialization order: SSatoms may not exist yet.
- //var/do_initialize = SSatoms.initialized
+ var/do_initialize = SSatoms.initialized
if(do_initialize > INITIALIZATION_INSSATOMS)
args[1] = (do_initialize == INITIALIZATION_INNEW_MAPLOAD)
if(SSatoms.InitAtom(src, args))
diff --git a/code/game/gamemodes/cult/hell_universe.dm b/code/game/gamemodes/cult/hell_universe.dm
index ee794539334..27dd86df135 100644
--- a/code/game/gamemodes/cult/hell_universe.dm
+++ b/code/game/gamemodes/cult/hell_universe.dm
@@ -65,11 +65,11 @@ In short:
for(var/datum/lighting_corner/L in world)
L.update_lumcount(1, 0, 0)
- for(var/turf/space/T in turfs)
+ for(var/turf/space/T in world)
OnTurfChange(T)
/datum/universal_state/hell/proc/MiscSet()
- for(var/turf/simulated/floor/T in turfs)
+ for(var/turf/simulated/floor/T in world)
if(!T.holy && prob(1))
new /obj/effect/gateway/active/cult(T)
diff --git a/code/game/gamemodes/endgame/supermatter_cascade/blob.dm b/code/game/gamemodes/endgame/supermatter_cascade/blob.dm
index be856161436..88da43257da 100644
--- a/code/game/gamemodes/endgame/supermatter_cascade/blob.dm
+++ b/code/game/gamemodes/endgame/supermatter_cascade/blob.dm
@@ -14,8 +14,8 @@
var/next_check=0
var/list/avail_dirs = list(NORTH,SOUTH,EAST,WEST)
-/turf/unsimulated/wall/supermatter/New()
- ..()
+/turf/unsimulated/wall/supermatter/Initialize(mapload)
+ . = ..()
START_PROCESSING(SSturfs, src)
next_check = world.time+5 SECONDS
diff --git a/code/game/gamemodes/endgame/supermatter_cascade/universe.dm b/code/game/gamemodes/endgame/supermatter_cascade/universe.dm
index 0c0d4c1a403..8f4f861b425 100644
--- a/code/game/gamemodes/endgame/supermatter_cascade/universe.dm
+++ b/code/game/gamemodes/endgame/supermatter_cascade/universe.dm
@@ -98,7 +98,7 @@ The access requirements on the Asteroid Shuttles' consoles have now been revoked
else
L.update_lumcount(0.0, 0.4, 1)
- for(var/turf/space/T in turfs)
+ for(var/turf/space/T in world)
OnTurfChange(T)
/datum/universal_state/supermatter_cascade/proc/MiscSet()
diff --git a/code/game/gamemodes/events/wormholes.dm b/code/game/gamemodes/events/wormholes.dm
index 83f42466962..20f7da63f3e 100644
--- a/code/game/gamemodes/events/wormholes.dm
+++ b/code/game/gamemodes/events/wormholes.dm
@@ -3,7 +3,7 @@
var/list/pick_turfs = list()
var/list/Z_choices = list()
Z_choices |= using_map.get_map_levels(1, FALSE)
- for(var/turf/simulated/floor/T in turfs)
+ for(var/turf/simulated/floor/T in world)
if(T.z in Z_choices)
if(!T.block_tele)
pick_turfs += T
diff --git a/code/game/machinery/alarm.dm b/code/game/machinery/air_alarm.dm
similarity index 69%
rename from code/game/machinery/alarm.dm
rename to code/game/machinery/air_alarm.dm
index 0072adb9fb3..56cbf72278c 100644
--- a/code/game/machinery/alarm.dm
+++ b/code/game/machinery/air_alarm.dm
@@ -1,1134 +1,787 @@
-////////////////////////////////////////
-//CONTAINS: Air Alarms and Fire Alarms//
-////////////////////////////////////////
-
-#define AALARM_MODE_SCRUBBING 1
-#define AALARM_MODE_REPLACEMENT 2 //like scrubbing, but faster.
-#define AALARM_MODE_PANIC 3 //constantly sucks all air
-#define AALARM_MODE_CYCLE 4 //sucks off all air, then refill and switches to scrubbing
-#define AALARM_MODE_FILL 5 //emergency fill
-#define AALARM_MODE_OFF 6 //Shuts it all down.
-
-#define AALARM_SCREEN_MAIN 1
-#define AALARM_SCREEN_VENT 2
-#define AALARM_SCREEN_SCRUB 3
-#define AALARM_SCREEN_MODE 4
-#define AALARM_SCREEN_SENSORS 5
-
-#define AALARM_REPORT_TIMEOUT 100
-
-#define RCON_NO 1
-#define RCON_AUTO 2
-#define RCON_YES 3
-
-#define MAX_TEMPERATURE 90
-#define MIN_TEMPERATURE -40
-
-//all air alarms in area are connected via magic
-/area
- var/obj/machinery/alarm/master_air_alarm
- var/list/air_vent_names = list()
- var/list/air_scrub_names = list()
- var/list/air_vent_info = list()
- var/list/air_scrub_info = list()
-
-/obj/machinery/alarm
- name = "alarm"
- desc = "Used to control various station atmospheric systems. The light indicates the current air status of the area."
- icon = 'icons/obj/monitors.dmi'
- icon_state = "alarm0"
- plane = TURF_PLANE
- layer = ABOVE_TURF_LAYER
- anchored = 1
- use_power = 1
- idle_power_usage = 80
- active_power_usage = 1000 //For heating/cooling rooms. 1000 joules equates to about 1 degree every 2 seconds for a single tile of air.
- power_channel = ENVIRON
- req_one_access = list(access_atmospherics, access_engine_equip)
- clicksound = "button"
- clickvol = 30
- var/alarm_id = null
- var/breach_detection = 1 // Whether to use automatic breach detection or not
- var/frequency = 1439
- //var/skipprocess = 0 //Experimenting
- var/alarm_frequency = 1437
- var/remote_control = 0
- var/rcon_setting = 2
- var/rcon_time = 0
- var/locked = 1
- panel_open = 0 // If it's been screwdrivered open.
- var/aidisabled = 0
- var/shorted = 0
- circuit = /obj/item/weapon/circuitboard/airalarm
-
- var/datum/wires/alarm/wires
-
- var/mode = AALARM_MODE_SCRUBBING
- var/screen = AALARM_SCREEN_MAIN
- var/area_uid
- var/area/alarm_area
-
- var/target_temperature = T0C+20
- var/regulating_temperature = 0
-
- var/datum/radio_frequency/radio_connection
-
- var/list/TLV = list()
- var/list/trace_gas = list("sleeping_agent", "volatile_fuel") //list of other gases that this air alarm is able to detect
-
- var/danger_level = 0
- var/pressure_dangerlevel = 0
- var/oxygen_dangerlevel = 0
- var/co2_dangerlevel = 0
- var/phoron_dangerlevel = 0
- var/temperature_dangerlevel = 0
- var/other_dangerlevel = 0
-
- var/report_danger_level = 1
-
- var/alarms_hidden = FALSE //If the alarms from this machine are visible on consoles
-
-/obj/machinery/alarm/nobreach
- breach_detection = 0
-
-/obj/machinery/alarm/monitor
- report_danger_level = 0
- breach_detection = 0
-
-/obj/machinery/alarm/alarms_hidden
- alarms_hidden = TRUE
-
-/obj/machinery/alarm/server/New()
- ..()
- req_access = list(access_rd, access_atmospherics, access_engine_equip)
- TLV["oxygen"] = list(-1.0, -1.0,-1.0,-1.0) // Partial pressure, kpa
- TLV["carbon dioxide"] = list(-1.0, -1.0, 5, 10) // Partial pressure, kpa
- TLV["phoron"] = list(-1.0, -1.0, 0, 0.5) // Partial pressure, kpa
- TLV["other"] = list(-1.0, -1.0, 0.5, 1.0) // Partial pressure, kpa
- TLV["pressure"] = list(0,ONE_ATMOSPHERE*0.10,ONE_ATMOSPHERE*1.40,ONE_ATMOSPHERE*1.60) /* kpa */
- TLV["temperature"] = list(20, 40, 140, 160) // K
- target_temperature = 90
-
-/obj/machinery/alarm/Destroy()
- unregister_radio(src, frequency)
- qdel(wires)
- wires = null
- if(alarm_area && alarm_area.master_air_alarm == src)
- alarm_area.master_air_alarm = null
- elect_master(exclude_self = TRUE)
- return ..()
-
-/obj/machinery/alarm/New()
- ..()
- first_run()
-
-/obj/machinery/alarm/proc/first_run()
- alarm_area = get_area(src)
- area_uid = alarm_area.uid
- if(name == "alarm")
- name = "[alarm_area.name] Air Alarm"
-
- if(!wires)
- wires = new(src)
-
- // breathable air according to human/Life()
- TLV["oxygen"] = list(16, 19, 135, 140) // Partial pressure, kpa
- TLV["carbon dioxide"] = list(-1.0, -1.0, 5, 10) // Partial pressure, kpa
- TLV["phoron"] = list(-1.0, -1.0, 0, 0.5) // Partial pressure, kpa
- TLV["other"] = list(-1.0, -1.0, 0.5, 1.0) // Partial pressure, kpa
- TLV["pressure"] = list(ONE_ATMOSPHERE * 0.80, ONE_ATMOSPHERE * 0.90, ONE_ATMOSPHERE * 1.10, ONE_ATMOSPHERE * 1.20) /* kpa */
- TLV["temperature"] = list(T0C - 26, T0C, T0C + 40, T0C + 66) // K
-
-
-/obj/machinery/alarm/Initialize()
- . = ..()
- set_frequency(frequency)
- if(!master_is_operating())
- elect_master()
-
-/obj/machinery/alarm/process()
- if((stat & (NOPOWER|BROKEN)) || shorted)
- return
-
- var/turf/simulated/location = src.loc
- if(!istype(location)) return//returns if loc is not simulated
-
- var/datum/gas_mixture/environment = location.return_air()
-
- //Handle temperature adjustment here.
- handle_heating_cooling(environment)
-
- var/old_level = danger_level
- var/old_pressurelevel = pressure_dangerlevel
- danger_level = overall_danger_level(environment)
-
- if(old_level != danger_level)
- apply_danger_level(danger_level)
-
- if(old_pressurelevel != pressure_dangerlevel)
- if(breach_detected())
- mode = AALARM_MODE_OFF
- apply_mode()
-
- if(mode == AALARM_MODE_CYCLE && environment.return_pressure() < ONE_ATMOSPHERE * 0.05)
- mode = AALARM_MODE_FILL
- apply_mode()
-
- //atmos computer remote controll stuff
- switch(rcon_setting)
- if(RCON_NO)
- remote_control = 0
- if(RCON_AUTO)
- if(danger_level == 2)
- remote_control = 1
- else
- remote_control = 0
- if(RCON_YES)
- remote_control = 1
-
- return
-
-/obj/machinery/alarm/proc/handle_heating_cooling(var/datum/gas_mixture/environment)
- if(!regulating_temperature)
- //check for when we should start adjusting temperature
- if(!get_danger_level(target_temperature, TLV["temperature"]) && abs(environment.temperature - target_temperature) > 2.0)
- update_use_power(2)
- regulating_temperature = 1
- audible_message("\The [src] clicks as it starts [environment.temperature > target_temperature ? "cooling" : "heating"] the room.",\
- "You hear a click and a faint electronic hum.")
- playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
- else
- //check for when we should stop adjusting temperature
- if(get_danger_level(target_temperature, TLV["temperature"]) || abs(environment.temperature - target_temperature) <= 0.5)
- update_use_power(1)
- regulating_temperature = 0
- audible_message("\The [src] clicks quietly as it stops [environment.temperature > target_temperature ? "cooling" : "heating"] the room.",\
- "You hear a click as a faint electronic humming stops.")
- playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
-
- if(regulating_temperature)
- if(target_temperature > T0C + MAX_TEMPERATURE)
- target_temperature = T0C + MAX_TEMPERATURE
-
- if(target_temperature < T0C + MIN_TEMPERATURE)
- target_temperature = T0C + MIN_TEMPERATURE
-
- var/datum/gas_mixture/gas
- gas = environment.remove(0.25 * environment.total_moles)
- if(gas)
-
- if(gas.temperature <= target_temperature) //gas heating
- var/energy_used = min(gas.get_thermal_energy_change(target_temperature) , active_power_usage)
-
- gas.add_thermal_energy(energy_used)
- //use_power(energy_used, ENVIRON) //handle by update_use_power instead
- else //gas cooling
- var/heat_transfer = min(abs(gas.get_thermal_energy_change(target_temperature)), active_power_usage)
-
- //Assume the heat is being pumped into the hull which is fixed at 20 C
- //none of this is really proper thermodynamics but whatever
-
- var/cop = gas.temperature / T20C //coefficient of performance -> power used = heat_transfer/cop
-
- heat_transfer = min(heat_transfer, cop * active_power_usage) //this ensures that we don't use more than active_power_usage amount of power
-
- heat_transfer = -gas.add_thermal_energy(-heat_transfer) //get the actual heat transfer
-
- //use_power(heat_transfer / cop, ENVIRON) //handle by update_use_power instead
-
- environment.merge(gas)
-
-/obj/machinery/alarm/proc/overall_danger_level(var/datum/gas_mixture/environment)
- var/partial_pressure = R_IDEAL_GAS_EQUATION * environment.temperature/environment.volume
- var/environment_pressure = environment.return_pressure()
-
- var/other_moles = 0
- for(var/g in trace_gas)
- other_moles += environment.gas[g] //this is only going to be used in a partial pressure calc, so we don't need to worry about group_multiplier here.
-
- pressure_dangerlevel = get_danger_level(environment_pressure, TLV["pressure"])
- oxygen_dangerlevel = get_danger_level(environment.gas["oxygen"]*partial_pressure, TLV["oxygen"])
- co2_dangerlevel = get_danger_level(environment.gas["carbon_dioxide"]*partial_pressure, TLV["carbon dioxide"])
- phoron_dangerlevel = get_danger_level(environment.gas["phoron"]*partial_pressure, TLV["phoron"])
- temperature_dangerlevel = get_danger_level(environment.temperature, TLV["temperature"])
- other_dangerlevel = get_danger_level(other_moles*partial_pressure, TLV["other"])
-
- return max(
- pressure_dangerlevel,
- oxygen_dangerlevel,
- co2_dangerlevel,
- phoron_dangerlevel,
- other_dangerlevel,
- temperature_dangerlevel
- )
-
-// Returns whether this air alarm thinks there is a breach, given the sensors that are available to it.
-/obj/machinery/alarm/proc/breach_detected()
- var/turf/simulated/location = src.loc
-
- if(!istype(location))
- return 0
-
- if(breach_detection == 0)
- return 0
-
- var/datum/gas_mixture/environment = location.return_air()
- var/environment_pressure = environment.return_pressure()
- var/pressure_levels = TLV["pressure"]
-
- if(environment_pressure <= pressure_levels[1]) //low pressures
- if(!(mode == AALARM_MODE_PANIC || mode == AALARM_MODE_CYCLE))
- playsound(src.loc, 'sound/machines/airalarm.ogg', 25, 0, 4)
- return 1
-
- return 0
-
-/obj/machinery/alarm/proc/master_is_operating()
- return alarm_area && alarm_area.master_air_alarm && !(alarm_area.master_air_alarm.stat & (NOPOWER | BROKEN))
-
-/obj/machinery/alarm/proc/elect_master(exclude_self = FALSE)
- for(var/obj/machinery/alarm/AA in alarm_area)
- if(exclude_self && AA == src)
- continue
- if(!(AA.stat & (NOPOWER|BROKEN)))
- alarm_area.master_air_alarm = AA
- return 1
- return 0
-
-/obj/machinery/alarm/proc/get_danger_level(var/current_value, var/list/danger_levels)
- if((current_value >= danger_levels[4] && danger_levels[4] > 0) || current_value <= danger_levels[1])
- return 2
- if((current_value >= danger_levels[3] && danger_levels[3] > 0) || current_value <= danger_levels[2])
- return 1
- return 0
-
-/obj/machinery/alarm/update_icon()
- if(panel_open)
- icon_state = "alarmx"
- set_light(0)
- return
- if((stat & (NOPOWER|BROKEN)) || shorted)
- icon_state = "alarmp"
- set_light(0)
- return
-
- var/icon_level = danger_level
- if(alarm_area.atmosalm)
- icon_level = max(icon_level, 1) //if there's an atmos alarm but everything is okay locally, no need to go past yellow
-
- var/new_color = null
- switch(icon_level)
- if(0)
- icon_state = "alarm0"
- new_color = "#03A728"
- if(1)
- icon_state = "alarm2" //yes, alarm2 is yellow alarm
- new_color = "#EC8B2F"
- if(2)
- icon_state = "alarm1"
- new_color = "#DA0205"
-
- set_light(l_range = 2, l_power = 0.25, l_color = new_color)
-
-/obj/machinery/alarm/receive_signal(datum/signal/signal)
- if(stat & (NOPOWER|BROKEN))
- return
- if(alarm_area.master_air_alarm != src)
- if(master_is_operating())
- return
- elect_master()
- if(alarm_area.master_air_alarm != src)
- return
- if(!signal || signal.encryption)
- return
- var/id_tag = signal.data["tag"]
- if(!id_tag)
- return
- if(signal.data["area"] != area_uid)
- return
- if(signal.data["sigtype"] != "status")
- return
-
- var/dev_type = signal.data["device"]
- if(!(id_tag in alarm_area.air_scrub_names) && !(id_tag in alarm_area.air_vent_names))
- register_env_machine(id_tag, dev_type)
- if(dev_type == "AScr")
- alarm_area.air_scrub_info[id_tag] = signal.data
- else if(dev_type == "AVP")
- alarm_area.air_vent_info[id_tag] = signal.data
-
-/obj/machinery/alarm/proc/register_env_machine(var/m_id, var/device_type)
- var/new_name
- if(device_type == "AVP")
- new_name = "[alarm_area.name] Vent Pump #[alarm_area.air_vent_names.len+1]"
- alarm_area.air_vent_names[m_id] = new_name
- else if(device_type == "AScr")
- new_name = "[alarm_area.name] Air Scrubber #[alarm_area.air_scrub_names.len+1]"
- alarm_area.air_scrub_names[m_id] = new_name
- else
- return
- spawn(10)
- send_signal(m_id, list("init" = new_name))
-
-/obj/machinery/alarm/proc/refresh_all()
- for(var/id_tag in alarm_area.air_vent_names)
- var/list/I = alarm_area.air_vent_info[id_tag]
- if(I && I["timestamp"] + AALARM_REPORT_TIMEOUT / 2 > world.time)
- continue
- send_signal(id_tag, list("status"))
- for(var/id_tag in alarm_area.air_scrub_names)
- var/list/I = alarm_area.air_scrub_info[id_tag]
- if(I && I["timestamp"] + AALARM_REPORT_TIMEOUT / 2 > world.time)
- continue
- send_signal(id_tag, list("status"))
-
-/obj/machinery/alarm/proc/set_frequency(new_frequency)
- radio_controller.remove_object(src, frequency)
- frequency = new_frequency
- radio_connection = radio_controller.add_object(src, frequency, RADIO_TO_AIRALARM)
-
-/obj/machinery/alarm/proc/send_signal(var/target, var/list/command)//sends signal 'command' to 'target'. Returns 0 if no radio connection, 1 otherwise
- if(!radio_connection)
- return 0
-
- var/datum/signal/signal = new
- signal.transmission_method = 1 //radio signal
- signal.source = src
-
- signal.data = command
- signal.data["tag"] = target
- signal.data["sigtype"] = "command"
-
- radio_connection.post_signal(src, signal, RADIO_FROM_AIRALARM)
-// to_world("Signal [command] Broadcasted to [target]")
-
- return 1
-
-/obj/machinery/alarm/proc/apply_mode()
- //propagate mode to other air alarms in the area
- //TODO: make it so that players can choose between applying the new mode to the room they are in (related area) vs the entire alarm area
- for(var/obj/machinery/alarm/AA in alarm_area)
- AA.mode = mode
-
- switch(mode)
- if(AALARM_MODE_SCRUBBING)
- for(var/device_id in alarm_area.air_scrub_names)
- send_signal(device_id, list("power"= 1, "co2_scrub"= 1, "scrubbing"= 1, "panic_siphon"= 0))
- for(var/device_id in alarm_area.air_vent_names)
- send_signal(device_id, list("power"= 1, "checks"= "default", "set_external_pressure"= "default"))
-
- if(AALARM_MODE_PANIC, AALARM_MODE_CYCLE)
- for(var/device_id in alarm_area.air_scrub_names)
- send_signal(device_id, list("power"= 1, "panic_siphon"= 1))
- for(var/device_id in alarm_area.air_vent_names)
- send_signal(device_id, list("power"= 0))
-
- if(AALARM_MODE_REPLACEMENT)
- for(var/device_id in alarm_area.air_scrub_names)
- send_signal(device_id, list("power"= 1, "panic_siphon"= 1))
- for(var/device_id in alarm_area.air_vent_names)
- send_signal(device_id, list("power"= 1, "checks"= "default", "set_external_pressure"= "default"))
-
- if(AALARM_MODE_FILL)
- for(var/device_id in alarm_area.air_scrub_names)
- send_signal(device_id, list("power"= 0))
- for(var/device_id in alarm_area.air_vent_names)
- send_signal(device_id, list("power"= 1, "checks"= "default", "set_external_pressure"= "default"))
-
- if(AALARM_MODE_OFF)
- for(var/device_id in alarm_area.air_scrub_names)
- send_signal(device_id, list("power"= 0))
- for(var/device_id in alarm_area.air_vent_names)
- send_signal(device_id, list("power"= 0))
-
-/obj/machinery/alarm/proc/apply_danger_level(var/new_danger_level)
- if(report_danger_level && alarm_area.atmosalert(new_danger_level, src))
- post_alert(new_danger_level)
-
- update_icon()
-
-/obj/machinery/alarm/proc/post_alert(alert_level)
- var/datum/radio_frequency/frequency = radio_controller.return_frequency(alarm_frequency)
- if(!frequency)
- return
-
- var/datum/signal/alert_signal = new
- alert_signal.source = src
- alert_signal.transmission_method = 1
- alert_signal.data["zone"] = alarm_area.name
- alert_signal.data["type"] = "Atmospheric"
-
- if(alert_level==2)
- alert_signal.data["alert"] = "severe"
- else if(alert_level==1)
- alert_signal.data["alert"] = "minor"
- else if(alert_level==0)
- alert_signal.data["alert"] = "clear"
-
- frequency.post_signal(src, alert_signal)
-
-/obj/machinery/alarm/attack_ai(mob/user)
- ui_interact(user)
-
-/obj/machinery/alarm/attack_hand(mob/user)
- . = ..()
- if(.)
- return
- return interact(user)
-
-/obj/machinery/alarm/interact(mob/user)
- ui_interact(user)
- wires.Interact(user)
-
-/obj/machinery/alarm/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
- var/data[0]
- var/remote_connection = 0
- var/remote_access = 0
- if(state)
- var/list/href = state.href_list(user)
- remote_connection = href["remote_connection"] // Remote connection means we're non-adjacent/connecting from another computer
- remote_access = href["remote_access"] // Remote access means we also have the privilege to alter the air alarm.
-
- data["locked"] = locked && !issilicon(user)
- data["remote_connection"] = remote_connection
- data["remote_access"] = remote_access
- data["rcon"] = rcon_setting
- data["screen"] = screen
-
- populate_status(data)
-
- if(!(locked && !remote_connection) || remote_access || issilicon(user))
- populate_controls(data)
-
- ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
- if(!ui)
- ui = new(user, src, ui_key, "air_alarm.tmpl", name, 325, 625, master_ui = master_ui, state = state)
- ui.set_initial_data(data)
- ui.open()
- ui.set_auto_update(1)
-
-/obj/machinery/alarm/proc/populate_status(var/data)
- var/turf/location = get_turf(src)
- var/datum/gas_mixture/environment = location.return_air()
- var/total = environment.total_moles
-
- var/list/environment_data = new
- data["has_environment"] = total
- if(total)
- var/pressure = environment.return_pressure()
- environment_data[++environment_data.len] = list("name" = "Pressure", "value" = pressure, "unit" = "kPa", "danger_level" = pressure_dangerlevel)
- environment_data[++environment_data.len] = list("name" = "Oxygen", "value" = environment.gas["oxygen"] / total * 100, "unit" = "%", "danger_level" = oxygen_dangerlevel)
- environment_data[++environment_data.len] = list("name" = "Carbon dioxide", "value" = environment.gas["carbon_dioxide"] / total * 100, "unit" = "%", "danger_level" = co2_dangerlevel)
- environment_data[++environment_data.len] = list("name" = "Toxins", "value" = environment.gas["phoron"] / total * 100, "unit" = "%", "danger_level" = phoron_dangerlevel)
- environment_data[++environment_data.len] = list("name" = "Temperature", "value" = environment.temperature, "unit" = "K ([round(environment.temperature - T0C, 0.1)]C)", "danger_level" = temperature_dangerlevel)
- data["total_danger"] = danger_level
- data["environment"] = environment_data
- data["atmos_alarm"] = alarm_area.atmosalm
- data["fire_alarm"] = alarm_area.fire != null
- data["target_temperature"] = "[target_temperature - T0C]C"
-
-/obj/machinery/alarm/proc/populate_controls(var/list/data)
- switch(screen)
- if(AALARM_SCREEN_MAIN)
- data["mode"] = mode
- if(AALARM_SCREEN_VENT)
- var/vents[0]
- for(var/id_tag in alarm_area.air_vent_names)
- var/long_name = alarm_area.air_vent_names[id_tag]
- var/list/info = alarm_area.air_vent_info[id_tag]
- if(!info)
- continue
- vents[++vents.len] = list(
- "id_tag" = id_tag,
- "long_name" = sanitize(long_name),
- "power" = info["power"],
- "checks" = info["checks"],
- "direction" = info["direction"],
- "external" = info["external"]
- )
- data["vents"] = vents
- if(AALARM_SCREEN_SCRUB)
- var/scrubbers[0]
- for(var/id_tag in alarm_area.air_scrub_names)
- var/long_name = alarm_area.air_scrub_names[id_tag]
- var/list/info = alarm_area.air_scrub_info[id_tag]
- if(!info)
- continue
- scrubbers[++scrubbers.len] = list(
- "id_tag" = id_tag,
- "long_name" = sanitize(long_name),
- "power" = info["power"],
- "scrubbing" = info["scrubbing"],
- "panic" = info["panic"],
- "filters" = list()
- )
- scrubbers[scrubbers.len]["filters"] += list(list("name" = "Oxygen", "command" = "o2_scrub", "val" = info["filter_o2"]))
- scrubbers[scrubbers.len]["filters"] += list(list("name" = "Nitrogen", "command" = "n2_scrub", "val" = info["filter_n2"]))
- scrubbers[scrubbers.len]["filters"] += list(list("name" = "Carbon Dioxide", "command" = "co2_scrub","val" = info["filter_co2"]))
- scrubbers[scrubbers.len]["filters"] += list(list("name" = "Toxin" , "command" = "tox_scrub","val" = info["filter_phoron"]))
- scrubbers[scrubbers.len]["filters"] += list(list("name" = "Nitrous Oxide", "command" = "n2o_scrub","val" = info["filter_n2o"]))
- scrubbers[scrubbers.len]["filters"] += list(list("name" = "Fuel", "command" = "fuel_scrub","val" = info["filter_fuel"]))
- data["scrubbers"] = scrubbers
- if(AALARM_SCREEN_MODE)
- var/modes[0]
- modes[++modes.len] = list("name" = "Filtering - Scrubs out contaminants", "mode" = AALARM_MODE_SCRUBBING, "selected" = mode == AALARM_MODE_SCRUBBING, "danger" = 0)
- modes[++modes.len] = list("name" = "Replace Air - Siphons out air while replacing", "mode" = AALARM_MODE_REPLACEMENT, "selected" = mode == AALARM_MODE_REPLACEMENT, "danger" = 0)
- modes[++modes.len] = list("name" = "Panic - Siphons air out of the room", "mode" = AALARM_MODE_PANIC, "selected" = mode == AALARM_MODE_PANIC, "danger" = 1)
- modes[++modes.len] = list("name" = "Cycle - Siphons air before replacing", "mode" = AALARM_MODE_CYCLE, "selected" = mode == AALARM_MODE_CYCLE, "danger" = 1)
- modes[++modes.len] = list("name" = "Fill - Shuts off scrubbers and opens vents", "mode" = AALARM_MODE_FILL, "selected" = mode == AALARM_MODE_FILL, "danger" = 0)
- modes[++modes.len] = list("name" = "Off - Shuts off vents and scrubbers", "mode" = AALARM_MODE_OFF, "selected" = mode == AALARM_MODE_OFF, "danger" = 0)
- data["modes"] = modes
- data["mode"] = mode
- if(AALARM_SCREEN_SENSORS)
- var/list/selected
- var/thresholds[0]
-
- var/list/gas_names = list(
- "oxygen" = "O2",
- "carbon dioxide" = "CO2",
- "phoron" = "Toxin",
- "other" = "Other")
- for(var/g in gas_names)
- thresholds[++thresholds.len] = list("name" = gas_names[g], "settings" = list())
- selected = TLV[g]
- for(var/i = 1, i <= 4, i++)
- thresholds[thresholds.len]["settings"] += list(list("env" = g, "val" = i, "selected" = selected[i]))
-
- selected = TLV["pressure"]
- thresholds[++thresholds.len] = list("name" = "Pressure", "settings" = list())
- for(var/i = 1, i <= 4, i++)
- thresholds[thresholds.len]["settings"] += list(list("env" = "pressure", "val" = i, "selected" = selected[i]))
-
- selected = TLV["temperature"]
- thresholds[++thresholds.len] = list("name" = "Temperature", "settings" = list())
- for(var/i = 1, i <= 4, i++)
- thresholds[thresholds.len]["settings"] += list(list("env" = "temperature", "val" = i, "selected" = selected[i]))
-
- data["thresholds"] = thresholds
-
-/obj/machinery/alarm/CanUseTopic(var/mob/user, var/datum/topic_state/state, var/href_list = list())
- if(aidisabled && isAI(user))
- to_chat(user, "AI control for \the [src] interface has been disabled.")
- return STATUS_CLOSE
-
- . = shorted ? STATUS_DISABLED : STATUS_INTERACTIVE
-
- if(. == STATUS_INTERACTIVE)
- var/extra_href = state.href_list(usr)
- // Prevent remote users from altering RCON settings unless they already have access
- if(href_list["rcon"] && extra_href["remote_connection"] && !extra_href["remote_access"])
- . = STATUS_UPDATE
-
- return min(..(), .)
-
-/obj/machinery/alarm/Topic(href, href_list, var/datum/topic_state/state)
- if(..(href, href_list, state))
- return 1
-
- // hrefs that can always be called -walter0o
- if(href_list["rcon"])
- var/attempted_rcon_setting = text2num(href_list["rcon"])
-
- switch(attempted_rcon_setting)
- if(RCON_NO)
- rcon_setting = RCON_NO
- if(RCON_AUTO)
- rcon_setting = RCON_AUTO
- if(RCON_YES)
- rcon_setting = RCON_YES
- return 1
-
- if(href_list["temperature"])
- var/list/selected = TLV["temperature"]
- var/max_temperature = min(selected[3] - T0C, MAX_TEMPERATURE)
- var/min_temperature = max(selected[2] - T0C, MIN_TEMPERATURE)
- var/input_temperature = input("What temperature would you like the system to mantain? (Capped between [min_temperature] and [max_temperature]C)", "Thermostat Controls", target_temperature - T0C) as num|null
- if(isnum(input_temperature))
- if(input_temperature > max_temperature || input_temperature < min_temperature)
- to_chat(usr, "Temperature must be between [min_temperature]C and [max_temperature]C")
- else
- target_temperature = input_temperature + T0C
- return 1
-
- // hrefs that need the AA unlocked -walter0o
- var/extra_href = state.href_list(usr)
- if(!(locked && !extra_href["remote_connection"]) || extra_href["remote_access"] || issilicon(usr))
- if(href_list["command"])
- var/device_id = href_list["id_tag"]
- switch(href_list["command"])
- if("set_external_pressure")
- var/input_pressure = input("What pressure you like the system to mantain?", "Pressure Controls") as num|null
- if(isnum(input_pressure))
- send_signal(device_id, list(href_list["command"] = input_pressure))
- return 1
-
- if("reset_external_pressure")
- send_signal(device_id, list(href_list["command"] = ONE_ATMOSPHERE))
- return 1
-
- if( "power",
- "adjust_external_pressure",
- "checks",
- "o2_scrub",
- "n2_scrub",
- "co2_scrub",
- "tox_scrub",
- "n2o_scrub",
- "fuel_scrub",
- "panic_siphon",
- "scrubbing",
- "direction")
-
- send_signal(device_id, list(href_list["command"] = text2num(href_list["val"])))
- return 1
-
- if("set_threshold")
- var/env = href_list["env"]
- var/threshold = text2num(href_list["var"])
- var/list/selected = TLV[env]
- var/list/thresholds = list("lower bound", "low warning", "high warning", "upper bound")
- var/newval = input("Enter [thresholds[threshold]] for [env]", "Alarm triggers", selected[threshold]) as null | num
- if(isnull(newval))
- return 1
- if(newval<0)
- selected[threshold] = -1.0
- else if(env=="temperature" && newval>5000)
- selected[threshold] = 5000
- else if(env=="pressure" && newval>50*ONE_ATMOSPHERE)
- selected[threshold] = 50*ONE_ATMOSPHERE
- else if(env!="temperature" && env!="pressure" && newval>200)
- selected[threshold] = 200
- else
- newval = round(newval,0.01)
- selected[threshold] = newval
- if(threshold == 1)
- if(selected[1] > selected[2])
- selected[2] = selected[1]
- if(selected[1] > selected[3])
- selected[3] = selected[1]
- if(selected[1] > selected[4])
- selected[4] = selected[1]
- if(threshold == 2)
- if(selected[1] > selected[2])
- selected[1] = selected[2]
- if(selected[2] > selected[3])
- selected[3] = selected[2]
- if(selected[2] > selected[4])
- selected[4] = selected[2]
- if(threshold == 3)
- if(selected[1] > selected[3])
- selected[1] = selected[3]
- if(selected[2] > selected[3])
- selected[2] = selected[3]
- if(selected[3] > selected[4])
- selected[4] = selected[3]
- if(threshold == 4)
- if(selected[1] > selected[4])
- selected[1] = selected[4]
- if(selected[2] > selected[4])
- selected[2] = selected[4]
- if(selected[3] > selected[4])
- selected[3] = selected[4]
-
- apply_mode()
- return 1
-
- if(href_list["screen"])
- screen = text2num(href_list["screen"])
- return 1
-
- if(href_list["atmos_unlock"])
- switch(href_list["atmos_unlock"])
- if("0")
- alarm_area.firedoors_close()
- if("1")
- alarm_area.firedoors_open()
- return 1
-
- if(href_list["atmos_alarm"])
- if(alarm_area.atmosalert(2, src))
- apply_danger_level(2)
- update_icon()
- return 1
-
- if(href_list["atmos_reset"])
- if(alarm_area.atmosalert(0, src))
- apply_danger_level(0)
- update_icon()
- return 1
-
- if(href_list["mode"])
- mode = text2num(href_list["mode"])
- apply_mode()
- return 1
-
-/obj/machinery/alarm/attackby(obj/item/W as obj, mob/user as mob)
- add_fingerprint(user)
- if(alarm_deconstruction_screwdriver(user, W))
- return
- if(alarm_deconstruction_wirecutters(user, W))
- return
-
- if(istype(W, /obj/item/weapon/card/id) || istype(W, /obj/item/device/pda))// trying to unlock the interface with an ID card
- togglelock()
- return ..()
-
-/obj/machinery/alarm/verb/togglelock(mob/user as mob)
- if(stat & (NOPOWER|BROKEN))
- to_chat(user, "It does nothing.")
- return
- else
- if(allowed(usr) && !wires.IsIndexCut(AALARM_WIRE_IDSCAN))
- locked = !locked
- to_chat(user, "You [locked ? "lock" : "unlock"] the Air Alarm interface.")
- else
- to_chat(user, "Access denied.")
- return
-
-/obj/machinery/alarm/AltClick()
- ..()
- togglelock()
-
-/obj/machinery/alarm/power_change()
- ..()
- spawn(rand(0,15))
- update_icon()
-
-/obj/machinery/alarm/examine(mob/user)
- ..(user)
-/*
-AIR ALARM CIRCUIT
-Just a object used in constructing air alarms
-
-/obj/item/weapon/airalarm_electronics
- name = "air alarm electronics"
- icon = 'icons/obj/doors/door_assembly.dmi'
- icon_state = "door_electronics"
- desc = "Looks like a circuit. Probably is."
- w_class = ITEMSIZE_SMALL
- matter = list(DEFAULT_WALL_MATERIAL = 50, "glass" = 50)
-*/
-/*
-FIRE ALARM
-*/
-/obj/machinery/firealarm
- name = "fire alarm"
- desc = "\"Pull this in case of emergency\". Thus, keep pulling it forever."
- icon = 'icons/obj/monitors.dmi'
- icon_state = "fire0"
- plane = TURF_PLANE
- layer = ABOVE_TURF_LAYER
- var/detecting = 1.0
- var/working = 1.0
- var/time = 10.0
- var/timing = 0.0
- var/lockdownbyai = 0
- anchored = 1.0
- use_power = 1
- idle_power_usage = 2
- active_power_usage = 6
- power_channel = ENVIRON
- var/last_process = 0
- panel_open = 0
- var/seclevel
- circuit = /obj/item/weapon/circuitboard/firealarm
- var/alarms_hidden = FALSE //If the alarms from this machine are visible on consoles
-
-/obj/machinery/firealarm/alarms_hidden
- alarms_hidden = TRUE
-
-/obj/machinery/firealarm/update_icon()
- cut_overlays()
-
- if(panel_open)
- set_light(0)
- return
-
- if(stat & BROKEN)
- icon_state = "firex"
- set_light(0)
- else if(stat & NOPOWER)
- icon_state = "firep"
- set_light(0)
- else
- if(!detecting)
- icon_state = "fire1"
- set_light(l_range = 4, l_power = 0.9, l_color = "#ff0000")
- else
- icon_state = "fire0"
- switch(seclevel)
- if("green") set_light(l_range = 2, l_power = 0.25, l_color = "#00ff00")
- if("yellow") set_light(l_range = 2, l_power = 0.25, l_color = "#ffff00")
- if("violet") set_light(l_range = 2, l_power = 0.25, l_color = "#9933ff")
- if("orange") set_light(l_range = 2, l_power = 0.25, l_color = "#ff9900")
- if("blue") set_light(l_range = 2, l_power = 0.25, l_color = "#1024A9")
- if("red") set_light(l_range = 4, l_power = 0.9, l_color = "#ff0000")
- if("delta") set_light(l_range = 4, l_power = 0.9, l_color = "#FF6633")
- add_overlay("overlay_[seclevel]")
-
-/obj/machinery/firealarm/fire_act(datum/gas_mixture/air, temperature, volume)
- if(detecting)
- if(temperature > T0C + 200)
- alarm() // added check of detector status here
- return
-
-/obj/machinery/firealarm/attack_ai(mob/user as mob)
- return attack_hand(user)
-
-/obj/machinery/firealarm/bullet_act()
- return alarm()
-
-/obj/machinery/firealarm/emp_act(severity)
- if(prob(50 / severity))
- alarm(rand(30 / severity, 60 / severity))
- ..()
-
-/obj/machinery/firealarm/attackby(obj/item/W as obj, mob/user as mob)
- add_fingerprint(user)
-
- if(alarm_deconstruction_screwdriver(user, W))
- return
- if(alarm_deconstruction_wirecutters(user, W))
- return
-
- if(panel_open)
- if(istype(W, /obj/item/device/multitool))
- detecting = !(detecting)
- if(detecting)
- user.visible_message("\The [user] has reconnected [src]'s detecting unit!", "You have reconnected [src]'s detecting unit.")
- else
- user.visible_message("\The [user] has disconnected [src]'s detecting unit!", "You have disconnected [src]'s detecting unit.")
- return
-
- alarm()
- return
-
-/obj/machinery/firealarm/process()//Note: this processing was mostly phased out due to other code, and only runs when needed
- if(stat & (NOPOWER|BROKEN))
- return
-
- if(timing)
- if(time > 0)
- time = time - ((world.timeofday - last_process) / 10)
- else
- alarm()
- time = 0
- timing = 0
- STOP_PROCESSING(SSobj, src)
- updateDialog()
- last_process = world.timeofday
-
- if(locate(/obj/fire) in src.loc)
- alarm()
-
- return
-
-/obj/machinery/firealarm/power_change()
- ..()
- spawn(rand(0,15))
- update_icon()
-
-/obj/machinery/firealarm/attack_hand(mob/user as mob)
- if(user.stat || stat & (NOPOWER | BROKEN))
- return
-
- user.set_machine(src)
- var/area/A = src.loc
- var/d1
- var/d2
- if(istype(user, /mob/living/carbon/human) || istype(user, /mob/living/silicon))
- A = A.loc
-
- if(A.fire)
- d1 = text("Reset - Lockdown", src)
- else
- d1 = text("Alarm - Lockdown", src)
- if(timing)
- d2 = text("Stop Time Lock", src)
- else
- d2 = text("Initiate Time Lock", src)
- var/second = round(time) % 60
- var/minute = (round(time) - second) / 60
- var/dat = "
Fire alarm [d1]\n
The current alert level is: [get_security_level()]
\nTimer System: [d2]
\nTime Left: [(minute ? "[minute]:" : null)][second] - - + +\n"
- user << browse(dat, "window=firealarm")
- onclose(user, "firealarm")
- else
- A = A.loc
- if(A.fire)
- d1 = text("[]", src, stars("Reset - Lockdown"))
- else
- d1 = text("[]", src, stars("Alarm - Lockdown"))
- if(timing)
- d2 = text("[]", src, stars("Stop Time Lock"))
- else
- d2 = text("[]", src, stars("Initiate Time Lock"))
- var/second = round(time) % 60
- var/minute = (round(time) - second) / 60
- var/dat = "[stars("Fire alarm")] [d1]\n
The current alert level is: [stars(get_security_level())]
\nTimer System: [d2]
\nTime Left: [(minute ? text("[]:", minute) : null)][second] - - + +\n"
- user << browse(dat, "window=firealarm")
- onclose(user, "firealarm")
- return
-
-/obj/machinery/firealarm/Topic(href, href_list)
- ..()
- if(usr.stat || stat & (BROKEN | NOPOWER))
- return
-
- if((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon)))
- usr.set_machine(src)
- if(href_list["reset"])
- reset()
- else if(href_list["alarm"])
- alarm()
- else if(href_list["time"])
- timing = text2num(href_list["time"])
- last_process = world.timeofday
- START_PROCESSING(SSobj, src)
- else if(href_list["tp"])
- var/tp = text2num(href_list["tp"])
- time += tp
- time = min(max(round(time), 0), 120)
-
- updateUsrDialog()
-
- add_fingerprint(usr)
- else
- usr << browse(null, "window=firealarm")
- return
- return
-
-/obj/machinery/firealarm/proc/reset()
- if(!(working))
- return
- var/area/area = get_area(src)
- for(var/obj/machinery/firealarm/FA in area)
- fire_alarm.clearAlarm(src.loc, FA)
- update_icon()
- return
-
-/obj/machinery/firealarm/proc/alarm(var/duration = 0)
- if(!(working))
- return
- var/area/area = get_area(src)
- for(var/obj/machinery/firealarm/FA in area)
- fire_alarm.triggerAlarm(loc, FA, duration, hidden = alarms_hidden)
- update_icon()
- playsound(src.loc, 'sound/machines/airalarm.ogg', 25, 0, 4)
- return
-
-/obj/machinery/firealarm/proc/set_security_level(var/newlevel)
- if(seclevel != newlevel)
- seclevel = newlevel
- update_icon()
-
-/obj/machinery/firealarm/Initialize()
- . = ..()
- if(z in using_map.contact_levels)
- set_security_level(security_level? get_security_level() : "green")
-
-/*
-FIRE ALARM CIRCUIT
-Just a object used in constructing fire alarms
-
-/obj/item/weapon/firealarm_electronics
- name = "fire alarm electronics"
- icon = 'icons/obj/doors/door_assembly.dmi'
- icon_state = "door_electronics"
- desc = "A circuit. It has a label on it, it says \"Can handle heat levels up to 40 degrees celsius!\""
- w_class = ITEMSIZE_SMALL
- matter = list(DEFAULT_WALL_MATERIAL = 50, "glass" = 50)
-*/
-/obj/machinery/partyalarm
- name = "\improper PARTY BUTTON"
- desc = "Cuban Pete is in the house!"
- icon = 'icons/obj/monitors.dmi'
- icon_state = "fire0"
- var/detecting = 1.0
- var/working = 1.0
- var/time = 10.0
- var/timing = 0.0
- var/lockdownbyai = 0
- anchored = 1.0
- use_power = 1
- idle_power_usage = 2
- active_power_usage = 6
-
-/obj/machinery/partyalarm/attack_hand(mob/user as mob)
- if(user.stat || stat & (NOPOWER|BROKEN))
- return
-
- user.machine = src
- var/area/A = get_area(src)
- ASSERT(isarea(A))
- var/d1
- var/d2
- if(istype(user, /mob/living/carbon/human) || istype(user, /mob/living/silicon/ai))
-
- if(A.party)
- d1 = text("No Party :(", src)
- else
- d1 = text("PARTY!!!", src)
- if(timing)
- d2 = text("Stop Time Lock", src)
- else
- d2 = text("Initiate Time Lock", src)
- var/second = time % 60
- var/minute = (time - second) / 60
- var/dat = text("Party Button []\n
\nTimer System: []
\nTime Left: [][] - - + +\n", d1, d2, (minute ? text("[]:", minute) : null), second, src, src, src, src)
- user << browse(dat, "window=partyalarm")
- onclose(user, "partyalarm")
- else
- if(A.fire)
- d1 = text("[]", src, stars("No Party :("))
- else
- d1 = text("[]", src, stars("PARTY!!!"))
- if(timing)
- d2 = text("[]", src, stars("Stop Time Lock"))
- else
- d2 = text("[]", src, stars("Initiate Time Lock"))
- var/second = time % 60
- var/minute = (time - second) / 60
- var/dat = text("[] []\n
\nTimer System: []
\nTime Left: [][] - - + +\n", stars("Party Button"), d1, d2, (minute ? text("[]:", minute) : null), second, src, src, src, src)
- user << browse(dat, "window=partyalarm")
- onclose(user, "partyalarm")
- return
-
-/obj/machinery/partyalarm/proc/reset()
- if(!(working))
- return
- var/area/A = get_area(src)
- ASSERT(isarea(A))
- A.partyreset()
- return
-
-/obj/machinery/partyalarm/proc/alarm()
- if(!(working))
- return
- var/area/A = get_area(src)
- ASSERT(isarea(A))
- A.partyalert()
- return
-
-/obj/machinery/partyalarm/Topic(href, href_list)
- ..()
- if(usr.stat || stat & (BROKEN|NOPOWER))
- return
- if((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(loc, /turf))) || (istype(usr, /mob/living/silicon/ai)))
- usr.machine = src
- if(href_list["reset"])
- reset()
- else if(href_list["alarm"])
- alarm()
- else if(href_list["time"])
- timing = text2num(href_list["time"])
- else if(href_list["tp"])
- var/tp = text2num(href_list["tp"])
- time += tp
- time = min(max(round(time), 0), 120)
- updateUsrDialog()
-
- add_fingerprint(usr)
- else
- usr << browse(null, "window=partyalarm")
- return
- return
+#define AALARM_MODE_SCRUBBING 1
+#define AALARM_MODE_REPLACEMENT 2 //like scrubbing, but faster.
+#define AALARM_MODE_PANIC 3 //constantly sucks all air
+#define AALARM_MODE_CYCLE 4 //sucks off all air, then refill and switches to scrubbing
+#define AALARM_MODE_FILL 5 //emergency fill
+#define AALARM_MODE_OFF 6 //Shuts it all down.
+
+#define AALARM_SCREEN_MAIN 1
+#define AALARM_SCREEN_VENT 2
+#define AALARM_SCREEN_SCRUB 3
+#define AALARM_SCREEN_MODE 4
+#define AALARM_SCREEN_SENSORS 5
+
+#define AALARM_REPORT_TIMEOUT 100
+
+#define MAX_TEMPERATURE 90
+#define MIN_TEMPERATURE -40
+
+//all air alarms in area are connected via magic
+/area
+ var/obj/machinery/alarm/master_air_alarm
+ var/list/air_vent_names = list()
+ var/list/air_scrub_names = list()
+ var/list/air_vent_info = list()
+ var/list/air_scrub_info = list()
+
+/obj/machinery/alarm
+ name = "alarm"
+ desc = "Used to control various station atmospheric systems. The light indicates the current air status of the area."
+ icon = 'icons/obj/monitors.dmi'
+ icon_state = "alarm0"
+ plane = TURF_PLANE
+ layer = ABOVE_TURF_LAYER
+ anchored = 1
+ use_power = 1
+ idle_power_usage = 80
+ active_power_usage = 1000 //For heating/cooling rooms. 1000 joules equates to about 1 degree every 2 seconds for a single tile of air.
+ power_channel = ENVIRON
+ req_one_access = list(access_atmospherics, access_engine_equip)
+ clicksound = "button"
+ clickvol = 30
+ var/alarm_id = null
+ var/breach_detection = 1 // Whether to use automatic breach detection or not
+ var/frequency = 1439
+ //var/skipprocess = 0 //Experimenting
+ var/alarm_frequency = 1437
+ var/remote_control = 0
+ var/rcon_setting = 2
+ var/rcon_time = 0
+ var/locked = 1
+ panel_open = 0 // If it's been screwdrivered open.
+ var/aidisabled = 0
+ var/shorted = 0
+ circuit = /obj/item/weapon/circuitboard/airalarm
+
+ var/datum/wires/alarm/wires
+
+ var/mode = AALARM_MODE_SCRUBBING
+ var/screen = AALARM_SCREEN_MAIN
+ var/area_uid
+ var/area/alarm_area
+
+ var/target_temperature = T0C+20
+ var/regulating_temperature = 0
+
+ var/datum/radio_frequency/radio_connection
+
+ var/list/TLV = list()
+ var/list/trace_gas = list("sleeping_agent", "volatile_fuel") //list of other gases that this air alarm is able to detect
+
+ var/danger_level = 0
+ var/pressure_dangerlevel = 0
+ var/oxygen_dangerlevel = 0
+ var/co2_dangerlevel = 0
+ var/phoron_dangerlevel = 0
+ var/temperature_dangerlevel = 0
+ var/other_dangerlevel = 0
+
+ var/report_danger_level = 1
+
+ var/alarms_hidden = FALSE //If the alarms from this machine are visible on consoles
+
+/obj/machinery/alarm/nobreach
+ breach_detection = 0
+
+/obj/machinery/alarm/monitor
+ report_danger_level = 0
+ breach_detection = 0
+
+/obj/machinery/alarm/alarms_hidden
+ alarms_hidden = TRUE
+
+/obj/machinery/alarm/server/Initialize(mapload)
+ . = ..()
+ req_access = list(access_rd, access_atmospherics, access_engine_equip)
+ TLV["oxygen"] = list(-1.0, -1.0,-1.0,-1.0) // Partial pressure, kpa
+ TLV["carbon dioxide"] = list(-1.0, -1.0, 5, 10) // Partial pressure, kpa
+ TLV["phoron"] = list(-1.0, -1.0, 0, 0.5) // Partial pressure, kpa
+ TLV["other"] = list(-1.0, -1.0, 0.5, 1.0) // Partial pressure, kpa
+ TLV["pressure"] = list(0,ONE_ATMOSPHERE*0.10,ONE_ATMOSPHERE*1.40,ONE_ATMOSPHERE*1.60) /* kpa */
+ TLV["temperature"] = list(20, 40, 140, 160) // K
+ target_temperature = 90
+
+/obj/machinery/alarm/Initialize(mapload)
+ . = ..()
+ first_run()
+
+/obj/machinery/alarm/Destroy()
+ unregister_radio(src, frequency)
+ qdel(wires)
+ wires = null
+ if(alarm_area && alarm_area.master_air_alarm == src)
+ alarm_area.master_air_alarm = null
+ elect_master(exclude_self = TRUE)
+ return ..()
+
+/obj/machinery/alarm/proc/first_run()
+ alarm_area = get_area(src)
+ area_uid = alarm_area.uid
+ if(name == "alarm")
+ name = "[alarm_area.name] Air Alarm"
+
+ if(!wires)
+ wires = new(src)
+
+ // breathable air according to human/Life()
+ TLV["oxygen"] = list(16, 19, 135, 140) // Partial pressure, kpa
+ TLV["carbon dioxide"] = list(-1.0, -1.0, 5, 10) // Partial pressure, kpa
+ TLV["phoron"] = list(-1.0, -1.0, 0, 0.5) // Partial pressure, kpa
+ TLV["other"] = list(-1.0, -1.0, 0.5, 1.0) // Partial pressure, kpa
+ TLV["pressure"] = list(ONE_ATMOSPHERE * 0.80, ONE_ATMOSPHERE * 0.90, ONE_ATMOSPHERE * 1.10, ONE_ATMOSPHERE * 1.20) /* kpa */
+ TLV["temperature"] = list(T0C - 26, T0C, T0C + 40, T0C + 66) // K
+
+
+/obj/machinery/alarm/Initialize()
+ . = ..()
+ set_frequency(frequency)
+ if(!master_is_operating())
+ elect_master()
+
+/obj/machinery/alarm/process()
+ if((stat & (NOPOWER|BROKEN)) || shorted)
+ return
+
+ var/turf/simulated/location = src.loc
+ if(!istype(location)) return//returns if loc is not simulated
+
+ var/datum/gas_mixture/environment = location.return_air()
+
+ //Handle temperature adjustment here.
+ handle_heating_cooling(environment)
+
+ var/old_level = danger_level
+ var/old_pressurelevel = pressure_dangerlevel
+ danger_level = overall_danger_level(environment)
+
+ if(old_level != danger_level)
+ apply_danger_level(danger_level)
+
+ if(old_pressurelevel != pressure_dangerlevel)
+ if(breach_detected())
+ mode = AALARM_MODE_OFF
+ apply_mode()
+
+ if(mode == AALARM_MODE_CYCLE && environment.return_pressure() < ONE_ATMOSPHERE * 0.05)
+ mode = AALARM_MODE_FILL
+ apply_mode()
+
+ //atmos computer remote controll stuff
+ switch(rcon_setting)
+ if(RCON_NO)
+ remote_control = 0
+ if(RCON_AUTO)
+ if(danger_level == 2)
+ remote_control = 1
+ else
+ remote_control = 0
+ if(RCON_YES)
+ remote_control = 1
+
+ return
+
+/obj/machinery/alarm/proc/handle_heating_cooling(var/datum/gas_mixture/environment)
+ if(!regulating_temperature)
+ //check for when we should start adjusting temperature
+ if(!get_danger_level(target_temperature, TLV["temperature"]) && abs(environment.temperature - target_temperature) > 2.0)
+ update_use_power(2)
+ regulating_temperature = 1
+ audible_message("\The [src] clicks as it starts [environment.temperature > target_temperature ? "cooling" : "heating"] the room.",\
+ "You hear a click and a faint electronic hum.")
+ playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
+ else
+ //check for when we should stop adjusting temperature
+ if(get_danger_level(target_temperature, TLV["temperature"]) || abs(environment.temperature - target_temperature) <= 0.5)
+ update_use_power(1)
+ regulating_temperature = 0
+ audible_message("\The [src] clicks quietly as it stops [environment.temperature > target_temperature ? "cooling" : "heating"] the room.",\
+ "You hear a click as a faint electronic humming stops.")
+ playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
+
+ if(regulating_temperature)
+ if(target_temperature > T0C + MAX_TEMPERATURE)
+ target_temperature = T0C + MAX_TEMPERATURE
+
+ if(target_temperature < T0C + MIN_TEMPERATURE)
+ target_temperature = T0C + MIN_TEMPERATURE
+
+ var/datum/gas_mixture/gas
+ gas = environment.remove(0.25 * environment.total_moles)
+ if(gas)
+
+ if(gas.temperature <= target_temperature) //gas heating
+ var/energy_used = min(gas.get_thermal_energy_change(target_temperature) , active_power_usage)
+
+ gas.add_thermal_energy(energy_used)
+ //use_power(energy_used, ENVIRON) //handle by update_use_power instead
+ else //gas cooling
+ var/heat_transfer = min(abs(gas.get_thermal_energy_change(target_temperature)), active_power_usage)
+
+ //Assume the heat is being pumped into the hull which is fixed at 20 C
+ //none of this is really proper thermodynamics but whatever
+
+ var/cop = gas.temperature / T20C //coefficient of performance -> power used = heat_transfer/cop
+
+ heat_transfer = min(heat_transfer, cop * active_power_usage) //this ensures that we don't use more than active_power_usage amount of power
+
+ heat_transfer = -gas.add_thermal_energy(-heat_transfer) //get the actual heat transfer
+
+ //use_power(heat_transfer / cop, ENVIRON) //handle by update_use_power instead
+
+ environment.merge(gas)
+
+/obj/machinery/alarm/proc/overall_danger_level(var/datum/gas_mixture/environment)
+ var/partial_pressure = R_IDEAL_GAS_EQUATION * environment.temperature/environment.volume
+ var/environment_pressure = environment.return_pressure()
+
+ var/other_moles = 0
+ for(var/g in trace_gas)
+ other_moles += environment.gas[g] //this is only going to be used in a partial pressure calc, so we don't need to worry about group_multiplier here.
+
+ pressure_dangerlevel = get_danger_level(environment_pressure, TLV["pressure"])
+ oxygen_dangerlevel = get_danger_level(environment.gas["oxygen"]*partial_pressure, TLV["oxygen"])
+ co2_dangerlevel = get_danger_level(environment.gas["carbon_dioxide"]*partial_pressure, TLV["carbon dioxide"])
+ phoron_dangerlevel = get_danger_level(environment.gas["phoron"]*partial_pressure, TLV["phoron"])
+ temperature_dangerlevel = get_danger_level(environment.temperature, TLV["temperature"])
+ other_dangerlevel = get_danger_level(other_moles*partial_pressure, TLV["other"])
+
+ return max(
+ pressure_dangerlevel,
+ oxygen_dangerlevel,
+ co2_dangerlevel,
+ phoron_dangerlevel,
+ other_dangerlevel,
+ temperature_dangerlevel
+ )
+
+// Returns whether this air alarm thinks there is a breach, given the sensors that are available to it.
+/obj/machinery/alarm/proc/breach_detected()
+ var/turf/simulated/location = src.loc
+
+ if(!istype(location))
+ return 0
+
+ if(breach_detection == 0)
+ return 0
+
+ var/datum/gas_mixture/environment = location.return_air()
+ var/environment_pressure = environment.return_pressure()
+ var/pressure_levels = TLV["pressure"]
+
+ if(environment_pressure <= pressure_levels[1]) //low pressures
+ if(!(mode == AALARM_MODE_PANIC || mode == AALARM_MODE_CYCLE))
+ playsound(src.loc, 'sound/machines/airalarm.ogg', 25, 0, 4)
+ return 1
+
+ return 0
+
+/obj/machinery/alarm/proc/master_is_operating()
+ return alarm_area && alarm_area.master_air_alarm && !(alarm_area.master_air_alarm.stat & (NOPOWER | BROKEN))
+
+/obj/machinery/alarm/proc/elect_master(exclude_self = FALSE)
+ for(var/obj/machinery/alarm/AA in alarm_area)
+ if(exclude_self && AA == src)
+ continue
+ if(!(AA.stat & (NOPOWER|BROKEN)))
+ alarm_area.master_air_alarm = AA
+ return 1
+ return 0
+
+/obj/machinery/alarm/proc/get_danger_level(var/current_value, var/list/danger_levels)
+ if((current_value >= danger_levels[4] && danger_levels[4] > 0) || current_value <= danger_levels[1])
+ return 2
+ if((current_value >= danger_levels[3] && danger_levels[3] > 0) || current_value <= danger_levels[2])
+ return 1
+ return 0
+
+/obj/machinery/alarm/update_icon()
+ if(panel_open)
+ icon_state = "alarmx"
+ set_light(0)
+ return
+ if((stat & (NOPOWER|BROKEN)) || shorted)
+ icon_state = "alarmp"
+ set_light(0)
+ return
+
+ var/icon_level = danger_level
+ if(alarm_area?.atmosalm)
+ icon_level = max(icon_level, 1) //if there's an atmos alarm but everything is okay locally, no need to go past yellow
+
+ var/new_color = null
+ switch(icon_level)
+ if(0)
+ icon_state = "alarm0"
+ new_color = "#03A728"
+ if(1)
+ icon_state = "alarm2" //yes, alarm2 is yellow alarm
+ new_color = "#EC8B2F"
+ if(2)
+ icon_state = "alarm1"
+ new_color = "#DA0205"
+
+ set_light(l_range = 2, l_power = 0.25, l_color = new_color)
+
+/obj/machinery/alarm/receive_signal(datum/signal/signal)
+ if(stat & (NOPOWER|BROKEN))
+ return
+ if(alarm_area.master_air_alarm != src)
+ if(master_is_operating())
+ return
+ elect_master()
+ if(alarm_area.master_air_alarm != src)
+ return
+ if(!signal || signal.encryption)
+ return
+ var/id_tag = signal.data["tag"]
+ if(!id_tag)
+ return
+ if(signal.data["area"] != area_uid)
+ return
+ if(signal.data["sigtype"] != "status")
+ return
+
+ var/dev_type = signal.data["device"]
+ if(!(id_tag in alarm_area.air_scrub_names) && !(id_tag in alarm_area.air_vent_names))
+ register_env_machine(id_tag, dev_type)
+ if(dev_type == "AScr")
+ alarm_area.air_scrub_info[id_tag] = signal.data
+ else if(dev_type == "AVP")
+ alarm_area.air_vent_info[id_tag] = signal.data
+
+/obj/machinery/alarm/proc/register_env_machine(var/m_id, var/device_type)
+ var/new_name
+ if(device_type == "AVP")
+ new_name = "[alarm_area.name] Vent Pump #[alarm_area.air_vent_names.len+1]"
+ alarm_area.air_vent_names[m_id] = new_name
+ else if(device_type == "AScr")
+ new_name = "[alarm_area.name] Air Scrubber #[alarm_area.air_scrub_names.len+1]"
+ alarm_area.air_scrub_names[m_id] = new_name
+ else
+ return
+ spawn(10)
+ send_signal(m_id, list("init" = new_name))
+
+/obj/machinery/alarm/proc/refresh_all()
+ for(var/id_tag in alarm_area.air_vent_names)
+ var/list/I = alarm_area.air_vent_info[id_tag]
+ if(I && I["timestamp"] + AALARM_REPORT_TIMEOUT / 2 > world.time)
+ continue
+ send_signal(id_tag, list("status"))
+ for(var/id_tag in alarm_area.air_scrub_names)
+ var/list/I = alarm_area.air_scrub_info[id_tag]
+ if(I && I["timestamp"] + AALARM_REPORT_TIMEOUT / 2 > world.time)
+ continue
+ send_signal(id_tag, list("status"))
+
+/obj/machinery/alarm/proc/set_frequency(new_frequency)
+ radio_controller.remove_object(src, frequency)
+ frequency = new_frequency
+ radio_connection = radio_controller.add_object(src, frequency, RADIO_TO_AIRALARM)
+
+/obj/machinery/alarm/proc/send_signal(var/target, var/list/command)//sends signal 'command' to 'target'. Returns 0 if no radio connection, 1 otherwise
+ if(!radio_connection)
+ return 0
+
+ var/datum/signal/signal = new
+ signal.transmission_method = 1 //radio signal
+ signal.source = src
+
+ signal.data = command
+ signal.data["tag"] = target
+ signal.data["sigtype"] = "command"
+
+ radio_connection.post_signal(src, signal, RADIO_FROM_AIRALARM)
+// to_world("Signal [command] Broadcasted to [target]")
+
+ return 1
+
+/obj/machinery/alarm/proc/apply_mode()
+ //propagate mode to other air alarms in the area
+ //TODO: make it so that players can choose between applying the new mode to the room they are in (related area) vs the entire alarm area
+ for(var/obj/machinery/alarm/AA in alarm_area)
+ AA.mode = mode
+
+ switch(mode)
+ if(AALARM_MODE_SCRUBBING)
+ for(var/device_id in alarm_area.air_scrub_names)
+ send_signal(device_id, list("power"= 1, "co2_scrub"= 1, "scrubbing"= 1, "panic_siphon"= 0))
+ for(var/device_id in alarm_area.air_vent_names)
+ send_signal(device_id, list("power"= 1, "checks"= "default", "set_external_pressure"= "default"))
+
+ if(AALARM_MODE_PANIC, AALARM_MODE_CYCLE)
+ for(var/device_id in alarm_area.air_scrub_names)
+ send_signal(device_id, list("power"= 1, "panic_siphon"= 1))
+ for(var/device_id in alarm_area.air_vent_names)
+ send_signal(device_id, list("power"= 0))
+
+ if(AALARM_MODE_REPLACEMENT)
+ for(var/device_id in alarm_area.air_scrub_names)
+ send_signal(device_id, list("power"= 1, "panic_siphon"= 1))
+ for(var/device_id in alarm_area.air_vent_names)
+ send_signal(device_id, list("power"= 1, "checks"= "default", "set_external_pressure"= "default"))
+
+ if(AALARM_MODE_FILL)
+ for(var/device_id in alarm_area.air_scrub_names)
+ send_signal(device_id, list("power"= 0))
+ for(var/device_id in alarm_area.air_vent_names)
+ send_signal(device_id, list("power"= 1, "checks"= "default", "set_external_pressure"= "default"))
+
+ if(AALARM_MODE_OFF)
+ for(var/device_id in alarm_area.air_scrub_names)
+ send_signal(device_id, list("power"= 0))
+ for(var/device_id in alarm_area.air_vent_names)
+ send_signal(device_id, list("power"= 0))
+
+/obj/machinery/alarm/proc/apply_danger_level(var/new_danger_level)
+ if(report_danger_level && alarm_area.atmosalert(new_danger_level, src))
+ post_alert(new_danger_level)
+
+ update_icon()
+
+/obj/machinery/alarm/proc/post_alert(alert_level)
+ var/datum/radio_frequency/frequency = radio_controller.return_frequency(alarm_frequency)
+ if(!frequency)
+ return
+
+ var/datum/signal/alert_signal = new
+ alert_signal.source = src
+ alert_signal.transmission_method = 1
+ alert_signal.data["zone"] = alarm_area.name
+ alert_signal.data["type"] = "Atmospheric"
+
+ if(alert_level==2)
+ alert_signal.data["alert"] = "severe"
+ else if(alert_level==1)
+ alert_signal.data["alert"] = "minor"
+ else if(alert_level==0)
+ alert_signal.data["alert"] = "clear"
+
+ frequency.post_signal(src, alert_signal)
+
+/obj/machinery/alarm/attack_ai(mob/user)
+ ui_interact(user)
+
+/obj/machinery/alarm/attack_hand(mob/user)
+ . = ..()
+ if(.)
+ return
+ return interact(user)
+
+/obj/machinery/alarm/interact(mob/user)
+ ui_interact(user)
+ wires.Interact(user)
+
+/obj/machinery/alarm/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
+ var/data[0]
+ var/remote_connection = 0
+ var/remote_access = 0
+ if(state)
+ var/list/href = state.href_list(user)
+ remote_connection = href["remote_connection"] // Remote connection means we're non-adjacent/connecting from another computer
+ remote_access = href["remote_access"] // Remote access means we also have the privilege to alter the air alarm.
+
+ data["locked"] = locked && !issilicon(user)
+ data["remote_connection"] = remote_connection
+ data["remote_access"] = remote_access
+ data["rcon"] = rcon_setting
+ data["screen"] = screen
+
+ populate_status(data)
+
+ if(!(locked && !remote_connection) || remote_access || issilicon(user))
+ populate_controls(data)
+
+ ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
+ if(!ui)
+ ui = new(user, src, ui_key, "air_alarm.tmpl", name, 325, 625, master_ui = master_ui, state = state)
+ ui.set_initial_data(data)
+ ui.open()
+ ui.set_auto_update(1)
+
+/obj/machinery/alarm/proc/populate_status(var/data)
+ var/turf/location = get_turf(src)
+ var/datum/gas_mixture/environment = location.return_air()
+ var/total = environment.total_moles
+
+ var/list/environment_data = new
+ data["has_environment"] = total
+ if(total)
+ var/pressure = environment.return_pressure()
+ environment_data[++environment_data.len] = list("name" = "Pressure", "value" = pressure, "unit" = "kPa", "danger_level" = pressure_dangerlevel)
+ environment_data[++environment_data.len] = list("name" = "Oxygen", "value" = environment.gas["oxygen"] / total * 100, "unit" = "%", "danger_level" = oxygen_dangerlevel)
+ environment_data[++environment_data.len] = list("name" = "Carbon dioxide", "value" = environment.gas["carbon_dioxide"] / total * 100, "unit" = "%", "danger_level" = co2_dangerlevel)
+ environment_data[++environment_data.len] = list("name" = "Toxins", "value" = environment.gas["phoron"] / total * 100, "unit" = "%", "danger_level" = phoron_dangerlevel)
+ environment_data[++environment_data.len] = list("name" = "Temperature", "value" = environment.temperature, "unit" = "K ([round(environment.temperature - T0C, 0.1)]C)", "danger_level" = temperature_dangerlevel)
+ data["total_danger"] = danger_level
+ data["environment"] = environment_data
+ data["atmos_alarm"] = alarm_area.atmosalm
+ data["fire_alarm"] = alarm_area.fire != null
+ data["target_temperature"] = "[target_temperature - T0C]C"
+
+/obj/machinery/alarm/proc/populate_controls(var/list/data)
+ switch(screen)
+ if(AALARM_SCREEN_MAIN)
+ data["mode"] = mode
+ if(AALARM_SCREEN_VENT)
+ var/vents[0]
+ for(var/id_tag in alarm_area.air_vent_names)
+ var/long_name = alarm_area.air_vent_names[id_tag]
+ var/list/info = alarm_area.air_vent_info[id_tag]
+ if(!info)
+ continue
+ vents[++vents.len] = list(
+ "id_tag" = id_tag,
+ "long_name" = sanitize(long_name),
+ "power" = info["power"],
+ "checks" = info["checks"],
+ "direction" = info["direction"],
+ "external" = info["external"]
+ )
+ data["vents"] = vents
+ if(AALARM_SCREEN_SCRUB)
+ var/scrubbers[0]
+ for(var/id_tag in alarm_area.air_scrub_names)
+ var/long_name = alarm_area.air_scrub_names[id_tag]
+ var/list/info = alarm_area.air_scrub_info[id_tag]
+ if(!info)
+ continue
+ scrubbers[++scrubbers.len] = list(
+ "id_tag" = id_tag,
+ "long_name" = sanitize(long_name),
+ "power" = info["power"],
+ "scrubbing" = info["scrubbing"],
+ "panic" = info["panic"],
+ "filters" = list()
+ )
+ scrubbers[scrubbers.len]["filters"] += list(list("name" = "Oxygen", "command" = "o2_scrub", "val" = info["filter_o2"]))
+ scrubbers[scrubbers.len]["filters"] += list(list("name" = "Nitrogen", "command" = "n2_scrub", "val" = info["filter_n2"]))
+ scrubbers[scrubbers.len]["filters"] += list(list("name" = "Carbon Dioxide", "command" = "co2_scrub","val" = info["filter_co2"]))
+ scrubbers[scrubbers.len]["filters"] += list(list("name" = "Toxin" , "command" = "tox_scrub","val" = info["filter_phoron"]))
+ scrubbers[scrubbers.len]["filters"] += list(list("name" = "Nitrous Oxide", "command" = "n2o_scrub","val" = info["filter_n2o"]))
+ scrubbers[scrubbers.len]["filters"] += list(list("name" = "Fuel", "command" = "fuel_scrub","val" = info["filter_fuel"]))
+ data["scrubbers"] = scrubbers
+ if(AALARM_SCREEN_MODE)
+ var/modes[0]
+ modes[++modes.len] = list("name" = "Filtering - Scrubs out contaminants", "mode" = AALARM_MODE_SCRUBBING, "selected" = mode == AALARM_MODE_SCRUBBING, "danger" = 0)
+ modes[++modes.len] = list("name" = "Replace Air - Siphons out air while replacing", "mode" = AALARM_MODE_REPLACEMENT, "selected" = mode == AALARM_MODE_REPLACEMENT, "danger" = 0)
+ modes[++modes.len] = list("name" = "Panic - Siphons air out of the room", "mode" = AALARM_MODE_PANIC, "selected" = mode == AALARM_MODE_PANIC, "danger" = 1)
+ modes[++modes.len] = list("name" = "Cycle - Siphons air before replacing", "mode" = AALARM_MODE_CYCLE, "selected" = mode == AALARM_MODE_CYCLE, "danger" = 1)
+ modes[++modes.len] = list("name" = "Fill - Shuts off scrubbers and opens vents", "mode" = AALARM_MODE_FILL, "selected" = mode == AALARM_MODE_FILL, "danger" = 0)
+ modes[++modes.len] = list("name" = "Off - Shuts off vents and scrubbers", "mode" = AALARM_MODE_OFF, "selected" = mode == AALARM_MODE_OFF, "danger" = 0)
+ data["modes"] = modes
+ data["mode"] = mode
+ if(AALARM_SCREEN_SENSORS)
+ var/list/selected
+ var/thresholds[0]
+
+ var/list/gas_names = list(
+ "oxygen" = "O2",
+ "carbon dioxide" = "CO2",
+ "phoron" = "Toxin",
+ "other" = "Other")
+ for(var/g in gas_names)
+ thresholds[++thresholds.len] = list("name" = gas_names[g], "settings" = list())
+ selected = TLV[g]
+ for(var/i = 1, i <= 4, i++)
+ thresholds[thresholds.len]["settings"] += list(list("env" = g, "val" = i, "selected" = selected[i]))
+
+ selected = TLV["pressure"]
+ thresholds[++thresholds.len] = list("name" = "Pressure", "settings" = list())
+ for(var/i = 1, i <= 4, i++)
+ thresholds[thresholds.len]["settings"] += list(list("env" = "pressure", "val" = i, "selected" = selected[i]))
+
+ selected = TLV["temperature"]
+ thresholds[++thresholds.len] = list("name" = "Temperature", "settings" = list())
+ for(var/i = 1, i <= 4, i++)
+ thresholds[thresholds.len]["settings"] += list(list("env" = "temperature", "val" = i, "selected" = selected[i]))
+
+ data["thresholds"] = thresholds
+
+/obj/machinery/alarm/CanUseTopic(var/mob/user, var/datum/topic_state/state, var/href_list = list())
+ if(aidisabled && isAI(user))
+ to_chat(user, "AI control for \the [src] interface has been disabled.")
+ return STATUS_CLOSE
+
+ . = shorted ? STATUS_DISABLED : STATUS_INTERACTIVE
+
+ if(. == STATUS_INTERACTIVE)
+ var/extra_href = state.href_list(usr)
+ // Prevent remote users from altering RCON settings unless they already have access
+ if(href_list["rcon"] && extra_href["remote_connection"] && !extra_href["remote_access"])
+ . = STATUS_UPDATE
+
+ return min(..(), .)
+
+/obj/machinery/alarm/Topic(href, href_list, var/datum/topic_state/state)
+ if(..(href, href_list, state))
+ return 1
+
+ // hrefs that can always be called -walter0o
+ if(href_list["rcon"])
+ var/attempted_rcon_setting = text2num(href_list["rcon"])
+
+ switch(attempted_rcon_setting)
+ if(RCON_NO)
+ rcon_setting = RCON_NO
+ if(RCON_AUTO)
+ rcon_setting = RCON_AUTO
+ if(RCON_YES)
+ rcon_setting = RCON_YES
+ return 1
+
+ if(href_list["temperature"])
+ var/list/selected = TLV["temperature"]
+ var/max_temperature = min(selected[3] - T0C, MAX_TEMPERATURE)
+ var/min_temperature = max(selected[2] - T0C, MIN_TEMPERATURE)
+ var/input_temperature = input("What temperature would you like the system to mantain? (Capped between [min_temperature] and [max_temperature]C)", "Thermostat Controls", target_temperature - T0C) as num|null
+ if(isnum(input_temperature))
+ if(input_temperature > max_temperature || input_temperature < min_temperature)
+ to_chat(usr, "Temperature must be between [min_temperature]C and [max_temperature]C")
+ else
+ target_temperature = input_temperature + T0C
+ return 1
+
+ // hrefs that need the AA unlocked -walter0o
+ var/extra_href = state.href_list(usr)
+ if(!(locked && !extra_href["remote_connection"]) || extra_href["remote_access"] || issilicon(usr))
+ if(href_list["command"])
+ var/device_id = href_list["id_tag"]
+ switch(href_list["command"])
+ if("set_external_pressure")
+ var/input_pressure = input("What pressure you like the system to mantain?", "Pressure Controls") as num|null
+ if(isnum(input_pressure))
+ send_signal(device_id, list(href_list["command"] = input_pressure))
+ return 1
+
+ if("reset_external_pressure")
+ send_signal(device_id, list(href_list["command"] = ONE_ATMOSPHERE))
+ return 1
+
+ if( "power",
+ "adjust_external_pressure",
+ "checks",
+ "o2_scrub",
+ "n2_scrub",
+ "co2_scrub",
+ "tox_scrub",
+ "n2o_scrub",
+ "fuel_scrub",
+ "panic_siphon",
+ "scrubbing",
+ "direction")
+
+ send_signal(device_id, list(href_list["command"] = text2num(href_list["val"])))
+ return 1
+
+ if("set_threshold")
+ var/env = href_list["env"]
+ var/threshold = text2num(href_list["var"])
+ var/list/selected = TLV[env]
+ var/list/thresholds = list("lower bound", "low warning", "high warning", "upper bound")
+ var/newval = input("Enter [thresholds[threshold]] for [env]", "Alarm triggers", selected[threshold]) as null | num
+ if(isnull(newval))
+ return 1
+ if(newval<0)
+ selected[threshold] = -1.0
+ else if(env=="temperature" && newval>5000)
+ selected[threshold] = 5000
+ else if(env=="pressure" && newval>50*ONE_ATMOSPHERE)
+ selected[threshold] = 50*ONE_ATMOSPHERE
+ else if(env!="temperature" && env!="pressure" && newval>200)
+ selected[threshold] = 200
+ else
+ newval = round(newval,0.01)
+ selected[threshold] = newval
+ if(threshold == 1)
+ if(selected[1] > selected[2])
+ selected[2] = selected[1]
+ if(selected[1] > selected[3])
+ selected[3] = selected[1]
+ if(selected[1] > selected[4])
+ selected[4] = selected[1]
+ if(threshold == 2)
+ if(selected[1] > selected[2])
+ selected[1] = selected[2]
+ if(selected[2] > selected[3])
+ selected[3] = selected[2]
+ if(selected[2] > selected[4])
+ selected[4] = selected[2]
+ if(threshold == 3)
+ if(selected[1] > selected[3])
+ selected[1] = selected[3]
+ if(selected[2] > selected[3])
+ selected[2] = selected[3]
+ if(selected[3] > selected[4])
+ selected[4] = selected[3]
+ if(threshold == 4)
+ if(selected[1] > selected[4])
+ selected[1] = selected[4]
+ if(selected[2] > selected[4])
+ selected[2] = selected[4]
+ if(selected[3] > selected[4])
+ selected[3] = selected[4]
+
+ apply_mode()
+ return 1
+
+ if(href_list["screen"])
+ screen = text2num(href_list["screen"])
+ return 1
+
+ if(href_list["atmos_unlock"])
+ switch(href_list["atmos_unlock"])
+ if("0")
+ alarm_area.firedoors_close()
+ if("1")
+ alarm_area.firedoors_open()
+ return 1
+
+ if(href_list["atmos_alarm"])
+ if(alarm_area.atmosalert(2, src))
+ apply_danger_level(2)
+ update_icon()
+ return 1
+
+ if(href_list["atmos_reset"])
+ if(alarm_area.atmosalert(0, src))
+ apply_danger_level(0)
+ update_icon()
+ return 1
+
+ if(href_list["mode"])
+ mode = text2num(href_list["mode"])
+ apply_mode()
+ return 1
+
+/obj/machinery/alarm/attackby(obj/item/W as obj, mob/user as mob)
+ add_fingerprint(user)
+ if(alarm_deconstruction_screwdriver(user, W))
+ return
+ if(alarm_deconstruction_wirecutters(user, W))
+ return
+
+ if(istype(W, /obj/item/weapon/card/id) || istype(W, /obj/item/device/pda))// trying to unlock the interface with an ID card
+ togglelock()
+ return ..()
+
+/obj/machinery/alarm/verb/togglelock(mob/user as mob)
+ if(stat & (NOPOWER|BROKEN))
+ to_chat(user, "It does nothing.")
+ return
+ else
+ if(allowed(usr) && !wires.IsIndexCut(AALARM_WIRE_IDSCAN))
+ locked = !locked
+ to_chat(user, "You [locked ? "lock" : "unlock"] the Air Alarm interface.")
+ else
+ to_chat(user, "Access denied.")
+ return
+
+/obj/machinery/alarm/AltClick()
+ ..()
+ togglelock()
+
+/obj/machinery/alarm/power_change()
+ ..()
+ spawn(rand(0,15))
+ update_icon()
diff --git a/code/game/machinery/fire_alarm.dm b/code/game/machinery/fire_alarm.dm
new file mode 100644
index 00000000000..a9b4a0705e6
--- /dev/null
+++ b/code/game/machinery/fire_alarm.dm
@@ -0,0 +1,324 @@
+/*
+FIRE ALARM
+*/
+/obj/machinery/firealarm
+ name = "fire alarm"
+ desc = "\"Pull this in case of emergency\". Thus, keep pulling it forever."
+ icon = 'icons/obj/monitors.dmi'
+ icon_state = "fire0"
+ plane = TURF_PLANE
+ layer = ABOVE_TURF_LAYER
+ var/detecting = 1.0
+ var/working = 1.0
+ var/time = 10.0
+ var/timing = 0.0
+ var/lockdownbyai = 0
+ anchored = 1.0
+ use_power = 1
+ idle_power_usage = 2
+ active_power_usage = 6
+ power_channel = ENVIRON
+ var/last_process = 0
+ panel_open = 0
+ var/seclevel
+ circuit = /obj/item/weapon/circuitboard/firealarm
+ var/alarms_hidden = FALSE //If the alarms from this machine are visible on consoles
+
+/obj/machinery/firealarm/alarms_hidden
+ alarms_hidden = TRUE
+
+/obj/machinery/firealarm/Initialize()
+ . = ..()
+ if(z in using_map.contact_levels)
+ set_security_level(security_level ? get_security_level() : "green")
+
+/obj/machinery/firealarm/update_icon()
+ cut_overlays()
+
+ if(panel_open)
+ set_light(0)
+ return
+
+ if(stat & BROKEN)
+ icon_state = "firex"
+ set_light(0)
+ else if(stat & NOPOWER)
+ icon_state = "firep"
+ set_light(0)
+ else
+ if(!detecting)
+ icon_state = "fire1"
+ set_light(l_range = 4, l_power = 0.9, l_color = "#ff0000")
+ else
+ icon_state = "fire0"
+ switch(seclevel)
+ if("green") set_light(l_range = 2, l_power = 0.25, l_color = "#00ff00")
+ if("yellow") set_light(l_range = 2, l_power = 0.25, l_color = "#ffff00")
+ if("violet") set_light(l_range = 2, l_power = 0.25, l_color = "#9933ff")
+ if("orange") set_light(l_range = 2, l_power = 0.25, l_color = "#ff9900")
+ if("blue") set_light(l_range = 2, l_power = 0.25, l_color = "#1024A9")
+ if("red") set_light(l_range = 4, l_power = 0.9, l_color = "#ff0000")
+ if("delta") set_light(l_range = 4, l_power = 0.9, l_color = "#FF6633")
+ add_overlay("overlay_[seclevel]")
+
+/obj/machinery/firealarm/fire_act(datum/gas_mixture/air, temperature, volume)
+ if(detecting)
+ if(temperature > T0C + 200)
+ alarm() // added check of detector status here
+ return
+
+/obj/machinery/firealarm/attack_ai(mob/user as mob)
+ return attack_hand(user)
+
+/obj/machinery/firealarm/bullet_act()
+ return alarm()
+
+/obj/machinery/firealarm/emp_act(severity)
+ if(prob(50 / severity))
+ alarm(rand(30 / severity, 60 / severity))
+ ..()
+
+/obj/machinery/firealarm/attackby(obj/item/W as obj, mob/user as mob)
+ add_fingerprint(user)
+
+ if(alarm_deconstruction_screwdriver(user, W))
+ return
+ if(alarm_deconstruction_wirecutters(user, W))
+ return
+
+ if(panel_open)
+ if(istype(W, /obj/item/device/multitool))
+ detecting = !(detecting)
+ if(detecting)
+ user.visible_message("\The [user] has reconnected [src]'s detecting unit!", "You have reconnected [src]'s detecting unit.")
+ else
+ user.visible_message("\The [user] has disconnected [src]'s detecting unit!", "You have disconnected [src]'s detecting unit.")
+ return
+
+ alarm()
+ return
+
+/obj/machinery/firealarm/process()//Note: this processing was mostly phased out due to other code, and only runs when needed
+ if(stat & (NOPOWER|BROKEN))
+ return
+
+ if(timing)
+ if(time > 0)
+ time = time - ((world.timeofday - last_process) / 10)
+ else
+ alarm()
+ time = 0
+ timing = 0
+ STOP_PROCESSING(SSobj, src)
+ updateDialog()
+ last_process = world.timeofday
+
+ if(locate(/obj/fire) in src.loc)
+ alarm()
+
+ return
+
+/obj/machinery/firealarm/power_change()
+ ..()
+ spawn(rand(0,15))
+ update_icon()
+
+/obj/machinery/firealarm/attack_hand(mob/user as mob)
+ if(user.stat || stat & (NOPOWER | BROKEN))
+ return
+
+ user.set_machine(src)
+ var/area/A = src.loc
+ var/d1
+ var/d2
+ if(istype(user, /mob/living/carbon/human) || istype(user, /mob/living/silicon))
+ A = A.loc
+
+ if(A.fire)
+ d1 = text("Reset - Lockdown", src)
+ else
+ d1 = text("Alarm - Lockdown", src)
+ if(timing)
+ d2 = text("Stop Time Lock", src)
+ else
+ d2 = text("Initiate Time Lock", src)
+ var/second = round(time) % 60
+ var/minute = (round(time) - second) / 60
+ var/dat = "Fire alarm [d1]\n
The current alert level is: [get_security_level()]
\nTimer System: [d2]
\nTime Left: [(minute ? "[minute]:" : null)][second] - - + +\n"
+ user << browse(dat, "window=firealarm")
+ onclose(user, "firealarm")
+ else
+ A = A.loc
+ if(A.fire)
+ d1 = text("[]", src, stars("Reset - Lockdown"))
+ else
+ d1 = text("[]", src, stars("Alarm - Lockdown"))
+ if(timing)
+ d2 = text("[]", src, stars("Stop Time Lock"))
+ else
+ d2 = text("[]", src, stars("Initiate Time Lock"))
+ var/second = round(time) % 60
+ var/minute = (round(time) - second) / 60
+ var/dat = "[stars("Fire alarm")] [d1]\n
The current alert level is: [stars(get_security_level())]
\nTimer System: [d2]
\nTime Left: [(minute ? text("[]:", minute) : null)][second] - - + +\n"
+ user << browse(dat, "window=firealarm")
+ onclose(user, "firealarm")
+ return
+
+/obj/machinery/firealarm/Topic(href, href_list)
+ ..()
+ if(usr.stat || stat & (BROKEN | NOPOWER))
+ return
+
+ if((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon)))
+ usr.set_machine(src)
+ if(href_list["reset"])
+ reset()
+ else if(href_list["alarm"])
+ alarm()
+ else if(href_list["time"])
+ timing = text2num(href_list["time"])
+ last_process = world.timeofday
+ START_PROCESSING(SSobj, src)
+ else if(href_list["tp"])
+ var/tp = text2num(href_list["tp"])
+ time += tp
+ time = min(max(round(time), 0), 120)
+
+ updateUsrDialog()
+
+ add_fingerprint(usr)
+ else
+ usr << browse(null, "window=firealarm")
+ return
+ return
+
+/obj/machinery/firealarm/proc/reset()
+ if(!(working))
+ return
+ var/area/area = get_area(src)
+ for(var/obj/machinery/firealarm/FA in area)
+ fire_alarm.clearAlarm(src.loc, FA)
+ update_icon()
+ return
+
+/obj/machinery/firealarm/proc/alarm(var/duration = 0)
+ if(!(working))
+ return
+ var/area/area = get_area(src)
+ for(var/obj/machinery/firealarm/FA in area)
+ fire_alarm.triggerAlarm(loc, FA, duration, hidden = alarms_hidden)
+ update_icon()
+ playsound(src.loc, 'sound/machines/airalarm.ogg', 25, 0, 4)
+ return
+
+/obj/machinery/firealarm/proc/set_security_level(var/newlevel)
+ if(seclevel != newlevel)
+ seclevel = newlevel
+ update_icon()
+
+/*
+FIRE ALARM CIRCUIT
+Just a object used in constructing fire alarms
+
+/obj/item/weapon/firealarm_electronics
+ name = "fire alarm electronics"
+ icon = 'icons/obj/doors/door_assembly.dmi'
+ icon_state = "door_electronics"
+ desc = "A circuit. It has a label on it, it says \"Can handle heat levels up to 40 degrees celsius!\""
+ w_class = ITEMSIZE_SMALL
+ matter = list(DEFAULT_WALL_MATERIAL = 50, "glass" = 50)
+*/
+/obj/machinery/partyalarm
+ name = "\improper PARTY BUTTON"
+ desc = "Cuban Pete is in the house!"
+ icon = 'icons/obj/monitors.dmi'
+ icon_state = "fire0"
+ var/detecting = 1.0
+ var/working = 1.0
+ var/time = 10.0
+ var/timing = 0.0
+ var/lockdownbyai = 0
+ anchored = 1.0
+ use_power = 1
+ idle_power_usage = 2
+ active_power_usage = 6
+
+/obj/machinery/partyalarm/attack_hand(mob/user as mob)
+ if(user.stat || stat & (NOPOWER|BROKEN))
+ return
+
+ user.machine = src
+ var/area/A = get_area(src)
+ ASSERT(isarea(A))
+ var/d1
+ var/d2
+ if(istype(user, /mob/living/carbon/human) || istype(user, /mob/living/silicon/ai))
+
+ if(A.party)
+ d1 = text("No Party :(", src)
+ else
+ d1 = text("PARTY!!!", src)
+ if(timing)
+ d2 = text("Stop Time Lock", src)
+ else
+ d2 = text("Initiate Time Lock", src)
+ var/second = time % 60
+ var/minute = (time - second) / 60
+ var/dat = text("Party Button []\n
\nTimer System: []
\nTime Left: [][] - - + +\n", d1, d2, (minute ? text("[]:", minute) : null), second, src, src, src, src)
+ user << browse(dat, "window=partyalarm")
+ onclose(user, "partyalarm")
+ else
+ if(A.fire)
+ d1 = text("[]", src, stars("No Party :("))
+ else
+ d1 = text("[]", src, stars("PARTY!!!"))
+ if(timing)
+ d2 = text("[]", src, stars("Stop Time Lock"))
+ else
+ d2 = text("[]", src, stars("Initiate Time Lock"))
+ var/second = time % 60
+ var/minute = (time - second) / 60
+ var/dat = text("[] []\n
\nTimer System: []
\nTime Left: [][] - - + +\n", stars("Party Button"), d1, d2, (minute ? text("[]:", minute) : null), second, src, src, src, src)
+ user << browse(dat, "window=partyalarm")
+ onclose(user, "partyalarm")
+ return
+
+/obj/machinery/partyalarm/proc/reset()
+ if(!(working))
+ return
+ var/area/A = get_area(src)
+ ASSERT(isarea(A))
+ A.partyreset()
+ return
+
+/obj/machinery/partyalarm/proc/alarm()
+ if(!(working))
+ return
+ var/area/A = get_area(src)
+ ASSERT(isarea(A))
+ A.partyalert()
+ return
+
+/obj/machinery/partyalarm/Topic(href, href_list)
+ ..()
+ if(usr.stat || stat & (BROKEN|NOPOWER))
+ return
+ if((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(loc, /turf))) || (istype(usr, /mob/living/silicon/ai)))
+ usr.machine = src
+ if(href_list["reset"])
+ reset()
+ else if(href_list["alarm"])
+ alarm()
+ else if(href_list["time"])
+ timing = text2num(href_list["time"])
+ else if(href_list["tp"])
+ var/tp = text2num(href_list["tp"])
+ time += tp
+ time = min(max(round(time), 0), 120)
+ updateUsrDialog()
+
+ add_fingerprint(usr)
+ else
+ usr << browse(null, "window=partyalarm")
+ return
+ return
diff --git a/code/game/turfs/simulated.dm b/code/game/turfs/simulated.dm
index 21488e5f26a..9e48b3777c0 100644
--- a/code/game/turfs/simulated.dm
+++ b/code/game/turfs/simulated.dm
@@ -55,8 +55,8 @@
B.clean_blood()
..()
-/turf/simulated/New()
- ..()
+/turf/simulated/Initialize(mapload)
+ . = ..()
if(istype(loc, /area/chapel))
holy = 1
levelupdate()
diff --git a/code/game/turfs/simulated/dungeon/wall.dm b/code/game/turfs/simulated/dungeon/wall.dm
index 3bae19db694..2bfc23145ea 100644
--- a/code/game/turfs/simulated/dungeon/wall.dm
+++ b/code/game/turfs/simulated/dungeon/wall.dm
@@ -3,8 +3,8 @@
/turf/simulated/wall/dungeon
block_tele = TRUE // Anti-cheese.
-/turf/simulated/wall/dungeon/New(var/newloc)
- ..(newloc,"dungeonium")
+/turf/simulated/wall/dungeon/Initialize(mapload)
+ . = ..(mapload, "dungeonium")
/turf/simulated/wall/dungeon/attackby()
return
@@ -20,8 +20,8 @@
var/rock_side = "rock_side"
block_tele = TRUE
-/turf/simulated/wall/solidrock/New(var/newloc)
- ..(newloc,"bedrock")
+/turf/simulated/wall/solidrock/Initialize(mapload)
+ . = ..(mapload, "bedrock")
/turf/simulated/wall/solidrock/Initialize()
. = ..()
@@ -81,8 +81,8 @@
desc = "An old, yet impressively durably rock wall."
var/mossyrock_side = "mossyrock_side"
-/turf/simulated/wall/solidrock/New(var/newloc)
- ..(newloc,"mossyrock")
+/turf/simulated/wall/solidrock/Initialize(mapload)
+ . = ..(mapload, "mossyrock")
/turf/simulated/wall/solidrock/mossyrockpoi/update_icon(var/update_neighbors)
if(density)
diff --git a/code/game/turfs/simulated/floor.dm b/code/game/turfs/simulated/floor.dm
index 31bfd62684d..7e8db4dbf9e 100644
--- a/code/game/turfs/simulated/floor.dm
+++ b/code/game/turfs/simulated/floor.dm
@@ -35,12 +35,12 @@
/turf/simulated/floor/is_plating()
return !flooring
-/turf/simulated/floor/New(var/newloc, var/floortype)
- ..(newloc)
+/turf/simulated/floor/Initialize(mapload, floortype)
+ . = ..()
if(!floortype && initial_flooring)
floortype = initial_flooring
if(floortype)
- set_flooring(get_flooring_data(floortype))
+ set_flooring(get_flooring_data(floortype), TRUE)
else
footstep_sounds = base_footstep_sounds
if(can_dirty && can_start_dirty)
@@ -48,29 +48,24 @@
dirt += rand(50,100)
update_dirt() //5% chance to start with dirt on a floor tile- give the janitor something to do
-/turf/simulated/floor/proc/set_flooring(var/decl/flooring/newflooring)
+/turf/simulated/floor/proc/swap_decals()
+ var/current_decals = decals
+ decals = old_decals
+ old_decals = current_decals
+
+/turf/simulated/floor/proc/set_flooring(var/decl/flooring/newflooring, var/initializing)
make_plating(defer_icon_update = 1)
+ if(!flooring && !initializing) // Plating -> Flooring
+ swap_decals()
flooring = newflooring
footstep_sounds = newflooring.footstep_sounds
- // VOREStation Edit - We are plating switching to flooring, swap out old_decals for decals
- var/tmp/list/overfloor_decals = old_decals
- old_decals = decals
- decals = overfloor_decals
- // VOREStation Edit End
update_icon(1)
levelupdate()
//This proc will set floor_type to null and the update_icon() proc will then change the icon_state of the turf
//This proc auto corrects the grass tiles' siding.
/turf/simulated/floor/proc/make_plating(var/place_product, var/defer_icon_update)
-
cut_overlays()
- // VOREStation Edit - We are flooring switching to plating, swap out old_decals for decals.
- if(flooring)
- var/tmp/list/underfloor_decals = old_decals
- old_decals = decals
- decals = underfloor_decals
- // VOREStation Edit End
name = base_name
desc = base_desc
@@ -78,7 +73,8 @@
icon_state = base_icon_state
footstep_sounds = base_footstep_sounds
- if(flooring)
+ if(flooring) // Flooring -> Plating
+ swap_decals()
if(flooring.build_type && place_product)
new flooring.build_type(src)
flooring = null
diff --git a/code/game/turfs/simulated/floor_types.dm b/code/game/turfs/simulated/floor_types.dm
index 6b2215a11cb..2a85a6d1315 100644
--- a/code/game/turfs/simulated/floor_types.dm
+++ b/code/game/turfs/simulated/floor_types.dm
@@ -85,7 +85,7 @@
var/join_group = "shuttle" //A tag for what other walls to join with. Null if you don't want them to.
var/static/list/antilight_cache
-/turf/simulated/shuttle/New()
+/turf/simulated/shuttle/Initialize(mapload)
..()
if(!antilight_cache)
antilight_cache = list()
diff --git a/code/game/turfs/simulated/outdoors/outdoors.dm b/code/game/turfs/simulated/outdoors/outdoors.dm
index a378cc48daf..7bef49cd495 100644
--- a/code/game/turfs/simulated/outdoors/outdoors.dm
+++ b/code/game/turfs/simulated/outdoors/outdoors.dm
@@ -24,10 +24,10 @@ var/list/turf_edge_cache = list()
update_icon()
. = ..()
-/turf/simulated/floor/New()
+/turf/simulated/floor/Initialize(mapload)
if(outdoors)
SSplanets.addTurf(src)
- ..()
+ . = ..()
/turf/simulated/floor/Destroy()
if(outdoors)
diff --git a/code/game/turfs/simulated/wall_types.dm b/code/game/turfs/simulated/wall_types.dm
index bff82d6e0e3..96979c8452f 100644
--- a/code/game/turfs/simulated/wall_types.dm
+++ b/code/game/turfs/simulated/wall_types.dm
@@ -1,89 +1,89 @@
/turf/simulated/wall/r_wall
icon_state = "rgeneric"
-/turf/simulated/wall/r_wall/New(var/newloc)
- ..(newloc, "plasteel","plasteel") //3strong
+/turf/simulated/wall/r_wall/Initialize(mapload)
+ . = ..(mapload, "plasteel","plasteel") //3strong
-/turf/simulated/wall/shull/New(var/newloc) //Spaaaace ship.
- ..(newloc, MAT_STEELHULL, null, MAT_STEELHULL)
-/turf/simulated/wall/rshull/New(var/newloc)
- ..(newloc, MAT_STEELHULL, MAT_STEELHULL, MAT_STEELHULL)
-/turf/simulated/wall/pshull/New(var/newloc) //Spaaaace-er ship.
- ..(newloc, MAT_PLASTEELHULL, null, MAT_PLASTEELHULL)
-/turf/simulated/wall/rpshull/New(var/newloc)
- ..(newloc, MAT_PLASTEELHULL, MAT_PLASTEELHULL, MAT_PLASTEELHULL)
-/turf/simulated/wall/dshull/New(var/newloc) //Spaaaace-est ship.
- ..(newloc, MAT_DURASTEELHULL, null, MAT_DURASTEELHULL)
-/turf/simulated/wall/rdshull/New(var/newloc)
- ..(newloc, MAT_DURASTEELHULL, MAT_DURASTEELHULL, MAT_DURASTEELHULL)
-/turf/simulated/wall/thull/New(var/newloc)
- ..(newloc, MAT_TITANIUMHULL, null, MAT_TITANIUMHULL)
-/turf/simulated/wall/rthull/New(var/newloc)
- ..(newloc, MAT_TITANIUMHULL, MAT_TITANIUMHULL, MAT_TITANIUMHULL)
+/turf/simulated/wall/shull/Initialize(mapload) //Spaaaace ship.
+ . = ..(mapload, MAT_STEELHULL, null, MAT_STEELHULL)
+/turf/simulated/wall/rshull/Initialize(mapload)
+ . = ..(mapload, MAT_STEELHULL, MAT_STEELHULL, MAT_STEELHULL)
+/turf/simulated/wall/pshull/Initialize(mapload) //Spaaaace-er ship.
+ . = ..(mapload, MAT_PLASTEELHULL, null, MAT_PLASTEELHULL)
+/turf/simulated/wall/rpshull/Initialize(mapload)
+ . = ..(mapload, MAT_PLASTEELHULL, MAT_PLASTEELHULL, MAT_PLASTEELHULL)
+/turf/simulated/wall/dshull/Initialize(mapload) //Spaaaace-est ship.
+ . = ..(mapload, MAT_DURASTEELHULL, null, MAT_DURASTEELHULL)
+/turf/simulated/wall/rdshull/Initialize(mapload)
+ . = ..(mapload, MAT_DURASTEELHULL, MAT_DURASTEELHULL, MAT_DURASTEELHULL)
+/turf/simulated/wall/thull/Initialize(mapload)
+ . = ..(mapload, MAT_TITANIUMHULL, null, MAT_TITANIUMHULL)
+/turf/simulated/wall/rthull/Initialize(mapload)
+ . = ..(mapload, MAT_TITANIUMHULL, MAT_TITANIUMHULL, MAT_TITANIUMHULL)
/turf/simulated/wall/cult
icon_state = "cult"
-/turf/simulated/wall/cult/New(var/newloc)
- ..(newloc,"cult","cult2","cult")
+/turf/simulated/wall/cult/Initialize(mapload)
+ . = ..(mapload, "cult","cult2","cult")
/turf/unsimulated/wall/cult
name = "cult wall"
desc = "Hideous images dance beneath the surface."
icon = 'icons/turf/wall_masks.dmi'
icon_state = "cult"
-/turf/simulated/wall/iron/New(var/newloc)
- ..(newloc,"iron")
-/turf/simulated/wall/uranium/New(var/newloc)
- ..(newloc,"uranium")
-/turf/simulated/wall/diamond/New(var/newloc)
- ..(newloc,"diamond")
-/turf/simulated/wall/gold/New(var/newloc)
- ..(newloc,"gold")
-/turf/simulated/wall/silver/New(var/newloc)
- ..(newloc,"silver")
-/turf/simulated/wall/lead/New(var/newloc)
- ..(newloc,"lead")
-/turf/simulated/wall/r_lead/New(var/newloc)
- ..(newloc,"lead", "lead")
-/turf/simulated/wall/phoron/New(var/newloc)
- ..(newloc,"phoron")
-/turf/simulated/wall/sandstone/New(var/newloc)
- ..(newloc,"sandstone")
-/turf/simulated/wall/ironphoron/New(var/newloc)
- ..(newloc,"iron","phoron")
-/turf/simulated/wall/golddiamond/New(var/newloc)
- ..(newloc,"gold","diamond")
-/turf/simulated/wall/silvergold/New(var/newloc)
- ..(newloc,"silver","gold")
-/turf/simulated/wall/sandstonediamond/New(var/newloc)
- ..(newloc,"sandstone","diamond")
-/turf/simulated/wall/snowbrick/New(var/newloc)
- ..(newloc,"packed snow")
+/turf/simulated/wall/iron/Initialize(mapload)
+ . = ..(mapload, "iron")
+/turf/simulated/wall/uranium/Initialize(mapload)
+ . = ..(mapload, "uranium")
+/turf/simulated/wall/diamond/Initialize(mapload)
+ . = ..(mapload, "diamond")
+/turf/simulated/wall/gold/Initialize(mapload)
+ . = ..(mapload, "gold")
+/turf/simulated/wall/silver/Initialize(mapload)
+ . = ..(mapload, "silver")
+/turf/simulated/wall/lead/Initialize(mapload)
+ . = ..(mapload, "lead")
+/turf/simulated/wall/r_lead/Initialize(mapload)
+ . = ..(mapload, "lead", "lead")
+/turf/simulated/wall/phoron/Initialize(mapload)
+ . = ..(mapload, "phoron")
+/turf/simulated/wall/sandstone/Initialize(mapload)
+ . = ..(mapload, "sandstone")
+/turf/simulated/wall/ironphoron/Initialize(mapload)
+ . = ..(mapload, "iron","phoron")
+/turf/simulated/wall/golddiamond/Initialize(mapload)
+ . = ..(mapload, "gold","diamond")
+/turf/simulated/wall/silvergold/Initialize(mapload)
+ . = ..(mapload, "silver","gold")
+/turf/simulated/wall/sandstonediamond/Initialize(mapload)
+ . = ..(mapload, "sandstone","diamond")
+/turf/simulated/wall/snowbrick/Initialize(mapload)
+ . = ..(mapload, "packed snow")
-/turf/simulated/wall/resin/New(var/newloc)
- ..(newloc,"resin",null,"resin")
+/turf/simulated/wall/resin/Initialize(mapload)
+ . = ..(mapload, "resin",null,"resin")
// Kind of wondering if this is going to bite me in the butt.
-/turf/simulated/wall/skipjack/New(var/newloc)
- ..(newloc,"alienalloy")
+/turf/simulated/wall/skipjack/Initialize(mapload)
+ . = ..(mapload, "alienalloy")
/turf/simulated/wall/skipjack/attackby()
return
-/turf/simulated/wall/titanium/New(var/newloc)
- ..(newloc,"titanium")
+/turf/simulated/wall/titanium/Initialize(mapload)
+ . = ..(mapload, "titanium")
-/turf/simulated/wall/durasteel/New(var/newloc)
- ..(newloc,"durasteel", "durasteel")
+/turf/simulated/wall/durasteel/Initialize(mapload)
+ . = ..(mapload, "durasteel", "durasteel")
-/turf/simulated/wall/wood/New(var/newloc)
- ..(newloc, MAT_WOOD)
+/turf/simulated/wall/wood/Initialize(mapload)
+ . = ..(mapload, MAT_WOOD)
-/turf/simulated/wall/sifwood/New(var/newloc)
- ..(newloc, MAT_SIFWOOD)
+/turf/simulated/wall/sifwood/Initialize(mapload)
+ . = ..(mapload, MAT_SIFWOOD)
-/turf/simulated/wall/log/New(var/newloc)
- ..(newloc, MAT_LOG)
+/turf/simulated/wall/log/Initialize(mapload)
+ . = ..(mapload, MAT_LOG)
-/turf/simulated/wall/log_sif/New(var/newloc)
- ..(newloc, MAT_SIFLOG)
+/turf/simulated/wall/log_sif/Initialize(mapload)
+ . = ..(mapload, MAT_SIFLOG)
// Shuttle Walls
/turf/simulated/shuttle/wall
@@ -152,16 +152,14 @@
icon_state = "alien-nj"
join_group = null
-/turf/simulated/shuttle/wall/New()
- ..()
- //To allow mappers to rename shuttle walls to like "redfloor interior" or whatever for ease of use.
- name = true_name
-
/turf/simulated/shuttle/wall/Initialize()
. = ..()
+ //To allow mappers to rename shuttle walls to like "redfloor interior" or whatever for ease of use.
+ name = true_name
+
if(join_group)
- src.auto_join()
+ auto_join()
else
icon_state = base_state
diff --git a/code/game/turfs/simulated/wall_types_vr.dm b/code/game/turfs/simulated/wall_types_vr.dm
index e8e3961ce59..6ebf9df004b 100644
--- a/code/game/turfs/simulated/wall_types_vr.dm
+++ b/code/game/turfs/simulated/wall_types_vr.dm
@@ -35,8 +35,8 @@
/turf/simulated/flesh/attackby()
return
-/turf/simulated/flesh/New()
- ..()
+/turf/simulated/flesh/Initialize(mapload)
+ . = ..()
update_icon(1)
var/list/flesh_overlay_cache = list()
diff --git a/code/game/turfs/simulated/walls.dm b/code/game/turfs/simulated/walls.dm
index bf5f711b206..d72beb290c0 100644
--- a/code/game/turfs/simulated/walls.dm
+++ b/code/game/turfs/simulated/walls.dm
@@ -27,8 +27,8 @@
for(var/obj/O in src)
O.hide(1)
-/turf/simulated/wall/New(var/newloc, var/materialtype, var/rmaterialtype, var/girdertype)
- ..(newloc)
+/turf/simulated/wall/Initialize(mapload, materialtype, rmaterialtype, girdertype)
+ . = ..()
icon_state = "blank"
if(!materialtype)
materialtype = DEFAULT_WALL_MATERIAL
diff --git a/code/game/turfs/space/space.dm b/code/game/turfs/space/space.dm
index cf5d512cf5b..47cdf435555 100644
--- a/code/game/turfs/space/space.dm
+++ b/code/game/turfs/space/space.dm
@@ -9,82 +9,38 @@
thermal_conductivity = OPEN_HEAT_TRANSFER_COEFFICIENT
can_build_into_floor = TRUE
var/keep_sprite = FALSE
-// heat_capacity = 700000 No.
- var/static/list/dust_cache
- var/static/list/speedspace_cache
- var/static/list/phase_shift_by_x
- var/static/list/phase_shift_by_y
-
-/turf/space/proc/build_dust_cache()
- //Static
- LAZYINITLIST(dust_cache)
- for (var/i in 0 to 25)
- var/image/im = image('icons/turf/space_dust.dmi', "[i]")
- im.plane = DUST_PLANE
- im.alpha = 128 //80
- im.blend_mode = BLEND_ADD
- dust_cache["[i]"] = im
- //Moving
- LAZYINITLIST(speedspace_cache)
- for (var/i in 0 to 14)
- // NORTH/SOUTH
- var/image/im = image('icons/turf/space_dust_transit.dmi', "speedspace_ns_[i]")
- im.plane = DUST_PLANE
- im.blend_mode = BLEND_ADD
- speedspace_cache["NS_[i]"] = im
- // EAST/WEST
- im = image('icons/turf/space_dust_transit.dmi', "speedspace_ew_[i]")
- im.plane = DUST_PLANE
- im.blend_mode = BLEND_ADD
- speedspace_cache["EW_[i]"] = im
/turf/space/Initialize()
. = ..()
+
if(!keep_sprite)
icon_state = "white"
- update_starlight()
- if (!dust_cache)
- build_dust_cache()
- toggle_transit() //add static dust
+
+ if(config.starlight)
+ update_starlight()
+
+ toggle_transit() //Add static dust (not passing a dir)
/turf/space/proc/toggle_transit(var/direction)
cut_overlays()
if(!direction)
- add_overlay(dust_cache["[((x + y) ^ ~(x * y) + z) % 25]"])
+ add_overlay(SSskybox.dust_cache["[((x + y) ^ ~(x * y) + z) % 25]"])
return
if(direction & (NORTH|SOUTH))
- if(!phase_shift_by_x)
- phase_shift_by_x = get_cross_shift_list(15)
- var/x_shift = phase_shift_by_x[src.x % (phase_shift_by_x.len - 1) + 1]
+ var/x_shift = SSskybox.phase_shift_by_x[src.x % (SSskybox.phase_shift_by_x.len - 1) + 1]
var/transit_state = ((direction & SOUTH ? world.maxy - src.y : src.y) + x_shift)%15
- add_overlay(speedspace_cache["NS_[transit_state]"])
+ add_overlay(SSskybox.speedspace_cache["NS_[transit_state]"])
else if(direction & (EAST|WEST))
- if(!phase_shift_by_y)
- phase_shift_by_y = get_cross_shift_list(15)
- var/y_shift = phase_shift_by_y[src.y % (phase_shift_by_y.len - 1) + 1]
+ var/y_shift = SSskybox.phase_shift_by_y[src.y % (SSskybox.phase_shift_by_y.len - 1) + 1]
var/transit_state = ((direction & WEST ? world.maxx - src.x : src.x) + y_shift)%15
- add_overlay(speedspace_cache["EW_[transit_state]"])
+ add_overlay(SSskybox.speedspace_cache["EW_[transit_state]"])
for(var/atom/movable/AM in src)
if (AM.simulated && !AM.anchored)
AM.throw_at(get_step(src,reverse_direction(direction)), 5, 1)
-//generates a list used to randomize transit animations so they aren't in lockstep
-/turf/space/proc/get_cross_shift_list(var/size)
- var/list/result = list()
-
- result += rand(0, 14)
- for(var/i in 2 to size)
- var/shifts = list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
- shifts -= result[i - 1] //consecutive shifts should not be equal
- if(i == size)
- shifts -= result[1] //because shift list is a ring buffer
- result += pick(shifts)
-
- return result
-
/turf/space/is_space()
return 1
@@ -97,8 +53,6 @@
return locate(/obj/structure/lattice, src) //counts as solid structure if it has a lattice
/turf/space/proc/update_starlight()
- if(!config.starlight)
- return
if(locate(/turf/simulated) in orange(src,1))
set_light(config.starlight)
else
diff --git a/code/game/turfs/space/transit.dm b/code/game/turfs/space/transit.dm
index 8b9c7b2d35e..5f19e691f26 100644
--- a/code/game/turfs/space/transit.dm
+++ b/code/game/turfs/space/transit.dm
@@ -13,12 +13,10 @@
icon_state = "arrow-north"
pushdirection = SOUTH // south because the space tile is scrolling south
-/turf/space/transit/north/New()
- ..()
- if(!phase_shift_by_x)
- phase_shift_by_x = get_cross_shift_list(15)
+/turf/space/transit/north/Initialize()
+ . = ..()
- var/x_shift = phase_shift_by_x[src.x % (phase_shift_by_x.len - 1) + 1]
+ var/x_shift = SSskybox.phase_shift_by_x[src.x % (SSskybox.phase_shift_by_x.len - 1) + 1]
var/transit_state = (world.maxy - src.y + x_shift)%15 + 1
icon_state = "speedspace_ns_[transit_state]"
@@ -28,12 +26,10 @@
icon_state = "arrow-south"
pushdirection = SOUTH // south because the space tile is scrolling south
-/turf/space/transit/south/New()
- ..()
- if(!phase_shift_by_x)
- phase_shift_by_x = get_cross_shift_list(15)
+/turf/space/transit/south/Initialize()
+ . = ..()
- var/x_shift = phase_shift_by_x[src.x % (phase_shift_by_x.len - 1) + 1]
+ var/x_shift = SSskybox.phase_shift_by_x[src.x % (SSskybox.phase_shift_by_x.len - 1) + 1]
var/transit_state = (world.maxy - src.y + x_shift)%15 + 1
var/icon/I = new(icon, "speedspace_ns_[transit_state]")
@@ -45,12 +41,10 @@
icon_state = "arrow-east"
pushdirection = WEST
-/turf/space/transit/east/New()
- ..()
- if(!phase_shift_by_y)
- phase_shift_by_y = get_cross_shift_list(15)
+/turf/space/transit/east/Initialize()
+ . = ..()
- var/y_shift = phase_shift_by_y[src.y % (phase_shift_by_y.len - 1) + 1]
+ var/y_shift = SSskybox.phase_shift_by_y[src.y % (SSskybox.phase_shift_by_y.len - 1) + 1]
var/transit_state = (world.maxx - src.x + y_shift)%15 + 1
icon_state = "speedspace_ew_[transit_state]"
@@ -60,12 +54,10 @@
icon_state = "arrow-west"
pushdirection = WEST
-/turf/space/transit/west/New()
- ..()
- if(!phase_shift_by_y)
- phase_shift_by_y = get_cross_shift_list(15)
+/turf/space/transit/west/Initialize()
+ . = ..()
- var/y_shift = phase_shift_by_y[src.y % (phase_shift_by_y.len - 1) + 1]
+ var/y_shift = SSskybox.phase_shift_by_y[src.y % (SSskybox.phase_shift_by_y.len - 1) + 1]
var/transit_state = (world.maxx - src.x + y_shift)%15 + 1
var/icon/I = new(icon, "speedspace_ew_[transit_state]")
diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm
index f46ff9501f8..1447a379978 100644
--- a/code/game/turfs/turf.dm
+++ b/code/game/turfs/turf.dm
@@ -34,26 +34,22 @@
var/can_build_into_floor = FALSE // Used for things like RCDs (and maybe lattices/floor tiles in the future), to see if a floor should replace it.
var/list/dangerous_objects // List of 'dangerous' objs that the turf holds that can cause something bad to happen when stepped on, used for AI mobs.
-/turf/New()
- ..()
- for(var/atom/movable/AM as mob|obj in src)
- spawn( 0 )
- src.Entered(AM)
- return
- turfs |= src
-
- if(dynamic_lighting)
- luminosity = 0
- else
- luminosity = 1
+/turf/Initialize(mapload)
+ . = ..()
+ for(var/atom/movable/AM in src)
+ Entered(AM)
+ //Lighting related
+ luminosity = !(dynamic_lighting)
+ has_opaque_atom |= (opacity)
+
+ //Pathfinding related
if(movement_cost && pathweight == 1) // This updates pathweight automatically.
pathweight = movement_cost
/turf/Destroy()
- turfs -= src
+ . = QDEL_HINT_IWILLGC
..()
- return QDEL_HINT_IWILLGC
/turf/ex_act(severity)
return 0
diff --git a/code/game/turfs/unsimulated.dm b/code/game/turfs/unsimulated.dm
index 894fac57b24..584137ff45a 100644
--- a/code/game/turfs/unsimulated.dm
+++ b/code/game/turfs/unsimulated.dm
@@ -10,9 +10,10 @@
icon = 'icons/turf/space.dmi'
icon_state = "0"
dynamic_lighting = FALSE
+ initialized = FALSE
-/turf/unsimulated/fake_space/New()
- ..()
+/turf/unsimulated/fake_space/Initialize(mapload)
+ . = ..()
icon_state = "[((x + y) ^ ~(x * y) + z) % 25]"
//VOREStation Add End
diff --git a/code/game/turfs/unsimulated/beach.dm b/code/game/turfs/unsimulated/beach.dm
index 4638b15cab6..056facb60ce 100644
--- a/code/game/turfs/unsimulated/beach.dm
+++ b/code/game/turfs/unsimulated/beach.dm
@@ -14,9 +14,10 @@
/turf/unsimulated/beach/water
name = "Water"
icon_state = "water"
+ initialized = FALSE
-/turf/unsimulated/beach/water/New()
- ..()
+/turf/unsimulated/beach/water/Initialize()
+ . = ..()
add_overlay(image("icon"='icons/misc/beach.dmi',"icon_state"="water2","layer"=MOB_LAYER+0.1))
/turf/simulated/floor/beach
@@ -54,6 +55,6 @@
/turf/simulated/floor/beach/water/ocean
icon_state = "seadeep"
-/turf/simulated/floor/beach/water/New()
- ..()
+/turf/simulated/floor/beach/water/Initialize()
+ . = ..()
add_overlay(image("icon"='icons/misc/beach.dmi',"icon_state"="water5","layer"=MOB_LAYER+0.1))
diff --git a/code/game/turfs/unsimulated/planetary.dm b/code/game/turfs/unsimulated/planetary.dm
index 35cd7aa4a80..4fb26f16b6a 100644
--- a/code/game/turfs/unsimulated/planetary.dm
+++ b/code/game/turfs/unsimulated/planetary.dm
@@ -9,6 +9,7 @@
density = 1
alpha = 0
blocks_air = 0
+ initialized = FALSE
// Set these to get your desired planetary atmosphere.
oxygen = 0
@@ -17,8 +18,8 @@
phoron = 0
temperature = T20C
-/turf/unsimulated/wall/planetary/New()
- ..()
+/turf/unsimulated/wall/planetary/Initialize()
+ . = ..()
SSplanets.addTurf(src)
/turf/unsimulated/wall/planetary/Destroy()
diff --git a/code/modules/admin/verbs/adminjump.dm b/code/modules/admin/verbs/adminjump.dm
index 8859439ce7b..db948d08e65 100644
--- a/code/modules/admin/verbs/adminjump.dm
+++ b/code/modules/admin/verbs/adminjump.dm
@@ -21,7 +21,7 @@
else
alert("Admin jumping disabled")
-/client/proc/jumptoturf(var/turf/T in turfs)
+/client/proc/jumptoturf(var/turf/T in world)
set name = "Jump to Turf"
set category = "Admin"
if(!check_rights(R_ADMIN|R_MOD|R_DEBUG|R_EVENT))
diff --git a/code/modules/admin/verbs/atmosdebug.dm b/code/modules/admin/verbs/atmosdebug.dm
index 653b62ddeee..2f7d65db05c 100644
--- a/code/modules/admin/verbs/atmosdebug.dm
+++ b/code/modules/admin/verbs/atmosdebug.dm
@@ -28,7 +28,7 @@
to_chat(usr, "Checking for overlapping pipes...")
next_turf:
- for(var/turf/T in turfs)
+ for(var/turf/T in world)
for(var/dir in cardinal)
var/list/connect_types = list(1 = 0, 2 = 0, 3 = 0)
for(var/obj/machinery/atmospherics/pipe in T)
diff --git a/code/modules/admin/verbs/grief_fixers.dm b/code/modules/admin/verbs/grief_fixers.dm
index 00e5ee1e059..b8815876b23 100644
--- a/code/modules/admin/verbs/grief_fixers.dm
+++ b/code/modules/admin/verbs/grief_fixers.dm
@@ -38,7 +38,7 @@
unsorted_overlays |= gas_data.tile_overlay[id]
- for(var/turf/simulated/T in turfs)
+ for(var/turf/simulated/T in world)
T.air = null
T.overlays.Remove(unsorted_overlays)
T.zone = null
diff --git a/code/modules/holodeck/HolodeckObjects.dm b/code/modules/holodeck/HolodeckObjects.dm
index ca18f84d6fa..7b923d8c533 100644
--- a/code/modules/holodeck/HolodeckObjects.dm
+++ b/code/modules/holodeck/HolodeckObjects.dm
@@ -67,7 +67,8 @@
name = "reinforced holofloor"
icon_state = "reinforced"
-/turf/simulated/floor/holofloor/space/New()
+/turf/simulated/floor/holofloor/space/Initialize()
+ . = ..()
icon_state = "[((x + y) ^ ~(x * y) + z) % 25]"
/turf/simulated/floor/holofloor/beach
diff --git a/code/modules/lighting/lighting_turf.dm b/code/modules/lighting/lighting_turf.dm
index 743a0d8e2b7..bc3c0990911 100644
--- a/code/modules/lighting/lighting_turf.dm
+++ b/code/modules/lighting/lighting_turf.dm
@@ -9,12 +9,6 @@
var/tmp/list/datum/lighting_corner/corners
var/tmp/has_opaque_atom = FALSE // Not to be confused with opacity, this will be TRUE if there's any opaque atom on the tile.
-/turf/New()
- . = ..()
-
- if(opacity)
- has_opaque_atom = TRUE
-
// Causes any affecting light sources to be queued for a visibility update, for example a door got opened.
/turf/proc/reconsider_lights()
for(var/datum/light_source/L in affecting_lights)
diff --git a/code/modules/mob/freelook/update_triggers.dm b/code/modules/mob/freelook/update_triggers.dm
index 0b31e24cce2..e6d1976fad5 100644
--- a/code/modules/mob/freelook/update_triggers.dm
+++ b/code/modules/mob/freelook/update_triggers.dm
@@ -17,8 +17,8 @@
updateVisibility(src)
return ..()
-/turf/simulated/New()
- ..()
+/turf/simulated/Initialize()
+ . = ..()
updateVisibility(src)
diff --git a/code/modules/overmap/_defines.dm b/code/modules/overmap/_defines.dm
index bf967eb3b96..6cfde467938 100644
--- a/code/modules/overmap/_defines.dm
+++ b/code/modules/overmap/_defines.dm
@@ -33,8 +33,8 @@ var/global/list/map_sectors = list()
opacity = 1
density = 1
-/turf/unsimulated/map/New()
- ..()
+/turf/unsimulated/map/Initialize()
+ . = ..()
name = "[x]-[y]"
var/list/numbers = list()
diff --git a/code/modules/random_map/automata/diona.dm b/code/modules/random_map/automata/diona.dm
index e9e58a03a47..d6bee1c0ff4 100644
--- a/code/modules/random_map/automata/diona.dm
+++ b/code/modules/random_map/automata/diona.dm
@@ -1,5 +1,5 @@
-/turf/simulated/wall/diona/New(var/newloc)
- ..(newloc,"biomass")
+/turf/simulated/wall/diona/Initialize(mapload)
+ ..(mapload, "biomass")
/turf/simulated/wall/diona/attack_generic(var/mob/user, var/damage, var/attack_message)
if(istype(user, /mob/living/carbon/alien/diona))
diff --git a/code/modules/turbolift/turbolift_turfs.dm b/code/modules/turbolift/turbolift_turfs.dm
index 632160efaa1..8949f71448f 100644
--- a/code/modules/turbolift/turbolift_turfs.dm
+++ b/code/modules/turbolift/turbolift_turfs.dm
@@ -1,2 +1,2 @@
-/turf/simulated/wall/elevator/New(var/newloc)
- ..(newloc,"elevatorium")
+/turf/simulated/wall/elevator/Initialize(mapload)
+ ..(mapload, "elevatorium")
diff --git a/maps/~map_system/maps.dm b/maps/~map_system/maps.dm
index efd8667f622..c3dd9ba0f15 100644
--- a/maps/~map_system/maps.dm
+++ b/maps/~map_system/maps.dm
@@ -141,17 +141,6 @@ var/list/all_maps = list()
/datum/map/proc/perform_map_generation()
return
-// Used to apply various post-compile procedural effects to the map.
-/datum/map/proc/refresh_mining_turfs()
-
- set background = 1
- set waitfor = 0
-
- // Update all turfs to ensure everything looks good post-generation. Yes,
- // it's brute-forcey, but frankly the alternative is a mine turf rewrite.
- for(var/turf/simulated/mineral/M in turfs) // Ugh.
- M.update_icon()
-
/datum/map/proc/get_network_access(var/network)
return 0
diff --git a/vorestation.dme b/vorestation.dme
index 186ae33051c..23605f0fd15 100644
--- a/vorestation.dme
+++ b/vorestation.dme
@@ -735,8 +735,8 @@
#include "code\game\machinery\adv_med.dm"
#include "code\game\machinery\adv_med_vr.dm"
#include "code\game\machinery\ai_slipper.dm"
+#include "code\game\machinery\air_alarm.dm"
#include "code\game\machinery\airconditioner_vr.dm"
-#include "code\game\machinery\alarm.dm"
#include "code\game\machinery\atmo_control.dm"
#include "code\game\machinery\autolathe.dm"
#include "code\game\machinery\Beacon.dm"
@@ -755,6 +755,7 @@
#include "code\game\machinery\doorbell_vr.dm"
#include "code\game\machinery\doppler_array.dm"
#include "code\game\machinery\exonet_node.dm"
+#include "code\game\machinery\fire_alarm.dm"
#include "code\game\machinery\flasher.dm"
#include "code\game\machinery\floodlight.dm"
#include "code\game\machinery\floor_light.dm"