Refactor gasmix mole change into a proc (#95327)

## About The Pull Request
Refactor the majority of the current gasmix mole change use cases into a
proc called adjust_gas which simply adds the designated mole count of
the species into the gas mix while also handling asserting the gas and
garbage_collect()
I also added adjust_multiple_gases and convert_gas() for modifying
multiple gases and within a gasmix

## Why It's Good For The Game
Lemon wanted this to be done as part of the air group refactor 

## Changelog

🆑
refactor: refactored majority of gas_mix mole change into adjust_gas()
proc
/🆑
This commit is contained in:
FinancialGoose
2026-04-21 13:43:47 -07:00
committed by GitHub
parent 55366497a3
commit e98cb75c57
30 changed files with 211 additions and 218 deletions
@@ -44,11 +44,10 @@
/datum/disease/gastritium/proc/tritium_burp(hot_chance = FALSE)
var/datum/gas_mixture/burp = new
ADD_GAS(/datum/gas/tritium, burp.gases)
burp.gases[/datum/gas/tritium][MOLES] = MOLES_GAS_VISIBLE
burp.set_gas(/datum/gas/tritium, MOLES_GAS_VISIBLE)
burp.temperature = affected_mob.bodytemperature
if(hot_chance && prob(tritium_burp_hot_chance))
burp.temperature = TRITIUM_MINIMUM_BURN_TEMPERATURE
burp.set_temperature(TRITIUM_MINIMUM_BURN_TEMPERATURE)
if(affected_mob.stat == CONSCIOUS)
to_chat(affected_mob, span_warning("Your throat feels hot!"))
affected_mob.visible_message("burps out green gas.", visible_message_flags = EMOTE_MESSAGE)
+2 -2
View File
@@ -30,7 +30,7 @@
SIGNAL_HANDLER
var/datum/gas_mixture/mix_to_spawn = new()
mix_to_spawn.add_gas(gas_type)
mix_to_spawn.gases[gas_type][MOLES] = amount_of_gas
mix_to_spawn.temperature = T20C
mix_to_spawn.set_gas(gas_type, amount_of_gas)
mix_to_spawn.set_temperature(T20C)
var/turf/open/our_turf = get_turf(target)
our_turf.assume_air(mix_to_spawn)
@@ -291,10 +291,9 @@
QDEL_NULL(hotspot)
var/datum/gas_mixture/air = location.air
var/list/gases = air.gases
if (gases[/datum/gas/plasma])
var/scrub_amt = min(30, gases[/datum/gas/plasma][MOLES]) //Absorb some plasma
gases[/datum/gas/plasma][MOLES] -= scrub_amt
if (air.gases[/datum/gas/plasma])
var/scrub_amt = min(30, air.gases[/datum/gas/plasma][MOLES]) //Absorb some plasma
air.adjust_gas(/datum/gas/plasma, -scrub_amt)
absorbed_plasma += scrub_amt
if (air.temperature > T20C)
air.temperature = max(air.temperature / 2, T20C)
@@ -297,11 +297,10 @@
if(!distcheck || get_dist(location, chilly) < blast) // Otherwise we'll get silliness like people using Nanofrost to kill people through walls with cold air
air.temperature = temperature
var/list/gases = air.gases
if(gases[/datum/gas/plasma])
air.assert_gas(/datum/gas/nitrogen)
gases[/datum/gas/nitrogen][MOLES] += gases[/datum/gas/plasma][MOLES]
gases[/datum/gas/plasma][MOLES] = 0
if(air.gases[/datum/gas/plasma])
var/mole_count = air.gases[/datum/gas/plasma][MOLES]
air.adjust_gas(/datum/gas/nitrogen, mole_count)
air.adjust_gas(/datum/gas/plasma, -mole_count)
air.garbage_collect()
for(var/obj/effect/hotspot/fire in chilly)
@@ -44,14 +44,11 @@
if(!first_gasmix || !second_gasmix)
return
first_gasmix.temperature = 1413
second_gasmix.temperature = 141.3
first_gasmix.set_temperature(1413)
second_gasmix.set_temperature(141.3)
first_gasmix.assert_gas(/datum/gas/plasma)
second_gasmix.assert_gas(/datum/gas/oxygen)
first_gasmix.gases[/datum/gas/plasma][MOLES] = calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/oxygen][MOLES] = calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)
first_gasmix.set_gas(/datum/gas/plasma, calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1))
second_gasmix.set_gas(/datum/gas/oxygen, calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1))
/obj/effect/spawner/newbomb/tritium
@@ -60,16 +57,13 @@
if(!first_gasmix || !second_gasmix)
return
first_gasmix.temperature = 8000
second_gasmix.temperature = 43
first_gasmix.set_temperature(8000)
second_gasmix.set_temperature(43)
first_gasmix.assert_gas(/datum/gas/plasma)
second_gasmix.assert_gas(/datum/gas/oxygen)
second_gasmix.assert_gas(/datum/gas/tritium)
first_gasmix.set_gas(/datum/gas/plasma, calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1))
first_gasmix.gases[/datum/gas/plasma][MOLES] = calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/oxygen][MOLES] = 0.67 * calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/tritium][MOLES] = 0.33 * calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.set_gas(/datum/gas/oxygen, 0.67 * calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1))
second_gasmix.set_gas(/datum/gas/tritium, 0.33 * calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1))
/obj/effect/spawner/newbomb/isolated_tritium
@@ -78,16 +72,13 @@
if(!first_gasmix || !second_gasmix)
return
first_gasmix.temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 1
second_gasmix.temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 1
first_gasmix.set_temperature(FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 1)
second_gasmix.set_temperature(FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 1)
first_gasmix.assert_gas(/datum/gas/hypernoblium)
first_gasmix.assert_gas(/datum/gas/tritium)
second_gasmix.assert_gas(/datum/gas/oxygen)
first_gasmix.set_gas(/datum/gas/hypernoblium, REACTION_OPPRESSION_THRESHOLD - 0.01,)
first_gasmix.set_gas( /datum/gas/tritium, 0.5 * calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1))
first_gasmix.gases[/datum/gas/hypernoblium][MOLES] = REACTION_OPPRESSION_THRESHOLD - 0.01
first_gasmix.gases[/datum/gas/tritium][MOLES] = 0.5 * calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/oxygen][MOLES] = calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE-1)
second_gasmix.set_gas(/datum/gas/oxygen, calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE-1))
/obj/effect/spawner/newbomb/noblium
@@ -96,14 +87,11 @@
if(!first_gasmix || !second_gasmix)
return
first_gasmix.temperature = 2.7
second_gasmix.temperature = 2.7
first_gasmix.set_temperature(2.7)
second_gasmix.set_temperature(2.7)
first_gasmix.assert_gas(/datum/gas/nitrogen)
second_gasmix.assert_gas(/datum/gas/tritium)
first_gasmix.gases[/datum/gas/nitrogen][MOLES] = calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/tritium][MOLES] = calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)
first_gasmix.set_gas(/datum/gas/nitrogen, calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1))
second_gasmix.set_gas(/datum/gas/tritium, calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1))
/obj/effect/spawner/newbomb/pressure
@@ -112,11 +100,8 @@
if(!first_gasmix || !second_gasmix)
return
first_gasmix.temperature = 20000
second_gasmix.temperature = 2.7
first_gasmix.set_temperature(20000)
second_gasmix.set_temperature(2.7)
first_gasmix.assert_gas(/datum/gas/hypernoblium)
second_gasmix.assert_gas(/datum/gas/tritium)
first_gasmix.gases[/datum/gas/hypernoblium][MOLES] = calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/tritium][MOLES] = calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)
first_gasmix.set_gas(/datum/gas/hypernoblium, calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1))
second_gasmix.set_gas(/datum/gas/tritium, calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1))
+1 -2
View File
@@ -73,8 +73,7 @@
/obj/item/tank/jetpack/populate_gas()
if(gas_type)
var/datum/gas_mixture/our_mix = return_air()
our_mix.assert_gas(gas_type)
our_mix.gases[gas_type][MOLES] = ((6 * ONE_ATMOSPHERE) * volume / (R_IDEAL_GAS_EQUATION * T20C))
our_mix.set_gas(gas_type, ((6 * ONE_ATMOSPHERE) * volume / (R_IDEAL_GAS_EQUATION * T20C)))
/obj/item/tank/jetpack/ui_action_click(mob/user, action)
if(istype(action, /datum/action/item_action/toggle_jetpack))
+17 -28
View File
@@ -35,8 +35,7 @@
/obj/item/tank/internals/oxygen/populate_gas()
air_contents.assert_gas(/datum/gas/oxygen)
air_contents.gases[/datum/gas/oxygen][MOLES] = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.set_gas(/datum/gas/oxygen, (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C))
/obj/item/tank/internals/oxygen/yellow
@@ -68,9 +67,9 @@
force = 10
/obj/item/tank/internals/anesthetic/populate_gas()
air_contents.assert_gases(/datum/gas/oxygen, /datum/gas/nitrous_oxide)
air_contents.gases[/datum/gas/oxygen][MOLES] = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * O2STANDARD
air_contents.gases[/datum/gas/nitrous_oxide][MOLES] = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * N2STANDARD
air_contents.set_gas(/datum/gas/oxygen, (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * O2STANDARD)
air_contents.set_gas(/datum/gas/nitrous_oxide, (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * N2STANDARD)
/obj/item/tank/internals/anesthetic/examine(mob/user)
. = ..()
@@ -82,8 +81,7 @@
icon_state = "anesthetic_warning"
/obj/item/tank/internals/anesthetic/pure/populate_gas()
air_contents.assert_gases(/datum/gas/nitrous_oxide)
air_contents.gases[/datum/gas/nitrous_oxide][MOLES] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.adjust_gas(/datum/gas/nitrous_oxide, (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C))
/*
* Plasma
@@ -101,8 +99,7 @@
/obj/item/tank/internals/plasma/populate_gas()
air_contents.assert_gas(/datum/gas/plasma)
air_contents.gases[/datum/gas/plasma][MOLES] = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.set_gas(/datum/gas/plasma, (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C))
/obj/item/tank/internals/plasma/attackby(obj/item/W, mob/user, list/modifiers, list/attack_modifiers)
if(istype(W, /obj/item/flamethrower))
@@ -118,8 +115,7 @@
return ..()
/obj/item/tank/internals/plasma/full/populate_gas()
air_contents.assert_gas(/datum/gas/plasma)
air_contents.gases[/datum/gas/plasma][MOLES] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.set_gas(/datum/gas/plasma, (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C))
/obj/item/tank/internals/plasma/empty/populate_gas()
return
@@ -138,12 +134,10 @@
distribute_pressure = TANK_PLASMAMAN_RELEASE_PRESSURE
/obj/item/tank/internals/plasmaman/populate_gas()
air_contents.assert_gas(/datum/gas/plasma)
air_contents.gases[/datum/gas/plasma][MOLES] = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.set_gas(/datum/gas/plasma, (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C))
/obj/item/tank/internals/plasmaman/full/populate_gas()
air_contents.assert_gas(/datum/gas/plasma)
air_contents.gases[/datum/gas/plasma][MOLES] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.set_gas(/datum/gas/plasma, (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C))
/obj/item/tank/internals/plasmaman/belt
@@ -158,8 +152,7 @@
w_class = WEIGHT_CLASS_SMALL //thanks i forgot this
/obj/item/tank/internals/plasmaman/belt/full/populate_gas()
air_contents.assert_gas(/datum/gas/plasma)
air_contents.gases[/datum/gas/plasma][MOLES] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.set_gas(/datum/gas/plasma, (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C))
/obj/item/tank/internals/plasmaman/belt/empty/populate_gas()
return
@@ -186,8 +179,7 @@
/obj/item/tank/internals/emergency_oxygen/populate_gas()
air_contents.assert_gas(/datum/gas/oxygen)
air_contents.gases[/datum/gas/oxygen][MOLES] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.set_gas(/datum/gas/oxygen, (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C))
/obj/item/tank/internals/emergency_oxygen/empty/populate_gas()
@@ -246,21 +238,18 @@
/obj/item/tank/internals/emergency_oxygen/engi/clown/n2o
/obj/item/tank/internals/emergency_oxygen/engi/clown/n2o/populate_gas()
air_contents.assert_gases(/datum/gas/oxygen, /datum/gas/nitrous_oxide)
air_contents.gases[/datum/gas/oxygen][MOLES] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * 0.95
air_contents.gases[/datum/gas/nitrous_oxide][MOLES] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * 0.05
air_contents.set_gas(/datum/gas/oxygen, (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * 0.95)
air_contents.set_gas(/datum/gas/nitrous_oxide, (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * 0.05)
/obj/item/tank/internals/emergency_oxygen/engi/clown/bz
/obj/item/tank/internals/emergency_oxygen/engi/clown/bz/populate_gas()
air_contents.assert_gases(/datum/gas/oxygen, /datum/gas/bz)
air_contents.gases[/datum/gas/oxygen][MOLES] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * 0.9
air_contents.gases[/datum/gas/bz][MOLES] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * 0.1
air_contents.set_gas(/datum/gas/oxygen,(10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * 0.9)
air_contents.set_gas(/datum/gas/bz,(10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * 0.1)
/obj/item/tank/internals/emergency_oxygen/engi/clown/helium
distribute_pressure = TANK_CLOWN_RELEASE_PRESSURE + 2
/obj/item/tank/internals/emergency_oxygen/engi/clown/helium/populate_gas()
air_contents.assert_gases(/datum/gas/oxygen, /datum/gas/helium)
air_contents.gases[/datum/gas/oxygen][MOLES] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * 0.75
air_contents.gases[/datum/gas/helium][MOLES] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * 0.25
air_contents.set_gas(/datum/gas/oxygen, (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * 0.75)
air_contents.set_gas(/datum/gas/helium, (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * 0.25)
@@ -231,7 +231,8 @@
var/datum/gas_mixture/air_transfer = tank_mix.remove_ratio(release_amount)
if(air_transfer.gases[/datum/gas/plasma])
air_transfer.gases[/datum/gas/plasma][MOLES] *= 5 //Suffering
var/moles = air_transfer.gases[/datum/gas/plasma][MOLES] * 5 //Suffering
air_transfer.set_gas(/datum/gas/plasma, moles)
target.assume_air(air_transfer)
//Burn it based on transferred gas
target.hotspot_expose((tank_mix.temperature*2) + 380,500)
@@ -286,8 +287,7 @@
SIGNAL_HANDLER
if(ptank)
var/datum/gas_mixture/tank_mix = ptank.return_air()
tank_mix.assert_gas(/datum/gas/plasma)
tank_mix.gases[/datum/gas/plasma][MOLES] = (10*ONE_ATMOSPHERE)*ptank.volume/(R_IDEAL_GAS_EQUATION*T20C)
tank_mix.set_gas(/datum/gas/plasma, (10*ONE_ATMOSPHERE)*ptank.volume/(R_IDEAL_GAS_EQUATION*T20C))
else
ptank = new /obj/item/tank/internals/plasma/full(src)
update_appearance()
@@ -297,8 +297,8 @@
air_contents.temperature = T20C
air_contents.assert_gases(/datum/gas/oxygen, /datum/gas/nitrogen)
air_contents.gases[/datum/gas/oxygen][MOLES] = (ONE_ATMOSPHERE*50)/(R_IDEAL_GAS_EQUATION*T20C) * O2STANDARD
air_contents.gases[/datum/gas/nitrogen][MOLES] = (ONE_ATMOSPHERE*50)/(R_IDEAL_GAS_EQUATION*T20C) * N2STANDARD
air_contents.adjust_gas(/datum/gas/oxygen, (ONE_ATMOSPHERE*50)/(R_IDEAL_GAS_EQUATION*T20C) * O2STANDARD)
air_contents.adjust_gas(/datum/gas/nitrogen, (ONE_ATMOSPHERE*50)/(R_IDEAL_GAS_EQUATION*T20C) * N2STANDARD)
/obj/structure/closet/body_bag/environmental/nanotrasen
name = "elite environmental protection bag"
@@ -428,8 +428,8 @@
air_contents.temperature = T20C
air_contents.assert_gases(/datum/gas/oxygen, /datum/gas/nitrous_oxide)
air_contents.gases[/datum/gas/oxygen][MOLES] = (ONE_ATMOSPHERE*50)/(R_IDEAL_GAS_EQUATION*T20C) * O2STANDARD
air_contents.gases[/datum/gas/nitrous_oxide][MOLES] = (ONE_ATMOSPHERE*50)/(R_IDEAL_GAS_EQUATION*T20C) * N2STANDARD
air_contents.adjust_gas(/datum/gas/oxygen, (ONE_ATMOSPHERE*50)/(R_IDEAL_GAS_EQUATION*T20C) * O2STANDARD)
air_contents.adjust_gas(/datum/gas/nitrous_oxide, (ONE_ATMOSPHERE*50)/(R_IDEAL_GAS_EQUATION*T20C) * N2STANDARD)
/obj/structure/closet/body_bag/environmental/hardlight
name = "hardlight bodybag"
@@ -509,11 +509,10 @@
var/inner_temp = T0C - 60
air_contents = null
air_contents = new(mol_count)
air_contents.temperature = inner_temp
air_contents.set_temperature(inner_temp)
air_contents.assert_gases(/datum/gas/oxygen, /datum/gas/nitrogen)
air_contents.gases[/datum/gas/oxygen][MOLES] = (ONE_ATMOSPHERE * mol_count) / (R_IDEAL_GAS_EQUATION * inner_temp) * O2STANDARD
air_contents.gases[/datum/gas/nitrogen][MOLES] = (ONE_ATMOSPHERE * mol_count) / (R_IDEAL_GAS_EQUATION * inner_temp) * N2STANDARD
air_contents.set_gas(/datum/gas/oxygen, ((ONE_ATMOSPHERE * mol_count) / (R_IDEAL_GAS_EQUATION * inner_temp) * O2STANDARD))
air_contents.set_gas(/datum/gas/nitrogen, ((ONE_ATMOSPHERE * mol_count) / (R_IDEAL_GAS_EQUATION * inner_temp) * N2STANDARD))
/obj/structure/closet/body_bag/environmental/stasis/examine_status(mob/user)
switch(100 * get_integrity_percentage())
+1 -1
View File
@@ -95,7 +95,7 @@
return FALSE
new /obj/item/flamethrower(get_turf(src))
var/obj/item/tank/internals/plasma/ptank = new /obj/item/tank/internals/plasma(get_turf(src))
ptank.air_contents.gases[/datum/gas/plasma][MOLES] = (0)
ptank.air_contents.set_gas(/datum/gas/plasma, 0)
drop_custom_materials()
qdel(src)
return TRUE
@@ -14,9 +14,8 @@
/obj/structure/transit_tube_pod/Initialize(mapload)
. = ..()
air_contents.add_gases(/datum/gas/oxygen, /datum/gas/nitrogen)
air_contents.gases[/datum/gas/oxygen][MOLES] = MOLES_O2STANDARD
air_contents.gases[/datum/gas/nitrogen][MOLES] = MOLES_N2STANDARD
var/list/new_gases = list(/datum/gas/oxygen = MOLES_O2STANDARD, /datum/gas/nitrogen = MOLES_N2STANDARD)
air_contents.adjust_multiple_gases(new_gases)
air_contents.temperature = T20C
/obj/structure/transit_tube_pod/Destroy()
+1 -1
View File
@@ -281,7 +281,7 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list(
var/list/giver_gases = mix.gases
for(var/giver_id in giver_gases)
ASSERT_GAS_IN_LIST(giver_id, total_gases)
total_gases[giver_id][MOLES] += giver_gases[giver_id][MOLES]
total.adjust_gas(giver_id, giver_gases[giver_id][MOLES])
total.temperature = energy / heat_cap
for(var/id in total_gases)
@@ -251,8 +251,7 @@
breather.emote("cough");
var/chosen_gas = pick_weight(gas_types)
var/datum/gas_mixture/mix_to_spawn = new()
mix_to_spawn.add_gas(pick(chosen_gas))
mix_to_spawn.gases[chosen_gas][MOLES] = gas_amount
mix_to_spawn.adjust_gas(pick(chosen_gas), gas_amount)
mix_to_spawn.temperature = breather.bodytemperature
log_atmos("[owner] coughed some gas into the air due to their corrupted lungs.", mix_to_spawn)
var/turf/open/our_turf = get_turf(breather)
@@ -172,6 +172,40 @@ GLOBAL_LIST_INIT(gaslist_cache, init_gaslist_cache())
SEND_SIGNAL(src, COMSIG_GASMIX_MERGED)
return TRUE
// Set the gas specie within the gas mix to a set amount, if there is none it will be created at the target temp
/datum/gas_mixture/proc/set_gas(gas_specie, amount)
ASSERT_GAS(gas_specie, src)
gases[gas_specie][MOLES] = amount
garbage_collect()
/datum/gas_mixture/proc/set_temperature(target_temp)
temperature = target_temp
/// Add a specific amount of moles to specified gas or add a new gas to the mix
/// amount is added so make it negative to remove
/datum/gas_mixture/proc/adjust_gas(gas, amount)
ASSERT_GAS(gas, src)
gases[gas][MOLES] += QUANTIZE(amount)
garbage_collect()
/// Add a specific amount of moles to all the gasses present or add a new gas to the mix
///gases_moles is an associative list of gas species to their amount to be added
/datum/gas_mixture/proc/adjust_multiple_gases(list/gases_moles)
for(var/gas_specie in gases_moles)
ASSERT_GAS(gas_specie, src)
gases[gas_specie][MOLES] += gases_moles[gas_specie]
garbage_collect()
/// Modify the gas list as to convert moles of gas species A to gas species B
/// reactant and product are the gas species to convert and conversion_amount is the amount to be converted
/datum/gas_mixture/proc/convert_gas(datum/gas/reactant, datum/gas/product, conversion_amount)
var/list/cached_gases = gases
assert_gases(reactant, product)
cached_gases[reactant][MOLES] -= QUANTIZE(conversion_amount)
cached_gases[product][MOLES] += QUANTIZE(conversion_amount)
garbage_collect()
///Proportionally removes amount of gas from the gas_mixture.
///Returns: gas_mixture with the gases removed
/datum/gas_mixture/proc/remove(amount)
@@ -764,3 +798,4 @@ GLOBAL_LIST_INIT(gaslist_cache, init_gaslist_cache())
atmos_contents += temperature_str
return atmos_contents.Join(";")
@@ -220,7 +220,7 @@
plasma_burn_rate = min(plasma_burn_rate, plasma[MOLES], oxygen[MOLES] * INVERSE(oxygen_burn_ratio)) //Ensures matter is conserved properly
plasma[MOLES] = QUANTIZE(plasma[MOLES] - plasma_burn_rate)
oxygen[MOLES] = QUANTIZE(oxygen[MOLES] - (plasma_burn_rate * oxygen_burn_ratio))
if (super_saturation)
if(super_saturation)
ASSERT_GAS(/datum/gas/tritium, air)
cached_gases[/datum/gas/tritium][MOLES] += plasma_burn_rate
else
@@ -229,6 +229,7 @@
cached_gases[/datum/gas/carbon_dioxide][MOLES] += plasma_burn_rate * 0.75
cached_gases[/datum/gas/water_vapor][MOLES] += plasma_burn_rate * 0.25
SET_REACTION_RESULTS((plasma_burn_rate) * (1 + oxygen_burn_ratio))
var/energy_released = FIRE_PLASMA_ENERGY_RELEASED * plasma_burn_rate
var/new_heat_capacity = air.heat_capacity()
@@ -583,6 +584,8 @@
nitrous_oxide[MOLES] -= 0.4 * bz_formed
plasma[MOLES] -= 0.8 * bz_formed * (1-nitrous_oxide_decomposed_factor)
SET_REACTION_RESULTS(bz_formed)
var/energy_released = bz_formed * (BZ_FORMATION_ENERGY + nitrous_oxide_decomposed_factor * (N2O_DECOMPOSITION_ENERGY - BZ_FORMATION_ENERGY))
var/new_heat_capacity = air.heat_capacity()
@@ -681,6 +684,7 @@
bz[MOLES] -= heat_efficiency * 0.05 //bz gets consumed to balance the nitrium production and not make it too common and/or easy
cached_gases[/datum/gas/nitrium][MOLES] += heat_efficiency
SET_REACTION_RESULTS(heat_efficiency)
var/energy_used = heat_efficiency * NITRIUM_FORMATION_ENERGY
var/new_heat_capacity = air.heat_capacity()
@@ -829,6 +833,7 @@
tritium[MOLES] -= 5 * nob_formed * reduction_factor
nitrogen[MOLES] -= 10 * nob_formed
cached_gases[/datum/gas/hypernoblium][MOLES] += nob_formed // I'm not going to nitpick, but N20H10 feels like it should be an explosive more than anything.
SET_REACTION_RESULTS(nob_formed)
var/energy_released = nob_formed * NOBLIUM_FORMATION_ENERGY / max(bz[MOLES], 1)
var/new_heat_capacity = air.heat_capacity()
@@ -1254,6 +1259,7 @@
continue
gas[MOLES] -= reaction_rate * gas[MOLES] / total_not_antinoblium_moles
antinoblium[MOLES] += reaction_rate
SET_REACTION_RESULTS(reaction_rate)
var/new_heat_capacity = air.heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
@@ -64,11 +64,11 @@ GLOBAL_LIST_INIT(electrolyzer_reactions, electrolyzer_reactions_list())
/datum/electrolyzer_reaction/h2o_conversion/react(datum/gas_mixture/air_mixture, working_power, list/electrolyzer_args = list())
var/old_heat_capacity = air_mixture.heat_capacity()
air_mixture.assert_gases(/datum/gas/water_vapor, /datum/gas/oxygen, /datum/gas/hydrogen)
var/proportion = min(air_mixture.gases[/datum/gas/water_vapor][MOLES] * INVERSE(2), (2.5 * (working_power ** 2)))
air_mixture.gases[/datum/gas/water_vapor][MOLES] -= proportion * 2
air_mixture.gases[/datum/gas/oxygen][MOLES] += proportion
air_mixture.gases[/datum/gas/hydrogen][MOLES] += proportion * 2
air_mixture.adjust_gas(/datum/gas/water_vapor, -proportion * 2)
air_mixture.adjust_gas(/datum/gas/oxygen, proportion)
air_mixture.adjust_gas(/datum/gas/hydrogen, proportion * 2)
var/new_heat_capacity = air_mixture.heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
air_mixture.temperature = max(air_mixture.temperature * old_heat_capacity / new_heat_capacity, TCMB)
@@ -100,8 +100,10 @@ GLOBAL_LIST_INIT(electrolyzer_reactions, electrolyzer_reactions_list())
var/list/hypernoblium = cached_gases[/datum/gas/hypernoblium]
var/list/antinoblium = cached_gases[/datum/gas/antinoblium]
var/electrolysed = hypernoblium[MOLES] * clamp(supermatter_power - POWER_PENALTY_THRESHOLD, 0, CRITICAL_POWER_PENALTY_THRESHOLD - POWER_PENALTY_THRESHOLD) / (CRITICAL_POWER_PENALTY_THRESHOLD - POWER_PENALTY_THRESHOLD)
hypernoblium[MOLES] -= electrolysed
antinoblium[MOLES] += electrolysed
air_mixture.adjust_gas(/datum/gas/hypernoblium, -electrolysed)
air_mixture.adjust_gas(/datum/gas/antinoblium, electrolysed)
var/new_heat_capacity = old_heat_capacity + electrolysed * (antinoblium[GAS_META][META_GAS_SPECIFIC_HEAT] - hypernoblium[GAS_META][META_GAS_SPECIFIC_HEAT])
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
air_mixture.temperature = max(air_mixture.temperature * old_heat_capacity / new_heat_capacity, TCMB)
@@ -126,9 +128,11 @@ GLOBAL_LIST_INIT(electrolyzer_reactions, electrolyzer_reactions_list())
var/old_heat_capacity = air_mixture.heat_capacity()
air_mixture.assert_gases(/datum/gas/bz, /datum/gas/oxygen, /datum/gas/halon)
var/reaction_efficency = min(air_mixture.gases[/datum/gas/bz][MOLES] * (1 - NUM_E ** (-0.5 * air_mixture.temperature * working_power / FIRE_MINIMUM_TEMPERATURE_TO_EXIST)), air_mixture.gases[/datum/gas/bz][MOLES])
air_mixture.gases[/datum/gas/bz][MOLES] -= reaction_efficency
air_mixture.gases[/datum/gas/oxygen][MOLES] += reaction_efficency * 0.2
air_mixture.gases[/datum/gas/halon][MOLES] += reaction_efficency * 2
air_mixture.adjust_gas(/datum/gas/bz, -reaction_efficency)
air_mixture.adjust_gas(/datum/gas/oxygen, reaction_efficency * 0.2)
air_mixture.adjust_gas(/datum/gas/halon, reaction_efficency * 2)
var/energy_used = reaction_efficency * HALON_FORMATION_ENERGY
var/new_heat_capacity = air_mixture.heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
@@ -250,37 +250,37 @@
var/scaled_production = production_amount * selected_fuel.gas_production_multiplier
for(var/gas_id in fuel.requirements)
internal_fusion.gases[gas_id][MOLES] -= min(fuel_list[gas_id], fuel_consumption)
internal_fusion.adjust_gas(gas_id, -min(fuel_list[gas_id], fuel_consumption))
for(var/gas_id in fuel.primary_products)
internal_fusion.gases[gas_id][MOLES] += fuel_consumption * 0.5
internal_fusion.adjust_gas(gas_id, fuel_consumption * 0.5)
// Each recipe provides a tier list of six output gases.
// Which gases are produced depend on what the fusion level is.
var/list/tier = fuel.secondary_products
switch(power_level)
if(1)
moderator_internal.gases[tier[1]][MOLES] += scaled_production * 0.95
moderator_internal.gases[tier[2]][MOLES] += scaled_production * 0.75
moderator_internal.adjust_gas(tier[1], scaled_production * 0.95)
moderator_internal.adjust_gas(tier[2], scaled_production * 0.75)
if(2)
moderator_internal.gases[tier[1]][MOLES] += scaled_production * 1.65
moderator_internal.gases[tier[2]][MOLES] += scaled_production
moderator_internal.adjust_gas(tier[1], scaled_production * 1.65)
moderator_internal.adjust_gas(tier[2], scaled_production)
if(moderator_list[/datum/gas/plasma] > 50)
moderator_internal.gases[tier[3]][MOLES] += scaled_production * 1.15
moderator_internal.adjust_gas(tier[3], scaled_production * 1.15)
if(3)
moderator_internal.gases[tier[2]][MOLES] += scaled_production * 0.5
moderator_internal.gases[tier[3]][MOLES] += scaled_production * 0.45
moderator_internal.adjust_gas(tier[2], scaled_production * 0.5)
moderator_internal.adjust_gas(tier[3], scaled_production * 0.45)
if(4)
moderator_internal.gases[tier[3]][MOLES] += scaled_production * 1.65
moderator_internal.gases[tier[4]][MOLES] += scaled_production * 1.25
moderator_internal.adjust_gas(tier[3], scaled_production * 1.65)
moderator_internal.adjust_gas(tier[4], scaled_production * 1.25)
if(moderator_list[/datum/gas/plasma] > 50)
moderator_internal.gases[tier[5]][MOLES] += scaled_production * 1.15
moderator_internal.adjust_gas(tier[5], scaled_production * 1.15)
if(5)
moderator_internal.gases[tier[4]][MOLES] += scaled_production * 0.65
moderator_internal.gases[tier[5]][MOLES] += scaled_production
moderator_internal.gases[tier[6]][MOLES] += scaled_production * 0.75
moderator_internal.adjust_gas(tier[4], scaled_production * 0.65)
moderator_internal.adjust_gas(tier[5], scaled_production)
moderator_internal.adjust_gas(tier[6], scaled_production * 0.75)
if(6)
moderator_internal.gases[tier[5]][MOLES] += scaled_production * 0.35
moderator_internal.gases[tier[6]][MOLES] += scaled_production
moderator_internal.adjust_gas(tier[5], scaled_production * 0.35)
moderator_internal.adjust_gas(tier[6], scaled_production)
/**
* Perform common fusion actions:
@@ -293,94 +293,81 @@
switch(power_level)
if(1)
if(moderator_list[/datum/gas/plasma] > 100)
internal_output.assert_gases(/datum/gas/nitrous_oxide)
internal_output.gases[/datum/gas/nitrous_oxide] += scaled_production * 0.5
moderator_internal.gases[/datum/gas/plasma][MOLES] -= min(moderator_internal.gases[/datum/gas/plasma][MOLES], scaled_production * 0.85)
internal_output.adjust_gas(/datum/gas/nitrous_oxide, scaled_production * 0.5)
moderator_internal.adjust_gas(/datum/gas/plasma, min(moderator_internal.gases[/datum/gas/plasma][MOLES], scaled_production * 0.85))
if(moderator_list[/datum/gas/bz] > 150)
internal_output.assert_gases(/datum/gas/halon)
internal_output.gases[/datum/gas/halon][MOLES] += scaled_production * 0.55
moderator_internal.gases[/datum/gas/bz][MOLES] -= min(moderator_internal.gases[/datum/gas/bz][MOLES], scaled_production * 0.95)
internal_output.adjust_gas(/datum/gas/halon, scaled_production * 0.55)
moderator_internal.adjust_gas(/datum/gas/bz, min(moderator_internal.gases[/datum/gas/bz][MOLES], scaled_production * 0.95))
if(2)
if(moderator_list[/datum/gas/plasma] > 50)
internal_output.assert_gases(/datum/gas/bz)
internal_output.gases[/datum/gas/bz][MOLES] += scaled_production * 1.8
moderator_internal.gases[/datum/gas/plasma][MOLES] -= min(moderator_internal.gases[/datum/gas/plasma][MOLES], scaled_production * 1.75)
internal_output.adjust_gas(/datum/gas/bz, scaled_production * 1.8)
moderator_internal.adjust_gas(/datum/gas/plasma, min(moderator_internal.gases[/datum/gas/plasma][MOLES], scaled_production * 1.75))
if(moderator_list[/datum/gas/proto_nitrate] > 20)
radiation *= 1.55
heat_output *= 1.025
internal_output.assert_gases(/datum/gas/nitrium)
internal_output.gases[/datum/gas/nitrium][MOLES] += scaled_production * 1.05
moderator_internal.gases[/datum/gas/proto_nitrate][MOLES] -= min(moderator_internal.gases[/datum/gas/proto_nitrate][MOLES], scaled_production * 1.35)
internal_output.adjust_gas(/datum/gas/nitrium, scaled_production * 1.05)
moderator_internal.adjust_gas(/datum/gas/proto_nitrate, min(moderator_internal.gases[/datum/gas/proto_nitrate][MOLES], scaled_production * 1.35))
if(3, 4)
if(moderator_list[/datum/gas/plasma] > 10)
internal_output.assert_gases(/datum/gas/freon, /datum/gas/nitrium)
internal_output.gases[/datum/gas/freon][MOLES] += scaled_production * 0.15
internal_output.gases[/datum/gas/nitrium][MOLES] += scaled_production * 1.05
moderator_internal.gases[/datum/gas/plasma][MOLES] -= min(moderator_internal.gases[/datum/gas/plasma][MOLES], scaled_production * 0.45)
var/list/new_gases = list(/datum/gas/freon = scaled_production * 0.15, /datum/gas/nitrium = scaled_production * 1.05)
internal_output.adjust_multiple_gases(new_gases)
moderator_internal.adjust_gas(/datum/gas/plasma, min(moderator_internal.gases[/datum/gas/plasma][MOLES], scaled_production * 0.45))
if(moderator_list[/datum/gas/freon] > 50)
heat_output *= 0.9
radiation *= 0.8
if(moderator_list[/datum/gas/proto_nitrate]> 15)
internal_output.assert_gases(/datum/gas/nitrium, /datum/gas/halon)
internal_output.gases[/datum/gas/nitrium][MOLES] += scaled_production * 1.25
internal_output.gases[/datum/gas/halon][MOLES] += scaled_production * 1.15
moderator_internal.gases[/datum/gas/proto_nitrate][MOLES] -= min(moderator_internal.gases[/datum/gas/proto_nitrate][MOLES], scaled_production * 1.55)
var/list/new_gases = list(/datum/gas/nitrium = scaled_production * 1.25, /datum/gas/halon = scaled_production * 1.15)
internal_output.adjust_multiple_gases(new_gases)
moderator_internal.adjust_gas(/datum/gas/proto_nitrate, min(moderator_internal.gases[/datum/gas/proto_nitrate][MOLES], scaled_production * 1.55))
radiation *= 1.95
heat_output *= 1.25
if(moderator_list[/datum/gas/bz] > 100)
internal_output.assert_gases(/datum/gas/healium, /datum/gas/proto_nitrate)
internal_output.gases[/datum/gas/proto_nitrate][MOLES] += scaled_production * 1.5
internal_output.gases[/datum/gas/healium][MOLES] += scaled_production * 1.5
var/list/new_gases = list(/datum/gas/healium = scaled_production * 1.5, /datum/gas/proto_nitrate = scaled_production * 1.5)
internal_output.adjust_multiple_gases(new_gases)
visible_hallucination_pulse(src, HALLUCINATION_HFR(heat_output), 100 SECONDS * power_level * seconds_per_tick)
if(5)
if(moderator_list[/datum/gas/plasma] > 15)
internal_output.assert_gases(/datum/gas/freon)
internal_output.gases[/datum/gas/freon][MOLES] += scaled_production *0.25
moderator_internal.gases[/datum/gas/plasma][MOLES] -= min(moderator_internal.gases[/datum/gas/plasma][MOLES], scaled_production * 1.45)
internal_output.adjust_gas(/datum/gas/freon, scaled_production *0.25)
moderator_internal.adjust_gas(/datum/gas/plasma,min(moderator_internal.gases[/datum/gas/plasma][MOLES], scaled_production * 1.45))
if(moderator_list[/datum/gas/freon] > 500)
heat_output *= 0.5
radiation *= 0.2
if(moderator_list[/datum/gas/proto_nitrate] > 50)
internal_output.assert_gases(/datum/gas/nitrium, /datum/gas/pluoxium)
internal_output.gases[/datum/gas/nitrium][MOLES] += scaled_production * 1.95
internal_output.gases[/datum/gas/pluoxium][MOLES] += scaled_production
moderator_internal.gases[/datum/gas/proto_nitrate][MOLES] -= min(moderator_internal.gases[/datum/gas/proto_nitrate][MOLES], scaled_production * 1.35)
var/list/new_gases = list(/datum/gas/nitrium = scaled_production * 1.95, /datum/gas/pluoxium = scaled_production)
internal_output.adjust_multiple_gases(new_gases)
moderator_internal.adjust_gas(/datum/gas/proto_nitrate, min(moderator_internal.gases[/datum/gas/proto_nitrate][MOLES], scaled_production * 1.35))
radiation *= 1.95
heat_output *= 1.25
if(moderator_list[/datum/gas/bz] > 100)
internal_output.assert_gases(/datum/gas/healium, /datum/gas/freon)
internal_output.gases[/datum/gas/healium][MOLES] += scaled_production
var/list/new_gases = list(/datum/gas/healium = scaled_production, /datum/gas/freon = scaled_production * 1.15)
internal_output.adjust_multiple_gases(new_gases)
visible_hallucination_pulse(src, HALLUCINATION_HFR(heat_output), 100 SECONDS * power_level * seconds_per_tick)
internal_output.gases[/datum/gas/freon][MOLES] += scaled_production * 1.15
if(moderator_list[/datum/gas/healium] > 100)
if(critical_threshold_proximity > 400)
critical_threshold_proximity = max(critical_threshold_proximity - (moderator_list[/datum/gas/healium] / 100 * seconds_per_tick ), 0)
moderator_internal.gases[/datum/gas/healium][MOLES] -= min(moderator_internal.gases[/datum/gas/healium][MOLES], scaled_production * 20)
moderator_internal.adjust_gas(/datum/gas/healium, -min(moderator_internal.gases[/datum/gas/healium][MOLES], scaled_production * 20))
if(moderator_internal.temperature < 1e7 || (moderator_list[/datum/gas/plasma] > 100 && moderator_list[/datum/gas/bz] > 50))
internal_output.assert_gases(/datum/gas/antinoblium)
internal_output.gases[/datum/gas/antinoblium][MOLES] += dirty_production_rate * 0.9 / 0.065 * seconds_per_tick
internal_output.adjust_gas(/datum/gas/antinoblium, dirty_production_rate * 0.9 / 0.065 * seconds_per_tick)
if(6)
internal_output.assert_gases(/datum/gas/antinoblium)
if(moderator_list[/datum/gas/plasma] > 30)
internal_output.assert_gases(/datum/gas/bz)
internal_output.gases[/datum/gas/bz][MOLES] += scaled_production * 1.15
moderator_internal.gases[/datum/gas/plasma][MOLES] -= min(moderator_internal.gases[/datum/gas/plasma][MOLES], scaled_production * 1.45)
internal_output.adjust_gas(/datum/gas/bz, scaled_production * 1.15)
moderator_internal.adjust_gas(/datum/gas/plasma, -min(moderator_internal.gases[/datum/gas/plasma][MOLES], scaled_production * 1.45))
if(moderator_list[/datum/gas/proto_nitrate])
internal_output.assert_gases(/datum/gas/zauker, /datum/gas/nitrium)
internal_output.gases[/datum/gas/zauker][MOLES] += scaled_production * 5.35
internal_output.gases[/datum/gas/nitrium][MOLES] += scaled_production * 2.15
moderator_internal.gases[/datum/gas/proto_nitrate][MOLES] -= min(moderator_internal.gases[/datum/gas/proto_nitrate][MOLES], scaled_production * 3.35)
var/list/new_gases = list(/datum/gas/zauker = scaled_production * 5.35, /datum/gas/nitrium = scaled_production * 2.15)
internal_output.adjust_multiple_gases(new_gases)
moderator_internal.adjust_gas(/datum/gas/proto_nitrate, -min(moderator_internal.gases[/datum/gas/proto_nitrate][MOLES], scaled_production * 3.35))
radiation *= 2
heat_output *= 2.25
if(moderator_list[/datum/gas/bz])
visible_hallucination_pulse(src, HALLUCINATION_HFR(heat_output), 100 SECONDS * power_level * seconds_per_tick)
internal_output.gases[/datum/gas/antinoblium][MOLES] += clamp(dirty_production_rate / 0.045, 0, 10) * seconds_per_tick
internal_output.adjust_gas(/datum/gas/antinoblium, clamp(dirty_production_rate / 0.045, 0, 10) * seconds_per_tick)
if(moderator_list[/datum/gas/healium] > 100)
if(critical_threshold_proximity > 400)
critical_threshold_proximity = max(critical_threshold_proximity - (moderator_list[/datum/gas/healium] / 100 * seconds_per_tick ), 0)
moderator_internal.gases[/datum/gas/healium][MOLES] -= min(moderator_internal.gases[/datum/gas/healium][MOLES], scaled_production * 20)
internal_fusion.gases[/datum/gas/antinoblium][MOLES] += dirty_production_rate * 0.01 / 0.095 * seconds_per_tick
moderator_internal.adjust_gas(/datum/gas/healium, -min(moderator_internal.gases[/datum/gas/healium][MOLES], scaled_production * 20))
internal_fusion.adjust_gas(/datum/gas/antinoblium, dirty_production_rate * 0.01 / 0.095 * seconds_per_tick)
//Modifies the internal_fusion temperature with the amount of heat output
var/temperature_modifier = selected_fuel.temperature_change_multiplier
@@ -413,7 +400,7 @@
var/max_iron_removable = IRON_OXYGEN_HEAL_PER_SECOND
var/iron_removed = min(max_iron_removable * seconds_per_tick, iron_content)
iron_content -= iron_removed
moderator_internal.gases[/datum/gas/oxygen][MOLES] -= iron_removed * OXYGEN_MOLES_CONSUMED_PER_IRON_HEAL
moderator_internal.adjust_gas(/datum/gas/oxygen, -iron_removed * OXYGEN_MOLES_CONSUMED_PER_IRON_HEAL)
check_gravity_pulse(seconds_per_tick)
@@ -143,8 +143,8 @@
var/pressure_limit = max_pressure * safety_margin
var/moles_to_add = (pressure_limit * air_contents.volume) / (R_IDEAL_GAS_EQUATION * air_contents.temperature)
air_contents.assert_gas(gastype)
air_contents.gases[gastype][MOLES] += moles_to_add
air_contents.adjust_gas(gastype, moles_to_add)
air_contents.archive()
/obj/machinery/atmospherics/components/tank/process_atmos()
@@ -308,9 +308,8 @@
pressure_limit = 1e14
/obj/machinery/portable_atmospherics/canister/fusion_test/create_gas()
air_contents.add_gases(/datum/gas/hydrogen, /datum/gas/tritium)
air_contents.gases[/datum/gas/hydrogen][MOLES] = 300
air_contents.gases[/datum/gas/tritium][MOLES] = 300
air_contents.adjust_gas(/datum/gas/hydrogen, 300)
air_contents.adjust_gas(/datum/gas/tritium, 300)
air_contents.temperature = 10000
SSair.start_processing_machine(src)
@@ -323,9 +322,8 @@
greyscale_colors = "#9fba6c#3d4680"
/obj/machinery/portable_atmospherics/canister/anesthetic_mix/create_gas()
air_contents.add_gases(/datum/gas/oxygen, /datum/gas/nitrous_oxide)
air_contents.gases[/datum/gas/oxygen][MOLES] = (O2_ANESTHETIC * maximum_pressure * filled) * air_contents.volume / (R_IDEAL_GAS_EQUATION * air_contents.temperature)
air_contents.gases[/datum/gas/nitrous_oxide][MOLES] = (N2O_ANESTHETIC * maximum_pressure * filled) * air_contents.volume / (R_IDEAL_GAS_EQUATION * air_contents.temperature)
air_contents.adjust_gas(/datum/gas/oxygen, (O2_ANESTHETIC * maximum_pressure * filled) * air_contents.volume / (R_IDEAL_GAS_EQUATION * air_contents.temperature))
air_contents.adjust_gas(/datum/gas/nitrous_oxide, (N2O_ANESTHETIC * maximum_pressure * filled) * air_contents.volume / (R_IDEAL_GAS_EQUATION * air_contents.temperature))
SSair.start_processing_machine(src)
/**
@@ -335,14 +333,12 @@
/obj/machinery/portable_atmospherics/canister/proc/create_gas()
if(!gas_type)
return
air_contents.add_gas(gas_type)
air_contents.gases[gas_type][MOLES] = (maximum_pressure * filled) * air_contents.volume / (R_IDEAL_GAS_EQUATION * air_contents.temperature)
air_contents.adjust_gas(gas_type, (maximum_pressure * filled) * air_contents.volume / (R_IDEAL_GAS_EQUATION * air_contents.temperature))
SSair.start_processing_machine(src)
/obj/machinery/portable_atmospherics/canister/air/create_gas()
air_contents.add_gases(/datum/gas/oxygen, /datum/gas/nitrogen)
air_contents.gases[/datum/gas/oxygen][MOLES] = (O2STANDARD * maximum_pressure * filled) * air_contents.volume / (R_IDEAL_GAS_EQUATION * air_contents.temperature)
air_contents.gases[/datum/gas/nitrogen][MOLES] = (N2STANDARD * maximum_pressure * filled) * air_contents.volume / (R_IDEAL_GAS_EQUATION * air_contents.temperature)
air_contents.adjust_gas(/datum/gas/oxygen, (O2STANDARD * maximum_pressure * filled) * air_contents.volume / (R_IDEAL_GAS_EQUATION * air_contents.temperature))
air_contents.adjust_gas(/datum/gas/nitrogen, (N2STANDARD * maximum_pressure * filled) * air_contents.volume / (R_IDEAL_GAS_EQUATION * air_contents.temperature))
SSair.start_processing_machine(src)
/obj/machinery/portable_atmospherics/canister/update_icon_state()
@@ -93,6 +93,7 @@
filtered.temperature = filtering.temperature
for(var/gas in filtering.gases & scrubbing)
filtered.add_gas(gas)
filtered.gases[gas][MOLES] = filtering.gases[gas][MOLES] // Shuffle the "bad" gasses to the filtered mixture.
filtering.gases[gas][MOLES] = 0
filtering.garbage_collect() // Now that the gasses are set to 0, clean up the mixture.
@@ -84,7 +84,7 @@
//contains all of the gas we're sucking out of the tile, gets put into our parent pipenet
var/datum/gas_mixture/filtered_out = new
var/list/filtered_gases = filtered_out.gases
filtered_out.temperature = environment.temperature
//maximum percentage of the turfs gas we can filter
@@ -102,8 +102,8 @@
filtered_out.add_gas(gas)
var/transferred_moles = max(QUANTIZE(env_gases[gas][MOLES] * removal_ratio * (env_gases[gas][MOLES] / total_moles_to_remove)), min(MOLAR_ACCURACY*1000, env_gases[gas][MOLES]))
filtered_gases[gas][MOLES] = transferred_moles
env_gases[gas][MOLES] -= transferred_moles
filtered_out.adjust_gas(gas, transferred_moles)
environment.adjust_gas(gas, -transferred_moles)
environment.garbage_collect()
+6 -6
View File
@@ -70,26 +70,26 @@
for(var/gas_id in breath.gases)
if(gas_id in high_filtering_gases)
if(breath.gases[gas_id][MOLES] > HIGH_FILTERING_MOLES)
breath.gases[gas_id][MOLES] = max(breath.gases[gas_id][MOLES] - filter_strength_high * filter_efficiency * HIGH_FILTERING_RATIO, 0)
breath.set_gas(gas_id, max(breath.gases[gas_id][MOLES] - filter_strength_high * filter_efficiency * HIGH_FILTERING_RATIO, 0))
danger_points += 1
continue
breath.gases[gas_id][MOLES] = max(breath.gases[gas_id][MOLES] - filter_strength_high * filter_efficiency * LOW_FILTERING_RATIO, 0)
breath.set_gas(gas_id, max(breath.gases[gas_id][MOLES] - filter_strength_high * filter_efficiency * LOW_FILTERING_RATIO, 0))
danger_points += 0.2
continue
if(gas_id in mid_filtering_gases)
if(breath.gases[gas_id][MOLES] > MID_FILTERING_MOLES)
breath.gases[gas_id][MOLES] = max(breath.gases[gas_id][MOLES] - filter_strength_mid * filter_efficiency * HIGH_FILTERING_RATIO, 0)
breath.set_gas(gas_id, max(breath.gases[gas_id][MOLES] - filter_strength_mid * filter_efficiency * HIGH_FILTERING_RATIO, 0))
danger_points += 1.25
continue
breath.gases[gas_id][MOLES] = max(breath.gases[gas_id][MOLES] - filter_strength_mid * filter_efficiency * LOW_FILTERING_RATIO, 0)
breath.set_gas(gas_id, max(breath.gases[gas_id][MOLES] - filter_strength_mid * filter_efficiency * LOW_FILTERING_RATIO, 0))
danger_points += 0.25
continue
if(gas_id in low_filtering_gases)
if(breath.gases[gas_id][MOLES] > LOW_FILTERING_MOLES)
breath.gases[gas_id][MOLES] = max(breath.gases[gas_id][MOLES] - filter_strength_low * filter_efficiency * HIGH_FILTERING_RATIO, 0)
breath.set_gas(gas_id, max(breath.gases[gas_id][MOLES] - filter_strength_low * filter_efficiency * HIGH_FILTERING_RATIO, 0))
danger_points += 1.5
continue
breath.gases[gas_id][MOLES] = max(breath.gases[gas_id][MOLES] - filter_strength_low * filter_efficiency * LOW_FILTERING_RATIO, 0)
breath.set_gas(gas_id, max(breath.gases[gas_id][MOLES] - filter_strength_low * filter_efficiency * LOW_FILTERING_RATIO, 0))
danger_points += 0.5
continue
@@ -287,7 +287,7 @@
if(!gas_mix.gases[gas_type])
return
gas_mix.gases[gas_type][MOLES] = max(gas_mix.gases[gas_type][MOLES] - GAS_MUTATION_REMOVAL_MULTIPLIER * holder.growth_stage, 0)
gas_mix.set_gas(gas_type, max(gas_mix.gases[gas_type][MOLES] - GAS_MUTATION_REMOVAL_MULTIPLIER * holder.growth_stage, 0))
gas_mix.garbage_collect()
/datum/spacevine_mutation/gas_eater/oxy_eater
+2 -2
View File
@@ -340,8 +340,8 @@ GLOBAL_LIST_INIT(spontaneous_fish_traits, populate_spontaneous_fish_traits())
return
var/datum/gas_mixture/stench = new
ADD_GAS(/datum/gas/miasma, stench.gases)
stench.gases[/datum/gas/miasma][MOLES] = MIASMA_CORPSE_MOLES * 2 * seconds_per_tick
stench.set_gas(/datum/gas/miasma, MIASMA_CORPSE_MOLES * 2 * seconds_per_tick)
stench.temperature = mob.bodytemperature
our_turf.assume_air(stench)
@@ -681,8 +681,8 @@
return
var/datum/gas_mixture/stank = new
ADD_GAS(/datum/gas/miasma, stank.gases)
stank.gases[/datum/gas/miasma][MOLES] = (seed.yield + 6) * 3.5 * MIASMA_CORPSE_MOLES * seconds_per_tick // this process is only being called about 2/7 as much as corpses so this is 12-32 times a corpses
stank.set_gas(/datum/gas/miasma, (seed.yield + 6) * 3.5 * MIASMA_CORPSE_MOLES * seconds_per_tick) // this process is only being called about 2/7 as much as corpses so this is 12-32 times a corpses
stank.temperature = T20C // without this the room would eventually freeze and miasma mining would be easier
tray_turf.assume_air(stank)
+3 -3
View File
@@ -68,11 +68,11 @@
var/turf/open/our_turf = src.loc
if(!our_turf.air || !our_turf.air.gases[/datum/gas/carbon_dioxide])
return
var/co2 = our_turf.air.gases[/datum/gas/carbon_dioxide][MOLES]
var/datum/gas_mixture/our_air = our_turf.air
var/co2 = our_air.gases[/datum/gas/carbon_dioxide][MOLES]
if(co2 > 0 && SPT_PROB(13, seconds_per_tick))
var/amt = min(co2, 9)
our_turf.air.gases[/datum/gas/carbon_dioxide][MOLES] -= amt
our_air.adjust_gas(/datum/gas/carbon_dioxide, -amt)
our_turf.atmos_spawn_air("[GAS_O2]=[amt]")
/mob/living/basic/tree/melee_attack(atom/target, list/modifiers, ignore_cooldown = FALSE)
+2 -3
View File
@@ -418,9 +418,8 @@
/obj/structure/chrono_field/return_air() //we always have nominal air and temperature
var/datum/gas_mixture/fresh_air = new
fresh_air.add_gases(/datum/gas/oxygen, /datum/gas/nitrogen)
fresh_air.gases[/datum/gas/oxygen][MOLES] = MOLES_O2STANDARD
fresh_air.gases[/datum/gas/nitrogen][MOLES] = MOLES_N2STANDARD
fresh_air.set_gas(/datum/gas/oxygen, MOLES_O2STANDARD)
fresh_air.set_gas(/datum/gas/nitrogen, MOLES_N2STANDARD)
fresh_air.temperature = T20C
return fresh_air
@@ -113,10 +113,10 @@ GLOBAL_LIST_INIT(sm_gas_behavior, init_sm_gas())
)
if(!consumed_co2)
return
sm.absorbed_gasmix.gases[/datum/gas/carbon_dioxide][MOLES] -= consumed_co2
sm.absorbed_gasmix.gases[/datum/gas/oxygen][MOLES] -= consumed_co2
ASSERT_GAS(/datum/gas/pluoxium, sm.absorbed_gasmix)
sm.absorbed_gasmix.gases[/datum/gas/pluoxium][MOLES] += consumed_co2
sm.absorbed_gasmix.adjust_gas(/datum/gas/carbon_dioxide, -consumed_co2)
sm.absorbed_gasmix.adjust_gas(/datum/gas/oxygen, -consumed_co2)
sm.absorbed_gasmix.adjust_gas(/datum/gas/pluoxium, consumed_co2)
/datum/sm_gas/plasma
gas_path = /datum/gas/plasma
@@ -178,7 +178,7 @@ GLOBAL_LIST_INIT(sm_gas_behavior, init_sm_gas())
var/consumed_miasma = sm.absorbed_gasmix.gases[/datum/gas/miasma][MOLES] * miasma_ratio
if(!consumed_miasma)
return
sm.absorbed_gasmix.gases[/datum/gas/miasma][MOLES] -= consumed_miasma
sm.absorbed_gasmix.adjust_gas(/datum/gas/miasma, -consumed_miasma)
sm.external_power_trickle += consumed_miasma * MIASMA_POWER_GAIN
sm.log_activation("miasma absorption")
@@ -1133,10 +1133,9 @@
/// H2O electrolysis
/obj/item/organ/lungs/ethereal/proc/consume_water(mob/living/carbon/breather, datum/gas_mixture/breath, h2o_pp, old_h2o_pp)
var/gas_breathed = breath.gases[/datum/gas/water_vapor][MOLES]
breath.gases[/datum/gas/water_vapor][MOLES] -= gas_breathed
breath_out.assert_gases(/datum/gas/oxygen, /datum/gas/hydrogen)
breath_out.gases[/datum/gas/oxygen][MOLES] += gas_breathed
breath_out.gases[/datum/gas/hydrogen][MOLES] += gas_breathed * 2
breath.adjust_gas(/datum/gas/water_vapor, -gas_breathed)
var/list/new_gases = list(/datum/gas/oxygen = gas_breathed, /datum/gas/hydrogen = gas_breathed * 2)
breath_out.adjust_multiple_gases(new_gases)
/obj/item/organ/lungs/pod
@@ -31,9 +31,8 @@
internal_tank.air_contents.volume = volume
internal_tank.maximum_pressure = maximum_pressure
if(start_full)
internal_tank.air_contents.temperature = T20C
internal_tank.air_contents.add_gases(/datum/gas/oxygen)
internal_tank.air_contents.gases[/datum/gas/oxygen][MOLES] = maximum_pressure * volume / (R_IDEAL_GAS_EQUATION * internal_tank.air_contents.temperature)
internal_tank.air_contents.set_temperature(T20C)
internal_tank.air_contents.set_gas(/datum/gas/oxygen, maximum_pressure * volume / (R_IDEAL_GAS_EQUATION * internal_tank.air_contents.temperature))
/obj/item/mecha_parts/mecha_equipment/air_tank/Destroy()
if(chassis)