Started expanding auxgm a bit

This commit is contained in:
Putnam
2021-06-10 04:40:23 -07:00
parent 56b5c68172
commit 3b25f3e199
25 changed files with 142 additions and 124 deletions
@@ -6,15 +6,6 @@ What are the archived variables for?
#define MINIMUM_HEAT_CAPACITY 0.0003
#define MINIMUM_MOLE_COUNT 0.01
//Unomos - global list inits for all of the meta gas lists.
//This setup allows procs to only look at one list instead of trying to dig around in lists-within-lists
GLOBAL_LIST_INIT(meta_gas_specific_heats, meta_gas_heat_list())
GLOBAL_LIST_INIT(meta_gas_names, meta_gas_name_list())
GLOBAL_LIST_INIT(meta_gas_visibility, meta_gas_visibility_list())
GLOBAL_LIST_INIT(meta_gas_overlays, meta_gas_overlay_list())
GLOBAL_LIST_INIT(meta_gas_flags, meta_gas_flags_list())
GLOBAL_LIST_INIT(meta_gas_ids, meta_gas_id_list())
GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
/datum/gas_mixture
/// Never ever set this variable, hooked into vv_get_var for view variables viewing.
var/gas_list_view_only
@@ -1,72 +1,65 @@
GLOBAL_LIST_INIT(hardcoded_gases, list(GAS_O2, GAS_N2, GAS_CO2, GAS_PLASMA)) //the main four gases, which were at one time hardcoded
GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(GAS_O2, GAS_N2, GAS_CO2, GAS_PLUOXIUM, GAS_STIMULUM, GAS_NITRYL))) //unable to react amongst themselves
// Listmos 2.0
// aka "auxgm", a send-up of XGM
// it's basically the same architecture as XGM but
// structured differently to make it more convenient for auxmos
// Auxgm
// It's a send-up of XGM, like what baystation got.
// It's got the same architecture as XGM, but it's structured
// differently to make it more convenient for auxmos.
// most important compared to TG is that it does away with hardcoded typepaths,
// which lead to problems on the auxmos end anyway.
// Most important compared to TG is that it does away with hardcoded typepaths,
// which lead to problems on the auxmos end anyway. We cache the string value
// references on the Rust end, so no performance is lost here.
// second most important is that i hate how breath is handled
// and most basically every other thing in the codebase
// when it comes to hardcoded gas typepaths, so, yeah, go away
// Also allows you to add new gases at runtime
GLOBAL_LIST_INIT(gas_data, meta_gas_info_list())
/proc/_auxtools_register_gas(datum/gas/gas) // makes sure auxtools knows stuff about this gas
/proc/meta_gas_info_list()
. = list()
for(var/gas_path in subtypesof(/datum/gas))
var/datum/gas/gas = new gas_path // !
if(gas.id)
.[gas.id] = gas
/datum/auxgm
var/list/datums = list()
var/list/specific_heats = list()
var/list/names = list()
var/list/visibility = list()
var/list/overlays = list()
var/list/flags = list()
var/list/ids = list()
var/list/typepaths = list()
var/list/fusion_powers = list()
/proc/meta_gas_heat_list()
. = list()
for(var/gas_path in subtypesof(/datum/gas))
var/datum/gas/gas = gas_path
.[initial(gas.id)] = initial(gas.specific_heat)
/proc/meta_gas_name_list()
. = list()
for(var/gas_path in subtypesof(/datum/gas))
var/datum/gas/gas = gas_path
.[initial(gas.id)] = initial(gas.name)
/proc/meta_gas_visibility_list()
. = list()
for(var/gas_path in subtypesof(/datum/gas))
var/datum/gas/gas = gas_path
.[initial(gas.id)] = initial(gas.moles_visible)
/proc/meta_gas_overlay_list()
. = list()
for(var/gas_path in subtypesof(/datum/gas))
var/datum/gas/gas = gas_path
.[initial(gas.id)] = 0 //gotta make sure if(GLOB.meta_gas_overlays[gaspath]) doesn't break
if(initial(gas.moles_visible) != null)
.[initial(gas.id)] = new /list(FACTOR_GAS_VISIBLE_MAX)
/datum/auxgm/add_gas(datum/gas/gas)
var/g = gas.id
if(g)
datums[g] = gas
specific_heats[g] = gas.specific_heat
names[g] = gas.name
if(gas.moles_visible)
visibility[g] = gas.moles_visible
overlays[g] = new /list(FACTOR_GAS_VISIBLE_MAX)
for(var/i in 1 to FACTOR_GAS_VISIBLE_MAX)
.[initial(gas.id)][i] = new /obj/effect/overlay/gas(initial(gas.gas_overlay), i * 255 / FACTOR_GAS_VISIBLE_MAX)
overlays[g][i] = new /obj/effect/overlay/gas(gas.gas_overlay, i * 255 / FACTOR_GAS_VISIBLE_MAX)
else
visibility[g] = 0
overlays[g] = 0
flags[g] = gas.flags
ids[g] = g
typepaths[g] = gas_path
fusion_powers[g] = gas.fusion_power
_auxtools_register_gas(gas)
/proc/meta_gas_flags_list()
. = list()
/datum/auxgm/New()
for(var/gas_path in subtypesof(/datum/gas))
var/datum/gas/gas = gas_path
.[initial(gas.id)] = initial(gas.flags)
var/datum/gas/gas = new gas_path
add_gas(gas)
/proc/meta_gas_id_list()
. = list()
for(var/gas_path in subtypesof(/datum/gas))
var/datum/gas/gas = gas_path
.[initial(gas.id)] = initial(gas.id)
GLOBAL_DATUM_INIT(gas_data, /datum/auxgm, new)
/proc/meta_gas_fusion_list()
. = list()
for(var/gas_path in subtypesof(/datum/gas))
var/datum/gas/gas = gas_path
.[initial(gas.id)] = initial(gas.fusion_power)
/datum/breath_info
var/breathing_power = 1 // how much this gas counts for good-breath
var/breathing_class = null // what type of breath this is; lungs can also use gas IDs directly
var/breath_results = GAS_CO2 // what breathing a mole of this results in
/datum/oxidation_info
var/oxidation_temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST // temperature above which this gas is an oxidizer
var/list/oxidation_provides = list() // a list of elements this gas provides in combustion
/datum/gas
var/id = ""
@@ -75,27 +68,36 @@ GLOBAL_LIST_INIT(gas_data, meta_gas_info_list())
var/gas_overlay = "" //icon_state in icons/effects/atmospherics.dmi
var/moles_visible = null
var/flags = NONE //currently used by canisters
var/fusion_power = 0 //How much the gas accelerates a fusion reaction
var/rarity = 0 // relative rarity compared to other gases, used when setting up the reactions list.
var/fusion_power = 0 // How much the gas destabilizes a fusion reaction
var/breathing_power = 1 // how much this gas counts for good-breath
var/breathing_class = null // what type of breath this is; lungs can also use gas IDs directly
var/breath_results = GAS_CO2 // what breathing a mole of this results in
var/oxidation_temperature = null // temperature above which this gas is an oxidizer; null for none
var/oxidation_rate = 1 // how many moles of this can oxidize how many moles of material
var/oxidation_energy_released = 0 // how many moles are released per mole burned
var/list/oxidation_products = null // extra results from oxidizing this (per mole); null for none
var/fire_temperature = null // temperature above which gas may catch fire; null for none
var/list/fire_provides = null // what elements this gas provides as fuel for combustion; null for none
var/fire_energy_released = 0 // how much energy is released per mole of fuel burned
var/fire_burn_rate = 1 // how many moles are burned per product released
/datum/gas/oxygen
id = GAS_O2
specific_heat = 20
name = "Oxygen"
rarity = 900
breathing_class = BREATH_OXY
oxidation_temperature = T0C - 100 // it checks max of this and fire temperature, so rarely will things spontaneously combust
/datum/gas/nitrogen
id = GAS_N2
specific_heat = 20
name = "Nitrogen"
rarity = 1000
/datum/gas/carbon_dioxide //what the fuck is this?
id = GAS_CO2
specific_heat = 30
name = "Carbon Dioxide"
fusion_power = 3
rarity = 700
/datum/gas/plasma
id = GAS_PLASMA
@@ -104,7 +106,8 @@ GLOBAL_LIST_INIT(gas_data, meta_gas_info_list())
gas_overlay = "plasma"
moles_visible = MOLES_GAS_VISIBLE
flags = GAS_FLAG_DANGEROUS
rarity = 800
breathing_class = BREATH_PLASMA
// no fire info cause it has its own bespoke reaction for trit generation reasons
/datum/gas/water_vapor
id = GAS_H2O
@@ -113,7 +116,6 @@ GLOBAL_LIST_INIT(gas_data, meta_gas_info_list())
gas_overlay = "water_vapor"
moles_visible = MOLES_GAS_VISIBLE
fusion_power = 8
rarity = 500
/datum/gas/hypernoblium
id = GAS_HYPERNOB
@@ -121,7 +123,6 @@ GLOBAL_LIST_INIT(gas_data, meta_gas_info_list())
name = "Hyper-noblium"
gas_overlay = "freon"
moles_visible = MOLES_GAS_VISIBLE
rarity = 50
/datum/gas/nitrous_oxide
id = GAS_NITROUS
@@ -130,7 +131,9 @@ GLOBAL_LIST_INIT(gas_data, meta_gas_info_list())
gas_overlay = "nitrous_oxide"
moles_visible = MOLES_GAS_VISIBLE * 2
flags = GAS_FLAG_DANGEROUS
rarity = 600
oxidation_products = list(GAS_N2 = 1)
oxidation_rate = 0.5
oxidation_temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 100
/datum/gas/nitryl
id = GAS_NITRYL
@@ -140,7 +143,8 @@ GLOBAL_LIST_INIT(gas_data, meta_gas_info_list())
moles_visible = MOLES_GAS_VISIBLE
flags = GAS_FLAG_DANGEROUS
fusion_power = 15
rarity = 100
oxidation_products = list(GAS_N2 = 0.5)
oxidation_temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST - 50
/datum/gas/tritium
id = GAS_TRITIUM
@@ -150,7 +154,13 @@ GLOBAL_LIST_INIT(gas_data, meta_gas_info_list())
moles_visible = MOLES_GAS_VISIBLE
flags = GAS_FLAG_DANGEROUS
fusion_power = 1
rarity = 300
/*
these are for when we add hydrogen, trit gets to keep its hardcoded fire for legacy reasons
fire_provides = list(GAS_H2O = 2)
fire_burn_rate = 2
fire_energy_released = FIRE_HYDROGEN_ENERGY_RELEASED
fire_temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST - 50
*/
/datum/gas/bz
id = GAS_BZ
@@ -158,21 +168,22 @@ GLOBAL_LIST_INIT(gas_data, meta_gas_info_list())
name = "BZ"
flags = GAS_FLAG_DANGEROUS
fusion_power = 8
rarity = 400
/datum/gas/stimulum
id = GAS_STIMULUM
specific_heat = 5
name = "Stimulum"
fusion_power = 7
rarity = 1
/datum/gas/pluoxium
id = GAS_PLUOXIUM
specific_heat = 80
name = "Pluoxium"
fusion_power = 10
rarity = 200
breathing_power = 8
breathing_class = CLASS_OXY
oxidation_temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 100
oxidation_rate = 8
/datum/gas/miasma
id = GAS_MIASMA
@@ -181,20 +192,25 @@ GLOBAL_LIST_INIT(gas_data, meta_gas_info_list())
name = "Miasma"
gas_overlay = "miasma"
moles_visible = MOLES_GAS_VISIBLE * 60
rarity = 250
/datum/gas/methane
id = GAS_METHANE
specific_heat = 30
name = "Methane"
rarity = 320
fire_provides = list(GAS_CO2 = 1, GAS_H2O = 2)
fire_burn_rate = 0.5
fire_energy_released = FIRE_CARBON_ENERGY_RELEASED
fire_temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST
/datum/gas/methyl_bromide
id = GAS_METHYL_BROMIDE
specific_heat = 42
name = "Methyl Bromide"
flags = GAS_FLAG_DANGEROUS
rarity = 310
fire_provides = list(GAS_CO2 = 1, GAS_H2O = 1.5, GAS_BZ = 0.5)
fire_energy_released = FIRE_CARBON_ENERGY_RELEASED
fire_burn_rate = 0.5
fire_temperature = 808 // its autoignition, it apparently doesn't spark readily, so i don't put it lower
/obj/effect/overlay/gas
@@ -241,6 +241,22 @@
return list("success" = FALSE, "message" = "Plasma fires aren't making trit!")
return ..()
/datum/gas_reaction/genericfire
priority = -3 // very last reaction
name = "Combustion"
id = "genericfire"
// no requirements, always runs
// bad idea? maybe
// this is overridden by auxmos but, hey, good idea to have it readable
/datum/gas_reaction/genericfire/react(datum/gas_mixture/air, datum/holder)
var/temperature = air.return_temperature()
var/list/oxidation_temps = GLOB.gas_data.oxidation_temps
for(var/datum/gas/G in air.get_gases())
//fusion: a terrible idea that was fun but broken. Now reworked to be less broken and more interesting. Again (and again, and again). Again!
//Fusion Rework Counter: Please increment this if you make a major overhaul to this system again.
//6 reworks
@@ -291,7 +307,7 @@
var/scale_factor = (air.return_volume())/(PI) //We scale it down by volume/Pi because for fusion conditions, moles roughly = 2*volume, but we want it to be based off something constant between reactions.
var/toroidal_size = (2*PI)+TORADIANS(arctan((air.return_volume()-TOROID_VOLUME_BREAKEVEN)/TOROID_VOLUME_BREAKEVEN)) //The size of the phase space hypertorus
var/gas_power = 0
var/list/gas_fusion_powers = GLOB.meta_gas_fusions
var/list/gas_fusion_powers = GLOB.gas_data.fusion_powers
for (var/gas_id in air.get_gases())
gas_power += (gas_fusion_powers[gas_id]*air.get_moles(gas_id))
var/instability = MODULUS((gas_power*INSTABILITY_GAS_POWER_FACTOR)**2,toroidal_size) //Instability effects how chaotic the behavior of the reaction is
@@ -9,14 +9,14 @@
/datum/gas_mixture/heat_capacity() //joules per kelvin
var/list/cached_gases = gases
var/list/cached_gasheats = GLOB.meta_gas_specific_heats
var/list/cached_gasheats = GLOB.gas_data.specific_heats
. = 0
for(var/id in cached_gases)
. += cached_gases[id] * cached_gasheats[id]
/datum/gas_mixture/turf/heat_capacity() // Same as above except vacuums return HEAT_CAPACITY_VACUUM
var/list/cached_gases = gases
var/list/cached_gasheats = GLOB.meta_gas_specific_heats
var/list/cached_gasheats = GLOB.gas_data.specific_heats
for(var/id in cached_gases)
. += cached_gases[id] * cached_gasheats[id]
if(!.)
@@ -208,7 +208,7 @@
var/delta
var/gas_heat_capacity
//and also cache this shit rq because that results in sanic speed for reasons byond explanation
var/list/cached_gasheats = GLOB.meta_gas_specific_heats
var/list/cached_gasheats = GLOB.gas_data.specific_heats
//GAS TRANSFER
for(var/id in cached_gases | sharer_gases) // transfer gases