diff --git a/__DEFINES/gases.dm b/__DEFINES/gases.dm index 302c1171363..0e2294e933e 100644 --- a/__DEFINES/gases.dm +++ b/__DEFINES/gases.dm @@ -5,110 +5,3 @@ #define GAS_SLEEPING "sleeping_agent" #define GAS_VOLATILE "volatile_fuel" #define GAS_OXAGENT "oxygen_agent_b" - -/datum/gas - var/id = "" - var/name = "Unnamed Gas" - var/short_name // HTML-formatted short name. - var/specific_heat = 20 // J/(mol*K) - var/molar_mass = 0.032 // kg/mol - - var/tile_overlay = null - var/overlay_limit = null - - var/flags = 0 - -/datum/gas/proc/is_human_safe(var/moles, var/datum/gas_mixture/mixture) - return TRUE - -/datum/gas/oxygen - id = GAS_OXYGEN - name = "Oxygen" - short_name = "O2" - specific_heat = 20 // J/(mol*K) - molar_mass = 0.032 // kg/mol - - flags = XGM_GAS_OXIDIZER - -/datum/gas/oxygen/is_human_safe(var/moles, var/datum/gas_mixture/mixture) - return abs(moles/mixture.total_moles() - O2STANDARD) < 0.02 - -/datum/gas/nitrogen - id = GAS_NITROGEN - name = "Nitrogen" - short_name = "N2" - specific_heat = 20 // J/(mol*K) - molar_mass = 0.028 // kg/mol - -/datum/gas/nitrogen/is_human_safe(var/moles, var/datum/gas_mixture/mixture) - return abs(moles/mixture.total_moles() - N2STANDARD) < 0.2 - -/datum/gas/carbon_dioxide - id = GAS_CARBON - name = "Carbon Dioxide" - short_name = "CO2" - specific_heat = 30 // J/(mol*K) - molar_mass = 0.044 // kg/mol - - flags = XGM_GAS_LOGGED - -/datum/gas/carbon_dioxide/is_human_safe(var/moles, var/datum/gas_mixture/mixture) - return moles/mixture.total_moles() < 0.01 - -/datum/gas/plasma - id = GAS_PLASMA - name = "Plasma" - - //Note that this has a significant impact on TTV yield. - //Because it is so high, any leftover plasma soaks up a lot of heat and drops the yield pressure. - specific_heat = 200 // J/(mol*K) - - //Hypothetical group 14 (same as carbon), period 8 element. - //Using multiplicity rule, it's atomic number is 162 - //and following a N/Z ratio of 1.5, the molar mass of a monatomic gas is: - molar_mass = 0.405 // kg/mol - - tile_overlay = "plasma" - overlay_limit = MOLES_PLASMA_VISIBLE / CELL_VOLUME - flags = XGM_GAS_FUEL | XGM_GAS_CONTAMINANT | XGM_GAS_LOGGED - -/datum/gas/plasma/is_human_safe(var/moles, var/datum/gas_mixture/mixture) - return moles/mixture.total_moles() < 0.01 - -/datum/gas/sleeping_agent - id = GAS_SLEEPING - name = "Sleeping Agent" - short_name = "N2O" - specific_heat = 40 // J/(mol*K) - molar_mass = 0.044 // kg/mol. N₂O - - tile_overlay = "sleeping_agent" - overlay_limit = 1 / CELL_VOLUME - flags = XGM_GAS_OXIDIZER | XGM_GAS_LOGGED // N₂O is a powerful oxidizer - -/datum/gas/sleeping_agent/is_human_safe(var/moles, var/datum/gas_mixture/mixture) - return moles/mixture.total_moles() < 0.01 - -/datum/gas/volatile_fuel - id = GAS_VOLATILE - name = "Volatile Fuel" - - specific_heat = 30 - molar_mass = 0.163 // @MoMMI#9954 roll 32 405 - - flags = XGM_GAS_FUEL | XGM_GAS_LOGGED - -/datum/gas/volatile_fuel/is_human_safe(var/moles, var/datum/gas_mixture/mixture) - return moles/mixture.total_moles() < 0.01 - -/datum/gas/oxygen_agent_b - id = GAS_OXAGENT - name = "Oxygen Agent B" - - specific_heat = 300 - molar_mass = 0.300 - - flags = XGM_GAS_FUEL | XGM_GAS_OXIDIZER | XGM_GAS_CONTAMINANT | XGM_GAS_LOGGED - -/datum/gas/oxygen_agent_b/is_human_safe(var/moles, var/datum/gas_mixture/mixture) - return moles/mixture.total_moles() < 0.01 diff --git a/code/ZAS/XGM.dm b/code/ZAS/XGM.dm index b8a88fe413f..52fd3ce2abb 100644 --- a/code/ZAS/XGM.dm +++ b/code/ZAS/XGM.dm @@ -11,9 +11,9 @@ var/list/specific_heat = list() // Molar mass of the gas. Used for calculating specific entropy. var/list/molar_mass = list() - // Tile overlays. /images, created from references to 'icons/effects/tile_effects.dmi' + // Tile overlays. var/list/tile_overlay = list() - // Overlay limits. There must be at least this many moles for the overlay to appear. + // Overlay limits. There must be strictly more than this many moles per liter for the overlay to appear. var/list/overlay_limit = list() // Flags. var/list/flags = list() @@ -38,8 +38,8 @@ molar_mass[gas.id] = gas.molar_mass flags[gas.id] = gas.flags if(gas.tile_overlay) - tile_overlay[gas.id] = image('icons/effects/tile_effects.dmi', gas.tile_overlay, FLY_LAYER) - if(gas.overlay_limit) + tile_overlay[gas.id] = gas.tile_overlay + if(isnum(gas.overlay_limit)) overlay_limit[gas.id] = gas.overlay_limit return TRUE diff --git a/code/ZAS/XGM_gases.dm b/code/ZAS/XGM_gases.dm new file mode 100644 index 00000000000..6f47041d616 --- /dev/null +++ b/code/ZAS/XGM_gases.dm @@ -0,0 +1,110 @@ +/datum/gas + var/id = "" + var/name = "Unnamed Gas" + var/short_name // HTML-formatted short name. + var/specific_heat = 20 // J/(mol*K) + var/molar_mass = 0.032 // kg/mol + + var/tile_overlay = null //The overlay to draw over tiles containing this gas if it is visible. Can be anything that the overlays list will accept. + var/overlay_limit = null //If the molar_density of this gas in a zone is strictly greater than this number, it is visible. + + var/flags = 0 + +//This should probably be in a different file, but currently it's only used here. +/image/effect + plane = EFFECTS_PLANE + +/datum/gas/proc/is_human_safe(var/moles, var/datum/gas_mixture/mixture) + return TRUE + +/datum/gas/oxygen + id = GAS_OXYGEN + name = "Oxygen" + short_name = "O2" + specific_heat = 20 // J/(mol*K) + molar_mass = 0.032 // kg/mol + + flags = XGM_GAS_OXIDIZER + +/datum/gas/oxygen/is_human_safe(var/moles, var/datum/gas_mixture/mixture) + return abs(moles/mixture.total_moles() - O2STANDARD) < 0.02 + +/datum/gas/nitrogen + id = GAS_NITROGEN + name = "Nitrogen" + short_name = "N2" + specific_heat = 20 // J/(mol*K) + molar_mass = 0.028 // kg/mol + +/datum/gas/nitrogen/is_human_safe(var/moles, var/datum/gas_mixture/mixture) + return abs(moles/mixture.total_moles() - N2STANDARD) < 0.2 + +/datum/gas/carbon_dioxide + id = GAS_CARBON + name = "Carbon Dioxide" + short_name = "CO2" + specific_heat = 30 // J/(mol*K) + molar_mass = 0.044 // kg/mol + + flags = XGM_GAS_LOGGED + +/datum/gas/carbon_dioxide/is_human_safe(var/moles, var/datum/gas_mixture/mixture) + return moles/mixture.total_moles() < 0.01 + +/datum/gas/plasma + id = GAS_PLASMA + name = "Plasma" + + //Note that this has a significant impact on TTV yield. + //Because it is so high, any leftover plasma soaks up a lot of heat and drops the yield pressure. + specific_heat = 200 // J/(mol*K) + + //Hypothetical group 14 (same as carbon), period 8 element. + //Using multiplicity rule, it's atomic number is 162 + //and following a N/Z ratio of 1.5, the molar mass of a monatomic gas is: + molar_mass = 0.405 // kg/mol + + tile_overlay = new /image/effect('icons/effects/tile_effects.dmi', "plasma", FLY_LAYER) + overlay_limit = MOLES_PLASMA_VISIBLE / CELL_VOLUME + flags = XGM_GAS_FUEL | XGM_GAS_CONTAMINANT | XGM_GAS_LOGGED + +/datum/gas/plasma/is_human_safe(var/moles, var/datum/gas_mixture/mixture) + return moles/mixture.total_moles() < 0.01 + +/datum/gas/sleeping_agent + id = GAS_SLEEPING + name = "Sleeping Agent" + short_name = "N2O" + specific_heat = 40 // J/(mol*K) + molar_mass = 0.044 // kg/mol. N₂O + + tile_overlay = new /image/effect('icons/effects/tile_effects.dmi', "sleeping_agent", FLY_LAYER) + overlay_limit = 1 / CELL_VOLUME + flags = XGM_GAS_OXIDIZER | XGM_GAS_LOGGED // N₂O is a powerful oxidizer + +/datum/gas/sleeping_agent/is_human_safe(var/moles, var/datum/gas_mixture/mixture) + return moles/mixture.total_moles() < 0.01 + +/datum/gas/volatile_fuel + id = GAS_VOLATILE + name = "Volatile Fuel" + + specific_heat = 30 + molar_mass = 0.163 // @MoMMI#9954 roll 32 405 + + flags = XGM_GAS_FUEL | XGM_GAS_LOGGED + +/datum/gas/volatile_fuel/is_human_safe(var/moles, var/datum/gas_mixture/mixture) + return moles/mixture.total_moles() < 0.01 + +/datum/gas/oxygen_agent_b + id = GAS_OXAGENT + name = "Oxygen Agent B" + + specific_heat = 300 + molar_mass = 0.300 + + flags = XGM_GAS_FUEL | XGM_GAS_OXIDIZER | XGM_GAS_CONTAMINANT | XGM_GAS_LOGGED + +/datum/gas/oxygen_agent_b/is_human_safe(var/moles, var/datum/gas_mixture/mixture) + return moles/mixture.total_moles() < 0.01 diff --git a/code/ZAS/_gas_mixture.dm b/code/ZAS/_gas_mixture.dm index 49d78478f33..3195944f9c0 100644 --- a/code/ZAS/_gas_mixture.dm +++ b/code/ZAS/_gas_mixture.dm @@ -232,21 +232,20 @@ //Removes the given number of moles from src, and returns a new gas_mixture containing the removed gas. /datum/gas_mixture/proc/remove(moles, update = TRUE, update_removed = TRUE) var/sum = total_moles - if(!sum) - return moles = min(moles, sum) //Cannot take more air than tile has! - return remove_ratio(moles / sum, update, update_removed) + var/ratio = sum && (moles / sum) //Don't divide by zero + return remove_ratio(ratio, update, update_removed) //Removes the given proportion of the gas in src, and returns a new gas_mixture containing the removed gas. /datum/gas_mixture/proc/remove_ratio(ratio, update = TRUE, update_removed = TRUE) + var/datum/gas_mixture/removed = new() + if(ratio <= 0 || total_moles <= 0) - return + return removed ratio = min(ratio, 1) - var/datum/gas_mixture/removed = new() - for(var/g in gas) var/moles = gas[g] * ratio gas[g] -= moles @@ -265,10 +264,9 @@ //Removes the given volume of gas from src, and returns a new gas_mixture containing the removed gas, with the given volume. /datum/gas_mixture/proc/remove_volume(removed_volume, update = TRUE, update_removed = TRUE) var/datum/gas_mixture/removed = remove_ratio(removed_volume / volume, update, FALSE) - if(removed) - removed.volume = removed_volume - if(update_removed) - removed.update_values() + removed.volume = removed_volume + if(update_removed) + removed.update_values() return removed @@ -481,13 +479,13 @@ var/static/list/sharing_lookup_table = list(0.30, 0.40, 0.48, 0.54, 0.60, 0.66) /datum/gas_mixture/unsimulated/remove_ratio(ratio, update, update_removed = TRUE) + var/datum/gas_mixture/removed = new() + if(ratio <= 0 || total_moles <= 0) - return null + return removed ratio = min(ratio, 1) - var/datum/gas_mixture/removed = new() - for(var/g in gas) removed[g] += gas[g] * ratio diff --git a/vgstation13.dme b/vgstation13.dme index f4cca1e12c1..70076c3d6d3 100644 --- a/vgstation13.dme +++ b/vgstation13.dme @@ -2421,6 +2421,7 @@ #include "code\ZAS\Plasma.dm" #include "code\ZAS\Turf.dm" #include "code\ZAS\XGM.dm" +#include "code\ZAS\XGM_gases.dm" #include "code\ZAS\Zone.dm" #include "goon\code\datums\browserOutput.dm" #include "goon\code\obj\machinery\bot\chefbot.dm"