unfucks vents/scrubbers

This commit is contained in:
Katherine Kiefer
2022-04-18 17:39:31 +10:00
parent d5ca7fe400
commit 6f4549db82
3 changed files with 82 additions and 32 deletions

View File

@@ -186,10 +186,6 @@
/turf/open/proc/equalize_pressure_in_zone(cyclenum)
/turf/open/proc/consider_firelocks(turf/T2)
for(var/obj/machinery/atmospherics/components/unary/vent_pump/stopped in T2)
stopped.on = FALSE
for(var/obj/machinery/atmospherics/components/unary/vent_pump/stopped in src)
stopped.on = FALSE
for(var/obj/machinery/door/firedoor/FD in T2)
FD.emergency_pressure_stop()
for(var/obj/machinery/door/firedoor/FD in src)

View File

@@ -6,7 +6,7 @@
#define RELEASING 1
/obj/machinery/atmospherics/components/unary/vent_pump
icon_state = "vent_map-2"
icon_state = "vent_map-3"
name = "air vent"
desc = "Has a valve and pump attached to it."
@@ -16,6 +16,8 @@
welded = FALSE
level = 1
layer = GAS_SCRUBBER_LAYER
shift_underlay_only = FALSE
showpipe = FALSE
interacts_with_air = TRUE
@@ -29,6 +31,12 @@
// INT_BOUND: Do not pass internal_pressure_bound
// NO_BOUND: Do not pass either
var/fast_fill = TRUE
var/space_detection = TRUE
var/space_shutoff_ticks = 0
var/last_moles
var/last_moles_added
var/frequency = FREQ_ATMOS_CONTROL
var/datum/radio_frequency/radio_connection
var/radio_filter_out
@@ -42,6 +50,9 @@
..()
if(!id_tag)
id_tag = assign_uid_vents()
var/datum/gas_mixture/N = airs[1]
N.set_volume(1000) // Increase the volume of the air vent's node.
// Allows it to pump much faster.
/obj/machinery/atmospherics/components/unary/vent_pump/Destroy()
var/area/A = get_area(src)
@@ -58,8 +69,10 @@
/obj/machinery/atmospherics/components/unary/vent_pump/update_icon_nopipes()
cut_overlays()
if(showpipe)
var/image/cap = getpipeimage(icon, "vent_cap", initialize_directions, piping_layer = piping_layer)
var/image/cap = getpipeimage(icon, "vent_cap", initialize_directions)
add_overlay(cap)
else
PIPING_LAYER_SHIFT(src, PIPING_LAYER_DEFAULT)
if(welded)
icon_state = "vent_welded"
@@ -71,12 +84,21 @@
return
if(pump_direction & RELEASING)
icon_state = "vent_out-off"
var/do_flick = (icon_state == "vent_out")
if(space_shutoff_ticks > 0)
icon_state = "vent_off_spaceerror"
else
icon_state = "vent_off"
if(do_flick)
flick("vent_out-off", src)
else // pump_direction == SIPHONING
icon_state = "vent_in-off"
var/do_flick = (icon_state == "vent_in")
icon_state = "vent_off"
if(do_flick)
flick("vent_in-off",src)
return
if(icon_state == ("vent_out-off" || "vent_in-off" || "vent_off"))
if(icon_state == "vent_out-off" || icon_state == "vent_in-off" || icon_state == "vent_off" || icon_state == "vent_off_spaceerror")
if(pump_direction & RELEASING)
icon_state = "vent_out"
flick("vent_out-starting", src)
@@ -93,36 +115,58 @@
/obj/machinery/atmospherics/components/unary/vent_pump/process_atmos()
..()
if(!is_operational() || !isopenturf(loc))
last_moles_added = 0
return
if(space_shutoff_ticks > 0)
space_shutoff_ticks--
if(space_shutoff_ticks <= 1 && !on)
on = TRUE
update_icon()
if(!nodes[1])
on = FALSE
if(!on || welded)
last_moles_added = 0
return
var/datum/gas_mixture/air_contents = airs[1]
var/datum/gas_mixture/environment = loc.return_air()
if(environment == null)
return
var/environment_pressure = environment.return_pressure()
var/environment_moles = environment.total_moles()
var/last_moles_real_added = environment_moles - last_moles
if(!aac)
if((last_moles_added > 0 && environment_moles == 0 && space_detection) || (is_mining_level(z) && ISINRANGE(environment_moles, 36, 38)))
// looks like we have a S P A C E problem.
last_moles_added = 0
on = FALSE
space_shutoff_ticks = 20 // shut off for about 20 seconds before trying again.
update_icon()
return
if(pump_direction & RELEASING) // internal -> external
var/pressure_delta = 10000
if(pressure_checks&EXT_BOUND)
pressure_delta = min(pressure_delta, (external_pressure_bound - environment_pressure))
var/multiplier = 1 // fast_fill multiplier
if(fast_fill)
if(last_moles_added > 0 && last_moles_real_added > 0)
multiplier = clamp(last_moles_added / last_moles_real_added * 0.25, 1, 100)
else if(last_moles_added > 0 && last_moles_real_added < 0 && environment_moles != 0)
multiplier = 10 // pressure is going down, but let's fight it anyways
pressure_delta = min(pressure_delta, (external_pressure_bound - environment_pressure) * multiplier)
if(pressure_checks&INT_BOUND)
pressure_delta = min(pressure_delta, (air_contents.return_pressure() - internal_pressure_bound))
if(space_shutoff_ticks > 0) // if we just came off a space-shutoff, only transfer a little bit.
pressure_delta = min(pressure_delta, 10)
if(pressure_delta > 0)
if(air_contents.return_temperature() > 0)
var/transfer_moles = pressure_delta*environment.return_volume()/(air_contents.return_temperature() * R_IDEAL_GAS_EQUATION)
var/transfer_moles = pressure_delta*environment.return_volume()/(air_contents.return_temperature() * R_IDEAL_GAS_EQUATION)
last_moles_added = transfer_moles
loc.assume_air_moles(air_contents, transfer_moles)
air_update_turf()
else // external -> internal
last_moles_added = 0
if(environment.return_pressure() > 0)
var/our_multiplier = air_contents.return_volume() / (environment.return_temperature() * R_IDEAL_GAS_EQUATION)
var/moles_delta = 10000 * our_multiplier
@@ -133,7 +177,7 @@
if(moles_delta > 0)
loc.transfer_air(air_contents, moles_delta)
air_update_turf()
last_moles = environment_moles
update_parents()
//Radio remote control
@@ -199,9 +243,11 @@
if("power" in signal.data)
on = text2num(signal.data["power"])
space_shutoff_ticks = 0
if("power_toggle" in signal.data)
on = !on
space_shutoff_ticks = 0
if("checks" in signal.data)
var/old_checks = pressure_checks
@@ -254,23 +300,25 @@
/obj/machinery/atmospherics/components/unary/vent_pump/welder_act(mob/living/user, obj/item/I)
if(!I.tool_start_check(user, amount=0))
return TRUE
to_chat(user, "<span class='notice'>You begin welding the vent...</span>")
to_chat(user, span_notice("You begin welding the vent..."))
if(I.use_tool(src, user, 20, volume=50))
if(!welded)
user.visible_message("[user] welds the vent shut.", "<span class='notice'>You weld the vent shut.</span>", "<span class='italics'>You hear welding.</span>")
user.visible_message("[user] welds the vent shut.", span_notice("You weld the vent shut."), span_italics("You hear welding."))
welded = TRUE
else
user.visible_message("[user] unwelded the vent.", "<span class='notice'>You unweld the vent.</span>", "<span class='italics'>You hear welding.</span>")
user.visible_message("[user] unwelded the vent.", span_notice("You unweld the vent."), span_italics("You hear welding."))
welded = FALSE
update_icon()
pipe_vision_img = image(src, loc, layer = ABOVE_HUD_LAYER, dir = dir)
pipe_vision_img.plane = ABOVE_HUD_PLANE
investigate_log("was [welded ? "welded shut" : "unwelded"] by [key_name(user)]", INVESTIGATE_ATMOS)
add_fingerprint(user)
return TRUE
/obj/machinery/atmospherics/components/unary/vent_pump/can_unwrench(mob/user)
. = ..()
if(. && on && is_operational())
to_chat(user, "<span class='warning'>You cannot unwrench [src], turn it off first!</span>")
to_chat(user, span_warning("You cannot unwrench [src], turn it off first!"))
return FALSE
/obj/machinery/atmospherics/components/unary/vent_pump/examine(mob/user)
@@ -279,16 +327,16 @@
. += "It seems welded shut."
/obj/machinery/atmospherics/components/unary/vent_pump/power_change()
..()
. = ..()
update_icon_nopipes()
/obj/machinery/atmospherics/components/unary/vent_pump/can_crawl_through()
return !welded
/obj/machinery/atmospherics/components/unary/vent_pump/attack_alien(mob/user)
if(!welded || !(do_after(user, 20, target = src)))
if(!welded || !(do_after(user, 2 SECONDS, target = src)))
return
user.visible_message("<span class='warning'>[user] furiously claws at [src]!</span>", "<span class='notice'>You manage to clear away the stuff blocking the vent.</span>", "<span class='warning'>You hear loud scraping noises.</span>")
user.visible_message("[user] furiously claws at [src]!", "You manage to clear away the stuff blocking the vent", "You hear loud scraping noises.")
welded = FALSE
update_icon()
pipe_vision_img = image(src, loc, layer = ABOVE_HUD_LAYER, dir = dir)

View File

@@ -2,7 +2,7 @@
#define SCRUBBING 1
/obj/machinery/atmospherics/components/unary/vent_scrubber
icon_state = "scrub_map-2"
icon_state = "scrub_map-3"
name = "air scrubber"
desc = "Has a valve and pump attached to it."
@@ -13,13 +13,15 @@
welded = FALSE
level = 1
layer = GAS_SCRUBBER_LAYER
shift_underlay_only = FALSE
showpipe = FALSE
interacts_with_air = TRUE
var/id_tag = null
var/scrubbing = SCRUBBING //0 = siphoning, 1 = scrubbing
var/filter_types = list(GAS_CO2, GAS_BZ)
var/filter_types = list(GAS_CO2)
var/volume_rate = 200
var/widenet = 0 //is this scrubber acting on the 3x3 area around it.
var/list/turf/adjacent_turfs = list()
@@ -66,8 +68,10 @@
/obj/machinery/atmospherics/components/unary/vent_scrubber/update_icon_nopipes()
cut_overlays()
if(showpipe)
var/image/cap = getpipeimage(icon, "scrub_cap", initialize_directions, piping_layer = piping_layer)
var/image/cap = getpipeimage(icon, "scrub_cap", initialize_directions)
add_overlay(cap)
else
PIPING_LAYER_SHIFT(src, PIPING_LAYER_DEFAULT)
if(welded)
icon_state = "scrub_welded"
@@ -223,13 +227,13 @@
return
/obj/machinery/atmospherics/components/unary/vent_scrubber/power_change()
..()
. = ..()
update_icon_nopipes()
/obj/machinery/atmospherics/components/unary/vent_scrubber/welder_act(mob/living/user, obj/item/I)
if(!I.tool_start_check(user, amount=0))
return TRUE
to_chat(user, "<span class='notice'>Now welding the scrubber.</span>")
to_chat(user, span_notice("Now welding the scrubber."))
if(I.use_tool(src, user, 20, volume=50))
if(!welded)
user.visible_message("[user] welds the scrubber shut.","You weld the scrubber shut.", "You hear welding.")
@@ -240,12 +244,14 @@
update_icon()
pipe_vision_img = image(src, loc, layer = ABOVE_HUD_LAYER, dir = dir)
pipe_vision_img.plane = ABOVE_HUD_PLANE
investigate_log("was [welded ? "welded shut" : "unwelded"] by [key_name(user)]", INVESTIGATE_ATMOS)
add_fingerprint(user)
return TRUE
/obj/machinery/atmospherics/components/unary/vent_scrubber/can_unwrench(mob/user)
. = ..()
if(. && on && is_operational())
to_chat(user, "<span class='warning'>You cannot unwrench [src], turn it off first!</span>")
to_chat(user, span_warning("You cannot unwrench [src], turn it off first!"))
return FALSE
/obj/machinery/atmospherics/components/unary/vent_scrubber/examine(mob/user)
@@ -257,9 +263,9 @@
return !welded
/obj/machinery/atmospherics/components/unary/vent_scrubber/attack_alien(mob/user)
if(!welded || !(do_after(user, 20, target = src)))
if(!welded || !(do_after(user, 2 SECONDS, target = src)))
return
user.visible_message("<span class='warning'>[user] furiously claws at [src]!</span>", "<span class='notice'>You manage to clear away the stuff blocking the scrubber.</span>", "<span class='warning'>You hear loud scraping noises.</span>")
user.visible_message("[user] furiously claws at [src]!", "You manage to clear away the stuff blocking the scrubber.", "You hear loud scraping noises.")
welded = FALSE
update_icon()
pipe_vision_img = image(src, loc, layer = ABOVE_HUD_LAYER, dir = dir)