Skip to content

Commit

Permalink
[MIRROR] Halon combustion releases resin foam and pluoxium. Halon is …
Browse files Browse the repository at this point in the history
…formed by electrolysing BZ, and the reaction is much quicker. (#1773)

* Halon combustion releases resin foam and pluoxium. Halon is formed by electrolysing BZ, and the reaction is much quicker. (#81887)

## About The Pull Request
Original PRs: #69196 and #74472

Applies both of those PRs to this PR.
Doesn't apply the firefighter backpack halon requirement changes since
absolutely no one liked that.

Halon combustion will combust into 2.5 moles of pluoxium per mole of
halon consumed, and release atmos resin. The resin will not only help
choke out fires, but it will also help seal rooms from fires, or seal
fires from other rooms. Halon formation now requires electrolysing BZ
instead of CO2 and N2O. The electrolysis is much faster. 2 moles of
halon and 0.2 moles of oxygen is released with 91.2321kJ of thermal
energy per mole of BZ electrolysed. Halon combustion starts at 343.15K
instead of 373.15K.

Resin foam no longer consumes halon and pluoxium. The resin foam
released from halon combustion is a special type that lasts longer to
ensure the halon can spread and not block itself when combusting.
## Why It's Good For The Game
I have only seen one, maybe two rounds ever where someone created halon,
and 0 rounds where it was actually used. The main reason why it (at
least I think) isn't used is because it takes a rather large amount of
effort and time for something that is only going to be used in a
fraction of rounds. Preemptively spending that much effort every round,
where most of the time it doesn't get used, will get boring and
repetitive for pretty much anyone very quickly. Creating it as a
response to a fire is going to take too long because you need to build a
special cooling chamber and a contraption to ensure low pressure, and
then wait for it to react slowly.

This PR tries to resolve this by changing the requirement to BZ, making
the electrolysis much quicker and scales with temperature instead of
inversely with pressure, and making it combust into pluoxium. BZ is a
gas that takes a little effort to make, but is probably the most
frequently made gas and is likely already available when there is an
emergency. With the BZ requirement combined with electrolysis speed
change, creating halon is just a matter of dumping BZ into an
electrolyser, turning the electrolyser on then extracting the halon,
which can be reasonably done as a response to a plasmaflood or whatever.

Halon combusting into pluoxium also makes halon not a dead end on the
tree of gases. By letting halon combust into pluoxium, atmospheric
technicians may persue halon to create pluoxium, which should let it
feel less of a waste of time if someone decides to make it and there's
no emergency that calls for the use of it. Halon combustion releasing
resin foam conveys a visual effect that it is strong at choking fires.
Reducing the temperature allows it to react earlier to a spreading fire,
so it can block it before it spreads.
## Changelog
:cl:
balance: Halon combustion releases 2.5 moles of pluoxium per mole of
halon consumed.
balance: Halon combustion no longer releases carbon dioxide.
balance: Halon combustion releases resin foam.
balance: Halon formation requirements changed to require electrolysing
BZ instead of N2O and CO2.
balance: Halon formation changed to no longer slow down at higher
pressures. It instead accelerates at higher temperatures. It is much
faster overall.
balance: Halon formation releases 91.2321kJ of thermal energy per mole
of halon consumed.
/:cl:

---------

Co-authored-by: Ghom <[email protected]>

* Halon combustion releases resin foam and pluoxium. Halon is formed by electrolysing BZ, and the reaction is much quicker.

---------

Co-authored-by: Pickle-Coding <[email protected]>
Co-authored-by: Ghom <[email protected]>
  • Loading branch information
3 people authored and StealsThePRs committed Apr 2, 2024
1 parent 6875b7d commit d158971
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 79 deletions.
16 changes: 10 additions & 6 deletions code/__DEFINES/reactions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,19 @@
#define REACTION_OPPRESSION_THRESHOLD 5

// Halon:
/// The minimum temperature required for halon to form from tritium and BZ.
#define HALON_FORMATION_MIN_TEMPERATURE 30
/// The maximum temperature required for halon to form from tritium and BZ.
#define HALON_FORMATION_MAX_TEMPERATURE 55
/// The amount of energy 4.25 moles of halon forming from tritium and BZ releases.
#define HALON_FORMATION_ENERGY 300
/// Energy released per mole of BZ consumed during halon formation.
#define HALON_FORMATION_ENERGY 91232.1

/// How much energy a mole of halon combusting consumes.
#define HALON_COMBUSTION_ENERGY 2500
/// The minimum temperature required for halon to combust.
#define HALON_COMBUSTION_MIN_TEMPERATURE (T0C + 70)
/// The temperature scale for halon combustion reaction rate.
#define HALON_COMBUSTION_TEMPERATURE_SCALE (FIRE_MINIMUM_TEMPERATURE_TO_EXIST * 10)
/// Amount of halon required to be consumed in order to release resin. This is always possible as long as there's enough gas.
#define HALON_COMBUSTION_MINIMUM_RESIN_MOLES (0.99 * HALON_COMBUSTION_MIN_TEMPERATURE / HALON_COMBUSTION_TEMPERATURE_SCALE)
/// The volume of the resin foam fluid when halon combusts, in turfs.
#define HALON_COMBUSTION_RESIN_VOLUME 1

// Healium:
/// The minimum temperature healium can form from BZ and freon at.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,12 @@
alpha = 120
max_integrity = 10
pass_flags_self = PASSGLASS
var/static/list/ignored_gases = typecacheof(list(
/datum/gas/nitrogen,
/datum/gas/oxygen,
/datum/gas/pluoxium,
/datum/gas/halon,
))

/obj/structure/foamedmetal/resin/Initialize(mapload)
. = ..()
Expand All @@ -432,11 +438,8 @@

var/list/gases = air.gases
for(var/gas_type in gases)
switch(gas_type)
if(/datum/gas/oxygen, /datum/gas/nitrogen)
continue
else
gases[gas_type][MOLES] = 0
if(!(ignored_gases[gas_type]))
gases[gas_type][MOLES] = 0
air.garbage_collect()

for(var/obj/machinery/atmospherics/components/unary/comp in location)
Expand All @@ -450,6 +453,22 @@
for(var/obj/item/potential_tinder in location)
potential_tinder.extinguish()

/datum/effect_system/fluid_spread/foam/metal/resin/halon
effect_type = /obj/effect/particle_effect/fluid/foam/metal/resin/halon

/// A variant of resin foam that is created from halon combustion. It does not dissolve in heat to allow the gas to spread before foaming.
/obj/effect/particle_effect/fluid/foam/metal/resin/halon

/obj/effect/particle_effect/fluid/foam/metal/resin/halon/Initialize(mapload)
. = ..()
RemoveElement(/datum/element/atmos_sensitive) // Doesn't dissolve in heat.

/obj/effect/particle_effect/fluid/foam/metal/resin/halon/should_atmos_process(datum/gas_mixture/air, exposed_temperature)
return FALSE // Doesn't dissolve in heat.

/obj/effect/particle_effect/fluid/foam/metal/resin/halon/atmos_expose(datum/gas_mixture/air, exposed_temperature)
return // Doesn't dissolve in heat.

/datum/effect_system/fluid_spread/foam/dirty
effect_type = /obj/effect/particle_effect/fluid/foam/dirty

Expand Down
114 changes: 62 additions & 52 deletions code/modules/atmospherics/gasmixtures/reactions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -448,18 +448,18 @@

/datum/gas_reaction/nitrousformation/react(datum/gas_mixture/air)
var/list/cached_gases = air.gases
var/heat_efficency = min(cached_gases[/datum/gas/oxygen][MOLES] * INVERSE(0.5), cached_gases[/datum/gas/nitrogen][MOLES])
if ((cached_gases[/datum/gas/oxygen][MOLES] - heat_efficency * 0.5 < 0 ) || (cached_gases[/datum/gas/nitrogen][MOLES] - heat_efficency < 0))
var/heat_efficiency = min(cached_gases[/datum/gas/oxygen][MOLES] * INVERSE(0.5), cached_gases[/datum/gas/nitrogen][MOLES])
if ((cached_gases[/datum/gas/oxygen][MOLES] - heat_efficiency * 0.5 < 0 ) || (cached_gases[/datum/gas/nitrogen][MOLES] - heat_efficiency < 0))
return NO_REACTION // Shouldn't produce gas from nothing.

var/old_heat_capacity = air.heat_capacity()
cached_gases[/datum/gas/oxygen][MOLES] -= heat_efficency * 0.5
cached_gases[/datum/gas/nitrogen][MOLES] -= heat_efficency
cached_gases[/datum/gas/oxygen][MOLES] -= heat_efficiency * 0.5
cached_gases[/datum/gas/nitrogen][MOLES] -= heat_efficiency
ASSERT_GAS(/datum/gas/nitrous_oxide, air)
cached_gases[/datum/gas/nitrous_oxide][MOLES] += heat_efficency
cached_gases[/datum/gas/nitrous_oxide][MOLES] += heat_efficiency

SET_REACTION_RESULTS(heat_efficency)
var/energy_released = heat_efficency * N2O_FORMATION_ENERGY
SET_REACTION_RESULTS(heat_efficiency)
var/energy_released = heat_efficiency * N2O_FORMATION_ENERGY
var/new_heat_capacity = air.heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
air.temperature = max(((air.temperature * old_heat_capacity + energy_released) / new_heat_capacity), TCMB) // The air cools down when reacting.
Expand Down Expand Up @@ -642,20 +642,20 @@
/datum/gas_reaction/nitrium_formation/react(datum/gas_mixture/air)
var/list/cached_gases = air.gases
var/temperature = air.temperature
var/heat_efficency = min(temperature / NITRIUM_FORMATION_TEMP_DIVISOR, cached_gases[/datum/gas/tritium][MOLES], cached_gases[/datum/gas/nitrogen][MOLES], cached_gases[/datum/gas/bz][MOLES] * INVERSE(0.05))
var/heat_efficiency = min(temperature / NITRIUM_FORMATION_TEMP_DIVISOR, cached_gases[/datum/gas/tritium][MOLES], cached_gases[/datum/gas/nitrogen][MOLES], cached_gases[/datum/gas/bz][MOLES] * INVERSE(0.05))

if( heat_efficency <= 0 || (cached_gases[/datum/gas/tritium][MOLES] - heat_efficency < 0 ) || (cached_gases[/datum/gas/nitrogen][MOLES] - heat_efficency < 0) || (cached_gases[/datum/gas/bz][MOLES] - heat_efficency * 0.05 < 0)) //Shouldn't produce gas from nothing.
if( heat_efficiency <= 0 || (cached_gases[/datum/gas/tritium][MOLES] - heat_efficiency < 0 ) || (cached_gases[/datum/gas/nitrogen][MOLES] - heat_efficiency < 0) || (cached_gases[/datum/gas/bz][MOLES] - heat_efficiency * 0.05 < 0)) //Shouldn't produce gas from nothing.
return NO_REACTION

var/old_heat_capacity = air.heat_capacity()
ASSERT_GAS(/datum/gas/nitrium, air)
cached_gases[/datum/gas/tritium][MOLES] -= heat_efficency
cached_gases[/datum/gas/nitrogen][MOLES] -= heat_efficency
cached_gases[/datum/gas/bz][MOLES] -= heat_efficency * 0.05 //bz gets consumed to balance the nitrium production and not make it too common and/or easy
cached_gases[/datum/gas/nitrium][MOLES] += heat_efficency
cached_gases[/datum/gas/tritium][MOLES] -= heat_efficiency
cached_gases[/datum/gas/nitrogen][MOLES] -= heat_efficiency
cached_gases[/datum/gas/bz][MOLES] -= heat_efficiency * 0.05 //bz gets consumed to balance the nitrium production and not make it too common and/or easy
cached_gases[/datum/gas/nitrium][MOLES] += heat_efficiency

SET_REACTION_RESULTS(heat_efficency)
var/energy_used = heat_efficency * NITRIUM_FORMATION_ENERGY
SET_REACTION_RESULTS(heat_efficiency)
var/energy_used = heat_efficiency * NITRIUM_FORMATION_ENERGY
var/new_heat_capacity = air.heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
air.temperature = max(((temperature * old_heat_capacity - energy_used) / new_heat_capacity), TCMB) //the air cools down when reacting
Expand Down Expand Up @@ -687,19 +687,19 @@
var/temperature = air.temperature

//This reaction is agressively slow. like, a tenth of a mole per fire slow. Keep that in mind
var/heat_efficency = min(temperature / NITRIUM_DECOMPOSITION_TEMP_DIVISOR, cached_gases[/datum/gas/nitrium][MOLES])
var/heat_efficiency = min(temperature / NITRIUM_DECOMPOSITION_TEMP_DIVISOR, cached_gases[/datum/gas/nitrium][MOLES])

if (heat_efficency <= 0 || (cached_gases[/datum/gas/nitrium][MOLES] - heat_efficency < 0)) //Shouldn't produce gas from nothing.
if (heat_efficiency <= 0 || (cached_gases[/datum/gas/nitrium][MOLES] - heat_efficiency < 0)) //Shouldn't produce gas from nothing.
return NO_REACTION

var/old_heat_capacity = air.heat_capacity()
air.assert_gases(/datum/gas/nitrogen, /datum/gas/hydrogen)
cached_gases[/datum/gas/nitrium][MOLES] -= heat_efficency
cached_gases[/datum/gas/hydrogen][MOLES] += heat_efficency
cached_gases[/datum/gas/nitrogen][MOLES] += heat_efficency
cached_gases[/datum/gas/nitrium][MOLES] -= heat_efficiency
cached_gases[/datum/gas/hydrogen][MOLES] += heat_efficiency
cached_gases[/datum/gas/nitrogen][MOLES] += heat_efficiency

SET_REACTION_RESULTS(heat_efficency)
var/energy_released = heat_efficency * NITRIUM_DECOMPOSITION_ENERGY
SET_REACTION_RESULTS(heat_efficiency)
var/energy_released = heat_efficiency * NITRIUM_DECOMPOSITION_ENERGY
var/new_heat_capacity = air.heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
air.temperature = max(((temperature * old_heat_capacity + energy_released) / new_heat_capacity), TCMB) //the air heats up when reacting
Expand Down Expand Up @@ -821,28 +821,38 @@
requirements = list(
/datum/gas/halon = MINIMUM_MOLE_COUNT,
/datum/gas/oxygen = MINIMUM_MOLE_COUNT,
"MIN_TEMP" = FIRE_MINIMUM_TEMPERATURE_TO_EXIST,
"MIN_TEMP" = HALON_COMBUSTION_MIN_TEMPERATURE,
)

/datum/gas_reaction/halon_o2removal/react(datum/gas_mixture/air, datum/holder)
var/list/cached_gases = air.gases
var/temperature = air.temperature

var/heat_efficency = min(temperature / ( FIRE_MINIMUM_TEMPERATURE_TO_EXIST * 10), cached_gases[/datum/gas/halon][MOLES], cached_gases[/datum/gas/oxygen][MOLES] * INVERSE(20))
if (heat_efficency <= 0 || (cached_gases[/datum/gas/halon][MOLES] - heat_efficency < 0 ) || (cached_gases[/datum/gas/oxygen][MOLES] - heat_efficency * 20 < 0)) //Shouldn't produce gas from nothing.
var/heat_efficiency = min(temperature / HALON_COMBUSTION_TEMPERATURE_SCALE, cached_gases[/datum/gas/halon][MOLES], cached_gases[/datum/gas/oxygen][MOLES] * INVERSE(20))
if (heat_efficiency <= 0 || (cached_gases[/datum/gas/halon][MOLES] - heat_efficiency < 0 ) || (cached_gases[/datum/gas/oxygen][MOLES] - heat_efficiency * 20 < 0)) //Shouldn't produce gas from nothing.
return NO_REACTION

var/old_heat_capacity = air.heat_capacity()
ASSERT_GAS(/datum/gas/carbon_dioxide, air)
cached_gases[/datum/gas/halon][MOLES] -= heat_efficency
cached_gases[/datum/gas/oxygen][MOLES] -= heat_efficency * 20
cached_gases[/datum/gas/carbon_dioxide][MOLES] += heat_efficency * 5
ASSERT_GAS(/datum/gas/pluoxium, air)
cached_gases[/datum/gas/halon][MOLES] -= heat_efficiency
cached_gases[/datum/gas/oxygen][MOLES] -= heat_efficiency * 20
cached_gases[/datum/gas/pluoxium][MOLES] += heat_efficiency * 2.5

SET_REACTION_RESULTS(heat_efficency * 5)
var/energy_used = heat_efficency * HALON_COMBUSTION_ENERGY
SET_REACTION_RESULTS(heat_efficiency * 5)
var/energy_used = heat_efficiency * HALON_COMBUSTION_ENERGY
var/new_heat_capacity = air.heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
air.temperature = max(((temperature * old_heat_capacity - energy_used) / new_heat_capacity), TCMB)

// Resin foam effects.
var/turf/open/location = holder
var/obj/effect/particle_effect/fluid/foam/foam = locate() in location
var/obj/structure/foamedmetal/resin = locate() in location
if(heat_efficiency > HALON_COMBUSTION_MINIMUM_RESIN_MOLES && isopenturf(location) && !foam && !resin) // Don't resin if there is aleady resin or we are not in an open turf.
var/datum/effect_system/fluid_spread/foam/metal/resin/halon/foaming = new
foaming.set_up(amount = HALON_COMBUSTION_RESIN_VOLUME, holder = holder, location = location)
foaming.start()

return REACTING


Expand Down Expand Up @@ -870,18 +880,18 @@
/datum/gas_reaction/healium_formation/react(datum/gas_mixture/air, datum/holder)
var/list/cached_gases = air.gases
var/temperature = air.temperature
var/heat_efficency = min(temperature * 0.3, cached_gases[/datum/gas/freon][MOLES] * INVERSE(2.75), cached_gases[/datum/gas/bz][MOLES] * INVERSE(0.25))
if (heat_efficency <= 0 || (cached_gases[/datum/gas/freon][MOLES] - heat_efficency * 2.75 < 0 ) || (cached_gases[/datum/gas/bz][MOLES] - heat_efficency * 0.25 < 0)) //Shouldn't produce gas from nothing.
var/heat_efficiency = min(temperature * 0.3, cached_gases[/datum/gas/freon][MOLES] * INVERSE(2.75), cached_gases[/datum/gas/bz][MOLES] * INVERSE(0.25))
if (heat_efficiency <= 0 || (cached_gases[/datum/gas/freon][MOLES] - heat_efficiency * 2.75 < 0 ) || (cached_gases[/datum/gas/bz][MOLES] - heat_efficiency * 0.25 < 0)) //Shouldn't produce gas from nothing.
return NO_REACTION

var/old_heat_capacity = air.heat_capacity()
ASSERT_GAS(/datum/gas/healium, air)
cached_gases[/datum/gas/freon][MOLES] -= heat_efficency * 2.75
cached_gases[/datum/gas/bz][MOLES] -= heat_efficency * 0.25
cached_gases[/datum/gas/healium][MOLES] += heat_efficency * 3
cached_gases[/datum/gas/freon][MOLES] -= heat_efficiency * 2.75
cached_gases[/datum/gas/bz][MOLES] -= heat_efficiency * 0.25
cached_gases[/datum/gas/healium][MOLES] += heat_efficiency * 3

SET_REACTION_RESULTS(heat_efficency * 3)
var/energy_released = heat_efficency * HEALIUM_FORMATION_ENERGY
SET_REACTION_RESULTS(heat_efficiency * 3)
var/energy_released = heat_efficiency * HEALIUM_FORMATION_ENERGY
var/new_heat_capacity = air.heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
air.temperature = max(((temperature * old_heat_capacity + energy_released) / new_heat_capacity), TCMB)
Expand Down Expand Up @@ -911,18 +921,18 @@
var/list/cached_gases = air.gases
var/temperature = air.temperature

var/heat_efficency = min(temperature * ZAUKER_FORMATION_TEMPERATURE_SCALE, cached_gases[/datum/gas/hypernoblium][MOLES] * INVERSE(0.01), cached_gases[/datum/gas/nitrium][MOLES] * INVERSE(0.5))
if (heat_efficency <= 0 || (cached_gases[/datum/gas/hypernoblium][MOLES] - heat_efficency * 0.01 < 0 ) || (cached_gases[/datum/gas/nitrium][MOLES] - heat_efficency * 0.5 < 0)) //Shouldn't produce gas from nothing.
var/heat_efficiency = min(temperature * ZAUKER_FORMATION_TEMPERATURE_SCALE, cached_gases[/datum/gas/hypernoblium][MOLES] * INVERSE(0.01), cached_gases[/datum/gas/nitrium][MOLES] * INVERSE(0.5))
if (heat_efficiency <= 0 || (cached_gases[/datum/gas/hypernoblium][MOLES] - heat_efficiency * 0.01 < 0 ) || (cached_gases[/datum/gas/nitrium][MOLES] - heat_efficiency * 0.5 < 0)) //Shouldn't produce gas from nothing.
return NO_REACTION

var/old_heat_capacity = air.heat_capacity()
ASSERT_GAS(/datum/gas/zauker, air)
cached_gases[/datum/gas/hypernoblium][MOLES] -= heat_efficency * 0.01
cached_gases[/datum/gas/nitrium][MOLES] -= heat_efficency * 0.5
cached_gases[/datum/gas/zauker][MOLES] += heat_efficency * 0.5
cached_gases[/datum/gas/hypernoblium][MOLES] -= heat_efficiency * 0.01
cached_gases[/datum/gas/nitrium][MOLES] -= heat_efficiency * 0.5
cached_gases[/datum/gas/zauker][MOLES] += heat_efficiency * 0.5

SET_REACTION_RESULTS(heat_efficency * 0.5)
var/energy_used = heat_efficency * ZAUKER_FORMATION_ENERGY
SET_REACTION_RESULTS(heat_efficiency * 0.5)
var/energy_used = heat_efficiency * ZAUKER_FORMATION_ENERGY
var/new_heat_capacity = air.heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
air.temperature = max(((temperature * old_heat_capacity - energy_used) / new_heat_capacity), TCMB)
Expand Down Expand Up @@ -993,18 +1003,18 @@
var/list/cached_gases = air.gases
var/temperature = air.temperature

var/heat_efficency = min(temperature * 0.005, cached_gases[/datum/gas/pluoxium][MOLES] * INVERSE(0.2), cached_gases[/datum/gas/hydrogen][MOLES] * INVERSE(2))
if (heat_efficency <= 0 || (cached_gases[/datum/gas/pluoxium][MOLES] - heat_efficency * 0.2 < 0 ) || (cached_gases[/datum/gas/hydrogen][MOLES] - heat_efficency * 2 < 0)) //Shouldn't produce gas from nothing.
var/heat_efficiency = min(temperature * 0.005, cached_gases[/datum/gas/pluoxium][MOLES] * INVERSE(0.2), cached_gases[/datum/gas/hydrogen][MOLES] * INVERSE(2))
if (heat_efficiency <= 0 || (cached_gases[/datum/gas/pluoxium][MOLES] - heat_efficiency * 0.2 < 0 ) || (cached_gases[/datum/gas/hydrogen][MOLES] - heat_efficiency * 2 < 0)) //Shouldn't produce gas from nothing.
return NO_REACTION

var/old_heat_capacity = air.heat_capacity()
ASSERT_GAS(/datum/gas/proto_nitrate, air)
cached_gases[/datum/gas/hydrogen][MOLES] -= heat_efficency * 2
cached_gases[/datum/gas/pluoxium][MOLES] -= heat_efficency * 0.2
cached_gases[/datum/gas/proto_nitrate][MOLES] += heat_efficency * 2.2
cached_gases[/datum/gas/hydrogen][MOLES] -= heat_efficiency * 2
cached_gases[/datum/gas/pluoxium][MOLES] -= heat_efficiency * 0.2
cached_gases[/datum/gas/proto_nitrate][MOLES] += heat_efficiency * 2.2

SET_REACTION_RESULTS(heat_efficency * 2.2)
var/energy_released = heat_efficency * PN_FORMATION_ENERGY
SET_REACTION_RESULTS(heat_efficiency * 2.2)
var/energy_released = heat_efficiency * PN_FORMATION_ENERGY
var/new_heat_capacity = air.heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
air.temperature = max(((temperature * old_heat_capacity + energy_released) / new_heat_capacity), TCMB)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,30 +89,26 @@ GLOBAL_LIST_INIT(electrolyzer_reactions, electrolyzer_reactions_list())
/datum/electrolyzer_reaction/halon_generation
name = "Halon generation"
id = "halon_generation"
desc = "Production of halon from CO2 and N2O"
desc = "Production of halon from the electrolysis of BZ."
requirements = list(
/datum/gas/carbon_dioxide = MINIMUM_MOLE_COUNT,
/datum/gas/nitrous_oxide = MINIMUM_MOLE_COUNT,
"MAX_TEMP" = 230
/datum/gas/bz = MINIMUM_MOLE_COUNT,
)
factor = list(
/datum/gas/carbon_dioxide = "2 moles of CO2 get consumed",
/datum/gas/nitrous_oxide = "1 mole of N2O gets consumed",
/datum/gas/halon = "1 mole of Halon gets produced",
"Energy" = "300 joules of energy is released per mole",
"Temperature" = "Can only occur under 230 kelvin.",
/datum/gas/bz = "Consumed during reaction.",
/datum/gas/oxygen = "0.2 moles of oxygen gets produced per mole of BZ consumed.",
/datum/gas/halon = "2 moles of Halon gets produced per mole of BZ consumed.",
"Energy" = "91.2321 kJ of thermal energy is released per mole of BZ consumed.",
"Temperature" = "Reaction efficiency is proportional to temperature.",
"Location" = "Can only happen on turfs with an active Electrolyzer.",
)

/datum/electrolyzer_reaction/halon_generation/react(turf/location, datum/gas_mixture/air_mixture, working_power)

var/old_heat_capacity = air_mixture.heat_capacity()
air_mixture.assert_gases(/datum/gas/carbon_dioxide, /datum/gas/nitrous_oxide, /datum/gas/halon)
var/pressure = air_mixture.return_pressure()
var/reaction_efficency = min(1 / ((pressure / (0.5 * ONE_ATMOSPHERE)) * (max(air_mixture.gases[/datum/gas/carbon_dioxide][MOLES] / air_mixture.gases[/datum/gas/nitrous_oxide][MOLES], 1))), air_mixture.gases[/datum/gas/nitrous_oxide][MOLES], air_mixture.gases[/datum/gas/carbon_dioxide][MOLES] * INVERSE(2))
air_mixture.gases[/datum/gas/carbon_dioxide][MOLES] -= reaction_efficency * 2
air_mixture.gases[/datum/gas/nitrous_oxide][MOLES] -= reaction_efficency
air_mixture.gases[/datum/gas/halon][MOLES] += reaction_efficency
air_mixture.assert_gases(/datum/gas/bz, /datum/gas/oxygen, /datum/gas/halon)
var/reaction_efficency = min(air_mixture.gases[/datum/gas/bz][MOLES] * (1 - NUM_E ** (-0.5 * air_mixture.temperature * working_power / FIRE_MINIMUM_TEMPERATURE_TO_EXIST)), air_mixture.gases[/datum/gas/bz][MOLES])
air_mixture.gases[/datum/gas/bz][MOLES] -= reaction_efficency
air_mixture.gases[/datum/gas/oxygen][MOLES] += reaction_efficency * 0.2
air_mixture.gases[/datum/gas/halon][MOLES] += reaction_efficency * 2
var/energy_used = reaction_efficency * HALON_FORMATION_ENERGY
var/new_heat_capacity = air_mixture.heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
Expand Down

0 comments on commit d158971

Please sign in to comment.