Finished the first auxgm expansion

This commit is contained in:
Putnam
2021-06-11 16:15:00 -07:00
parent eda6a4d2e2
commit 571a25c052
11 changed files with 146 additions and 97 deletions
@@ -16,12 +16,12 @@
/datum/breathing_class/oxygen
gases = list(
GAS_O2 = 1
GAS_O2 = 1,
GAS_PLUOXIUM = 8,
GAS_CO2 = -0.7, // CO2 isn't actually toxic, just an asphyxiant
)
products = list(
GAS_CO2 = 1
GAS_CO2 = 1,
)
/datum/breathing_class/plasma
+6 -7
View File
@@ -11,7 +11,7 @@
not_enough_alert = list(
alert_category = "not_enough_nitro",
alert_type = /obj/screen/alert/not_enough_nitro
)
),
too_much_alert = list(
alert_category = "too_much_nitro",
alert_type = /obj/screen/alert/too_much_nitro
@@ -28,13 +28,12 @@
not_enough_alert = list(
alert_category = "not_enough_co2",
alert_type = /obj/screen/alert/not_enough_co2
)
),
too_much_alert = list(
alert_category = "too_much_co2",
alert_type = /obj/screen/alert/too_much_co2
)
)
breath_reagent_dangerous = /datum/reagent/co2_toxic
fusion_power = 3
/datum/gas/plasma
@@ -134,13 +133,13 @@
specific_heat = 30
name = "Methane"
breath_results = GAS_METHYL_BROMIDE
fire_provides = list(GAS_CO2 = 1, GAS_H2O = 2)
fire_products = list(GAS_CO2 = 1, GAS_H2O = 2)
fire_burn_rate = 0.5
breath_alert_info = list(
not_enough_alert = list(
alert_category = "not_enough_ch4",
alert_type = /obj/screen/alert/not_enough_ch4
)
),
too_much_alert = list(
alert_category = "too_much_ch4",
alert_type = /obj/screen/alert/too_much_ch4
@@ -158,13 +157,13 @@
not_enough_alert = list(
alert_category = "not_enough_ch3br",
alert_type = /obj/screen/alert/not_enough_ch3br
)
),
too_much_alert = list(
alert_category = "too_much_ch3br",
alert_type = /obj/screen/alert/too_much_ch3br
)
)
fire_provides = list(GAS_CO2 = 1, GAS_H2O = 1.5, GAS_BZ = 0.5)
fire_products = 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
@@ -61,7 +61,7 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(GAS_O2, GAS_N2, GAS_CO2, GA
// greatly prefer just adding a reagent. This is mostly around for legacy reasons.
return null
/datum/auxgm/add_gas(datum/gas/gas)
/datum/auxgm/proc/add_gas(datum/gas/gas)
var/g = gas.id
if(g)
datums[g] = gas
@@ -77,7 +77,7 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(GAS_O2, GAS_N2, GAS_CO2, GA
overlays[g] = 0
flags[g] = gas.flags
ids[g] = g
typepaths[g] = gas_path
typepaths[g] = gas.type
fusion_powers[g] = gas.fusion_power
if(gas.breath_alert_info)
@@ -103,10 +103,17 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(GAS_O2, GAS_N2, GAS_CO2, GA
_auxtools_register_gas(gas)
/proc/finalize_gas_refs()
/datum/auxgm/New()
for(var/gas_path in subtypesof(/datum/gas))
var/datum/gas/gas = new gas_path
add_gas(gas)
for(var/breathing_class_path in subtypesof(/datum/breathing_class))
var/datum/breathing_class/class = new breathing_class_path
breathing_classes[breathing_class_path] = class
finalize_gas_refs()
GLOBAL_DATUM_INIT(gas_data, /datum/auxgm, new)
@@ -246,19 +246,34 @@
name = "Combustion"
id = "genericfire"
/datum/gas_reaction/genericfire/init_reqs()
var/lowest_fire_temp = INFINITY
var/list/fire_temperatures = GLOB.gas_data.fire_temperatures
for(var/gas in fire_temperatures)
lowest_fire_temp = min(lowest_fire_temp, fire_temperatures[gas])
var/lowest_oxi_temp = INFINITY
var/list/oxidation_temperatures = GLOB.gas_data.oxidation_temperatures
for(var/gas in oxidation_temperatures)
lowest_oxi_temp = min(lowest_oxi_temp, oxidation_temperatures[gas])
min_requirements = list(
"TEMP" = max(lowest_oxi_temp, lowest_fire_temp),
"FIRE_REAGENTS" = MINIMUM_MOLE_COUNT
)
// 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
var/list/oxidation_temps = GLOB.gas_data.oxidation_temperatures
var/list/oxidation_rates = GLOB.gas_data.oxidation_rates
var/oxidation_power = 0
var/list/burn_results = list()
var/list/fuels = list()
var/list/oxidizers = list()
var/list/fuel_rates = GLOB.gas_data.fuel_rates
var/list/fuel_rates = GLOB.gas_data.fire_burn_rates
var/list/fuel_temps = GLOB.gas_data.fire_temperatures
var/total_fuel = 0
var/energy_released = 0
for(var/G in air.get_gases())
@@ -280,7 +295,7 @@
if(oxidation_ratio > 1)
for(var/oxidizer in oxidizers)
oxidizers[oxidizer] /= oxidation_ratio
else if oxidation_ratio < 1
else if(oxidation_ratio < 1)
for(var/fuel in fuels)
fuels[fuel] *= oxidation_ratio
fuels += oxidizers
@@ -295,7 +310,7 @@
for(var/product in fire_products[fuel])
if(!burn_results[product])
burn_results[product] = 0
burn_results[o] += amt
burn_results[product] += amt
var/final_energy = air.thermal_energy() + energy_released
for(var/result in burn_results)
air.adjust_moles(result, burn_results[result])
@@ -94,7 +94,7 @@
var/list/TLV = list( // Breathable air.
"pressure" = new/datum/tlv(ONE_ATMOSPHERE * 0.8, ONE_ATMOSPHERE* 0.9, ONE_ATMOSPHERE * 1.1, ONE_ATMOSPHERE * 1.2), // kPa
"temperature" = new/datum/tlv(T0C, T0C+10, T0C+40, T0C+66),
GAS_O2 = new/datum/tlv(16, 19, 135, 140), // Partial pressure, kpa
GAS_O2 = new/datum/tlv(16, 19, 40, 50), // Partial pressure, kpa
GAS_N2 = new/datum/tlv(-1, -1, 1000, 1000),
GAS_CO2 = new/datum/tlv(-1, -1, 5, 10),
GAS_MIASMA = new/datum/tlv(-1, -1, 2, 5),
@@ -106,7 +106,7 @@
GAS_TRITIUM = new/datum/tlv/dangerous,
GAS_STIMULUM = new/datum/tlv(-1, -1, 1000, 1000), // Stimulum has only positive effects
GAS_NITRYL = new/datum/tlv/dangerous,
GAS_PLUOXIUM = new/datum/tlv(-1, -1, 1000, 1000), // Unlike oxygen, pluoxium does not fuel plasma/tritium fires
GAS_PLUOXIUM = new/datum/tlv(-1, -1, 5, 6), // Unlike oxygen, pluoxium does not fuel plasma/tritium fires
GAS_METHANE = new/datum/tlv(-1, -1, 3, 6),
GAS_METHYL_BROMIDE = new/datum/tlv/dangerous
)
+1
View File
@@ -125,6 +125,7 @@
var/obj/loc_as_obj = loc
loc_as_obj.handle_internal_lifeform(src,0)
breath.set_volume(BREATH_VOLUME)
check_breath(breath)
if(breath)
+1 -2
View File
@@ -254,8 +254,7 @@
to_chat(H, "<span class='notice'>You feel resistant to airborne toxins.</span>")
if(locate(/obj/item/organ/lungs) in H.internal_organs)
var/obj/item/organ/lungs/L = H.internal_organs_slot[ORGAN_SLOT_LUNGS]
L.tox_breath_dam_min = 0
L.tox_breath_dam_max = 0
L.gas_max -= GAS_PLASMA
ADD_TRAIT(H, TRAIT_VIRUSIMMUNE, "dna_vault")
if(VAULT_NOBREATH)
to_chat(H, "<span class='notice'>Your lungs feel great.</span>")
+96 -75
View File
@@ -35,7 +35,7 @@
var/safe_damage_type = OXY
var/list/gas_min = list()
var/list/gas_max = list(
GAS_CO2 = 10, // Yes it's an arbitrary value who cares?
GAS_CO2 = 30, // Yes it's an arbitrary value who cares?
GAS_METHYL_BROMIDE = 1,
GAS_PLASMA = MOLES_GAS_VISIBLE
)
@@ -44,7 +44,7 @@
min = MIN_TOXIC_GAS_DAMAGE,
max = MAX_TOXIC_GAS_DAMAGE,
damage_type = OXY
)
),
GAS_PLASMA = list(
min = MIN_TOXIC_GAS_DAMAGE,
max = MAX_TOXIC_GAS_DAMAGE,
@@ -52,26 +52,11 @@
)
)
var/light_effect_resistance = 1 // PP at which light snowflake effects happen
var/heavy_effect_resistance = 5 // PP at which heavy snowflake effects happen
var/SA_para_min = 1 //nitrous values
var/SA_sleep_min = 5
var/BZ_trip_balls_min = 1 //BZ gas
var/gas_stimulation_min = 0.002 //Nitryl and Stimulum
var/oxy_breath_dam_min = MIN_TOXIC_GAS_DAMAGE
var/oxy_breath_dam_max = MAX_TOXIC_GAS_DAMAGE
var/oxy_damage_type = OXY
var/nitro_breath_dam_min = MIN_TOXIC_GAS_DAMAGE
var/nitro_breath_dam_max = MAX_TOXIC_GAS_DAMAGE
var/nitro_damage_type = OXY
var/co2_breath_dam_min = MIN_TOXIC_GAS_DAMAGE
var/co2_breath_dam_max = MAX_TOXIC_GAS_DAMAGE
var/co2_damage_type = OXY
var/tox_breath_dam_min = MIN_TOXIC_GAS_DAMAGE
var/tox_breath_dam_max = MAX_TOXIC_GAS_DAMAGE
var/tox_damage_type = TOX
var/methane_breath_dam_min = MIN_TOXIC_GAS_DAMAGE
var/methane_breath_dam_max = MAX_TOXIC_GAS_DAMAGE
var/methane_damage_type = OXY
var/cold_message = "your face freezing and an icicle forming"
var/cold_level_1_threshold = 260
var/cold_level_2_threshold = 200
@@ -93,6 +78,10 @@
var/crit_stabilizing_reagent = /datum/reagent/medicine/epinephrine
/obj/item/organ/lungs/New()
. = ..()
populate_gas_info()
/obj/item/organ/lungs/proc/populate_gas_info()
gas_min[breathing_class] = safe_breath_min
gas_max[breathing_class] = safe_breath_max
gas_damage[breathing_class] = list(
@@ -146,11 +135,23 @@
H.adjustOxyLoss(HUMAN_CRIT_MAX_OXYLOSS)
H.failed_last_breath = TRUE
var/list/alert = GLOB.gas_data.breath_alert_info[breathing_class]["not_enough_alert"]
H.throw_alert(alert["alert_category"], alert["alert_type"])
var/alert_category
var/alert_type
if(ispath(breathing_class))
var/datum/breathing_class/class = GLOB.gas_data.breathing_classes[breathing_class]
alert_category = class.low_alert_category
alert_type = class.low_alert_datum
else
var/list/breath_alert_info = GLOB.gas_data.breath_alert_info
if(breathing_class in breath_alert_info)
var/list/alert = breath_alert_info[breathing_class]["not_enough_alert"]
alert_category = alert["alert_category"]
alert_type = alert["alert_type"]
if(alert_category)
H.throw_alert(alert_category, alert_type)
return FALSE
#define PP_MOLES(X) ((X / total_moles) * pressure))
#define PP_MOLES(X) ((X / total_moles) * pressure)
#define PP(air, gas) PP_MOLES(air.get_moles(gas))
@@ -160,19 +161,20 @@
var/total_moles = breath.total_moles()
var/list/breath_alert_info = GLOB.gas_data.breath_alert_info
var/list/breath_results = GLOB.gas_data.breath_results
var/list/breathing_classes = GLOB.gas_data.breathing_classes
var/list/mole_adjustments = list()
for(var/entry in gas_min)
var/required_pp = 0
var/required_moles = 0
var/safe_min = gas_min[entry]
var/datum/breathing_class/breathing_class = entry
var/alert_category = ""
var/alert_category = null
var/alert_type = null
if(istype(breathing_class)) // breathing classes are numbers while gases are strings so internally this is how we do it
var/list/gases = initial(breathing_class.gases)
var/list/products = initial(breathing_class.products)
alert_category = initial(breathing_class.low_alert_category)
alert_type = initial(breathing_class.low_alert_type)
if(ispath(entry))
var/datum/breathing_class/class = breathing_classes[entry]
var/list/gases = class.gases
var/list/products = class.products
alert_category = class.low_alert_category
alert_type = class.low_alert_datum
for(var/gas in gases)
var/moles = breath.get_moles(gas)
var/multiplier = gases[gas]
@@ -185,65 +187,71 @@
else
required_moles = breath.get_moles(entry)
required_pp = PP_MOLES(required_moles)
var/list/alert = breath_alert_info[entry]["not_enough_alert"]
alert_category = alert["alert_category"]
alert_type = alert["alert_type"]
if(entry in breath_alert_info)
var/list/alert = breath_alert_info[entry]["not_enough_alert"]
alert_category = alert["alert_category"]
alert_type = alert["alert_type"]
mole_adjustments[entry] = -required_moles
mole_adjustments[breath_results[entry]] = required_moles
if(required_pp < safe_min)
var/multiplier = handle_too_little_breath(H, required_pp, safe_min, required_moles) / required_moles
for(var/entry in mole_adjustments)
mole_adjustments[entry] *= multiplier
H.throw_alert(alert_category, alert_type)
for(var/adjustment in mole_adjustments)
mole_adjustments[adjustment] *= multiplier
if(alert_category)
H.throw_alert(alert_category, alert_type)
else
H.failed_last_breath = FALSE
if(H.health >= H.crit_threshold)
H.adjustOxyLoss(-breathModifier)
H.clear_alert(alert_category)
if(alert_category)
H.clear_alert(alert_category)
var/list/danger_reagents = GLOB.gas_data.breath_reagents_dangerous
for(var/entry in gas_max)
var/found_pp = 0
var/datum/breathing_class/breathing_class = entry
var/datum/reagent/danger_reagent = null
var/alert_category = ""
var/alert_category = null
var/alert_type = null
if(istype(breathing_class))
var/list/gases = initial(breathing_class.gases)
alert_category = initial(breathing_class.high_alert_category)
alert_type = initial(breathing_class.high_alert_type)
danger_reagent = initial(breathing_class.danger_reagent)
if(ispath(breathing_class))
breathing_class = breathing_classes[breathing_class]
var/list/gases = breathing_class.gases
alert_category = breathing_class.high_alert_category
alert_type = breathing_class.high_alert_datum
danger_reagent = breathing_class.danger_reagent
for(var/gas in gases)
found_pp +== PP(breath, breathing_class)
found_pp += PP(breath, gas)
else
danger_reagent = danger_reagents[entry]
var/list/alert = breath_alert_info[entry]["too_much_alert"]
alert_category = alert["alert_category"]
alert_type = alert["alert_type"]
if(entry in breath_alert_info)
var/list/alert = breath_alert_info[entry]["too_much_alert"]
alert_category = alert["alert_category"]
alert_type = alert["alert_type"]
found_pp = PP(breath, entry)
if(found_pp > gas_max[entry])
if(istype(danger_reagent))
H.reagents.add_reagent(danger_reagent,1)
if(gas_flags[gas] & GAS_FLAG_BREATH_PROC)
gas_datums[gas].breath(PP_MOLES(moles), light_effect_resistance, heavy_effect_resistance, moles, H, src)
var/list/damage_info = gas_damage[entry]
var/dam = found_pp / gas_max[entry] * 10
H.apply_damage_type(clamp(ratio, damage_info["min"], damage_info["max"]), damage_info["damage_type"])
H.apply_damage_type(clamp(dam, damage_info["min"], damage_info["max"]), damage_info["damage_type"])
if(alert_category && alert_type)
H.throw_alert(alert_category, alert_type)
else if(alert_category)
H.clear_alert(alert_category)
var/list/breath_reagents = GLOB.gas_data.breath_reagents
var/list/gas_flags = GLOB.gas_data.flags
var/list/gas_datums = GLOB.gas_data.datums
for(var/gas in breath.get_gases())
if(gas in breath_reagents)
var/datum/reagent/R = breath_reagents[gas]
H.reagents.add_reagent(R, PP(breath,gas))
mole_adjustments[gas] = (gas in mole_adjustments) ? mole_adjustments[gas] - breath.get_moles(gas) : -breath.get_moles(gas)
breath.adjust_from_list(mole_adjustments)
for(var/gas in mole_adjustments)
breath.adjust_moles(gas, mole_adjustments[gas])
if(breath) // If there's some other shit in the air lets deal with it here.
// N2O
var/SA_pp = breath.get_breath_partial_pressure(breath.get_moles(GAS_NITROUS))
var/SA_pp = PP(breath, GAS_NITROUS)
if(SA_pp > SA_para_min) // Enough to make us stunned for a bit
H.Unconscious(60) // 60 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
@@ -257,7 +265,7 @@
// BZ
var/bz_pp = breath.get_breath_partial_pressure(breath.get_moles(GAS_BZ))
var/bz_pp = PP(breath, GAS_BZ)
if(bz_pp > BZ_trip_balls_min)
H.hallucination += 10
H.reagents.add_reagent(/datum/reagent/bz_metabolites,5)
@@ -269,7 +277,7 @@
H.reagents.add_reagent(/datum/reagent/bz_metabolites,1)
// Nitryl
var/nitryl_pp = breath.get_breath_partial_pressure(breath.get_moles(GAS_NITRYL))
var/nitryl_pp = PP(breath,GAS_NITRYL)
if (prob(nitryl_pp))
to_chat(H, "<span class='alert'>Your mouth feels like it's burning!</span>")
if (nitryl_pp >40)
@@ -287,7 +295,7 @@
breath.adjust_moles(GAS_NITRYL, -gas_breathed)
// Stimulum
gas_breathed = breath.get_moles(GAS_STIMULUM)
gas_breathed = PP(breath,GAS_STIMULUM)
if (gas_breathed > gas_stimulation_min)
var/existing = H.reagents.get_reagent_amount(/datum/reagent/stimulum)
H.reagents.add_reagent(/datum/reagent/stimulum, max(0, 5 - existing))
@@ -295,7 +303,7 @@
// Miasma
if (breath.get_moles(GAS_MIASMA))
var/miasma_pp = breath.get_breath_partial_pressure(breath.get_moles(GAS_MIASMA))
var/miasma_pp = PP(breath,GAS_MIASMA)
if(miasma_pp > MINIMUM_MOLES_DELTA_TO_MOVE)
//Miasma sickness
@@ -426,13 +434,13 @@
name = "plasma filter"
desc = "A spongy rib-shaped mass for filtering plasma from the air."
icon_state = "lungs-plasma"
safe_oxygen_min = 0 //We don't breath this
safe_oxygen_max = 0 // Like, at all.
safe_toxins_min = 16 //We breath THIS!
safe_toxins_max = 0
breathing_class = BREATH_PLASMA
maxHealth = INFINITY//I don't understand how plamamen work, so I'm not going to try t give them special lungs atm
/obj/item/organ/lungs/plasmaman/populate_gas_info()
..()
gas_max -= GAS_PLASMA
/obj/item/organ/lungs/cybernetic
name = "basic cybernetic lungs"
desc = "A basic cybernetic version of the lungs found in traditional humanoid entities."
@@ -447,8 +455,8 @@
desc = "A cybernetic version of the lungs found in traditional humanoid entities. Allows for greater intakes of oxygen than organic lungs, requiring slightly less pressure."
icon_state = "lungs-c-u"
maxHealth = 1.5 * STANDARD_ORGAN_THRESHOLD
safe_oxygen_min = 13
safe_oxygen_max = 100
safe_breath_min = 13
safe_breath_max = 100
emp_vulnerability = 2
/obj/item/organ/lungs/cybernetic/tier3
@@ -456,10 +464,13 @@
desc = "A more advanced version of the stock cybernetic lungs. Features the ability to filter out various airbourne toxins and carbon dioxide even at heavy levels."
icon_state = "lungs-c-u2"
maxHealth = 2 * STANDARD_ORGAN_THRESHOLD
safe_oxygen_min = 4 //You could literally be breathing the thinnest amount of oxygen and be fine
safe_oxygen_max = 250 //Or be in an enriched oxygen room for that matter
safe_toxins_max = 30
safe_co2_max = 30
safe_breath_min = 4 //You could literally be breathing the thinnest amount of oxygen and be fine
safe_breath_max = 250 //Or be in an enriched oxygen room for that matter
gas_max = list(
GAS_PLASMA = 30,
GAS_CO2 = 30,
GAS_METHYL_BROMIDE = 10
)
SA_para_min = 30
SA_sleep_min = 50
BZ_trip_balls_min = 30
@@ -484,9 +495,8 @@
name = "ash lungs"
desc = "blackened lungs identical from specimens recovered from lavaland, unsuited to higher air pressures."
icon_state = "lungs-ll"
safe_oxygen_min = 3 //able to handle much thinner oxygen, something something ash storm adaptation
safe_oxygen_max = 18 // Air standard is 22kpA of O2, LL is 14kpA
safe_nitro_max = 28 // Air standard is 82kpA of N2, LL is 23kpA
safe_breath_min = 3 //able to handle much thinner oxygen, something something ash storm adaptation
safe_breath_max = 18 // Air standards is 22kPa of O2, LL is 14kPa
cold_level_1_threshold = 280 // Ash Lizards can't take the cold very well, station air is only just warm enough
cold_level_2_threshold = 240
@@ -495,23 +505,31 @@
heat_level_1_threshold = 400 // better adapted for heat, obv. Lavaland standard is 300
heat_level_2_threshold = 600 // up 200 from level 1, 1000 is silly but w/e for level 3
/obj/item/organ/lungs/ashwalker/populate_gas_info()
..()
gas_max[GAS_N2] = 28
/obj/item/organ/lungs/slime
name = "vacuole"
icon_state = "lungs-s"
desc = "A large organelle designed to store oxygen and other important gasses."
safe_toxins_max = 0 //We breathe this to gain POWER.
cold_level_1_threshold = 285 // Remember when slimes used to be succeptable to cold? Well....
cold_level_2_threshold = 260
cold_level_3_threshold = 230
maxHealth = 250
/obj/item/organ/lungs/ashwalker/populate_gas_info()
..()
gas_max -= GAS_PLASMA
/obj/item/organ/lungs/slime/check_breath(datum/gas_mixture/breath, mob/living/carbon/human/H)
. = ..()
if (breath)
var/plasma_pp = breath.get_breath_partial_pressure(breath.get_moles(GAS_PLASMA))
var/total_moles = breath.total_moles()
var/pressure = breath.return_pressure()
var/plasma_pp = PP(breath, GAS_PLASMA)
owner.blood_volume += (0.2 * plasma_pp) // 10/s when breathing literally nothing but plasma, which will suffocate you.
/obj/item/organ/lungs/yamerol
@@ -524,3 +542,6 @@
. = ..()
if(.)
applyOrganDamage(2) //Yamerol lungs are temporary
#undef PP
#undef PP_MOLES