Makes supermatter properties auxgm-based

This commit is contained in:
Putnam3145
2021-07-20 22:46:33 -07:00
parent ff0f9f651a
commit 0b55928f9b
4 changed files with 105 additions and 117 deletions
+9
View File
@@ -268,6 +268,15 @@
#define GAS_FLAG_DANGEROUS (1<<0)
#define GAS_FLAG_BREATH_PROC (1<<1)
//SUPERMATTER DEFINES
#define HEAT_PENALTY "heat penalties"
#define TRANSMIT_MODIFIER "transmit"
#define RADIOACTIVITY_MODIFIER "radioactivity"
#define HEAT_RESISTANCE "heat resistance"
#define POWERLOSS_INHIBITION "powerloss inhibition"
#define ALL_SUPERMATTER_GASES "gases we care about"
#define POWER_MIX "gas powermix"
//HELPERS
#define PIPING_LAYER_SHIFT(T, PipingLayer) \
if(T.dir & (NORTH|SOUTH)) { \
+26 -1
View File
@@ -3,10 +3,16 @@
specific_heat = 20
name = "Oxygen"
oxidation_temperature = T0C - 100 // it checks max of this and fire temperature, so rarely will things spontaneously combust
powermix = 1
heat_penalty = 1
transmit_modifier = 1.5
/datum/gas/nitrogen
id = GAS_N2
specific_heat = 20
name = "Nitrogen"
powermix = -1
heat_penalty = -1.5
breath_alert_info = list(
not_enough_alert = list(
alert_category = "not_enough_nitro",
@@ -17,12 +23,14 @@
alert_type = /obj/screen/alert/too_much_nitro
)
)
name = "Nitrogen"
/datum/gas/carbon_dioxide //what the fuck is this?
id = GAS_CO2
specific_heat = 30
name = "Carbon Dioxide"
powermix = 1
heat_penalty = 0.1
powerloss_inhibition = 1
breath_results = GAS_O2
breath_alert_info = list(
not_enough_alert = list(
@@ -43,6 +51,9 @@
gas_overlay = "plasma"
moles_visible = MOLES_GAS_VISIBLE
flags = GAS_FLAG_DANGEROUS
heat_penalty = 15
transmit_modifier = 4
powermix = 1
// no fire info cause it has its own bespoke reaction for trit generation reasons
/datum/gas/water_vapor
@@ -52,6 +63,8 @@
gas_overlay = "water_vapor"
moles_visible = MOLES_GAS_VISIBLE
fusion_power = 8
heat_penalty = 8
powermix = 1
breath_reagent = /datum/reagent/water
/datum/gas/hypernoblium
@@ -71,6 +84,7 @@
fire_products = list(GAS_N2 = 1)
oxidation_rate = 0.5
oxidation_temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 100
heat_resistance = 6
/datum/gas/nitryl
id = GAS_NITRYL
@@ -91,6 +105,9 @@
moles_visible = MOLES_GAS_VISIBLE
flags = GAS_FLAG_DANGEROUS
fusion_power = 1
powermix = 1
heat_penalty = 10
transmit_modifier = 30
/*
these are for when we add hydrogen, trit gets to keep its hardcoded fire for legacy reasons
fire_provides = list(GAS_H2O = 2)
@@ -105,6 +122,10 @@
name = "BZ"
flags = GAS_FLAG_DANGEROUS
fusion_power = 8
powermix = 1
heat_penalty = 5
transmit_modifier = -2
radioactivity_modifier = 5
/datum/gas/stimulum
id = GAS_STIMULUM
@@ -119,6 +140,10 @@
fusion_power = 10
oxidation_temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST * 1000 // it is VERY stable
oxidation_rate = 8
powermix = -1
heat_penalty = -1
transmit_modifier = -5
heat_resistance = 3
/datum/gas/miasma
id = GAS_MIASMA
+16 -1
View File
@@ -35,6 +35,7 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(GAS_O2, GAS_N2, GAS_CO2, GA
var/list/fire_enthalpies = list()
var/list/fire_products = list()
var/list/fire_burn_rates = list()
var/list/supermatter = list()
/datum/gas
@@ -55,6 +56,12 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(GAS_O2, GAS_N2, GAS_CO2, GA
var/list/fire_products = null // what results when this gas is burned (oxidizer or fuel); 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
var/powermix = 0 // how much this gas contributes to the supermatter's powermix ratio
var/heat_penalty = 0 // heat and waste penalty from having the supermatter crystal surrounded by this gas; negative numbers reduce
var/transmit_modifier = 0 // bonus to supermatter power generation (multiplicative, since it's % based, and divided by 10)
var/radioactivity_modifier = 0 // improves effect of transmit modifiers, must be from -10 to 10
var/heat_resistance = 0 // makes the crystal more resistant against heat damage.
var/powerloss_inhibition = 0 // Reduces how much power the supermatter loses each tick
/datum/gas/proc/breath(partial_pressure, light_threshold, heavy_threshold, moles, mob/living/carbon/C, obj/item/organ/lungs/lungs)
// This is only called on gases with the GAS_FLAG_BREATH_PROC flag. When possible, do NOT use this--
@@ -100,12 +107,20 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(GAS_O2, GAS_N2, GAS_CO2, GA
if(gas.fire_products)
fire_products[g] = gas.fire_products
fire_enthalpies[g] = gas.fire_energy_released
add_supermatter_properties(gas)
_auxtools_register_gas(gas)
/proc/finalize_gas_refs()
/datum/auxgm/New()
src.supermatter[HEAT_PENALTY] = list()
src.supermatter[TRANSMIT_MODIFIER] = list()
src.supermatter[RADIOACTIVITY_MODIFIER] = list()
src.supermatter[HEAT_RESISTANCE] = list()
src.supermatter[POWERLOSS_INHIBITION] = list()
src.supermatter[POWER_MIX] = list()
src.supermatter[ALL_SUPERMATTER_GASES] = list()
for(var/gas_path in subtypesof(/datum/gas))
var/datum/gas/gas = new gas_path
add_gas(gas)
+54 -115
View File
@@ -12,6 +12,19 @@
#define OBJECT (LOWEST + 1)
#define LOWEST (1)
/datum/auxgm/proc/add_supermatter_properties(datum/gas/gas)
var/g = gas.id
var/list/props = src.supermatter
if(gas.heat_penalty || gas.transmit_modifier || gas.radioactivity_modifier || gas.heat_resistance || gas.powerloss_inhibition)
props[HEAT_PENALTY][g] = gas.heat_penalty
props[TRANSMIT_MODIFIER][g] = gas.transmit_modifier
props[RADIOACTIVITY_MODIFIER][g] = gas.radioactivity_modifier
props[HEAT_RESISTANCE][g] = gas.heat_resistance
props[POWERLOSS_INHIBITION][g] = gas.powerloss_inhibition
props[POWER_MIX][g] = gas.powermix
props[ALL_SUPERMATTER_GASES] += g
#define PLASMA_HEAT_PENALTY 15 // Higher == Bigger heat and waste penalty from having the crystal surrounded by this gas. Negative numbers reduce penalty.
#define OXYGEN_HEAT_PENALTY 1
#define PLUOXIUM_HEAT_PENALTY -1
@@ -148,90 +161,17 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
var/power = 0
///Determines the rate of positve change in gas comp values
var/gas_change_rate = 0.05
///The list of gases we will be interacting with in process_atoms()
var/list/gases_we_care_about = list(
GAS_O2,
GAS_H2O,
GAS_PLASMA,
GAS_CO2,
GAS_NITROUS,
GAS_N2,
GAS_PLUOXIUM,
GAS_TRITIUM,
GAS_BZ,
// /datum/gas/freon,
// /datum/gas/hydrogen,
)
///The list of gases mapped against their current comp. We use this to calculate different values the supermatter uses, like power or heat resistance. It doesn't perfectly match the air around the sm, instead moving up at a rate determined by gas_change_rate per call. Ranges from 0 to 1
var/list/gas_comp = list(
GAS_O2 = 0,
GAS_H2O = 0,
GAS_PLASMA = 0,
GAS_CO2 = 0,
GAS_NITROUS = 0,
GAS_N2 = 0,
GAS_PLUOXIUM = 0,
GAS_TRITIUM = 0,
GAS_BZ = 0,
// /datum/gas/freon = 0,
// /datum/gas/hydrogen = 0,
)
///The list of gases mapped against their transmit values. We use it to determine the effect different gases have on radiation
var/list/gas_trans = list(
GAS_O2 = OXYGEN_TRANSMIT_MODIFIER,
GAS_H2O = H2O_TRANSMIT_MODIFIER,
GAS_PLASMA = PLASMA_TRANSMIT_MODIFIER,
GAS_PLUOXIUM = PLUOXIUM_TRANSMIT_MODIFIER,
GAS_TRITIUM = TRITIUM_TRANSMIT_MODIFIER,
GAS_BZ = BZ_TRANSMIT_MODIFIER,
// /datum/gas/hydrogen = HYDROGEN_TRANSMIT_MODIFIER,
)
///The list of gases mapped against their heat penaltys. We use it to determin molar and heat output
var/list/gas_heat = list(
GAS_O2 = OXYGEN_HEAT_PENALTY,
GAS_H2O = H2O_HEAT_PENALTY,
GAS_PLASMA = PLASMA_HEAT_PENALTY,
GAS_CO2 = CO2_HEAT_PENALTY,
GAS_N2 = NITROGEN_HEAT_PENALTY,
GAS_PLUOXIUM = PLUOXIUM_HEAT_PENALTY,
GAS_TRITIUM = TRITIUM_HEAT_PENALTY,
GAS_BZ = BZ_HEAT_PENALTY,
// /datum/gas/freon = FREON_HEAT_PENALTY,
// /datum/gas/hydrogen = HYDROGEN_HEAT_PENALTY,
)
///The list of gases mapped against their heat resistance. We use it to moderate heat damage.
var/list/gas_resist = list(
GAS_NITROUS = N2O_HEAT_RESISTANCE,
GAS_PLUOXIUM = PLUOXIUM_HEAT_RESISTANCE,
// /datum/gas/hydrogen = HYDROGEN_HEAT_RESISTANCE,
)
///The list of gases mapped against their powermix ratio
var/list/gas_powermix = list(
GAS_O2 = 1,
GAS_H2O = 1,
GAS_PLASMA = 1,
GAS_CO2 = 1,
GAS_N2 = -1,
GAS_PLUOXIUM = -1,
GAS_TRITIUM = 1,
GAS_BZ = 1,
// /datum/gas/freon = -1,
// /datum/gas/hydrogen = 1,
)
var/list/gas_comp = list()
///The last air sample's total molar count, will always be above or equal to 0
var/combined_gas = 0
///Affects the power gain the sm experiances from heat
var/gasmix_power_ratio = 0
///Affects the amount of o2 and plasma the sm outputs, along with the heat it makes.
var/dynamic_heat_modifier = 1
///Affects the amount of damage and minimum point at which the sm takes heat damage
var/dynamic_heat_resistance = 1
///Uses powerloss_dynamic_scaling and combined_gas to lessen the effects of our powerloss functions
var/powerloss_inhibitor = 1
///Based on co2 percentage, slowly moves between 0 and 1. We use it to calc the powerloss_inhibitor
var/powerloss_dynamic_scaling= 0
///Affects the amount of radiation the sm makes. We multiply this with power to find the rads.
var/power_transmission_bonus = 0
///Used to increase or lessen the amount of damage the sm takes from heat based on molar counts.
var/mole_heat_penalty = 0
///Takes the energy throwing things into the sm generates and slowly turns it into actual power
@@ -481,6 +421,10 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
removed = new()
damage_archived = damage
var/list/gas_info = GLOB.gas_data.supermatter
var/list/gases_we_care_about = gas_info[ALL_SUPERMATTER_GASES]
/********
EXPERIMENTAL, HUGBOXY AS HELL CITADEL CHANGES: Even in a vaccum, update gas composition and modifiers.
This means that the SM will usually have a very small explosion if it ends up being breached to space,
@@ -491,7 +435,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
if(takes_damage)
damage += max((power / 1000) * DAMAGE_INCREASE_MULTIPLIER, 0.1) // always does at least some damage
combined_gas = max(0, combined_gas - 0.5) // Slowly wear off.
for(var/gasID in gases_we_care_about)
for(var/gasID in gas_comp)
gas_comp[gasID] = max(0, gas_comp[gasID] - 0.05) //slowly ramp down
else
if(takes_damage)
@@ -531,46 +475,49 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
//Prevents huge bursts of gas/heat when a large amount of something is introduced
//They range between 0 and 1
for(var/gasID in gases_we_care_about)
if(!(gas_id in gas_comp))
gas_comp[gasID] = 0
gas_comp[gasID] += clamp(max(removed.get_moles(gasID)/combined_gas, 0) - gas_comp[gasID], -1, gas_change_rate)
var/list/heat_mod = gases_we_care_about.Copy()
var/list/transit_mod = gases_we_care_about.Copy()
var/list/resistance_mod = gases_we_care_about.Copy()
var/list/threshold_mod = gases_we_care_about.Copy()
var/list/powermix = gas_info[POWER_MIX]
var/list/heat = gas_info[HEAT_PENALTY]
var/list/transmit = gas_info[TRANSMIT_MODIFIER]
var/list/resist = gas_info[HEAT_RESISTANCE]
var/list/radioactivity = gas_info[RADIOACTIVITY_MODIFIER]
var/list/inhibition = gas_info[POWERLOSS_INHIBITION]
//We're concerned about pluoxium being too easy to abuse at low percents, so we make sure there's a substantial amount.
var/pluoxiumbonus = (gas_comp[GAS_PLUOXIUM] >= 0.15) //makes pluoxium only work at 15%+
var/h2obonus = 1 - (gas_comp[GAS_H2O] * 0.25)//At max this value should be 0.75
var/h2obonus = 1 - (gas_comp[GAS_H2O] * 0.25)//At min this value should be 0.75
// var/freonbonus = (gas_comp[/datum/gas/freon] <= 0.03) //Let's just yeet power output if this shit is high
heat_mod[GAS_PLUOXIUM] = pluoxiumbonus
transit_mod[GAS_PLUOXIUM] = pluoxiumbonus
resistance_mod[GAS_PLUOXIUM] = pluoxiumbonus
threshold_mod[GAS_PLUOXIUM] = pluoxiumbonus
//No less then zero, and no greater then one, we use this to do explosions and heat to power transfer
//Be very careful with modifing this var by large amounts, and for the love of god do not push it past 1
gasmix_power_ratio = 0
for(var/gasID in gas_powermix)
gasmix_power_ratio += gas_comp[gasID] * gas_powermix[gasID]
gasmix_power_ratio = clamp(gasmix_power_ratio, 0, 1)
//Minimum value of -10, maximum value of 23. Effects plasma and o2 output and the output heat
dynamic_heat_modifier = 0
for(var/gasID in gas_heat)
dynamic_heat_modifier += gas_comp[gasID] * gas_heat[gasID] * (isnull(heat_mod[gasID]) ? 1 : heat_mod[gasID])
dynamic_heat_modifier *= h2obonus
dynamic_heat_modifier = max(dynamic_heat_modifier, 0.5)
//Value between 1 and 10. Effects the damage heat does to the crystal
//Affects the amount of o2 and plasma the sm outputs, along with the heat it makes.
var/dynamic_heat_modifier = 0
//Effects the damage heat does to the crystal.
dynamic_heat_resistance = 0
for(var/gasID in gas_resist)
dynamic_heat_resistance += gas_comp[gasID] * gas_resist[gasID] * (isnull(resistance_mod[gasID]) ? 1 : resistance_mod[gasID])
dynamic_heat_resistance = max(dynamic_heat_resistance, 1)
//Value between -5 and 30, used to determine radiation output as it concerns things like collectors.
//We multiply this with power to find the rads.
power_transmission_bonus = 0
for(var/gasID in gas_trans)
power_transmission_bonus += gas_comp[gasID] * gas_trans[gasID] * (isnull(transit_mod[gasID]) ? 1 : transit_mod[gasID])
var/powerloss_inhibition_gas = 0
var/radioactivity_modifier = 0
for(var/gasID in gas_comp)
var/this_comp = gas_comp[gasID] * (isnull(threshold_mod[gasID] ? 1 : threshold_mod[gasID]))
gasmix_power_ratio += this_comp * powermix[gasID]
dynamic_heat_modifier += this_comp * heat[gasID]
dynamic_heat_resistance += this_comp * resist[gasID]
power_transmission_bonus += this_comp * transmit[gasID]
powerloss_inhibition_gas += this_comp * inhibition[gasID]
radioactivity_modifier += this_comp * radioactivity[gasID]
dynamic_heat_modifier *= h2obonus
power_transmission_bonus *= h2obonus
gasmix_power_ratio = clamp(gasmix_power_ratio, 0, 1)
dynamic_heat_modifier = max(dynamic_heat_modifier, 0.5)
//more moles of gases are harder to heat than fewer, so let's scale heat damage around them
mole_heat_penalty = max(combined_gas / MOLE_HEAT_PENALTY, 0.25)
@@ -578,8 +525,8 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
//Ramps up or down in increments of 0.02 up to the proportion of co2
//Given infinite time, powerloss_dynamic_scaling = co2comp
//Some value between 0 and 1
if (combined_gas > POWERLOSS_INHIBITION_MOLE_THRESHOLD && gas_comp[GAS_CO2] > POWERLOSS_INHIBITION_GAS_THRESHOLD) //If there are more then 20 mols, and more then 20% co2
powerloss_dynamic_scaling = clamp(powerloss_dynamic_scaling + clamp(gas_comp[GAS_CO2] - powerloss_dynamic_scaling, -0.02, 0.02), 0, 1)
if (combined_gas > POWERLOSS_INHIBITION_MOLE_THRESHOLD && powerloss_inhibition_gas > POWERLOSS_INHIBITION_GAS_THRESHOLD) //If there are more then 20 mols, and more then 20% co2
powerloss_dynamic_scaling = clamp(powerloss_dynamic_scaling + clamp(powerloss_inhibition_gas - powerloss_dynamic_scaling, -0.02, 0.02), 0, 1)
else
powerloss_dynamic_scaling = clamp(powerloss_dynamic_scaling - 0.05, 0, 1)
//Ranges from 0 to 1(1-(value between 0 and 1 * ranges from 1 to 1.5(mol / 500)))
@@ -611,23 +558,15 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
if(prob(50))
//(1 + (tritRad + pluoxDampen * bzDampen * o2Rad * plasmaRad / (10 - bzrads))) * freonbonus
radiation_pulse(src, power * max(0, (1 + (power_transmission_bonus/(10-(gas_comp[GAS_BZ] * BZ_RADIOACTIVITY_MODIFIER)))) * 1))//freonbonus))// RadModBZ(500%)
if(gas_comp[GAS_BZ] >= 0.4 && prob(30 * gas_comp[GAS_BZ]))
src.fire_nuclear_particle() // Start to emit radballs at a maximum of 30% chance per tick
radiation_pulse(src, power * max(0, (1 + (power_transmission_bonus/(10-radioactivity_modifier)))))//freonbonus))// RadModBZ(500%)
if(radioactivity_modifier >= 2 && prob(6 * radioactivity_modifier))
src.fire_nuclear_particle()
//Power * 0.55 * a value between 1 and 0.8
var/device_energy = power * REACTION_POWER_MODIFIER
//To figure out how much temperature to add each tick, consider that at one atmosphere's worth
//of pure oxygen, with all four lasers firing at standard energy and no N2 present, at room temperature
//that the device energy is around 2140. At that stage, we don't want too much heat to be put out
//Since the core is effectively "cold"
//Also keep in mind we are only adding this temperature to (efficiency)% of the one tile the rock
//is on. An increase of 4*C @ 25% efficiency here results in an increase of 1*C / (#tilesincore) overall.
//Power * 0.55 * (some value between 1.5 and 23) / 5
removed.set_temperature(removed.return_temperature() + ((device_energy * dynamic_heat_modifier) / THERMAL_RELEASE_MODIFIER))
//We can only emit so much heat, that being 57500
//We don't want our output to be too hot
removed.set_temperature(max(0, min(removed.return_temperature(), 2500 * dynamic_heat_modifier)))
//Calculate how much gas to release