mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-28 23:58:07 +01:00
caches gases in more procs
This commit is contained in:
@@ -9,22 +9,23 @@
|
||||
|
||||
var/toxins_used = 0
|
||||
var/breath_pressure = (breath.total_moles()*R_IDEAL_GAS_EQUATION*breath.temperature)/BREATH_VOLUME
|
||||
var/list/breath_gases = breath.gases
|
||||
|
||||
//Partial pressure of the toxins in our breath
|
||||
var/Toxins_pp = (breath.gases[GAS_PL][MOLES]/breath.total_moles())*breath_pressure
|
||||
var/Toxins_pp = (breath_gases[GAS_PL][MOLES]/breath.total_moles())*breath_pressure
|
||||
|
||||
if(Toxins_pp) // Detect toxins in air
|
||||
adjustPlasma(breath.gases[GAS_PL][MOLES]*250)
|
||||
adjustPlasma(breath_gases[GAS_PL][MOLES]*250)
|
||||
throw_alert("alien_tox", /obj/screen/alert/alien_tox)
|
||||
|
||||
toxins_used = breath.gases[GAS_PL][MOLES]
|
||||
toxins_used = breath_gases[GAS_PL][MOLES]
|
||||
|
||||
else
|
||||
clear_alert("alien_tox")
|
||||
|
||||
//Breathe in toxins and out oxygen
|
||||
breath.gases[GAS_PL][MOLES] -= toxins_used
|
||||
breath.gases[GAS_O2][MOLES] += toxins_used
|
||||
breath_gases[GAS_PL][MOLES] -= toxins_used
|
||||
breath_gases[GAS_O2][MOLES] += toxins_used
|
||||
|
||||
//BREATH TEMPERATURE
|
||||
handle_breath_temperature(breath)
|
||||
|
||||
@@ -1167,10 +1167,12 @@
|
||||
|
||||
var/gas_breathed = 0
|
||||
|
||||
var/list/breath_gases = breath.gases
|
||||
|
||||
//Partial pressures in our breath
|
||||
var/O2_pp = breath.get_breath_partial_pressure(breath.gases[GAS_O2][MOLES])
|
||||
var/Toxins_pp = breath.get_breath_partial_pressure(breath.gases[GAS_PL][MOLES])
|
||||
var/CO2_pp = breath.get_breath_partial_pressure(breath.gases[GAS_CO2][MOLES])
|
||||
var/O2_pp = breath.get_breath_partial_pressure(breath_gases[GAS_O2][MOLES])
|
||||
var/Toxins_pp = breath.get_breath_partial_pressure(breath_gases[GAS_PL][MOLES])
|
||||
var/CO2_pp = breath.get_breath_partial_pressure(breath_gases[GAS_CO2][MOLES])
|
||||
|
||||
|
||||
//-- OXY --//
|
||||
@@ -1178,7 +1180,7 @@
|
||||
//Too much oxygen! //Yes, some species may not like it.
|
||||
if(safe_oxygen_max)
|
||||
if(O2_pp > safe_oxygen_max && !(NOBREATH in specflags))
|
||||
var/ratio = (breath.gases[GAS_O2][MOLES]/safe_oxygen_max) * 10
|
||||
var/ratio = (breath_gases[GAS_O2][MOLES]/safe_oxygen_max) * 10
|
||||
H.adjustOxyLoss(Clamp(ratio,oxy_breath_dam_min,oxy_breath_dam_max))
|
||||
H.throw_alert("too_much_oxy", /obj/screen/alert/too_much_oxy)
|
||||
else
|
||||
@@ -1187,17 +1189,17 @@
|
||||
//Too little oxygen!
|
||||
if(safe_oxygen_min)
|
||||
if(O2_pp < safe_oxygen_min)
|
||||
gas_breathed = handle_too_little_breath(H,O2_pp,safe_oxygen_min,breath.gases[GAS_O2][MOLES])
|
||||
gas_breathed = handle_too_little_breath(H,O2_pp,safe_oxygen_min,breath_gases[GAS_O2][MOLES])
|
||||
H.throw_alert("oxy", /obj/screen/alert/oxy)
|
||||
else
|
||||
H.failed_last_breath = 0
|
||||
H.adjustOxyLoss(-5)
|
||||
gas_breathed = breath.gases[GAS_O2][MOLES]/6
|
||||
gas_breathed = breath_gases[GAS_O2][MOLES]/6
|
||||
H.clear_alert("oxy")
|
||||
|
||||
//Exhale
|
||||
breath.gases[GAS_O2][MOLES] -= gas_breathed
|
||||
breath.gases[GAS_CO2][MOLES] += gas_breathed
|
||||
breath_gases[GAS_O2][MOLES] -= gas_breathed
|
||||
breath_gases[GAS_CO2][MOLES] += gas_breathed
|
||||
gas_breathed = 0
|
||||
|
||||
|
||||
@@ -1224,17 +1226,17 @@
|
||||
//Too little CO2!
|
||||
if(safe_co2_min)
|
||||
if(CO2_pp < safe_co2_min)
|
||||
gas_breathed = handle_too_little_breath(H,CO2_pp, safe_co2_min,breath.gases[GAS_CO2][MOLES])
|
||||
gas_breathed = handle_too_little_breath(H,CO2_pp, safe_co2_min,breath_gases[GAS_CO2][MOLES])
|
||||
H.throw_alert("not_enough_co2", /obj/screen/alert/not_enough_co2)
|
||||
else
|
||||
H.failed_last_breath = 0
|
||||
H.adjustOxyLoss(-5)
|
||||
gas_breathed = breath.gases[GAS_CO2][MOLES]/6
|
||||
gas_breathed = breath_gases[GAS_CO2][MOLES]/6
|
||||
H.clear_alert("not_enough_co2")
|
||||
|
||||
//Exhale
|
||||
breath.gases[GAS_CO2][MOLES] -= gas_breathed
|
||||
breath.gases[GAS_O2][MOLES] += gas_breathed
|
||||
breath_gases[GAS_CO2][MOLES] -= gas_breathed
|
||||
breath_gases[GAS_O2][MOLES] += gas_breathed
|
||||
gas_breathed = 0
|
||||
|
||||
|
||||
@@ -1243,7 +1245,7 @@
|
||||
//Too much toxins!
|
||||
if(safe_toxins_max)
|
||||
if(Toxins_pp > safe_toxins_max && !(NOBREATH in specflags))
|
||||
var/ratio = (breath.gases[GAS_PL][MOLES]/safe_toxins_max) * 10
|
||||
var/ratio = (breath_gases[GAS_PL][MOLES]/safe_toxins_max) * 10
|
||||
if(H.reagents)
|
||||
H.reagents.add_reagent("plasma", Clamp(ratio, tox_breath_dam_min, tox_breath_dam_max))
|
||||
H.throw_alert("tox_in_air", /obj/screen/alert/tox_in_air)
|
||||
@@ -1254,24 +1256,24 @@
|
||||
//Too little toxins!
|
||||
if(safe_toxins_min)
|
||||
if(Toxins_pp < safe_toxins_min && !(NOBREATH in specflags))
|
||||
gas_breathed = handle_too_little_breath(H,Toxins_pp, safe_toxins_min, breath.gases[GAS_PL][MOLES])
|
||||
gas_breathed = handle_too_little_breath(H,Toxins_pp, safe_toxins_min, breath_gases[GAS_PL][MOLES])
|
||||
H.throw_alert("not_enough_tox", /obj/screen/alert/not_enough_tox)
|
||||
else
|
||||
H.failed_last_breath = 0
|
||||
H.adjustOxyLoss(-5)
|
||||
gas_breathed = breath.gases[GAS_PL][MOLES]/6
|
||||
gas_breathed = breath_gases[GAS_PL][MOLES]/6
|
||||
H.clear_alert("not_enough_tox")
|
||||
|
||||
//Exhale
|
||||
breath.gases[GAS_PL][MOLES] -= gas_breathed
|
||||
breath.gases[GAS_CO2][MOLES] += gas_breathed
|
||||
breath_gases[GAS_PL][MOLES] -= gas_breathed
|
||||
breath_gases[GAS_CO2][MOLES] += gas_breathed
|
||||
gas_breathed = 0
|
||||
|
||||
|
||||
//-- TRACES --//
|
||||
|
||||
if(breath && !(NOBREATH in specflags)) // If there's some other shit in the air lets deal with it here.
|
||||
var/SA_pp = breath.get_breath_partial_pressure(breath.gases[GAS_N2O][MOLES])
|
||||
var/SA_pp = breath.get_breath_partial_pressure(breath_gases[GAS_N2O][MOLES])
|
||||
if(SA_pp > SA_para_min) // Enough to make us paralysed for a bit
|
||||
H.Paralyse(3) // 3 gives them one second to wake up and run away a bit!
|
||||
if(SA_pp > SA_sleep_min) // Enough to make us sleep as well
|
||||
|
||||
@@ -105,9 +105,11 @@
|
||||
var/oxygen_used = 0
|
||||
var/breath_pressure = (breath.total_moles()*R_IDEAL_GAS_EQUATION*breath.temperature)/BREATH_VOLUME
|
||||
|
||||
var/O2_partialpressure = (breath.gases[GAS_O2][MOLES]/breath.total_moles())*breath_pressure
|
||||
var/Toxins_partialpressure = (breath.gases[GAS_PL][MOLES]/breath.total_moles())*breath_pressure
|
||||
var/CO2_partialpressure = (breath.gases[GAS_CO2][MOLES]/breath.total_moles())*breath_pressure
|
||||
var/list/breath_gases = breath.gases
|
||||
|
||||
var/O2_partialpressure = (breath_gases[GAS_O2][MOLES]/breath.total_moles())*breath_pressure
|
||||
var/Toxins_partialpressure = (breath_gases[GAS_PL][MOLES]/breath.total_moles())*breath_pressure
|
||||
var/CO2_partialpressure = (breath_gases[GAS_CO2][MOLES]/breath.total_moles())*breath_pressure
|
||||
|
||||
|
||||
//OXYGEN
|
||||
@@ -119,7 +121,7 @@
|
||||
var/ratio = safe_oxy_min/O2_partialpressure
|
||||
adjustOxyLoss(min(5*ratio, 3))
|
||||
failed_last_breath = 1
|
||||
oxygen_used = breath.gases[GAS_O2][MOLES]*ratio/6
|
||||
oxygen_used = breath_gases[GAS_O2][MOLES]*ratio/6
|
||||
else
|
||||
adjustOxyLoss(3)
|
||||
failed_last_breath = 1
|
||||
@@ -128,11 +130,11 @@
|
||||
else //Enough oxygen
|
||||
failed_last_breath = 0
|
||||
adjustOxyLoss(-5)
|
||||
oxygen_used = breath.gases[GAS_O2][MOLES]/6
|
||||
oxygen_used = breath_gases[GAS_O2][MOLES]/6
|
||||
clear_alert("oxy")
|
||||
|
||||
breath.gases[GAS_O2][MOLES] -= oxygen_used
|
||||
breath.gases[GAS_CO2][MOLES] += oxygen_used
|
||||
breath_gases[GAS_O2][MOLES] -= oxygen_used
|
||||
breath_gases[GAS_CO2][MOLES] += oxygen_used
|
||||
|
||||
//CARBON DIOXIDE
|
||||
if(CO2_partialpressure > safe_co2_max)
|
||||
@@ -151,7 +153,7 @@
|
||||
|
||||
//TOXINS/PLASMA
|
||||
if(Toxins_partialpressure > safe_tox_max)
|
||||
var/ratio = (breath.gases[GAS_PL][MOLES]/safe_tox_max) * 10
|
||||
var/ratio = (breath_gases[GAS_PL][MOLES]/safe_tox_max) * 10
|
||||
if(reagents)
|
||||
reagents.add_reagent("plasma", Clamp(ratio, MIN_PLASMA_DAMAGE, MAX_PLASMA_DAMAGE))
|
||||
throw_alert("tox_in_air", /obj/screen/alert/tox_in_air)
|
||||
@@ -159,8 +161,8 @@
|
||||
clear_alert("tox_in_air")
|
||||
|
||||
//NITROUS OXIDE
|
||||
if(breath.gases[GAS_N2O][MOLES])
|
||||
var/SA_partialpressure = (breath.gases[GAS_N2O][MOLES]/breath.total_moles())*breath_pressure
|
||||
if(breath_gases[GAS_N2O][MOLES])
|
||||
var/SA_partialpressure = (breath_gases[GAS_N2O][MOLES]/breath.total_moles())*breath_pressure
|
||||
if(SA_partialpressure > SA_para_min)
|
||||
Paralyse(3)
|
||||
if(SA_partialpressure > SA_sleep_min)
|
||||
|
||||
@@ -386,12 +386,14 @@
|
||||
if(src.beacon) //Check that the beacon still exists and is in a safe place. No instant kills.
|
||||
if(beacon.air)
|
||||
var/datum/gas_mixture/Z = beacon.air
|
||||
var/trace_gases
|
||||
var/list/Z_gases = Z.gases
|
||||
var/trace_gases = FALSE
|
||||
|
||||
for(var/i in 5 to Z.gases.len)
|
||||
if(Z.gases[i][MOLES])
|
||||
if(Z_gases[i][MOLES])
|
||||
trace_gases = TRUE
|
||||
break
|
||||
if(Z.gases[GAS_O2][MOLES] >= 16 && !Z.gases[GAS_PL][MOLES] && Z.gases[GAS_CO2][MOLES] < 10 && !trace_gases)
|
||||
if(Z_gases[GAS_O2][MOLES] >= 16 && !Z_gases[GAS_PL][MOLES] && Z_gases[GAS_CO2][MOLES] < 10 && !trace_gases)
|
||||
if((Z.temperature > 270) && (Z.temperature < 360))
|
||||
var/pressure = Z.return_pressure()
|
||||
if((pressure > 20) && (pressure < 550))
|
||||
|
||||
@@ -196,10 +196,11 @@
|
||||
if(istype(T,/turf/simulated))
|
||||
var/turf/simulated/ST = T
|
||||
if(ST.air)
|
||||
var/tox = ST.air.gases[GAS_PL][MOLES]
|
||||
var/oxy = ST.air.gases[GAS_O2][MOLES]
|
||||
var/n2 = ST.air.gases[GAS_N2][MOLES]
|
||||
var/co2 = ST.air.gases[GAS_CO2][MOLES]
|
||||
var/ST_gases = ST.air.gases
|
||||
var/tox = ST_gases[GAS_PL][MOLES]
|
||||
var/oxy = ST_gases[GAS_O2][MOLES]
|
||||
var/n2 = ST_gases[GAS_N2][MOLES]
|
||||
var/co2 = ST_gases[GAS_CO2][MOLES]
|
||||
|
||||
if(atmos_requirements["min_oxy"] && oxy < atmos_requirements["min_oxy"])
|
||||
atmos_suitable = 0
|
||||
|
||||
Reference in New Issue
Block a user