Merge pull request #7131 from Citadel-Station-13/upstream-merge-38329

[MIRROR] [READY] [TESTED] Fusion Rework Episode V: The Phantom Fusion
This commit is contained in:
LetterJay
2018-06-18 09:37:47 -05:00
committed by GitHub
2 changed files with 110 additions and 53 deletions
@@ -57,7 +57,7 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(/datum/gas/oxygen, /datum/g
id = "co2"
specific_heat = 30
name = "Carbon Dioxide"
fusion_power = 2
fusion_power = 3
/datum/gas/plasma
id = "plasma"
@@ -73,6 +73,7 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(/datum/gas/oxygen, /datum/g
name = "Water Vapor"
gas_overlay = "water_vapor"
moles_visible = MOLES_GAS_VISIBLE
fusion_power = 4
/datum/gas/hypernoblium
id = "nob"
@@ -89,7 +90,6 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(/datum/gas/oxygen, /datum/g
gas_overlay = "nitrous_oxide"
moles_visible = 1
dangerous = TRUE
fusion_power = 2
/datum/gas/nitryl
id = "no2"
@@ -98,7 +98,7 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(/datum/gas/oxygen, /datum/g
gas_overlay = "nitryl"
moles_visible = MOLES_GAS_VISIBLE
dangerous = TRUE
fusion_power = 1.5
fusion_power = 10
/datum/gas/tritium
id = "tritium"
@@ -107,13 +107,15 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(/datum/gas/oxygen, /datum/g
gas_overlay = "tritium"
moles_visible = MOLES_GAS_VISIBLE
dangerous = TRUE
fusion_power = 2
fusion_power = 1
/datum/gas/bz
id = "bz"
specific_heat = 20
name = "BZ"
dangerous = TRUE
fusion_power = 2
fusion_power = 15
/datum/gas/stimulum
id = "stim"
specific_heat = 5
@@ -4,15 +4,15 @@
#define PLASMA_MINIMUM_OXYGEN_NEEDED 2
#define PLASMA_MINIMUM_OXYGEN_PLASMA_RATIO 30
#define FIRE_CARBON_ENERGY_RELEASED 100000 //Amount of heat released per mole of burnt carbon into the tile
#define FIRE_HYDROGEN_ENERGY_RELEASED 280000 // Amount of heat released per mole of burnt hydrogen and/or tritium(hydrogen isotope)
#define FIRE_HYDROGEN_ENERGY_RELEASED 280000 //Amount of heat released per mole of burnt hydrogen and/or tritium(hydrogen isotope)
#define FIRE_PLASMA_ENERGY_RELEASED 3000000 //Amount of heat released per mole of burnt plasma into the tile
//General assmos defines.
#define WATER_VAPOR_FREEZE 200
#define NITRYL_FORMATION_ENERGY 100000
#define TRITIUM_BURN_OXY_FACTOR 100
#define TRITIUM_BURN_TRIT_FACTOR 10
#define TRITIUM_BURN_RADIOACTIVITY_FACTOR 50000 //The neutrons gotta go somewhere. Completely arbitrary number.
#define TRITIUM_MINIMUM_RADIATION_ENERGY 0.1 //minimum 0.01 moles trit or 10 moles oxygen to start producing rads
#define TRITIUM_BURN_RADIOACTIVITY_FACTOR 50000 //The neutrons gotta go somewhere. Completely arbitrary number.
#define TRITIUM_MINIMUM_RADIATION_ENERGY 0.1 //minimum 0.01 moles trit or 10 moles oxygen to start producing rads
#define SUPER_SATURATION_THRESHOLD 96
#define STIMULUM_HEAT_SCALE 100000
#define STIMULUM_FIRST_RISE 0.65
@@ -20,14 +20,38 @@
#define STIMULUM_SECOND_RISE 0.0009
#define STIMULUM_ABSOLUTE_DROP 0.00000335
#define REACTION_OPPRESSION_THRESHOLD 5
//Plasma fusion properties
#define PLASMA_BINDING_ENERGY 3000000
#define MAX_CATALYST_EFFICENCY 9
#define PLASMA_FUSED_COEFFICENT 0.08
#define CATALYST_COEFFICENT 0.01
#define FUSION_PURITY_THRESHOLD 0.95
#define FUSION_HEAT_DROPOFF (20000+T0C)
#define NOBLIUM_FORMATION_ENERGY 2e9 //1 Mole of Noblium takes the planck energy to condense.
#define NOBLIUM_FORMATION_ENERGY 2e9 //1 Mole of Noblium takes the planck energy to condense.
//Plasma fusion properties
#define FUSION_ENERGY_THRESHOLD 3e9 //Amount of energy it takes to start a fusion reaction
#define FUSION_TEMPERATURE_THRESHOLD 1000 //Temperature required to start a fusion reaction
#define FUSION_MOLE_THRESHOLD 250 //Mole count required (tritium/plasma) to start a fusion reaction
#define FUSION_RELEASE_ENERGY_SUPER 3e9 //Amount of energy released in the fusion process, super tier
#define FUSION_RELEASE_ENERGY_HIGH 1e9 //Amount of energy released in the fusion process, high tier
#define FUSION_RELEASE_ENERGY_MID 5e8 //Amount of energy released in the fusion process, mid tier
#define FUSION_RELEASE_ENERGY_LOW 1e8 //Amount of energy released in the fusion process, low tier
#define FUSION_MEDIATION_FACTOR 80 //Arbitrary
#define FUSION_SUPER_TIER 50 //anything above this is super tier
#define FUSION_HIGH_TIER 20 //anything above this and below 50 is high tier
#define FUSION_MID_TIER 5 //anything above this and below 20 is mid tier - below this is low tier, but that doesnt need a define
#define FUSION_ENERGY_DIVISOR_SUPER 25
#define FUSION_ENERGY_DIVISOR_HIGH 20
#define FUSION_ENERGY_DIVISOR_MID 10
#define FUSION_ENERGY_DIVISOR_LOW 2
#define FUSION_GAS_CREATION_FACTOR_SUPER 0.20 //stimulum and pluoxium - 40% in total
#define FUSION_GAS_CREATION_FACTOR_HIGH 0.60 //trit - one gas, so its higher than the other two - 60% in total
#define FUSION_GAS_CREATION_FACTOR_MID 0.45 //BZ and N2O - 90% in total
#define FUSION_GAS_CREATION_FACTOR_LOW 0.48 //O2 and CO2 - 96% in total
#define FUSION_MID_TIER_RAD_PROB_FACTOR 2 //probability of radpulse is power ratio * this for whatever tier
#define FUSION_LOW_TIER_RAD_PROB_FACTOR 5
#define FUSION_EFFICIENCY_BASE 60 //used in the fusion efficiency calculations
#define FUSION_EFFICIENCY_DIVISOR 0.6 //ditto
#define FUSION_RADIATION_FACTOR 15000 //horizontal asymptote
#define FUSION_RADIATION_CONSTANT 30 //equation is form of (ax) / (x + b), where a = radiation factor and b = radiation constant (https://www.desmos.com/calculator/4i1f296phl)
#define FUSION_VOLUME_SUPER 100 //volume of the sound the fusion noises make
#define FUSION_VOLUME_HIGH 50
#define FUSION_VOLUME_MID 25
#define FUSION_VOLUME_LOW 10
/proc/init_gas_reactions()
var/list/reaction_types = list()
@@ -225,18 +249,20 @@
return cached_results["fire"] ? REACTING : NO_REACTION
//fusion: a terrible idea that was fun but broken. Now reworked to be less broken and more interesting. Again.
//fusion: a terrible idea that was fun but broken. Now reworked to be less broken and more interesting. Again (and again).
/datum/gas_reaction/fusion
exclude = TRUE
exclude = FALSE
priority = 2
name = "Plasmic Fusion"
id = "fusion"
//Since fusion isn't really intended to happen in successive chains, the requirements are very high
/datum/gas_reaction/fusion/init_reqs()
min_requirements = list(
"ENER" = PLASMA_BINDING_ENERGY * 1000,
/datum/gas/plasma = 50,
/datum/gas/carbon_dioxide = 1
"TEMP" = FUSION_TEMPERATURE_THRESHOLD,
"ENER" = FUSION_ENERGY_THRESHOLD,
/datum/gas/plasma = FUSION_MOLE_THRESHOLD,
/datum/gas/tritium = FUSION_MOLE_THRESHOLD
)
/datum/gas_reaction/fusion/react(datum/gas_mixture/air, datum/holder)
@@ -250,46 +276,75 @@
location = get_turf(holder)
var/old_heat_capacity = air.heat_capacity()
var/reaction_energy
var/mediation = 100*(air.heat_capacity()-(cached_gases[/datum/gas/plasma][MOLES]*cached_gases[/datum/gas/plasma][GAS_META][META_GAS_SPECIFIC_HEAT]))/(air.total_moles()-cached_gases[/datum/gas/plasma][MOLES]) //This is the average heat capacity of the mixture,not including plasma.
var/reaction_energy = 0
var/mediation = FUSION_MEDIATION_FACTOR*(air.heat_capacity()-(cached_gases[/datum/gas/plasma][MOLES]*cached_gases[/datum/gas/plasma][GAS_META][META_GAS_SPECIFIC_HEAT]))/(air.total_moles()-cached_gases[/datum/gas/plasma][MOLES]) //This is the average specific heat of the mixture,not including plasma.
var/moles_excluding_plasma = air.total_moles() - cached_gases[/datum/gas/plasma][MOLES]
var/plasma_differential = (cached_gases[/datum/gas/plasma][MOLES] - moles_excluding_plasma) / air.total_moles()
var/reaction_efficiency = FUSION_EFFICIENCY_BASE ** -((plasma_differential ** 2) / FUSION_EFFICIENCY_DIVISOR) //https://www.desmos.com/calculator/6jjx3vdrvx
var/gases_fused = air.total_moles()
var/gas_power = 0
for (var/id in cached_gases)
gas_power += cached_gases[id][GAS_META][META_GAS_FUSION_POWER]*cached_gases[id][MOLES]
var/plasma_fused = 0
var/power_ratio = min(gas_power/mediation,100)//100 is a lot, we really don't want to go over this.
if (power_ratio > 10) //Super-fusion. Fuses everything into one big atom which then turns to tritium instantly. Very dangerous, but super cool.
var/gases_fused = air.total_moles()
reaction_energy += gases_fused*PLASMA_BINDING_ENERGY*(gas_power/(mediation*100))
gas_power += reaction_efficiency * (cached_gases[id][GAS_META][META_GAS_FUSION_POWER]*cached_gases[id][MOLES])
var/power_ratio = gas_power/mediation
var/radiation_power = (FUSION_RADIATION_FACTOR * power_ratio) / (power_ratio + FUSION_RADIATION_CONSTANT) //https://www.desmos.com/calculator/4i1f296phl
if (power_ratio > FUSION_SUPER_TIER) //power ratio 50+: SUPER TIER. The gases become so energized that they fuse into stimulum and pluoxium, which is pretty nice! IF you can salvage them, which is going to be hard because this reaction is ridiculously dangerous.
reaction_energy += gases_fused * FUSION_RELEASE_ENERGY_SUPER * (power_ratio / FUSION_ENERGY_DIVISOR_SUPER)
for (var/id in cached_gases)
cached_gases[id][MOLES] = 0
air.assert_gas(/datum/gas/tritium)
cached_gases[/datum/gas/tritium][MOLES] += gases_fused
if (prob(power_ratio)) //You really don't want this to happen
empulse(location, power_ratio*0.5, power_ratio)
radiation_pulse(location, power_ratio*2000)
explosion(location,0,1,power_ratio*0.5,power_ratio,TRUE,TRUE)//Bypasses cap. Doesn't blow large hole in station, but produces moderate devestation for long ranges. Be careful with this.
air.assert_gases(/datum/gas/stimulum,/datum/gas/pluoxium)
cached_gases[/datum/gas/stimulum][MOLES] += gases_fused * FUSION_GAS_CREATION_FACTOR_SUPER //60% of the gas is converted to energy, 40% to stimulum and pluoxium
cached_gases[/datum/gas/pluoxium][MOLES] += gases_fused * FUSION_GAS_CREATION_FACTOR_SUPER
if (location) //It's going to happen regardless of whether you want it to or not
radiation_pulse(location, radiation_power * 2)
explosion(location,0,0,10,power_ratio,TRUE,TRUE)//A decent explosion with a huge shockwave. People WILL know you're doing fusion.
playsound(location, "sound/effects/supermatter.ogg", FUSION_VOLUME_SUPER, 0)
else if (power_ratio > 1) //Mediation is overpowered, fusion reaction starts to break down.
plasma_fused = cached_gases[/datum/gas/plasma][MOLES]
reaction_energy += plasma_fused*PLASMA_BINDING_ENERGY
cached_gases[/datum/gas/plasma][MOLES] -= plasma_fused
cached_gases[/datum/gas/carbon_dioxide][MOLES] = 0
else if (power_ratio > FUSION_HIGH_TIER) //power ratio 20-50; High tier. Fuses into one big atom which then turns to tritium instantly. Very dangerous, but super cool.
reaction_energy += gases_fused * FUSION_RELEASE_ENERGY_HIGH * (power_ratio / FUSION_ENERGY_DIVISOR_HIGH)
for (var/id in cached_gases)
cached_gases[id][MOLES] = 0
cached_gases[/datum/gas/tritium][MOLES] += gases_fused * FUSION_GAS_CREATION_FACTOR_HIGH //40% of the gas is converted to energy, 60% to tritium
if (location)
if(prob(power_ratio)) //You really don't want this to happen.
radiation_pulse(location, radiation_power)
explosion(location,0,0,3,power_ratio * 0.5,TRUE,TRUE)//A tiny explosion with a large shockwave. People will know you're doing fusion.
playsound(location, "sound/effects/supermatter.ogg", FUSION_VOLUME_HIGH, 0)
else
playsound(location, "sound/effects/phasein.ogg", FUSION_VOLUME_HIGH, 0)
else if (power_ratio > FUSION_MID_TIER) //power_ratio 5 to 20; Mediation is overpowered, fusion reaction starts to break down.
reaction_energy += gases_fused * FUSION_RELEASE_ENERGY_MID * (power_ratio / FUSION_ENERGY_DIVISOR_MID)
for (var/id in cached_gases)
cached_gases[id][MOLES] = 0
air.assert_gases(/datum/gas/bz,/datum/gas/nitrous_oxide)
cached_gases[/datum/gas/bz][MOLES] += gas_power*0.05
cached_gases[/datum/gas/nitrous_oxide][MOLES] += gas_power*0.05
cached_gases[/datum/gas/bz][MOLES] += gases_fused * FUSION_GAS_CREATION_FACTOR_MID //10% of the gas is converted to energy, 90% to BZ and N2O
cached_gases[/datum/gas/nitrous_oxide][MOLES] += gases_fused * FUSION_GAS_CREATION_FACTOR_MID
if (location)
empulse(location, mediation*0.002, mediation*0.004)
radiation_pulse(location, power_ratio*(reaction_energy)/(0.3*PLASMA_BINDING_ENERGY))
else
reaction_energy += cached_gases[/datum/gas/plasma][MOLES]*PLASMA_BINDING_ENERGY*(gas_power/mediation)
air.assert_gas(/datum/gas/oxygen)
cached_gases[/datum/gas/oxygen][MOLES] += gas_power + cached_gases[/datum/gas/plasma][MOLES]
cached_gases[/datum/gas/plasma][MOLES] = 0
if(prob(power_ratio * FUSION_MID_TIER_RAD_PROB_FACTOR)) //Still weak, but don't stand next to it unprotected
radiation_pulse(location, radiation_power * 0.5)
playsound(location, "sound/effects/supermatter.ogg", FUSION_VOLUME_MID, 0)
else
playsound(location, "sound/effects/phasein.ogg", FUSION_VOLUME_MID, 0)
else //power ratio 0 to 5; Gas power is overpowered. Fusion isn't nearly as powerful.
reaction_energy += gases_fused * FUSION_RELEASE_ENERGY_LOW * (power_ratio / FUSION_ENERGY_DIVISOR_LOW)
for (var/gas in cached_gases)
if (cached_gases[gas][GAS_META][META_GAS_FUSION_POWER])
cached_gases[gas][MOLES] = 0
cached_gases[gas][MOLES] = 0
air.assert_gases(/datum/gas/oxygen, /datum/gas/carbon_dioxide)
cached_gases[/datum/gas/oxygen][MOLES] += gases_fused * FUSION_GAS_CREATION_FACTOR_LOW //4% of the gas is converted to energy, 94% to oxygen and CO2
cached_gases[/datum/gas/carbon_dioxide][MOLES] += gases_fused * FUSION_GAS_CREATION_FACTOR_LOW
if (location)
radiation_pulse(location, (reaction_energy)/(0.3*PLASMA_BINDING_ENERGY))
if(prob(power_ratio * FUSION_LOW_TIER_RAD_PROB_FACTOR)) //Weak, but still something to look out for
radiation_pulse(location, radiation_power * 0.25)
playsound(location, "sound/effects/supermatter.ogg", FUSION_VOLUME_LOW, 0)
else
playsound(location, "sound/effects/phasein.ogg", FUSION_VOLUME_LOW, 0)
if(reaction_energy > 0)
var/new_heat_capacity = air.heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
@@ -336,7 +391,7 @@
/datum/gas_reaction/bzformation/init_reqs()
min_requirements = list(
/datum/gas/tritium = 10,
/datum/gas/nitrous_oxide = 10,
/datum/gas/plasma = 10
)