mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
Finishing touches on Air Alarms, Firedoors, and Central Atmos Control
This commit is contained in:
@@ -5,13 +5,14 @@
|
||||
name = "Air Vent"
|
||||
desc = "Has a valve and pump attached to it"
|
||||
|
||||
var/area/initial_loc
|
||||
level = 1
|
||||
var/area_uid
|
||||
var/id_tag = null
|
||||
var/id_tag
|
||||
power_channel = ENVIRON
|
||||
|
||||
var/on = 0
|
||||
var/pump_direction = 1 //0 = siphoning, 1 = releasing
|
||||
var/pump_speed = 1 //Used to adjust speed for siphons
|
||||
|
||||
var/external_pressure_bound = ONE_ATMOSPHERE
|
||||
var/internal_pressure_bound = 0
|
||||
@@ -42,25 +43,27 @@
|
||||
icon_state = "in"
|
||||
|
||||
New()
|
||||
initial_loc = get_area(loc)
|
||||
if (initial_loc.master)
|
||||
initial_loc = initial_loc.master
|
||||
area_uid = initial_loc.uid
|
||||
var/area/A = get_area(loc)
|
||||
if (A.master)
|
||||
A = A.master
|
||||
area_uid = A.uid
|
||||
if (!id_tag)
|
||||
assign_uid()
|
||||
id_tag = num2text(uid)
|
||||
if(ticker && ticker.current_state == 3)//if the game is running
|
||||
src.initialize()
|
||||
src.broadcast_status()
|
||||
initialize()
|
||||
broadcast_status()
|
||||
..()
|
||||
|
||||
high_volume
|
||||
name = "Large Air Vent"
|
||||
power_channel = EQUIP
|
||||
|
||||
New()
|
||||
..()
|
||||
air_contents.volume = 1000
|
||||
|
||||
|
||||
update_icon()
|
||||
if(welded)
|
||||
icon_state = "[level == 1 && istype(loc, /turf/simulated) ? "h" : "" ]weld"
|
||||
@@ -77,11 +80,12 @@
|
||||
|
||||
process()
|
||||
..()
|
||||
// broadcast_status()
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
if (!node)
|
||||
on = 0
|
||||
//broadcast_status() // from now air alarm/control computer should request update purposely --rastaf0
|
||||
|
||||
if(!on)
|
||||
return 0
|
||||
|
||||
@@ -101,7 +105,7 @@
|
||||
|
||||
if(pressure_delta > 0)
|
||||
if(air_contents.temperature > 0)
|
||||
var/transfer_moles = pressure_delta*environment.volume/(air_contents.temperature * R_IDEAL_GAS_EQUATION)
|
||||
var/transfer_moles = pressure_delta*environment.volume*environment.group_multiplier*pump_speed/(air_contents.temperature * R_IDEAL_GAS_EQUATION)
|
||||
|
||||
var/datum/gas_mixture/removed = air_contents.remove(transfer_moles)
|
||||
|
||||
@@ -119,7 +123,7 @@
|
||||
|
||||
if(pressure_delta > 0)
|
||||
if(environment.temperature > 0)
|
||||
var/transfer_moles = pressure_delta*air_contents.volume/(environment.temperature * R_IDEAL_GAS_EQUATION)
|
||||
var/transfer_moles = pressure_delta*air_contents.volume*air_contents.group_multiplier*pump_speed/(environment.temperature * R_IDEAL_GAS_EQUATION)
|
||||
|
||||
var/datum/gas_mixture/removed = loc.remove_air(transfer_moles)
|
||||
if (isnull(removed)) //in space
|
||||
@@ -132,39 +136,42 @@
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
|
||||
//Radio remote control
|
||||
|
||||
proc
|
||||
set_frequency(new_frequency)
|
||||
radio_controller.remove_object(src, frequency)
|
||||
frequency = new_frequency
|
||||
if(frequency)
|
||||
radio_connection = radio_controller.add_object(src, frequency,radio_filter_in)
|
||||
proc/set_frequency(new_frequency)
|
||||
radio_controller.remove_object(src, frequency)
|
||||
frequency = new_frequency
|
||||
if(frequency)
|
||||
radio_connection = radio_controller.add_object(src, frequency,radio_filter_in)
|
||||
|
||||
broadcast_status()
|
||||
if(!radio_connection)
|
||||
return 0
|
||||
proc/broadcast_status()
|
||||
if(!radio_connection)
|
||||
return 0
|
||||
|
||||
var/datum/signal/signal = new
|
||||
signal.transmission_method = 1 //radio signal
|
||||
signal.source = src
|
||||
var/datum/signal/signal = new
|
||||
signal.transmission_method = 1 //radio signal
|
||||
signal.source = src
|
||||
|
||||
signal.data = list(
|
||||
"area" = src.area_uid,
|
||||
"tag" = src.id_tag,
|
||||
"device" = "AVP",
|
||||
"power" = on,
|
||||
"direction" = pump_direction?("release"):("siphon"),
|
||||
"checks" = pressure_checks,
|
||||
"internal" = internal_pressure_bound,
|
||||
"external" = external_pressure_bound,
|
||||
"timestamp" = world.time,
|
||||
"sigtype" = "status"
|
||||
)
|
||||
signal.data = list(
|
||||
"area" = src.area_uid,
|
||||
"tag" = src.id_tag,
|
||||
"device" = "AVP",
|
||||
"power" = on,
|
||||
"direction" = pump_direction?("release"):("siphon"),
|
||||
"checks" = pressure_checks,
|
||||
"internal" = internal_pressure_bound,
|
||||
"external" = external_pressure_bound,
|
||||
"timestamp" = world.time,
|
||||
"sigtype" = "status",
|
||||
"setting" = pump_speed
|
||||
)
|
||||
|
||||
radio_connection.post_signal(src, signal, radio_filter_out)
|
||||
radio_connection.post_signal(src, signal, radio_filter_out)
|
||||
|
||||
return 1
|
||||
return 1
|
||||
|
||||
|
||||
initialize()
|
||||
@@ -176,6 +183,7 @@
|
||||
if(frequency)
|
||||
set_frequency(frequency)
|
||||
|
||||
|
||||
receive_signal(datum/signal/signal)
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
@@ -203,47 +211,29 @@
|
||||
if("checks_toggle" in signal.data)
|
||||
pressure_checks = (pressure_checks?0:3)
|
||||
|
||||
if("direction" in signal.data)
|
||||
if("direction" in signal)
|
||||
pump_direction = text2num(signal.data["direction"])
|
||||
|
||||
if("set_internal_pressure" in signal.data)
|
||||
internal_pressure_bound = between(
|
||||
0,
|
||||
text2num(signal.data["set_internal_pressure"]),
|
||||
ONE_ATMOSPHERE*50
|
||||
)
|
||||
internal_pressure_bound = between(0, text2num(signal.data["set_internal_pressure"]), ONE_ATMOSPHERE*50)
|
||||
|
||||
if("set_external_pressure" in signal.data)
|
||||
external_pressure_bound = between(
|
||||
0,
|
||||
text2num(signal.data["set_external_pressure"]),
|
||||
ONE_ATMOSPHERE*50
|
||||
)
|
||||
external_pressure_bound = between(0, text2num(signal.data["set_external_pressure"]), ONE_ATMOSPHERE*50)
|
||||
|
||||
if("adjust_internal_pressure" in signal.data)
|
||||
internal_pressure_bound = between(
|
||||
0,
|
||||
internal_pressure_bound + text2num(signal.data["adjust_internal_pressure"]),
|
||||
ONE_ATMOSPHERE*50
|
||||
)
|
||||
internal_pressure_bound = between(0, internal_pressure_bound + text2num(signal.data["adjust_internal_pressure"]), ONE_ATMOSPHERE*50)
|
||||
|
||||
if("adjust_external_pressure" in signal.data)
|
||||
external_pressure_bound = between(
|
||||
0,
|
||||
external_pressure_bound + text2num(signal.data["adjust_external_pressure"]),
|
||||
ONE_ATMOSPHERE*50
|
||||
)
|
||||
external_pressure_bound = between(0, external_pressure_bound + text2num(signal.data["adjust_external_pressure"]), ONE_ATMOSPHERE*50)
|
||||
|
||||
if("init" in signal.data)
|
||||
name = signal.data["init"]
|
||||
return
|
||||
|
||||
if("status" in signal.data)
|
||||
spawn(2)
|
||||
broadcast_status()
|
||||
return //do not update_icon
|
||||
if("setting" in signal.data)
|
||||
pump_speed = text2num(signal.data["setting"])
|
||||
|
||||
//log_admin("DEBUG \[[world.timeofday]\]: vent_pump/receive_signal: unknown command \"[signal.data["command"]]\"\n[signal.debug_print()]")
|
||||
//log_admin("DEBUG \[[world.timeofday]\]: vent_pump/receive_signal: unknown command \"[signal["command"]]\"\n[signal.debug_print()]")
|
||||
spawn(2)
|
||||
broadcast_status()
|
||||
update_icon()
|
||||
@@ -284,6 +274,7 @@
|
||||
else
|
||||
user << "\blue You need more welding fuel to complete this task."
|
||||
return 1
|
||||
|
||||
examine()
|
||||
set src in oview(1)
|
||||
..()
|
||||
@@ -321,10 +312,4 @@
|
||||
"\blue You have unfastened \the [src].", \
|
||||
"You hear ratchet.")
|
||||
new /obj/item/pipe(loc, make_from=src)
|
||||
del(src)
|
||||
|
||||
/obj/machinery/atmospherics/unary/vent_pump/Del()
|
||||
if (initial_loc.air_scrub_info)
|
||||
initial_loc.air_scrub_info -= id_tag
|
||||
..()
|
||||
return
|
||||
del(src)
|
||||
@@ -7,34 +7,36 @@
|
||||
|
||||
level = 1
|
||||
|
||||
var/area/initial_loc
|
||||
var/id_tag = null
|
||||
var/frequency = 1439
|
||||
var/datum/radio_frequency/radio_connection
|
||||
|
||||
var/on = 0
|
||||
var/scrubbing = 1 //0 = siphoning, 1 = scrubbing
|
||||
var/scrub_CO2 = 1
|
||||
var/scrub_Toxins = 0
|
||||
var/scrub_N2O = 0
|
||||
var/scrub_rate = 1
|
||||
|
||||
var/volume_rate = 120
|
||||
var/panic = 0 //is this scrubber panicked?
|
||||
|
||||
var/area_uid
|
||||
|
||||
var/frequency = 1439
|
||||
var/datum/radio_frequency/radio_connection
|
||||
var/radio_filter_out
|
||||
var/radio_filter_in
|
||||
|
||||
New()
|
||||
initial_loc = get_area(loc)
|
||||
if (initial_loc.master)
|
||||
initial_loc = initial_loc.master
|
||||
area_uid = initial_loc.uid
|
||||
var/area/A = get_area(loc)
|
||||
if (A.master)
|
||||
A = A.master
|
||||
area_uid = A.uid
|
||||
if (!id_tag)
|
||||
assign_uid()
|
||||
id_tag = num2text(uid)
|
||||
if(ticker && ticker.current_state == 3)//if the game is running
|
||||
src.initialize()
|
||||
src.broadcast_status()
|
||||
initialize()
|
||||
broadcast_status()
|
||||
..()
|
||||
|
||||
update_icon()
|
||||
@@ -86,20 +88,20 @@
|
||||
|
||||
process()
|
||||
..()
|
||||
// broadcast_status()
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
if (!node)
|
||||
on = 0
|
||||
//broadcast_status()
|
||||
|
||||
if(!on)
|
||||
return 0
|
||||
|
||||
|
||||
var/datum/gas_mixture/environment = loc.return_air()
|
||||
|
||||
if(scrubbing)
|
||||
if((environment.toxins>0) || (environment.carbon_dioxide>0) || (environment.trace_gases.len>0))
|
||||
var/transfer_moles = min(1, volume_rate/environment.volume)*environment.total_moles()
|
||||
var/transfer_moles = min(1, volume_rate*scrub_rate/environment.volume)*environment.total_moles
|
||||
|
||||
//Take a gas sample
|
||||
var/datum/gas_mixture/removed = loc.remove_air(transfer_moles)
|
||||
@@ -118,15 +120,14 @@
|
||||
|
||||
if(removed.trace_gases.len>0)
|
||||
for(var/datum/gas/trace_gas in removed.trace_gases)
|
||||
if(istype(trace_gas, /datum/gas/oxygen_agent_b))
|
||||
removed.trace_gases -= trace_gas
|
||||
filtered_out.trace_gases += trace_gas
|
||||
else if(istype(trace_gas, /datum/gas/sleeping_agent) && scrub_N2O)
|
||||
if(istype(trace_gas, /datum/gas/sleeping_agent) && scrub_N2O)
|
||||
removed.trace_gases -= trace_gas
|
||||
filtered_out.trace_gases += trace_gas
|
||||
|
||||
|
||||
//Remix the resulting gases
|
||||
filtered_out.update_values()
|
||||
removed.update_values()
|
||||
air_contents.merge(filtered_out)
|
||||
|
||||
loc.assume_air(removed)
|
||||
@@ -138,7 +139,7 @@
|
||||
if (air_contents.return_pressure()>=50*ONE_ATMOSPHERE)
|
||||
return
|
||||
|
||||
var/transfer_moles = environment.total_moles()*(volume_rate/environment.volume)
|
||||
var/transfer_moles = environment.total_moles*(volume_rate*scrub_rate/environment.volume)
|
||||
|
||||
var/datum/gas_mixture/removed = loc.remove_air(transfer_moles)
|
||||
|
||||
@@ -220,6 +221,9 @@
|
||||
broadcast_status()
|
||||
return //do not update_icon
|
||||
|
||||
if("setting" in signal.data)
|
||||
scrub_rate = text2num(signal.data["setting"])
|
||||
|
||||
// log_admin("DEBUG \[[world.timeofday]\]: vent_scrubber/receive_signal: unknown command \"[signal.data["command"]]\"\n[signal.debug_print()]")
|
||||
spawn(2)
|
||||
broadcast_status()
|
||||
@@ -227,7 +231,7 @@
|
||||
return
|
||||
|
||||
power_change()
|
||||
if(powered(power_channel))
|
||||
if(powered(ENVIRON))
|
||||
stat &= ~NOPOWER
|
||||
else
|
||||
stat |= NOPOWER
|
||||
@@ -257,10 +261,4 @@
|
||||
"\blue You have unfastened \the [src].", \
|
||||
"You hear ratchet.")
|
||||
new /obj/item/pipe(loc, make_from=src)
|
||||
del(src)
|
||||
|
||||
/obj/machinery/atmospherics/unary/vent_scrubber/Del()
|
||||
if (initial_loc.air_scrub_info)
|
||||
initial_loc.air_scrub_info -= id_tag
|
||||
..()
|
||||
return
|
||||
del(src)
|
||||
Reference in New Issue
Block a user