diff --git a/code/modules/power/fusion/core/_core.dm b/code/modules/power/fusion/core/_core.dm index 74da4e4acb..60af67cf92 100644 --- a/code/modules/power/fusion/core/_core.dm +++ b/code/modules/power/fusion/core/_core.dm @@ -41,7 +41,12 @@ var/list/fusion_cores = list() /obj/machinery/power/fusion_core/process() if((stat & BROKEN) || !powernet || !owned_field) Shutdown() - + if(owned_field) + spawn(1) + owned_field.stability_monitor() + owned_field.radiation_scale() + owned_field.temp_dump() + owned_field.temp_color() /obj/machinery/power/fusion_core/Topic(href, href_list) if(..()) return 1 diff --git a/code/modules/power/fusion/core/core_field.dm b/code/modules/power/fusion/core/core_field.dm index 587ec7637e..c882a95ccc 100644 --- a/code/modules/power/fusion/core/core_field.dm +++ b/code/modules/power/fusion/core/core_field.dm @@ -1,4 +1,6 @@ #define FUSION_ENERGY_PER_K 20 +#define FUSION_MAX_ENVIRO_HEAT 5000 //raise this if you want the reactor to dump more energy into the atmosphere +#define PLASMA_TEMP_RADIATION_DIVISIOR 15 //radiation divisior. plasma temp / divisor = radiation. /obj/effect/fusion_em_field name = "electromagnetic field" @@ -7,7 +9,7 @@ icon_state = "emfield_s1" alpha = 50 layer = 4 - light_color = COLOR_BLUE + light_color = "#cc7700" var/size = 1 var/energy = 0 @@ -16,6 +18,7 @@ var/field_strength = 0.01 var/tick_instability = 0 var/percent_unstable = 0 + var/stable = 1 var/obj/machinery/power/fusion_core/owned_core var/list/dormant_reactant_quantities = list() @@ -33,8 +36,8 @@ var/light_min_range = 2 var/light_min_power = 3 - var/light_max_range = 10 - var/light_max_power = 10 + var/light_max_range = 5 + var/light_max_power = 5 var/last_range var/last_power @@ -173,8 +176,6 @@ check_instability() Radiate() - if(radiation) - radiation_repository.radiate(src, radiation) return 1 /obj/effect/fusion_em_field/proc/check_instability() @@ -200,9 +201,10 @@ var/flare var/fuel_loss var/rupture - if(percent_unstable < 0.7) + if(percent_unstable < 0.2) visible_message("\The [src] ripples uneasily, like a disturbed pond.") fuel_loss = prob(5) + flare = prob(50) else if(percent_unstable < 0.9) visible_message("\The [src] undulates violently, shedding plumes of plasma!") flare = prob(50) @@ -238,6 +240,7 @@ set_light(15, 15, "#CCCCFF") empulse(get_turf(src), ceil(plasma_temperature/1000), ceil(plasma_temperature/300)) sleep(5) + global_announcer.autosay("WARNING: FIELD RUPTURE IMMINENT!", "Containment Monitor") RadiateAll() explosion(get_turf(owned_core),-1,-1,8,10) // Blow out all the windows. return @@ -318,12 +321,6 @@ tick_instability += rand(15,30) AM.emp_act(empsev) - if(owned_core && owned_core.loc) - var/datum/gas_mixture/environment = owned_core.loc.return_air() - if(environment && environment.temperature < (T0C+1000)) // Putting an upper bound on it to stop it being used in a TEG. - environment.add_thermal_energy(plasma_temperature*20000) - radiation = 0 - /obj/effect/fusion_em_field/proc/change_size(var/newsize = 1) var/changed = 0 switch(newsize) @@ -490,5 +487,59 @@ AddEnergy(Proj.damage) update_icon() return 0 +//All procs below this point are called in _core.dm, starting at line 41. +//Stability monitoring. Gives radio annoucements if field stability is below 80% +/obj/effect/fusion_em_field/proc/stability_monitor() + var/warnpoint = 0.10 + var/warnmessage = "Warning! Field unstable! Instability at [percent_unstable * 100]%, plasma temperature at [plasma_temperature + 295]k." + var/stablemessage = "Containment field returning to stable conditions." -#undef FUSION_HEAT_CAP \ No newline at end of file + if(percent_unstable >= warnpoint) + global_announcer.autosay(warnmessage, "Field Stability Monitor", "Engineering") + stable = 0 + sleep(20 SECONDS) + return + if(percent_unstable < warnpoint && stable == 0) + global_announcer.autosay(stablemessage, "Field Stability Monitor", "Engineering") + stable = 1 + return + +//Reaction radiation is fairly buggy and there's at least three procs dealing with radiation here, this is to ensure constant radiation output. +/obj/effect/fusion_em_field/proc/radiation_scale() + radiation_repository.radiate(src, 2 + plasma_temperature / PLASMA_TEMP_RADIATION_DIVISIOR) + +//Somehow fixing the radiation issue managed to break this, but moving it to it's own proc seemed to have fixed it. I don't know. +/obj/effect/fusion_em_field/proc/temp_dump() + if(owned_core && owned_core.loc) + var/datum/gas_mixture/environment = owned_core.loc.return_air() + if(environment && environment.temperature < (T0C+FUSION_MAX_ENVIRO_HEAT)) + environment.add_thermal_energy(plasma_temperature*20000) + +//Temperature changes depending on color. +/obj/effect/fusion_em_field/proc/temp_color() + if(plasma_temperature > 60000) //high ultraviolet - magenta + light_color = "#cc005f" + light_max_range = 25 + light_max_power = 10 + else if(plasma_temperature > 12000) //ultraviolet - blue + light_color = "#1b00cc" + light_max_range = 20 + light_max_power = 10 + else if(plasma_temperature > 8000) //nearing ultraviolet - cyan + light_color = "#00cccc" + light_max_range = 15 + light_max_power = 10 + else if(plasma_temperature > 4000) // green + light_color = "#1ab705" + light_max_range = 10 + light_max_power = 10 + else if(plasma_temperature <= 4000) //orange + light_color = "#cc7700" + light_max_range = 5 + light_max_power = 5 + return + + +#undef FUSION_HEAT_CAP +#undef FUSION_MAX_ENVIRO_HEAT +#undef PLASMA_TEMP_RADIATION_DIVISIOR \ No newline at end of file diff --git a/code/modules/power/fusion/fusion_reactions.dm b/code/modules/power/fusion/fusion_reactions.dm index f447164ea4..38f73812f9 100644 --- a/code/modules/power/fusion/fusion_reactions.dm +++ b/code/modules/power/fusion/fusion_reactions.dm @@ -48,14 +48,13 @@ proc/get_fusion_reaction(var/p_react, var/s_react, var/m_energy) s_react = "deuterium" energy_consumption = 1 energy_production = 2 - // Advanced production reactions (todo) + /decl/fusion_reaction/deuterium_helium p_react = "deuterium" s_react = "helium-3" energy_consumption = 1 energy_production = 5 - radiation = 2 /decl/fusion_reaction/deuterium_tritium p_react = "deuterium" @@ -64,7 +63,6 @@ proc/get_fusion_reaction(var/p_react, var/s_react, var/m_energy) energy_production = 1 products = list("helium-3" = 1) instability = 0.5 - radiation = 3 /decl/fusion_reaction/deuterium_lithium p_react = "deuterium" diff --git a/code/modules/power/fusion/fusion_reagents.dm b/code/modules/power/fusion/fusion_reagents.dm new file mode 100644 index 0000000000..875bf63fee --- /dev/null +++ b/code/modules/power/fusion/fusion_reagents.dm @@ -0,0 +1,8 @@ +//Additional fusion reagents. These likely don't have any other use aside from the RUST, but if you want to make stuff with 'em, be my guest. + +/datum/reagent/helium3 + name = "helium-3" + description = "A colorless, odorless, tasteless and generally inert gas used in fusion reactors. Non-radioactive." + id = "helium-3" + reagent_state = GAS + color = "#808080" \ No newline at end of file diff --git a/polaris.dme b/polaris.dme index 4b5d3f72d7..20c4844f0c 100644 --- a/polaris.dme +++ b/polaris.dme @@ -1990,6 +1990,7 @@ #include "code\modules\power\fusion\fusion_circuits.dm" #include "code\modules\power\fusion\fusion_particle_catcher.dm" #include "code\modules\power\fusion\fusion_reactions.dm" +#include "code\modules\power\fusion\fusion_reagents.dm" #include "code\modules\power\fusion\core\_core.dm" #include "code\modules\power\fusion\core\core_control.dm" #include "code\modules\power\fusion\core\core_field.dm"