mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
Buffs portable air scrubbers (#22976)
* portable scrubbers are now better * commit * pressure checks * gas selection * clarke scrubber interface * clarke scrubber can now be emptied * clarke scrubber can now be drained * more pressure * scrubber behaviour change * remove debug message * volume
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#define MAX_PRESSURE 50*ONE_ATMOSPHERE
|
||||
|
||||
/obj/machinery/portable_atmospherics/scrubber
|
||||
name = "Portable Air Scrubber"
|
||||
|
||||
@@ -6,12 +8,16 @@
|
||||
density = 1
|
||||
|
||||
var/on = 0
|
||||
var/volume_rate = 800
|
||||
var/volume_rate = 5000 //litres / tick
|
||||
var/scrubbing_rate = 300 //litres / tick, max amount of gas put in internal tank per tick
|
||||
|
||||
volume = 750
|
||||
var/scrub_o2 = FALSE
|
||||
var/scrub_n2 = FALSE
|
||||
var/scrub_n2o = TRUE
|
||||
var/scrub_co2 = TRUE
|
||||
var/scrub_plasma = TRUE
|
||||
|
||||
var/minrate = 0//probably useless, but whatever
|
||||
var/maxrate = 10 * ONE_ATMOSPHERE
|
||||
volume = 2000
|
||||
|
||||
/obj/machinery/portable_atmospherics/scrubber/emp_act(severity)
|
||||
if(stat & (BROKEN|NOPOWER))
|
||||
@@ -30,7 +36,8 @@
|
||||
icon_state = "scrubber:0"
|
||||
anchored = 1
|
||||
volume = 50000
|
||||
volume_rate = 5000
|
||||
volume_rate = 20000
|
||||
scrubbing_rate = 1200
|
||||
|
||||
var/global/gid = 1
|
||||
var/id = 0
|
||||
@@ -114,7 +121,7 @@
|
||||
/obj/machinery/portable_atmospherics/scrubber/process()
|
||||
..()
|
||||
|
||||
if(on)
|
||||
if(on && air_contents.return_pressure() < MAX_PRESSURE)
|
||||
var/datum/gas_mixture/environment = get_environment()
|
||||
var/transfer_moles = min(1, volume_rate / environment.volume) * environment.total_moles()
|
||||
|
||||
@@ -122,22 +129,32 @@
|
||||
var/datum/gas_mixture/removed = remove_sample(environment, transfer_moles)
|
||||
|
||||
//Filter it
|
||||
//copypasted from scrubber code with modifications to add the scrubbing rate limit
|
||||
if (removed)
|
||||
var/datum/gas_mixture/filtered_out = new
|
||||
var/datum/gas_mixture/total_to_filter = new
|
||||
total_to_filter.temperature = removed.temperature
|
||||
#define FILTER(g) total_to_filter.adjust_gas((g), removed[g], FALSE)
|
||||
if(scrub_plasma)
|
||||
FILTER(GAS_PLASMA)
|
||||
if(scrub_co2)
|
||||
FILTER(GAS_CARBON)
|
||||
if(scrub_n2o)
|
||||
FILTER(GAS_SLEEPING)
|
||||
if(scrub_n2)
|
||||
FILTER(GAS_NITROGEN)
|
||||
if(scrub_o2)
|
||||
FILTER(GAS_OXYGEN)
|
||||
FILTER(GAS_OXAGENT)
|
||||
#undef FILTER
|
||||
total_to_filter.update_values() //since the FILTER macro doesn't update to save perf, we need to update here
|
||||
//calculate the amount of moles in scrubbing_rate litres of gas in removed and apply the scrubbing rate limit
|
||||
var/filter_moles = min(1, scrubbing_rate / volume_rate) * removed.total_moles()
|
||||
var/datum/gas_mixture/filtered_out = total_to_filter.remove(filter_moles)
|
||||
|
||||
filtered_out.temperature = removed.temperature
|
||||
|
||||
|
||||
filtered_out.adjust_multi(
|
||||
GAS_PLASMA, removed[GAS_PLASMA],
|
||||
GAS_CARBON, removed[GAS_CARBON],
|
||||
GAS_SLEEPING, removed[GAS_SLEEPING],
|
||||
GAS_OXAGENT, removed[GAS_OXAGENT])
|
||||
removed.subtract(filtered_out)
|
||||
|
||||
//Remix the resulting gases
|
||||
//Remix the resulting gases
|
||||
air_contents.merge(filtered_out)
|
||||
|
||||
return_sample(environment, removed)
|
||||
//src.update_icon()
|
||||
nanomanager.update_uis(src)
|
||||
@@ -163,9 +180,12 @@
|
||||
data["portConnected"] = connected_port ? 1 : 0
|
||||
data["tankPressure"] = round(air_contents.return_pressure() > 0 ? air_contents.return_pressure() : 0)
|
||||
data["rate"] = round(volume_rate)
|
||||
data["minrate"] = round(minrate)
|
||||
data["maxrate"] = round(maxrate)
|
||||
data["on"] = on ? 1 : 0
|
||||
data["scrub_plasma"] = scrub_plasma
|
||||
data["scrub_co2"] = scrub_co2
|
||||
data["scrub_n2o"] = scrub_n2o
|
||||
data["scrub_n2"] = scrub_n2
|
||||
data["scrub_o2"] = scrub_o2
|
||||
|
||||
data["hasHoldingTank"] = holding ? 1 : 0
|
||||
if (holding)
|
||||
@@ -197,9 +217,19 @@
|
||||
if(holding)
|
||||
eject_holding()
|
||||
|
||||
if(href_list["volume_adj"])
|
||||
var/diff = text2num(href_list["volume_adj"])
|
||||
volume_rate = Clamp(volume_rate+diff, minrate, maxrate)
|
||||
if(href_list["scrub_toggle"])
|
||||
switch(href_list["scrub_toggle"])
|
||||
if("plasma")
|
||||
scrub_plasma = !scrub_plasma
|
||||
if("co2")
|
||||
scrub_co2 = !scrub_co2
|
||||
if("n2o")
|
||||
scrub_n2o = !scrub_n2o
|
||||
if("n2")
|
||||
scrub_n2 = !scrub_n2
|
||||
if("o2")
|
||||
scrub_o2 = !scrub_o2
|
||||
return 1
|
||||
|
||||
src.add_fingerprint(usr)
|
||||
return 1
|
||||
@@ -213,6 +243,12 @@
|
||||
/obj/machinery/portable_atmospherics/scrubber/mech
|
||||
volume = 50000
|
||||
volume_rate = 20000
|
||||
scrubbing_rate = 1200
|
||||
var/obj/mecha/mech //the mech associated with this scrubber
|
||||
|
||||
/obj/machinery/portable_atmospherics/scrubber/mech/New(var/location)
|
||||
..()
|
||||
src.mech = location
|
||||
|
||||
/obj/machinery/portable_atmospherics/scrubber/mech/get_environment()
|
||||
var/turf/T = get_turf(src)
|
||||
@@ -225,3 +261,36 @@
|
||||
/obj/machinery/portable_atmospherics/scrubber/mech/return_sample(var/environment, var/removed)
|
||||
var/turf/T = get_turf(src)
|
||||
T.assume_air(removed)
|
||||
|
||||
//required to allow the pilot to use the scrubber UI
|
||||
/obj/machinery/portable_atmospherics/scrubber/mech/is_on_same_z(var/mob/user)
|
||||
if(user == mech.occupant)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/obj/machinery/portable_atmospherics/scrubber/mech/is_in_range(var/mob/user)
|
||||
if(user == mech.occupant)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
//Have to override this to let it connect from the mech
|
||||
/obj/machinery/portable_atmospherics/connect(obj/machinery/atmospherics/unary/portables_connector/new_port)
|
||||
//Make sure not already connected to something else
|
||||
if(connected_port || !new_port || new_port.connected_device)
|
||||
return 0
|
||||
|
||||
//Perform the connection
|
||||
connected_port = new_port
|
||||
connected_port.connected_device = src
|
||||
|
||||
anchored = 1 //Prevent movement
|
||||
|
||||
//Actually enforce the air sharing
|
||||
var/datum/pipe_network/network = connected_port.return_network(src)
|
||||
if(network && !network.gases.Find(air_contents))
|
||||
network.gases += air_contents
|
||||
network.update = 1
|
||||
update_icon()
|
||||
return 1
|
||||
|
||||
#undef MAX_PRESSURE
|
||||
|
||||
@@ -362,6 +362,17 @@ Class Procs:
|
||||
update_multitool_menu(usr)
|
||||
return 1
|
||||
|
||||
/obj/machinery/proc/is_on_same_z(var/mob/user)
|
||||
var/turf/T = get_turf(user)
|
||||
if(!isAI(user) && T.z != z && user.z != map.zCentcomm)
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/proc/is_in_range(var/mob/user)
|
||||
if((!in_range(src, usr) || !istype(src.loc, /turf)) && !istype(usr, /mob/living/silicon))
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/Topic(href, href_list)
|
||||
..()
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
@@ -377,12 +388,10 @@ Class Procs:
|
||||
if (!usr.dexterity_check())
|
||||
to_chat(usr, "<span class='warning'>You don't have the dexterity to do this!</span>")
|
||||
return 1
|
||||
var/turf/T = get_turf(usr)
|
||||
if(!isAI(usr) && T.z != z)
|
||||
if(usr.z != map.zCentcomm)
|
||||
to_chat(usr, "<span class='warning'>WARNING: Unable to interface with \the [src.name].</span>")
|
||||
return 1
|
||||
if ((!in_range(src, usr) || !istype(src.loc, /turf)) && !istype(usr, /mob/living/silicon))
|
||||
if(!is_on_same_z(usr))
|
||||
to_chat(usr, "<span class='warning'>WARNING: Unable to interface with \the [src.name].</span>")
|
||||
return 1
|
||||
if(!is_in_range(usr))
|
||||
to_chat(usr, "<span class='warning'>WARNING: Connection failure. Reduce range.</span>")
|
||||
return 1
|
||||
else if(!custom_aghost_alerts)
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
var/image/thruster_overlay
|
||||
var/overlay_applied = FALSE
|
||||
var/obj/machinery/portable_atmospherics/scrubber/mech/scrubber
|
||||
var/obj/machinery/atmospherics/unary/portables_connector/scrubber_port = null
|
||||
|
||||
/obj/mecha/working/clarke/New()
|
||||
..()
|
||||
@@ -28,6 +29,12 @@
|
||||
/obj/mecha/working/clarke/check_for_support()
|
||||
return 1
|
||||
|
||||
/obj/mecha/working/clarke/relaymove()
|
||||
if(scrubber_port)
|
||||
occupant_message("Unable to move while connected to the air system port.", TRUE)
|
||||
return 0
|
||||
..()
|
||||
|
||||
/obj/mecha/working/clarke/mechturn(direction)
|
||||
dir = direction
|
||||
playsound(src,'sound/mecha/mechmove01.ogg',40,1)
|
||||
@@ -53,11 +60,44 @@
|
||||
/obj/mecha/working/clarke/startMechWalking()
|
||||
icon_state = initial_icon + "-move"
|
||||
|
||||
/obj/mecha/working/clarke/connect()
|
||||
if(scrubber_port)
|
||||
return 0
|
||||
return ..()
|
||||
|
||||
/obj/mecha/working/clarke/proc/connect_scrubber(obj/machinery/atmospherics/unary/portables_connector/new_port)
|
||||
//Make sure not already connected to something else
|
||||
if(connected_port || scrubber_port || !new_port || new_port.connected_device)
|
||||
return 0
|
||||
|
||||
//Make sure are close enough for a valid connection
|
||||
if(new_port.loc != src.loc)
|
||||
return 0
|
||||
|
||||
//Perform the connection
|
||||
scrubber_port = new_port
|
||||
scrubber.connect(new_port)
|
||||
|
||||
log_message("Connected to gas port.")
|
||||
return 1
|
||||
|
||||
/obj/mecha/working/clarke/proc/disconnect_scrubber()
|
||||
if(!scrubber_port)
|
||||
return 0
|
||||
|
||||
scrubber.disconnect()
|
||||
|
||||
scrubber_port = null
|
||||
src.log_message("Disconnected from gas port.")
|
||||
return 1
|
||||
|
||||
/obj/mecha/working/clarke/get_commands()
|
||||
var/output = {"<div class='wr'>
|
||||
<div class='header'>Special</div>
|
||||
<div class='links'>
|
||||
<a href='?src=\ref[src];scrubbing=1'><span id="scrubbing_command">[scrubber.on?"Deactivate":"Activate"] scrubber</span></a>
|
||||
<a href='?src=\ref[src];scrubber_interface=1'>Scrubber interface</a>
|
||||
<br>
|
||||
<span id="scrubbing_port">[src.scrubber_port ? "<a href='?src=\ref[src];scrubber_disconnect=1'>Disconnect Scrubber to Port</a>" : "<a href='?src=\ref[src];scrubber_connect=1'>Connect Scrubber to Port</a>"]</span>
|
||||
</div>
|
||||
</div>
|
||||
"}
|
||||
@@ -65,9 +105,32 @@
|
||||
return output
|
||||
|
||||
/obj/mecha/working/clarke/Topic(href, href_list)
|
||||
..()
|
||||
if (href_list["scrubbing"])
|
||||
scrubber.on = !scrubber.on
|
||||
send_byjax(src.occupant,"exosuit.browser","scrubbing_command","[scrubber.on?"Deactivate":"Activate"] scrubber")
|
||||
src.occupant_message("<font color=\"[scrubber.on?"#00f\">Activated":"#f00\">Deactivated"] scrubber.</font>")
|
||||
. = ..()
|
||||
if (href_list["scrubber_interface"])
|
||||
if(usr != src.occupant)
|
||||
return
|
||||
scrubber.ui_interact(occupant)
|
||||
return
|
||||
if (href_list["scrubber_connect"])
|
||||
if(usr != src.occupant)
|
||||
return
|
||||
var/obj/machinery/atmospherics/unary/portables_connector/possible_port = locate(/obj/machinery/atmospherics/unary/portables_connector/) in loc
|
||||
if(possible_port)
|
||||
if(connect_scrubber(possible_port))
|
||||
src.occupant_message("<span class='notice'>[name] connects to the port.</span>")
|
||||
send_byjax(src.occupant, "exosuit.browser", "scrubbing_port", src.scrubber_port ? "<a href='?src=\ref[src];scrubber_disconnect=1'>Disconnect Scrubber from Port</a>" : "<a href='?src=\ref[src];scrubber_connect=1'>Connect Scrubber to Port</a>")
|
||||
else
|
||||
src.occupant_message("<span class='warning'>[name] failed to connect to the port.</span>")
|
||||
else
|
||||
src.occupant_message("Nothing happens")
|
||||
return
|
||||
if (href_list["scrubber_disconnect"])
|
||||
if(usr != src.occupant)
|
||||
return
|
||||
if(disconnect_scrubber())
|
||||
src.occupant_message("<span class='notice'>[name] disconnects from the port.</span>")
|
||||
send_byjax(src.occupant, "exosuit.browser", "scrubbing_port", src.scrubber_port ? "<a href='?src=\ref[src];scrubber_disconnect=1'>Disconnect Scrubber from Port</a>" : "<a href='?src=\ref[src];scrubber_connect=1'>Connect Scrubber to Port</a>")
|
||||
else
|
||||
src.occupant_message("<span class='warning'>[name] is not connected to the port at the moment.</span>")
|
||||
return
|
||||
return
|
||||
@@ -41,25 +41,18 @@
|
||||
<div class="item"> </div>
|
||||
{{/if}}
|
||||
|
||||
|
||||
<h3>Power Regulator Status</h3>
|
||||
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Volume Rate:
|
||||
Scrubbing Gases:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:helper.displayBar(data.rate, data.minrate, data.maxrate)}}
|
||||
<div style="clear: both; padding-top: 4px;">
|
||||
{{:helper.link('-', null, {'volume_adj' : -1000}, (data.rate > data.minrate) ? null : 'disabled')}}
|
||||
{{:helper.link('-', null, {'volume_adj' : -100}, (data.rate > data.minrate) ? null : 'disabled')}}
|
||||
{{:helper.link('-', null, {'volume_adj' : -10}, (data.rate > data.minrate) ? null : 'disabled')}}
|
||||
{{:helper.link('-', null, {'volume_adj' : -1}, (data.rate > data.minrate) ? null : 'disabled')}}
|
||||
<div style="float: left; width: 80px; text-align: center;"> {{:data.rate}} kPa </div>
|
||||
{{:helper.link('+', null, {'volume_adj' : 1}, (data.rate < data.maxrate) ? null : 'disabled')}}
|
||||
{{:helper.link('+', null, {'volume_adj' : 10}, (data.rate < data.maxrate) ? null : 'disabled')}}
|
||||
{{:helper.link('+', null, {'volume_adj' : 100}, (data.rate < data.maxrate) ? null : 'disabled')}}
|
||||
{{:helper.link('+', null, {'volume_adj' : 1000}, (data.rate < data.maxrate) ? null : 'disabled')}}
|
||||
</div>
|
||||
{{:helper.link('CO<sub>2</sub>', null, {'scrub_toggle': 'co2'}, null, data.scrub_co2 ? 'greenBackground' : null)}}
|
||||
{{:helper.link('Plasma', null, {'scrub_toggle': 'plasma'}, null, data.scrub_plasma ? 'greenBackground' : null)}}
|
||||
{{:helper.link('N<sub>2</sub>O', null, {'scrub_toggle': 'n2o'}, null, data.scrub_n2o ? 'greenBackground' : null)}}
|
||||
{{:helper.link('N<sub>2</sub>', null, {'scrub_toggle': 'n2'}, null, data.scrub_n2 ? 'greenBackground' : null)}}
|
||||
{{:helper.link('O<sub>2</sub>', null, {'scrub_toggle': 'o2'}, null, data.scrub_o2 ? 'greenBackground' : null)}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user