Merge pull request #24 from Azarak/master

Big atmospheric update - SM, Fusion, TEG, Volume pumps and filters
This commit is contained in:
quotefox
2019-10-05 23:07:20 +01:00
committed by GitHub
14 changed files with 231 additions and 228 deletions

View File

@@ -121,6 +121,8 @@
//Atmos pipe limits
#define MAX_OUTPUT_PRESSURE 4500 // (kPa) What pressure pumps and powered equipment max out at.
#define MAX_TRANSFER_RATE 200 // (L/s) Maximum speed powered equipment can work at.
#define VOLUME_PUMP_LEAK_AMOUNT 0.05 //5% of an overclocked volume pump leaks into the air
#define VOLUME_PUMP_THRESHOLD_LEAK_AMOUNT 0.10 //10% of an overclocked volume pump leaks into the air if it goes beyond normal threshold
//used for device_type vars
#define UNARY 1

View File

@@ -30,41 +30,14 @@
#define STIMULUM_RESEARCH_AMOUNT 50
//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_THRESHOLD 50 //anything above this is super tier
#define FUSION_HIGH_TIER_THRESHOLD 20 //anything above this and below 50 is high tier
#define FUSION_MID_TIER_THRESHOLD 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 //power_ratio is divided by this during energy calculations
#define FUSION_ENERGY_DIVISOR_HIGH 20
#define FUSION_ENERGY_DIVISOR_MID 10
#define FUSION_ENERGY_DIVISOR_LOW 2
#define FUSION_GAS_CREATION_FACTOR_TRITIUM 0.40 //trit - one gas rather than two, so think about that when calculating stuff - 40% in total
#define FUSION_GAS_CREATION_FACTOR_STIM 0.05 //stim percentage creation from high tier - 5%, 60% in total with pluox
#define FUSION_GAS_CREATION_FACTOR_PLUOX 0.55 //pluox percentage creation from high tier - 55%, 60% in total with stim
#define FUSION_GAS_CREATION_FACTOR_NITRYL 0.20 //nitryl and N2O - 80% in total
#define FUSION_GAS_CREATION_FACTOR_N2O 0.60 //nitryl and N2O - 80% in total
#define FUSION_GAS_CREATION_FACTOR_BZ 0.05 //BZ - 5% - 90% in total with CO2
#define FUSION_GAS_CREATION_FACTOR_CO2 0.85 //CO2 - 85% - 90% in total with BZ
#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 and x = power ratio (https://www.desmos.com/calculator/4i1f296phl)
#define FUSION_ZAP_POWER_ASYMPTOTE 50000 //maximum value - not enough to instacrit but it'll still hurt like shit
#define FUSION_ZAP_POWER_CONSTANT 75 //equation is of from [ax / (x + b)] + c, where a = zap power asymptote, b = zap power constant, c = zap power base and x = power ratio
#define FUSION_ZAP_POWER_BASE 1000 //(https://www.desmos.com/calculator/vvbmhf4unm)
#define FUSION_ZAP_RANGE_SUPER 9 //range of the tesla zaps that occur from fusion
#define FUSION_ZAP_RANGE_HIGH 7
#define FUSION_ZAP_RANGE_MID 5
#define FUSION_ZAP_RANGE_LOW 3
#define FUSION_PARTICLE_FACTOR_SUPER 4 //# of particles fired out is equal to rand(3,6) * this for whatever tier
#define FUSION_PARTICLE_FACTOR_HIGH 3
#define FUSION_PARTICLE_FACTOR_MID 2
#define FUSION_PARTICLE_FACTOR_LOW 1
#define FUSION_TRITIUM_CONVERSION_COEFFICIENT (1e-10)
#define INSTABILITY_GAS_POWER_FACTOR 0.003
#define FUSION_TRITIUM_MOLES_USED 1
#define PLASMA_BINDING_ENERGY 20000000
#define TOROID_VOLUME_BREAKEVEN 1000
#define FUSION_TEMPERATURE_THRESHOLD 10000
#define PARTICLE_CHANCE_CONSTANT (-20000000)
#define FUSION_RAD_MAX 2000
#define FUSION_RAD_COEFFICIENT (-1000)
#define FUSION_INSTABILITY_ENDOTHERMALITY 2

View File

@@ -448,16 +448,6 @@
else
. = max(0, min(255, 138.5177312231 * log(temp - 10) - 305.0447927307))
/proc/fusionpower2text(power) //used when displaying fusion power on analyzers
switch(power)
if(0 to 5)
return "low"
if(5 to 20)
return "mid"
if(20 to 50)
return "high"
if(50 to INFINITY)
return "super"
/proc/color2hex(color) //web colors
if(!color)

View File

@@ -612,10 +612,9 @@ SLIME SCANNER
to_chat(user, "<span class='notice'>[target] is empty!</span>")
if(cached_scan_results && cached_scan_results["fusion"]) //notify the user if a fusion reaction was detected
var/fusion_power = round(cached_scan_results["fusion"], 0.01)
var/tier = fusionpower2text(fusion_power)
var/instability = round(cached_scan_results["fusion"], 0.01)
to_chat(user, "<span class='boldnotice'>Large amounts of free neutrons detected in the air indicate that a fusion reaction took place.</span>")
to_chat(user, "<span class='notice'>Power of the last fusion reaction: [fusion_power]\n This power indicates it was a [tier]-tier fusion reaction.</span>")
to_chat(user, "<span class='notice'>Instability of the last fusion reaction: [instability].</span>")
return
//slime scanner

View File

@@ -96,7 +96,6 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(/datum/gas/oxygen, /datum/g
id = "co2"
specific_heat = 30
name = "Carbon Dioxide"
fusion_power = 3
rarity = 700
/datum/gas/plasma
@@ -132,6 +131,7 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(/datum/gas/oxygen, /datum/g
name = "Nitrous Oxide"
gas_overlay = "nitrous_oxide"
moles_visible = MOLES_GAS_VISIBLE * 2
fusion_power = 10
dangerous = TRUE
rarity = 600
@@ -174,7 +174,7 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(/datum/gas/oxygen, /datum/g
id = "pluox"
specific_heat = 80
name = "Pluoxium"
fusion_power = 10
fusion_power = -10
rarity = 200
/datum/gas/miasma

View File

@@ -210,9 +210,9 @@
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 (and again, and again)
//fusion: a terrible idea that was fun but broken. Now reworked to be less broken and more interesting. Again (and again, and again). Again!
//Fusion Rework Counter: Please increment this if you make a major overhaul to this system again.
//5 reworks
//6 reworks
/datum/gas_reaction/fusion
exclude = FALSE
@@ -220,100 +220,79 @@
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(
"TEMP" = FUSION_TEMPERATURE_THRESHOLD,
"ENER" = FUSION_ENERGY_THRESHOLD,
/datum/gas/tritium = FUSION_TRITIUM_MOLES_USED,
/datum/gas/plasma = FUSION_MOLE_THRESHOLD,
/datum/gas/tritium = FUSION_MOLE_THRESHOLD
)
/datum/gas/carbon_dioxide = FUSION_MOLE_THRESHOLD)
/datum/gas_reaction/fusion/react(datum/gas_mixture/air, datum/holder)
var/list/cached_gases = air.gases
var/temperature = air.temperature
if(!air.analyzer_results)
air.analyzer_results = new
var/list/cached_scan_results = air.analyzer_results
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)
if(!air.analyzer_results)
air.analyzer_results = new
var/list/cached_scan_results = air.analyzer_results
var/old_heat_capacity = air.heat_capacity()
var/reaction_energy = 0
var/mediation = FUSION_MEDIATION_FACTOR*(air.heat_capacity()-(cached_gases[/datum/gas/plasma]*GLOB.meta_gas_specific_heats[/datum/gas/plasma]))/(air.total_moles()-cached_gases[/datum/gas/plasma]) //This is the average specific heat of the mixture,not including plasma.
var/gases_fused = air.total_moles() - cached_gases[/datum/gas/plasma]
var/plasma_differential = (cached_gases[/datum/gas/plasma] - gases_fused) / air.total_moles()
var/reaction_efficiency = FUSION_EFFICIENCY_BASE ** -((plasma_differential ** 2) / FUSION_EFFICIENCY_DIVISOR) //https://www.desmos.com/calculator/6jjx3vdrvx
var/reaction_energy = 0 //Reaction energy can be negative or positive, for both exothermic and endothermic reactions.
var/initial_plasma = cached_gases[/datum/gas/plasma]
var/initial_carbon = cached_gases[/datum/gas/carbon_dioxide]
var/scale_factor = (air.volume)/(PI) //We scale it down by volume/Pi because for fusion conditions, moles roughly = 2*volume, but we want it to be based off something constant between reactions.
var/toroidal_size = (2*PI)+TORADIANS(arctan((air.volume-TOROID_VOLUME_BREAKEVEN)/TOROID_VOLUME_BREAKEVEN)) //The size of the phase space hypertorus
var/gas_power = 0
var/list/gas_fusion_powers = GLOB.meta_gas_fusions
for (var/gas_id in cached_gases)
gas_power += reaction_efficiency * (GLOB.meta_gas_fusions[gas_id]*cached_gases[gas_id])
gas_power += (gas_fusion_powers[gas_id]*cached_gases[gas_id])
var/instability = MODULUS((gas_power*INSTABILITY_GAS_POWER_FACTOR)**2,toroidal_size) //Instability effects how chaotic the behavior of the reaction is
cached_scan_results[id] = instability//used for analyzer feedback
var/power_ratio = gas_power/mediation
cached_scan_results[id] = power_ratio //used for analyzer feedback
var/plasma = (initial_plasma-FUSION_MOLE_THRESHOLD)/(scale_factor) //We have to scale the amounts of carbon and plasma down a significant amount in order to show the chaotic dynamics we want
var/carbon = (initial_carbon-FUSION_MOLE_THRESHOLD)/(scale_factor) //We also subtract out the threshold amount to make it harder for fusion to burn itself out.
for (var/gas_id in cached_gases) //and now we fuse
cached_gases[gas_id] = 0
//The reaction is a specific form of the Kicked Rotator system, which displays chaotic behavior and can be used to model particle interactions.
plasma = MODULUS(plasma - (instability*sin(TODEGREES(carbon))), toroidal_size)
carbon = MODULUS(carbon - plasma, toroidal_size)
var/radiation_power = (FUSION_RADIATION_FACTOR * power_ratio) / (power_ratio + FUSION_RADIATION_CONSTANT) //https://www.desmos.com/calculator/4i1f296phl
var/zap_power = ((FUSION_ZAP_POWER_ASYMPTOTE * power_ratio) / (power_ratio + FUSION_ZAP_POWER_CONSTANT)) + FUSION_ZAP_POWER_BASE //https://www.desmos.com/calculator/n0zkdpxnrr
var/do_explosion = FALSE
var/zap_range //these ones are set later
var/fusion_prepare_to_die_edition_rng
if (power_ratio > FUSION_SUPER_TIER_THRESHOLD) //power ratio 50+: SUPER TIER. The gases become so energized that they fuse into a ton of tritium, which is pretty nice! Until you consider the fact that everything just exploded, the canister is probably going to break and you're irradiated.
reaction_energy += gases_fused * FUSION_RELEASE_ENERGY_SUPER * (power_ratio / FUSION_ENERGY_DIVISOR_SUPER)
cached_gases[/datum/gas/tritium] += gases_fused * FUSION_GAS_CREATION_FACTOR_TRITIUM //60% of the gas is converted to energy, 40% to trit
fusion_prepare_to_die_edition_rng = 100 //Wait a minute..
do_explosion = TRUE
zap_range = FUSION_ZAP_RANGE_SUPER
cached_gases[/datum/gas/plasma] = plasma*scale_factor + FUSION_MOLE_THRESHOLD //Scales the gases back up
cached_gases[/datum/gas/carbon_dioxide] = carbon*scale_factor + FUSION_MOLE_THRESHOLD
var/delta_plasma = initial_plasma - cached_gases[/datum/gas/plasma]
else if (power_ratio > FUSION_HIGH_TIER_THRESHOLD) //power ratio 20-50; High tier. The reaction is so energized that it fuses into a small amount of stimulum, and some pluoxium. Very dangerous, but super cool and super useful.
reaction_energy += gases_fused * FUSION_RELEASE_ENERGY_HIGH * (power_ratio / FUSION_ENERGY_DIVISOR_HIGH)
cached_gases[/datum/gas/stimulum] += gases_fused * FUSION_GAS_CREATION_FACTOR_STIM //40% of the gas is converted to energy, 60% to stim and pluox
cached_gases[/datum/gas/pluoxium] += gases_fused * FUSION_GAS_CREATION_FACTOR_PLUOX
fusion_prepare_to_die_edition_rng = power_ratio //Now we're getting into dangerous territory
do_explosion = TRUE
zap_range = FUSION_ZAP_RANGE_HIGH
else if (power_ratio > FUSION_MID_TIER_THRESHOLD) //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)
cached_gases[/datum/gas/nitryl] += gases_fused * FUSION_GAS_CREATION_FACTOR_NITRYL //20% of the gas is converted to energy, 80% to nitryl and N2O
cached_gases[/datum/gas/nitrous_oxide] += gases_fused * FUSION_GAS_CREATION_FACTOR_N2O
fusion_prepare_to_die_edition_rng = power_ratio * FUSION_MID_TIER_RAD_PROB_FACTOR //Still unlikely, but don't stand next to the reaction unprotected
zap_range = FUSION_ZAP_RANGE_MID
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)
cached_gases[/datum/gas/bz] += gases_fused * FUSION_GAS_CREATION_FACTOR_BZ //10% of the gas is converted to energy, 90% to BZ and CO2
cached_gases[/datum/gas/carbon_dioxide] += gases_fused * FUSION_GAS_CREATION_FACTOR_CO2
fusion_prepare_to_die_edition_rng = power_ratio * FUSION_LOW_TIER_RAD_PROB_FACTOR //Low, but still something to look out for
zap_range = FUSION_ZAP_RANGE_LOW
//All the deadly consequences of fusion, consolidated for your viewing pleasure
if (location)
if(prob(fusion_prepare_to_die_edition_rng)) //Some.. permanent effects
if(do_explosion)
explosion(location, 0, 0, 5, power_ratio, TRUE, TRUE) //large shockwave, the actual radius is quite small - people will recognize that you're doing fusion
radiation_pulse(location, radiation_power) //You mean causing a super-tier fusion reaction in the halls is a bad idea?
SSresearch.science_tech.add_point_type(TECHWEB_POINT_TYPE_DEFAULT, 30000)//The science is cool though.
playsound(location, 'sound/effects/supermatter.ogg', 100, 0)
else
playsound(location, 'sound/effects/phasein.ogg', 75, 0)
//These will always happen, so be prepared
tesla_zap(location, zap_range, zap_power, TESLA_FUSION_FLAGS) //larpers beware
location.fire_nuclear_particles(power_ratio) //see code/modules/projectile/energy/nuclear_particle.dm
reaction_energy += delta_plasma*PLASMA_BINDING_ENERGY //Energy is gained or lost corresponding to the creation or destruction of mass.
if(instability < FUSION_INSTABILITY_ENDOTHERMALITY)
reaction_energy = max(reaction_energy,0) //Stable reactions don't end up endothermic.
else if (reaction_energy < 0)
reaction_energy *= (instability-FUSION_INSTABILITY_ENDOTHERMALITY)**0.5
if(air.thermal_energy() + reaction_energy < 0) //No using energy that doesn't exist.
cached_gases[/datum/gas/plasma] = initial_plasma
cached_gases[/datum/gas/carbon_dioxide] = initial_carbon
return NO_REACTION
cached_gases[/datum/gas/tritium] -= FUSION_TRITIUM_MOLES_USED
//The decay of the tritium and the reaction's energy produces waste gases, different ones depending on whether the reaction is endo or exothermic
if(reaction_energy > 0)
cached_gases[/datum/gas/oxygen] += FUSION_TRITIUM_MOLES_USED*(reaction_energy*FUSION_TRITIUM_CONVERSION_COEFFICIENT)
cached_gases[/datum/gas/nitrous_oxide] += FUSION_TRITIUM_MOLES_USED*(reaction_energy*FUSION_TRITIUM_CONVERSION_COEFFICIENT)
else
cached_gases[/datum/gas/bz] += FUSION_TRITIUM_MOLES_USED*(reaction_energy*-FUSION_TRITIUM_CONVERSION_COEFFICIENT)
cached_gases[/datum/gas/nitryl] += FUSION_TRITIUM_MOLES_USED*(reaction_energy*-FUSION_TRITIUM_CONVERSION_COEFFICIENT)
if(reaction_energy)
if(location)
var/particle_chance = ((PARTICLE_CHANCE_CONSTANT)/(reaction_energy-PARTICLE_CHANCE_CONSTANT)) + 1//Asymptopically approaches 100% as the energy of the reaction goes up.
if(prob(PERCENT(particle_chance)))
location.fire_nuclear_particle()
var/rad_power = max((FUSION_RAD_COEFFICIENT/instability) + FUSION_RAD_MAX,0)
radiation_pulse(location,rad_power)
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)
air.temperature = CLAMP(((air.temperature*old_heat_capacity + reaction_energy)/new_heat_capacity),TCMB,INFINITY)
return REACTING
/datum/gas_reaction/nitrylformation //The formation of nitryl. Endothermic. Requires N2O as a catalyst.

View File

@@ -20,6 +20,7 @@ Thus, the two variables affect pump operation are set in New():
can_unwrench = TRUE
var/transfer_rate = MAX_TRANSFER_RATE
var/overclocked = FALSE
var/frequency = 0
var/id = null
@@ -32,6 +33,8 @@ Thus, the two variables affect pump operation are set in New():
. = ..()
to_chat(user,"<span class='notice'>You can hold <b>Ctrl</b> and click on it to toggle it on and off.</span>")
to_chat(user,"<span class='notice'>You can hold <b>Alt</b> and click on it to maximize its pressure.</span>")
if(overclocked)
to_chat(user,"Its warning light is on" + (on ? " and it's spewing gas!" : "."))
/obj/machinery/atmospherics/components/binary/volume_pump/CtrlClick(mob/user)
var/area/A = get_area(src)
@@ -86,18 +89,33 @@ Thus, the two variables affect pump operation are set in New():
var/datum/gas_mixture/air1 = airs[1]
var/datum/gas_mixture/air2 = airs[2]
// Pump mechanism just won't do anything if the pressure is too high/too low
// Pump mechanism just won't do anything if the pressure is too high/too low unless you overclock it.
var/input_starting_pressure = air1.return_pressure()
var/output_starting_pressure = air2.return_pressure()
if((input_starting_pressure < 0.01) || (output_starting_pressure > 9000))
if((input_starting_pressure < 0.01) || ((output_starting_pressure > 9000))&&!overclocked)
return
if((input_starting_pressure < 0.01) || ((output_starting_pressure > 15000)))//Overclocked pumps can only force gas a certain amount.
return
var/transfer_ratio = transfer_rate/air1.volume
var/datum/gas_mixture/removed = air1.remove_ratio(transfer_ratio)
if(overclocked)//Some of the gas from the mixture leaks to the environment when overclocked
var/turf/open/T = loc
if(istype(T))
if(output_starting_pressure > 9000)
var/datum/gas_mixture/leaked = removed.remove_ratio(VOLUME_PUMP_THRESHOLD_LEAK_AMOUNT)
T.assume_air(leaked)
T.air_update_turf()
else
var/datum/gas_mixture/leaked = removed.remove_ratio(VOLUME_PUMP_LEAK_AMOUNT)
T.assume_air(leaked)
T.air_update_turf()
air2.merge(removed)
update_parents()
@@ -208,3 +226,12 @@ Thus, the two variables affect pump operation are set in New():
investigate_log("Pump, [src.name], was unwrenched by [key_name(usr)] at [x], [y], [z], [A]", INVESTIGATE_ATMOS)
message_admins("Pump, [src.name], was unwrenched by [ADMIN_LOOKUPFLW(user)] at [A]")
return TRUE
/obj/machinery/atmospherics/components/binary/volume_pump/multitool_act(mob/living/user, obj/item/I)
if(!overclocked)
overclocked = TRUE
to_chat(user, "The pump makes a grinding noise and air starts to hiss out as you disable its pressure limits.")
else
overclocked = FALSE
to_chat(user, "The pump quiets down as you turn its limiters back on.")
return TRUE

View File

@@ -4,7 +4,7 @@
desc = "Very useful for filtering gasses."
density = FALSE
can_unwrench = TRUE
var/target_pressure = ONE_ATMOSPHERE
var/transfer_rate = MAX_TRANSFER_RATE
var/filter_type = null
var/frequency = 0
var/datum/radio_frequency/radio_connection
@@ -31,8 +31,8 @@
var/area/A = get_area(src)
var/turf/T = get_turf(src)
if(user.canUseTopic(src, BE_CLOSE, FALSE,))
target_pressure = MAX_OUTPUT_PRESSURE
to_chat(user,"<span class='notice'>You maximize the pressure on the [src].</span>")
transfer_rate = MAX_TRANSFER_RATE
to_chat(user,"<span class='notice'>You maximize the transfer rate on the [src].</span>")
investigate_log("Filter, [src.name], was maximized by [key_name(usr)] at [x], [y], [z], [A]", INVESTIGATE_ATMOS)
message_admins("Filter, [src.name], was maximized by [ADMIN_LOOKUPFLW(usr)] at [ADMIN_COORDJMP(T)], [A]")
@@ -146,52 +146,52 @@
if(!on || !(nodes[1] && nodes[2] && nodes[3]) || !is_operational())
return
//Early return
var/datum/gas_mixture/air1 = airs[1]
if(!air1 || air1.temperature <= 0)
return
var/datum/gas_mixture/air2 = airs[2]
var/datum/gas_mixture/air3 = airs[3]
var/output_starting_pressure = air3.return_pressure()
if(output_starting_pressure >= target_pressure)
if(output_starting_pressure >= MAX_OUTPUT_PRESSURE)
//No need to transfer if target is already full!
return
//Calculate necessary moles to transfer using PV=nRT
var/pressure_delta = target_pressure - output_starting_pressure
var/transfer_moles
if(air1.temperature > 0)
transfer_moles = pressure_delta*air3.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
var/transfer_ratio = transfer_rate/air1.volume
//Actually transfer the gas
if(transfer_moles > 0)
var/datum/gas_mixture/removed = air1.remove(transfer_moles)
if(transfer_ratio <= 0)
return
if(!removed)
return
var/datum/gas_mixture/removed = air1.remove_ratio(transfer_ratio)
var/filtering = TRUE
if(!ispath(filter_type))
if(filter_type)
filter_type = gas_id2path(filter_type) //support for mappers so they don't need to type out paths
else
filtering = FALSE
if(!removed)
return
if(filtering && removed.gases[filter_type])
var/datum/gas_mixture/filtered_out = new
var/filtering = TRUE
if(!ispath(filter_type))
if(filter_type)
filter_type = gas_id2path(filter_type) //support for mappers so they don't need to type out paths
else
filtering = FALSE
filtered_out.temperature = removed.temperature
filtered_out.gases[filter_type] = removed.gases[filter_type]
if(filtering && removed.gases[filter_type])
var/datum/gas_mixture/filtered_out = new
removed.gases[filter_type] = 0
GAS_GARBAGE_COLLECT(removed.gases)
filtered_out.temperature = removed.temperature
filtered_out.gases[filter_type] = removed.gases[filter_type]
var/datum/gas_mixture/target = (air2.return_pressure() < target_pressure ? air2 : air1) //if there's no room for the filtered gas; just leave it in air1
target.merge(filtered_out)
removed.gases[filter_type] = 0
GAS_GARBAGE_COLLECT(removed.gases)
air3.merge(removed)
var/datum/gas_mixture/target = (air2.return_pressure() < MAX_OUTPUT_PRESSURE ? air2 : air1) //if there's no room for the filtered gas; just leave it in air1
target.merge(filtered_out)
air3.merge(removed)
update_parents()
@@ -209,8 +209,8 @@
/obj/machinery/atmospherics/components/trinary/filter/ui_data()
var/data = list()
data["on"] = on
data["pressure"] = round(target_pressure)
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
data["rate"] = round(transfer_rate)
data["max_rate"] = round(MAX_TRANSFER_RATE)
data["filter_types"] = list()
data["filter_types"] += list(list("name" = "Nothing", "path" = "", "selected" = !filter_type))
@@ -227,21 +227,21 @@
on = !on
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", INVESTIGATE_ATMOS)
. = TRUE
if("pressure")
var/pressure = params["pressure"]
if(pressure == "max")
pressure = MAX_OUTPUT_PRESSURE
if("rate")
var/rate = params["rate"]
if(rate == "max")
rate = MAX_TRANSFER_RATE
. = TRUE
else if(pressure == "input")
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
if(!isnull(pressure) && !..())
else if(rate == "input")
rate = input("New transfer rate (0-[MAX_TRANSFER_RATE] L/s):", name, transfer_rate) as num|null
if(!isnull(rate) && !..())
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
else if(text2num(rate) != null)
rate = text2num(rate)
. = TRUE
if(.)
target_pressure = CLAMP(pressure, 0, MAX_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", INVESTIGATE_ATMOS)
transfer_rate = CLAMP(rate, 0, MAX_TRANSFER_RATE)
investigate_log("was set to [transfer_rate] L/s by [key_name(usr)]", INVESTIGATE_ATMOS)
if("filter")
filter_type = null
var/filter_name = "nothing"

View File

@@ -145,6 +145,30 @@
gas_type = /datum/gas/miasma
filled = 1
/obj/machinery/portable_atmospherics/canister/fusion_test
name = "Fusion Test Canister"
desc = "This should never be spawned in game."
icon_state = "green"
/obj/machinery/portable_atmospherics/canister/fusion_test/create_gas()
//air_contents.add_gases(/datum/gas/tritium,/datum/gas/plasma,/datum/gas/carbon_dioxide,/datum/gas/nitrous_oxide)
air_contents.gases[/datum/gas/tritium] = 100
air_contents.gases[/datum/gas/plasma] = 500
air_contents.gases[/datum/gas/carbon_dioxide] = 500
air_contents.gases[/datum/gas/nitrous_oxide] = 100
air_contents.temperature = 9999
/obj/machinery/portable_atmospherics/canister/fusion_test_2
name = "Fusion Test Canister"
desc = "This should never be spawned in game."
icon_state = "green"
/obj/machinery/portable_atmospherics/canister/fusion_test_2/create_gas()
//air_contents.add_gases(/datum/gas/tritium,/datum/gas/plasma,/datum/gas/carbon_dioxide,/datum/gas/nitrous_oxide)
air_contents.gases[/datum/gas/tritium] = 100
air_contents.gases[/datum/gas/plasma] = 15000
air_contents.gases[/datum/gas/carbon_dioxide] = 1500
air_contents.gases[/datum/gas/nitrous_oxide] = 100
air_contents.temperature = 9999
/obj/machinery/portable_atmospherics/canister/proc/get_time_left()
if(timing)
. = round(max(0, valve_timer - world.time) / 10, 1)

View File

@@ -65,7 +65,7 @@
if(delta_temperature > 0 && cold_air_heat_capacity > 0 && hot_air_heat_capacity > 0)
var/efficiency = 0.00025 + (hot_air.reaction_results["fire"]*0.01)
var/efficiency = 0.45
var/energy_transfer = delta_temperature*hot_air_heat_capacity*cold_air_heat_capacity/(hot_air_heat_capacity+cold_air_heat_capacity)

View File

@@ -5,12 +5,21 @@
#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 CO2_HEAT_PENALTY 0.1
#define NITROGEN_HEAT_MODIFIER -1.5
#define PLUOXIUM_HEAT_PENALTY -1
#define TRITIUM_HEAT_PENALTY 10
#define NITROGEN_HEAT_PENALTY -1.5
#define BZ_HEAT_PENALTY 5
#define OXYGEN_TRANSMIT_MODIFIER 1.5 //Higher == Bigger bonus to power generation.
#define PLASMA_TRANSMIT_MODIFIER 4
#define BZ_TRANSMIT_MODIFIER -2
#define TRITIUM_RADIOACTIVITY_MODIFIER 3 //Higher == Crystal spews out more radiation
#define BZ_RADIOACTIVITY_MODIFIER 5
#define PLUOXIUM_RADIOACTIVITY_MODIFIER -2
#define N2O_HEAT_RESISTANCE 6 //Higher == Gas makes the crystal more resistant against heat damage.
#define PLUOXIUM_HEAT_RESISTANCE 3
#define POWERLOSS_INHIBITION_GAS_THRESHOLD 0.20 //Higher == Higher percentage of inhibitor gas needed before the charge inertia chain reaction effect starts.
#define POWERLOSS_INHIBITION_MOLE_THRESHOLD 20 //Higher == More moles of the gas are needed before the charge inertia chain reaction effect starts. //Scales powerloss inhibition down until this amount of moles is reached
@@ -53,6 +62,7 @@
#define SUPERMATTER_EMERGENCY_PERCENT 25
#define SUPERMATTER_DANGER_PERCENT 50
#define SUPERMATTER_WARNING_PERCENT 100
#define CRITICAL_TEMPERATURE 10000
#define SUPERMATTER_COUNTDOWN_TIME 30 SECONDS
@@ -102,6 +112,11 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
var/o2comp = 0
var/co2comp = 0
var/n2ocomp = 0
var/pluoxiumcomp = 0
var/tritiumcomp = 0
var/bzcomp = 0
var/pluoxiumbonus = 0
var/combined_gas = 0
var/gasmix_power_ratio = 0
@@ -184,8 +199,6 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
to_chat(H, "<span class='danger'>You get headaches just from looking at it.</span>")
return
#define CRITICAL_TEMPERATURE 10000
/obj/machinery/power/supermatter_crystal/proc/get_status()
var/turf/T = get_turf(src)
if(!T)
@@ -354,16 +367,24 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
plasmacomp = max(removed.gases[/datum/gas/plasma]/combined_gas, 0)
o2comp = max(removed.gases[/datum/gas/oxygen]/combined_gas, 0)
co2comp = max(removed.gases[/datum/gas/carbon_dioxide]/combined_gas, 0)
pluoxiumcomp = max(removed.gases[/datum/gas/pluoxium]/combined_gas, 0)
tritiumcomp = max(removed.gases[/datum/gas/tritium]/combined_gas, 0)
bzcomp = max(removed.gases[/datum/gas/bz]/combined_gas, 0)
n2ocomp = max(removed.gases[/datum/gas/nitrous_oxide]/combined_gas, 0)
n2comp = max(removed.gases[/datum/gas/nitrogen]/combined_gas, 0)
gasmix_power_ratio = min(max(plasmacomp + o2comp + co2comp - n2comp, 0), 1)
if(pluoxiumcomp >= 0.15)
pluoxiumbonus = 1 //makes pluoxium only work at 15%+
else
pluoxiumbonus = 0
dynamic_heat_modifier = max((plasmacomp * PLASMA_HEAT_PENALTY)+(o2comp * OXYGEN_HEAT_PENALTY)+(co2comp * CO2_HEAT_PENALTY)+(n2comp * NITROGEN_HEAT_MODIFIER), 0.5)
dynamic_heat_resistance = max(n2ocomp * N2O_HEAT_RESISTANCE, 1)
gasmix_power_ratio = min(max(plasmacomp + o2comp + co2comp + tritiumcomp + bzcomp - pluoxiumcomp - n2comp, 0), 1)
power_transmission_bonus = max((plasmacomp * PLASMA_TRANSMIT_MODIFIER) + (o2comp * OXYGEN_TRANSMIT_MODIFIER), 0)
dynamic_heat_modifier = max((plasmacomp * PLASMA_HEAT_PENALTY) + (o2comp * OXYGEN_HEAT_PENALTY) + (co2comp * CO2_HEAT_PENALTY) + (tritiumcomp * TRITIUM_HEAT_PENALTY) + ((pluoxiumcomp * PLUOXIUM_HEAT_PENALTY) * pluoxiumbonus) + (n2comp * NITROGEN_HEAT_PENALTY) + (bzcomp * BZ_HEAT_PENALTY), 0.5)
dynamic_heat_resistance = max((n2ocomp * N2O_HEAT_RESISTANCE) + ((pluoxiumcomp * PLUOXIUM_HEAT_RESISTANCE) * pluoxiumbonus), 1)
power_transmission_bonus = max((plasmacomp * PLASMA_TRANSMIT_MODIFIER) + (o2comp * OXYGEN_TRANSMIT_MODIFIER) + (bzcomp * BZ_TRANSMIT_MODIFIER), 0)
//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)
@@ -392,7 +413,9 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
power = max( (removed.temperature * temp_factor / T0C) * gasmix_power_ratio + power, 0) //Total laser power plus an overload
if(prob(50))
radiation_pulse(src, power * (1 + power_transmission_bonus/10))
radiation_pulse(src, power * (1 + (tritiumcomp * TRITIUM_RADIOACTIVITY_MODIFIER) + ((pluoxiumcomp * PLUOXIUM_RADIOACTIVITY_MODIFIER) * pluoxiumbonus) * (power_transmission_bonus/(10-(bzcomp * BZ_RADIOACTIVITY_MODIFIER))))) // Rad Modifiers BZ(500%), Tritium(300%), and Pluoxium(-200%)
if(bzcomp >= 0.4 && prob(50 * bzcomp))
fire_nuclear_particle() // Start to emit radballs at a maximum of 50% chance per tick - was 30% before but figured that's mild
var/device_energy = power * REACTION_POWER_MODIFIER
@@ -527,11 +550,14 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
/obj/machinery/power/supermatter_crystal/attack_tk(mob/user)
if(iscarbon(user))
var/mob/living/carbon/C = user
log_game("[key_name(C)] has been disintegrated by a telekenetic grab on a supermatter crystal.</span>")
to_chat(C, "<span class='userdanger'>That was a really dense idea.</span>")
C.ghostize()
C.visible_message("<span class='userdanger'>A bright flare of radiation is seen from [C]'s head, shortly before you hear a sickening sizzling!</span>")
var/obj/item/organ/brain/rip_u = locate(/obj/item/organ/brain) in C.internal_organs
rip_u.Remove(C)
qdel(rip_u)
return
return ..()
/obj/machinery/power/supermatter_crystal/attack_paw(mob/user)
dust_mob(user, cause = "monkey attack")
@@ -787,4 +813,4 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
#undef HALLUCINATION_RANGE
#undef GRAVITATIONAL_ANOMALY
#undef FLUX_ANOMALY
#undef PYRO_ANOMALY
#undef PYRO_ANOMALY

View File

@@ -3,10 +3,9 @@
name = "nuclear particle"
icon_state = "nuclear_particle"
pass_flags = PASSTABLE | PASSGLASS | PASSGRILLE
damage = 20
damage_type = TOX
irradiate = 2500 //enough to knockdown and induce vomiting
speed = 0.4
flag = "rad"
irradiate = 5000
speed = 0.4
hitsound = 'sound/weapons/emitter2.ogg'
impact_type = /obj/effect/projectile/impact/xray
var/static/list/particle_colors = list(
@@ -25,22 +24,6 @@
add_atom_colour(particle_colors[our_color], FIXED_COLOUR_PRIORITY)
set_light(4, 3, particle_colors[our_color]) //Range of 4, brightness of 3 - Same range as a flashlight
/atom/proc/fire_nuclear_particles(power_ratio) //used by fusion to fire random # of nuclear particles - power ratio determines about how many are fired
var/random_particles = rand(3,6)
var/particles_to_fire
var/particles_fired
switch(power_ratio) //multiply random_particles * factor for whatever tier
if(0 to FUSION_MID_TIER_THRESHOLD)
particles_to_fire = random_particles * FUSION_PARTICLE_FACTOR_LOW
if(FUSION_MID_TIER_THRESHOLD to FUSION_HIGH_TIER_THRESHOLD)
particles_to_fire = random_particles * FUSION_PARTICLE_FACTOR_MID
if(FUSION_HIGH_TIER_THRESHOLD to FUSION_SUPER_TIER_THRESHOLD)
particles_to_fire = random_particles * FUSION_PARTICLE_FACTOR_HIGH
if(FUSION_SUPER_TIER_THRESHOLD to INFINITY)
particles_to_fire = random_particles * FUSION_PARTICLE_FACTOR_SUPER
while(particles_to_fire)
particles_fired++
var/angle = rand(0,360)
var/obj/item/projectile/energy/nuclear_particle/P = new /obj/item/projectile/energy/nuclear_particle(src)
addtimer(CALLBACK(P, /obj/item/projectile.proc/fire, angle), particles_fired) //multiply particles fired * delay so the particles end up stagnated (once every decisecond)
particles_to_fire--
/atom/proc/fire_nuclear_particle(angle = rand(0,360)) //used by fusion to fire random nuclear particles. Fires one particle in a random direction.
var/obj/item/projectile/energy/nuclear_particle/P = new /obj/item/projectile/energy/nuclear_particle(src)
P.fire(angle)

File diff suppressed because one or more lines are too long

View File

@@ -3,15 +3,15 @@
<ui-button icon='{{data.on ? "power-off" : "close"}}' style='{{data.on ? "selected" : null}}'
action='power'>{{data.on ? "On" : "Off"}}</ui-button>
</ui-section>
<ui-section label='Output Pressure'>
<ui-button icon='pencil' action='pressure' params='{"pressure": "input"}'>Set</ui-button>
<ui-button icon='plus' state='{{data.pressure == data.max_pressure ? "disabled" : null}}' action='pressure' params='{"pressure": "max"}'>Max</ui-button>
<span>{{Math.round(adata.pressure)}} kPa</span>
<ui-section label='Transfer Rate'>
<ui-button icon='pencil' action='rate' params='{"rate": "input"}'>Set</ui-button>
<ui-button icon='plus' state='{{data.rate == data.max_rate ? "disabled" : null}}' action='rate' params='{"rate": "max"}'>Max</ui-button>
<span>{{Math.round(adata.rate)}} L/s</span>
</ui-section>
<ui-section label='Filter'>
{{#each data.filter_types}}
<ui-button state='{{selected ? "selected" : null}}'
action='filter' params='{"mode": {{id}}}'>{{name}}</ui-button>
{{/each}}
</ui-section>
</ui-section>
</ui-display>