|
|
|
@@ -28,7 +28,6 @@
|
|
|
|
|
#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.
|
|
|
|
|
/datum/controller/subsystem/air/var/list/gas_reactions //this is our singleton of all reactions
|
|
|
|
|
|
|
|
|
|
/proc/init_gas_reactions()
|
|
|
|
|
var/list/reaction_types = list()
|
|
|
|
@@ -47,7 +46,7 @@
|
|
|
|
|
|
|
|
|
|
/datum/gas_reaction
|
|
|
|
|
//regarding the requirements lists: the minimum or maximum requirements must be non-zero.
|
|
|
|
|
//when in doubt, use MINIMUM_HEAT_CAPACITY.
|
|
|
|
|
//when in doubt, use MINIMUM_MOLE_COUNT.
|
|
|
|
|
var/list/min_requirements
|
|
|
|
|
var/list/max_requirements
|
|
|
|
|
var/exclude = FALSE //do it this way to allow for addition/removal of reactions midmatch in the future
|
|
|
|
@@ -59,6 +58,7 @@
|
|
|
|
|
init_reqs()
|
|
|
|
|
|
|
|
|
|
/datum/gas_reaction/proc/init_reqs()
|
|
|
|
|
|
|
|
|
|
/datum/gas_reaction/proc/react(datum/gas_mixture/air, atom/location)
|
|
|
|
|
return NO_REACTION
|
|
|
|
|
|
|
|
|
@@ -66,6 +66,7 @@
|
|
|
|
|
priority = INFINITY
|
|
|
|
|
name = "Hyper-Noblium Reaction Supression"
|
|
|
|
|
id = "nobstop"
|
|
|
|
|
|
|
|
|
|
/datum/gas_reaction/nobliumsupression/init_reqs()
|
|
|
|
|
min_requirements = list(/datum/gas/hypernoblium = REACTION_OPPRESSION_THRESHOLD)
|
|
|
|
|
|
|
|
|
@@ -81,7 +82,8 @@
|
|
|
|
|
/datum/gas_reaction/water_vapor/init_reqs()
|
|
|
|
|
min_requirements = list(/datum/gas/water_vapor = MOLES_GAS_VISIBLE)
|
|
|
|
|
|
|
|
|
|
/datum/gas_reaction/water_vapor/react(datum/gas_mixture/air, turf/open/location)
|
|
|
|
|
/datum/gas_reaction/water_vapor/react(datum/gas_mixture/air, datum/holder)
|
|
|
|
|
var/turf/open/location = isturf(holder) ? holder : null
|
|
|
|
|
. = NO_REACTION
|
|
|
|
|
if (air.temperature <= WATER_VAPOR_FREEZE)
|
|
|
|
|
if(location && location.freon_gas_act())
|
|
|
|
@@ -90,82 +92,46 @@
|
|
|
|
|
air.gases[/datum/gas/water_vapor][MOLES] -= MOLES_GAS_VISIBLE
|
|
|
|
|
. = REACTING
|
|
|
|
|
|
|
|
|
|
//fire: combustion of plasma and volatile fuel (treated as hydrocarbons). creates hotspots. exothermic
|
|
|
|
|
/datum/gas_reaction/fire
|
|
|
|
|
priority = -1 //fire should ALWAYS be last
|
|
|
|
|
name = "Hydrocarbon Combustion"
|
|
|
|
|
id = "fire"
|
|
|
|
|
//tritium combustion: combustion of oxygen and tritium (treated as hydrocarbons). creates hotspots. exothermic
|
|
|
|
|
/datum/gas_reaction/tritfire
|
|
|
|
|
priority = -1 //fire should ALWAYS be last, but tritium fires happen before plasma fires
|
|
|
|
|
name = "Tritium Combustion"
|
|
|
|
|
id = "tritfire"
|
|
|
|
|
|
|
|
|
|
/datum/gas_reaction/fire/init_reqs()
|
|
|
|
|
min_requirements = list("TEMP" = FIRE_MINIMUM_TEMPERATURE_TO_EXIST) //doesn't include plasma reqs b/c of other, rarer, burning gases.
|
|
|
|
|
/datum/gas_reaction/tritfire/init_reqs()
|
|
|
|
|
min_requirements = list(
|
|
|
|
|
"TEMP" = FIRE_MINIMUM_TEMPERATURE_TO_EXIST,
|
|
|
|
|
/datum/gas/tritium = MINIMUM_MOLE_COUNT,
|
|
|
|
|
/datum/gas/oxygen = MINIMUM_MOLE_COUNT
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
/datum/gas_reaction/fire/react(datum/gas_mixture/air, turf/open/location)
|
|
|
|
|
/datum/gas_reaction/tritfire/react(datum/gas_mixture/air, datum/holder)
|
|
|
|
|
var/energy_released = 0
|
|
|
|
|
var/old_heat_capacity = air.heat_capacity()
|
|
|
|
|
var/list/cached_gases = air.gases //this speeds things up because accessing datum vars is slow
|
|
|
|
|
var/temperature = air.temperature
|
|
|
|
|
var/list/cached_results = air.reaction_results
|
|
|
|
|
cached_results[id] = 0
|
|
|
|
|
var/turf/open/location = isturf(holder) ? holder : null
|
|
|
|
|
|
|
|
|
|
//General volatile gas burn
|
|
|
|
|
if(cached_gases[/datum/gas/tritium] && cached_gases[/datum/gas/tritium][MOLES])
|
|
|
|
|
var/burned_fuel
|
|
|
|
|
if(!cached_gases[/datum/gas/oxygen])
|
|
|
|
|
burned_fuel = 0
|
|
|
|
|
else if(cached_gases[/datum/gas/oxygen][MOLES] < cached_gases[/datum/gas/tritium][MOLES])
|
|
|
|
|
burned_fuel = cached_gases[/datum/gas/oxygen][MOLES]/TRITIUM_BURN_OXY_FACTOR
|
|
|
|
|
cached_gases[/datum/gas/tritium][MOLES] -= burned_fuel
|
|
|
|
|
else
|
|
|
|
|
burned_fuel = cached_gases[/datum/gas/tritium][MOLES]*TRITIUM_BURN_TRIT_FACTOR
|
|
|
|
|
cached_gases[/datum/gas/tritium][MOLES] -= cached_gases[/datum/gas/tritium][MOLES]/TRITIUM_BURN_TRIT_FACTOR
|
|
|
|
|
cached_gases[/datum/gas/oxygen][MOLES] -= cached_gases[/datum/gas/tritium][MOLES]
|
|
|
|
|
var/burned_fuel = 0
|
|
|
|
|
if(cached_gases[/datum/gas/oxygen][MOLES] < cached_gases[/datum/gas/tritium][MOLES])
|
|
|
|
|
burned_fuel = cached_gases[/datum/gas/oxygen][MOLES]/TRITIUM_BURN_OXY_FACTOR
|
|
|
|
|
cached_gases[/datum/gas/tritium][MOLES] -= burned_fuel
|
|
|
|
|
else
|
|
|
|
|
burned_fuel = cached_gases[/datum/gas/tritium][MOLES]*TRITIUM_BURN_TRIT_FACTOR
|
|
|
|
|
cached_gases[/datum/gas/tritium][MOLES] -= cached_gases[/datum/gas/tritium][MOLES]/TRITIUM_BURN_TRIT_FACTOR
|
|
|
|
|
cached_gases[/datum/gas/oxygen][MOLES] -= cached_gases[/datum/gas/tritium][MOLES]
|
|
|
|
|
|
|
|
|
|
if(burned_fuel)
|
|
|
|
|
energy_released += FIRE_HYDROGEN_ENERGY_RELEASED * burned_fuel
|
|
|
|
|
if(location && prob(10) && burned_fuel > TRITIUM_MINIMUM_RADIATION_ENERGY) //woah there let's not crash the server
|
|
|
|
|
radiation_pulse(location, energy_released/TRITIUM_BURN_RADIOACTIVITY_FACTOR)
|
|
|
|
|
if(burned_fuel)
|
|
|
|
|
energy_released += FIRE_HYDROGEN_ENERGY_RELEASED * burned_fuel
|
|
|
|
|
if(location && prob(10) && burned_fuel > TRITIUM_MINIMUM_RADIATION_ENERGY) //woah there let's not crash the server
|
|
|
|
|
radiation_pulse(location, energy_released/TRITIUM_BURN_RADIOACTIVITY_FACTOR)
|
|
|
|
|
|
|
|
|
|
ASSERT_GAS(/datum/gas/water_vapor, air) //oxygen+more-or-less hydrogen=H2O
|
|
|
|
|
cached_gases[/datum/gas/water_vapor][MOLES] += burned_fuel/TRITIUM_BURN_OXY_FACTOR
|
|
|
|
|
ASSERT_GAS(/datum/gas/water_vapor, air) //oxygen+more-or-less hydrogen=H2O
|
|
|
|
|
cached_gases[/datum/gas/water_vapor][MOLES] += burned_fuel/TRITIUM_BURN_OXY_FACTOR
|
|
|
|
|
|
|
|
|
|
cached_results[id] += burned_fuel
|
|
|
|
|
|
|
|
|
|
//Handle plasma burning
|
|
|
|
|
if(cached_gases[/datum/gas/plasma] && cached_gases[/datum/gas/plasma][MOLES] > MINIMUM_HEAT_CAPACITY)
|
|
|
|
|
var/plasma_burn_rate = 0
|
|
|
|
|
var/oxygen_burn_rate = 0
|
|
|
|
|
//more plasma released at higher temperatures
|
|
|
|
|
var/temperature_scale
|
|
|
|
|
var/super_saturation
|
|
|
|
|
if(temperature > PLASMA_UPPER_TEMPERATURE)
|
|
|
|
|
temperature_scale = 1
|
|
|
|
|
else
|
|
|
|
|
temperature_scale = (temperature-PLASMA_MINIMUM_BURN_TEMPERATURE)/(PLASMA_UPPER_TEMPERATURE-PLASMA_MINIMUM_BURN_TEMPERATURE)
|
|
|
|
|
if(temperature_scale > 0)
|
|
|
|
|
var/o2 = cached_gases[/datum/gas/oxygen] ? cached_gases[/datum/gas/oxygen][MOLES] : 0
|
|
|
|
|
oxygen_burn_rate = OXYGEN_BURN_RATE_BASE - temperature_scale
|
|
|
|
|
if(o2 / cached_gases[/datum/gas/plasma][MOLES] > SUPER_SATURATION_THRESHOLD) //supersaturation. Form Tritium.
|
|
|
|
|
super_saturation = TRUE
|
|
|
|
|
if(o2 > cached_gases[/datum/gas/plasma][MOLES]*PLASMA_OXYGEN_FULLBURN)
|
|
|
|
|
plasma_burn_rate = (cached_gases[/datum/gas/plasma][MOLES]*temperature_scale)/PLASMA_BURN_RATE_DELTA
|
|
|
|
|
else
|
|
|
|
|
plasma_burn_rate = (temperature_scale*(o2/PLASMA_OXYGEN_FULLBURN))/PLASMA_BURN_RATE_DELTA
|
|
|
|
|
|
|
|
|
|
if(plasma_burn_rate > MINIMUM_HEAT_CAPACITY)
|
|
|
|
|
ASSERT_GAS(/datum/gas/carbon_dioxide, air) //don't need to assert o2, since if it isn't present we'll never reach this point anyway
|
|
|
|
|
plasma_burn_rate = min(plasma_burn_rate,cached_gases[/datum/gas/plasma][MOLES],cached_gases[/datum/gas/oxygen][MOLES]/oxygen_burn_rate) //Ensures matter is conserved properly
|
|
|
|
|
cached_gases[/datum/gas/plasma][MOLES] = QUANTIZE(cached_gases[/datum/gas/plasma][MOLES] - plasma_burn_rate)
|
|
|
|
|
cached_gases[/datum/gas/oxygen][MOLES] = QUANTIZE(cached_gases[/datum/gas/oxygen][MOLES] - (plasma_burn_rate * oxygen_burn_rate))
|
|
|
|
|
if (super_saturation)
|
|
|
|
|
ASSERT_GAS(/datum/gas/tritium,air)
|
|
|
|
|
cached_gases[/datum/gas/tritium][MOLES] += plasma_burn_rate
|
|
|
|
|
else
|
|
|
|
|
ASSERT_GAS(/datum/gas/carbon_dioxide,air)
|
|
|
|
|
cached_gases[/datum/gas/carbon_dioxide][MOLES] += plasma_burn_rate
|
|
|
|
|
|
|
|
|
|
energy_released += FIRE_PLASMA_ENERGY_RELEASED * (plasma_burn_rate)
|
|
|
|
|
|
|
|
|
|
cached_results[id] += (plasma_burn_rate)*(1+oxygen_burn_rate)
|
|
|
|
|
cached_results[id] += burned_fuel
|
|
|
|
|
|
|
|
|
|
if(energy_released > 0)
|
|
|
|
|
var/new_heat_capacity = air.heat_capacity()
|
|
|
|
@@ -184,7 +150,82 @@
|
|
|
|
|
|
|
|
|
|
return cached_results[id] ? REACTING : NO_REACTION
|
|
|
|
|
|
|
|
|
|
//fusion: a terrible idea that was fun but broken. Now reworked to be less broken and more interesting.
|
|
|
|
|
//plasma combustion: combustion of oxygen and plasma (treated as hydrocarbons). creates hotspots. exothermic
|
|
|
|
|
/datum/gas_reaction/plasmafire
|
|
|
|
|
priority = -2 //fire should ALWAYS be last, but plasma fires happen after tritium fires
|
|
|
|
|
name = "Plasma Combustion"
|
|
|
|
|
id = "plasmafire"
|
|
|
|
|
|
|
|
|
|
/datum/gas_reaction/plasmafire/init_reqs()
|
|
|
|
|
min_requirements = list(
|
|
|
|
|
"TEMP" = FIRE_MINIMUM_TEMPERATURE_TO_EXIST,
|
|
|
|
|
/datum/gas/plasma = MINIMUM_MOLE_COUNT,
|
|
|
|
|
/datum/gas/oxygen = MINIMUM_MOLE_COUNT
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
/datum/gas_reaction/plasmafire/react(datum/gas_mixture/air, datum/holder)
|
|
|
|
|
var/energy_released = 0
|
|
|
|
|
var/old_heat_capacity = air.heat_capacity()
|
|
|
|
|
var/list/cached_gases = air.gases //this speeds things up because accessing datum vars is slow
|
|
|
|
|
var/temperature = air.temperature
|
|
|
|
|
var/list/cached_results = air.reaction_results
|
|
|
|
|
cached_results[id] = 0
|
|
|
|
|
var/turf/open/location = isturf(holder) ? holder : null
|
|
|
|
|
|
|
|
|
|
//Handle plasma burning
|
|
|
|
|
var/plasma_burn_rate = 0
|
|
|
|
|
var/oxygen_burn_rate = 0
|
|
|
|
|
//more plasma released at higher temperatures
|
|
|
|
|
var/temperature_scale = 0
|
|
|
|
|
//to make tritium
|
|
|
|
|
var/super_saturation = FALSE
|
|
|
|
|
|
|
|
|
|
if(temperature > PLASMA_UPPER_TEMPERATURE)
|
|
|
|
|
temperature_scale = 1
|
|
|
|
|
else
|
|
|
|
|
temperature_scale = (temperature-PLASMA_MINIMUM_BURN_TEMPERATURE)/(PLASMA_UPPER_TEMPERATURE-PLASMA_MINIMUM_BURN_TEMPERATURE)
|
|
|
|
|
if(temperature_scale > 0)
|
|
|
|
|
oxygen_burn_rate = OXYGEN_BURN_RATE_BASE - temperature_scale
|
|
|
|
|
if(cached_gases[/datum/gas/oxygen][MOLES] / cached_gases[/datum/gas/plasma][MOLES] > SUPER_SATURATION_THRESHOLD) //supersaturation. Form Tritium.
|
|
|
|
|
super_saturation = TRUE
|
|
|
|
|
if(cached_gases[/datum/gas/oxygen][MOLES] > cached_gases[/datum/gas/plasma][MOLES]*PLASMA_OXYGEN_FULLBURN)
|
|
|
|
|
plasma_burn_rate = (cached_gases[/datum/gas/plasma][MOLES]*temperature_scale)/PLASMA_BURN_RATE_DELTA
|
|
|
|
|
else
|
|
|
|
|
plasma_burn_rate = (temperature_scale*(cached_gases[/datum/gas/oxygen][MOLES]/PLASMA_OXYGEN_FULLBURN))/PLASMA_BURN_RATE_DELTA
|
|
|
|
|
|
|
|
|
|
if(plasma_burn_rate > MINIMUM_HEAT_CAPACITY)
|
|
|
|
|
plasma_burn_rate = min(plasma_burn_rate,cached_gases[/datum/gas/plasma][MOLES],cached_gases[/datum/gas/oxygen][MOLES]/oxygen_burn_rate) //Ensures matter is conserved properly
|
|
|
|
|
cached_gases[/datum/gas/plasma][MOLES] = QUANTIZE(cached_gases[/datum/gas/plasma][MOLES] - plasma_burn_rate)
|
|
|
|
|
cached_gases[/datum/gas/oxygen][MOLES] = QUANTIZE(cached_gases[/datum/gas/oxygen][MOLES] - (plasma_burn_rate * oxygen_burn_rate))
|
|
|
|
|
if (super_saturation)
|
|
|
|
|
ASSERT_GAS(/datum/gas/tritium,air)
|
|
|
|
|
cached_gases[/datum/gas/tritium][MOLES] += plasma_burn_rate
|
|
|
|
|
else
|
|
|
|
|
ASSERT_GAS(/datum/gas/carbon_dioxide,air)
|
|
|
|
|
cached_gases[/datum/gas/carbon_dioxide][MOLES] += plasma_burn_rate
|
|
|
|
|
|
|
|
|
|
energy_released += FIRE_PLASMA_ENERGY_RELEASED * (plasma_burn_rate)
|
|
|
|
|
|
|
|
|
|
cached_results[id] += (plasma_burn_rate)*(1+oxygen_burn_rate)
|
|
|
|
|
|
|
|
|
|
if(energy_released > 0)
|
|
|
|
|
var/new_heat_capacity = air.heat_capacity()
|
|
|
|
|
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
|
|
|
|
|
air.temperature = (temperature*old_heat_capacity + energy_released)/new_heat_capacity
|
|
|
|
|
|
|
|
|
|
//let the floor know a fire is happening
|
|
|
|
|
if(istype(location))
|
|
|
|
|
temperature = air.temperature
|
|
|
|
|
if(temperature > FIRE_MINIMUM_TEMPERATURE_TO_EXIST)
|
|
|
|
|
location.hotspot_expose(temperature, CELL_VOLUME)
|
|
|
|
|
for(var/I in location)
|
|
|
|
|
var/atom/movable/item = I
|
|
|
|
|
item.temperature_expose(air, temperature, CELL_VOLUME)
|
|
|
|
|
location.temperature_expose(air, temperature, CELL_VOLUME)
|
|
|
|
|
|
|
|
|
|
return cached_results[id] ? REACTING : NO_REACTION
|
|
|
|
|
|
|
|
|
|
//fusion: a terrible idea that was fun but broken. Now reworked to be less broken and more interesting. Again.
|
|
|
|
|
/datum/gas_reaction/fusion
|
|
|
|
|
exclude = TRUE
|
|
|
|
|
priority = 2
|
|
|
|
@@ -193,46 +234,66 @@
|
|
|
|
|
|
|
|
|
|
/datum/gas_reaction/fusion/init_reqs()
|
|
|
|
|
min_requirements = list(
|
|
|
|
|
"ENER" = PLASMA_BINDING_ENERGY * 10,
|
|
|
|
|
/datum/gas/plasma = MINIMUM_HEAT_CAPACITY,
|
|
|
|
|
/datum/gas/tritium = MINIMUM_HEAT_CAPACITY
|
|
|
|
|
"ENER" = PLASMA_BINDING_ENERGY * 1000,
|
|
|
|
|
/datum/gas/plasma = 50,
|
|
|
|
|
/datum/gas/carbon_dioxide = 1
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
/datum/gas_reaction/fusion/react(datum/gas_mixture/air, turf/open/location)
|
|
|
|
|
/datum/gas_reaction/fusion/react(datum/gas_mixture/air, datum/holder)
|
|
|
|
|
var/list/cached_gases = air.gases
|
|
|
|
|
var/temperature = air.temperature
|
|
|
|
|
|
|
|
|
|
if(((cached_gases[/datum/gas/plasma][MOLES]+cached_gases[/datum/gas/tritium][MOLES])/air.total_moles() < FUSION_PURITY_THRESHOLD) || air.return_pressure() < 10*ONE_ATMOSPHERE)
|
|
|
|
|
//Fusion wont occur if the level of impurities is too high or if there is too little pressure.
|
|
|
|
|
return NO_REACTION
|
|
|
|
|
var/turf/open/location
|
|
|
|
|
if (istype(holder,/datum/pipeline)) //Find the tile the reaction is occuring on, or a random part of the network if it's a pipenet.
|
|
|
|
|
var/datum/pipeline/fusion_pipenet = holder
|
|
|
|
|
location = get_turf(pick(fusion_pipenet.members))
|
|
|
|
|
else
|
|
|
|
|
location = get_turf(holder)
|
|
|
|
|
|
|
|
|
|
var/old_heat_capacity = air.heat_capacity()
|
|
|
|
|
var/catalyst_efficency = max(min(cached_gases[/datum/gas/plasma][MOLES]/cached_gases[/datum/gas/tritium][MOLES],MAX_CATALYST_EFFICENCY)-(temperature/FUSION_HEAT_DROPOFF),1)
|
|
|
|
|
var/reaction_energy = THERMAL_ENERGY(air)
|
|
|
|
|
var/moles_impurities = max(air.total_moles()-(cached_gases[/datum/gas/plasma][MOLES]+cached_gases[/datum/gas/tritium][MOLES]),1) //This makes it assume a minimum of 1 mol impurities so the reaction energy doesn't divide by 0
|
|
|
|
|
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/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))
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
var/plasma_fused = min((PLASMA_FUSED_COEFFICENT*catalyst_efficency)*(temperature/PLASMA_BINDING_ENERGY)/10,cached_gases[/datum/gas/plasma][MOLES]) //Preserve matter
|
|
|
|
|
var/tritium_catalyzed = min((CATALYST_COEFFICENT*catalyst_efficency)*(temperature/PLASMA_BINDING_ENERGY)/40,cached_gases[/datum/gas/tritium][MOLES]) //Ditto
|
|
|
|
|
var/oxygen_added = tritium_catalyzed
|
|
|
|
|
var/waste_added = max((plasma_fused-oxygen_added)-((air.total_moles()*air.heat_capacity())/PLASMA_BINDING_ENERGY),0)
|
|
|
|
|
reaction_energy = max(reaction_energy+((catalyst_efficency*cached_gases[/datum/gas/plasma][MOLES])/((moles_impurities/catalyst_efficency)+2)*10)+((plasma_fused/(moles_impurities/catalyst_efficency))*PLASMA_BINDING_ENERGY),0)
|
|
|
|
|
|
|
|
|
|
air.assert_gases(/datum/gas/oxygen, /datum/gas/carbon_dioxide, /datum/gas/water_vapor, /datum/gas/nitrous_oxide, /datum/gas/nitryl)
|
|
|
|
|
//Fusion produces an absurd amount of waste products now, requiring active filtration.
|
|
|
|
|
cached_gases[/datum/gas/plasma][MOLES] = max(cached_gases[/datum/gas/plasma][MOLES] - plasma_fused,0)
|
|
|
|
|
cached_gases[/datum/gas/tritium][MOLES] = max(cached_gases[/datum/gas/tritium][MOLES] - tritium_catalyzed,0)
|
|
|
|
|
cached_gases[/datum/gas/oxygen][MOLES] += oxygen_added
|
|
|
|
|
cached_gases[/datum/gas/water_vapor][MOLES] += waste_added
|
|
|
|
|
cached_gases[/datum/gas/nitrous_oxide][MOLES] += waste_added
|
|
|
|
|
cached_gases[/datum/gas/nitryl][MOLES] += waste_added
|
|
|
|
|
cached_gases[/datum/gas/carbon_dioxide][MOLES] += waste_added
|
|
|
|
|
if (location)
|
|
|
|
|
radiation_pulse(location, reaction_energy/(PLASMA_BINDING_ENERGY*MAX_CATALYST_EFFICENCY))
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
for (var/gas in cached_gases)
|
|
|
|
|
if (cached_gases[gas][GAS_META][META_GAS_FUSION_POWER])
|
|
|
|
|
cached_gases[gas][MOLES] = 0
|
|
|
|
|
if (location)
|
|
|
|
|
radiation_pulse(location, (reaction_energy)/(0.3*PLASMA_BINDING_ENERGY))
|
|
|
|
|
if(reaction_energy > 0)
|
|
|
|
|
var/new_heat_capacity = air.heat_capacity()
|
|
|
|
|
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
|
|
|
|
|
air.temperature = max(((temperature*old_heat_capacity + reaction_energy)/new_heat_capacity),TCMB)
|
|
|
|
|
//Prevents whatever mechanism is causing it to hit negative temperatures.
|
|
|
|
|
return REACTING
|
|
|
|
|
|
|
|
|
|
/datum/gas_reaction/nitrylformation //The formation of nitryl. Endothermic. Requires N2O as a catalyst.
|
|
|
|
@@ -256,7 +317,8 @@
|
|
|
|
|
var/heat_efficency = min(temperature/(FIRE_MINIMUM_TEMPERATURE_TO_EXIST*100),cached_gases[/datum/gas/oxygen][MOLES],cached_gases[/datum/gas/nitrogen][MOLES])
|
|
|
|
|
var/energy_used = heat_efficency*NITRYL_FORMATION_ENERGY
|
|
|
|
|
ASSERT_GAS(/datum/gas/nitryl,air)
|
|
|
|
|
|
|
|
|
|
if ((cached_gases[/datum/gas/oxygen][MOLES] - heat_efficency < 0 )|| (cached_gases[/datum/gas/nitrogen][MOLES] - heat_efficency < 0)) //Shouldn't produce gas from nothing.
|
|
|
|
|
return NO_REACTION
|
|
|
|
|
cached_gases[/datum/gas/oxygen][MOLES] -= heat_efficency
|
|
|
|
|
cached_gases[/datum/gas/nitrogen][MOLES] -= heat_efficency
|
|
|
|
|
cached_gases[/datum/gas/nitryl][MOLES] += heat_efficency*2
|
|
|
|
@@ -287,11 +349,12 @@
|
|
|
|
|
var/old_heat_capacity = air.heat_capacity()
|
|
|
|
|
var/reaction_efficency = min(1/((pressure/(0.1*ONE_ATMOSPHERE))*(max(cached_gases[/datum/gas/plasma][MOLES]/cached_gases[/datum/gas/tritium][MOLES],1))),cached_gases[/datum/gas/tritium][MOLES],cached_gases[/datum/gas/plasma][MOLES]/2)
|
|
|
|
|
var/energy_released = 2*reaction_efficency*FIRE_CARBON_ENERGY_RELEASED
|
|
|
|
|
|
|
|
|
|
if ((cached_gases[/datum/gas/tritium][MOLES] - reaction_efficency < 0 )|| (cached_gases[/datum/gas/plasma][MOLES] - (2*reaction_efficency) < 0)) //Shouldn't produce gas from nothing.
|
|
|
|
|
return NO_REACTION
|
|
|
|
|
ASSERT_GAS(/datum/gas/bz,air)
|
|
|
|
|
cached_gases[/datum/gas/bz][MOLES]+= reaction_efficency
|
|
|
|
|
cached_gases[/datum/gas/tritium][MOLES] = max(cached_gases[/datum/gas/tritium][MOLES]- reaction_efficency,0)
|
|
|
|
|
cached_gases[/datum/gas/plasma][MOLES] = max(cached_gases[/datum/gas/plasma][MOLES] - (2*reaction_efficency),0)
|
|
|
|
|
cached_gases[/datum/gas/bz][MOLES] += reaction_efficency
|
|
|
|
|
cached_gases[/datum/gas/tritium][MOLES] -= reaction_efficency
|
|
|
|
|
cached_gases[/datum/gas/plasma][MOLES] -= 2*reaction_efficency
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(energy_released > 0)
|
|
|
|
@@ -320,10 +383,12 @@
|
|
|
|
|
var/stim_energy_change = heat_scale + STIMULUM_FIRST_RISE*(heat_scale**2) - STIMULUM_FIRST_DROP*(heat_scale**3) + STIMULUM_SECOND_RISE*(heat_scale**4) - STIMULUM_ABSOLUTE_DROP*(heat_scale**5)
|
|
|
|
|
|
|
|
|
|
ASSERT_GAS(/datum/gas/stimulum,air)
|
|
|
|
|
if ((cached_gases[/datum/gas/tritium][MOLES] - heat_scale < 0 )|| (cached_gases[/datum/gas/plasma][MOLES] - heat_scale < 0) || (cached_gases[/datum/gas/nitryl][MOLES] - heat_scale < 0)) //Shouldn't produce gas from nothing.
|
|
|
|
|
return NO_REACTION
|
|
|
|
|
cached_gases[/datum/gas/stimulum][MOLES]+= heat_scale/10
|
|
|
|
|
cached_gases[/datum/gas/tritium][MOLES] = max(cached_gases[/datum/gas/tritium][MOLES]- heat_scale,0)
|
|
|
|
|
cached_gases[/datum/gas/plasma][MOLES] = max(cached_gases[/datum/gas/plasma][MOLES]- heat_scale,0)
|
|
|
|
|
cached_gases[/datum/gas/nitryl][MOLES] = max(cached_gases[/datum/gas/nitryl][MOLES]- heat_scale,0)
|
|
|
|
|
cached_gases[/datum/gas/tritium][MOLES] -= heat_scale
|
|
|
|
|
cached_gases[/datum/gas/plasma][MOLES] -= heat_scale
|
|
|
|
|
cached_gases[/datum/gas/nitryl][MOLES] -= heat_scale
|
|
|
|
|
|
|
|
|
|
if(stim_energy_change)
|
|
|
|
|
var/new_heat_capacity = air.heat_capacity()
|
|
|
|
@@ -331,7 +396,7 @@
|
|
|
|
|
air.temperature = max(((air.temperature*old_heat_capacity + stim_energy_change)/new_heat_capacity),TCMB)
|
|
|
|
|
return REACTING
|
|
|
|
|
|
|
|
|
|
/datum/gas_reaction/nobliumformation //Hyper-Nobelium formation is extrememly endothermic, but requires high temperatures to start. Due to its high mass, hyper-nobelium uses large amounts of nitrogen and tritium. BZ can be used as a catalyst to make it less endothermic.
|
|
|
|
|
/datum/gas_reaction/nobliumformation //Hyper-Noblium formation is extrememly endothermic, but requires high temperatures to start. Due to its high mass, hyper-nobelium uses large amounts of nitrogen and tritium. BZ can be used as a catalyst to make it less endothermic.
|
|
|
|
|
priority = 6
|
|
|
|
|
name = "Hyper-Noblium condensation"
|
|
|
|
|
id = "nobformation"
|
|
|
|
@@ -348,8 +413,10 @@
|
|
|
|
|
var/old_heat_capacity = air.heat_capacity()
|
|
|
|
|
var/nob_formed = min((cached_gases[/datum/gas/nitrogen][MOLES]+cached_gases[/datum/gas/tritium][MOLES])/100,cached_gases[/datum/gas/tritium][MOLES]/10,cached_gases[/datum/gas/nitrogen][MOLES]/20)
|
|
|
|
|
var/energy_taken = nob_formed*(NOBLIUM_FORMATION_ENERGY/(max(cached_gases[/datum/gas/bz][MOLES],1)))
|
|
|
|
|
cached_gases[/datum/gas/tritium][MOLES] = max(cached_gases[/datum/gas/tritium][MOLES]- 10*nob_formed,0)
|
|
|
|
|
cached_gases[/datum/gas/nitrogen][MOLES] = max(cached_gases[/datum/gas/nitrogen][MOLES]- 20*nob_formed,0)
|
|
|
|
|
if ((cached_gases[/datum/gas/tritium][MOLES] - 10*nob_formed < 0) || (cached_gases[/datum/gas/nitrogen][MOLES] - 20*nob_formed < 0))
|
|
|
|
|
return NO_REACTION
|
|
|
|
|
cached_gases[/datum/gas/tritium][MOLES] -= 10*nob_formed
|
|
|
|
|
cached_gases[/datum/gas/nitrogen][MOLES] -= 20*nob_formed
|
|
|
|
|
cached_gases[/datum/gas/hypernoblium][MOLES]+= nob_formed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|