forked from tgstation/tgstation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reaction rates, pH, purity and more! Brings a heavily improved, less …
…explosive and optimised fermichem to tg. (tgstation#56019) Brings a heavily improved, rewritten, and optimised fermichem to tg. I saw that tg seemed receptive to it, so I thought I’d do it myself. If you know of fermichem – there’s a lot changed and improved, so looking at other documents regarding it will not be accurate. Revamps the main chemistry reaction handler to allow for over time reactions instead of instant reactions. This revamp allows for simultaneous reactions, exo/endothermic reactions and pH consuming/producing behaviours. Most of the reactions in game will now inherit an easy one size fits all reaction. Temperature mechanics Temperature affects reaction rate The higher it is, the faster it is, but be careful, as chem reactions will perform special functions when overheated (presently it DOESN’T explode) Temperature will increase or decrease depending on the exo/endothermic nature of the reaction pH mechanics Each reaction requires the pH of a beaker to be within a certain range. If you are outside of the optimal, you'll incur impurity, which has a negative effect on the resultant chem pH of a beaker will change during a reaction Reacting Impure chem effects can vary from chem to chem, but for default will reduce the purity of other reagents in the beaker Consuming an impure chem will either cause liver or tox damage dependant on how impure it is as well as reducing consumed volume Purity can (presently) only be seen with a chemical analyser Impure chems can purposely be made by making the reagent with a low, but not explosive, purity. A chem made under the PurityMin will convert into the reagent’s failed chem in the beaker. Optional catalysts Reactions can use an optional catalyst to influence the reaction - at the more framework exists from tmeprature, reaction rate and pH changes as a result of a catalyst. Catalysts can be set to only work on a specific reagent subtype. It is preferable to those building upon this code that optional catalysts only affect a subsection of reagents. Presently the only catalyst that uses this is Palladium synthate catalyst - a catalyst that increases the reaction speed of medicines. Reaction agents These are reagents that will consume themselves when added to a beaker - even a full one, and apply effects to the total solution. One example being Tempomyocin which will speed up a reaction, or the buffer reagents which change the pH. Competitive reactions These reactions will go towards a certain product depending on the conditions of the holder. The example one given is a little tricky and requires a lot of temperature to push it towards one end. New and charged reactions (see the wiki for details) Acidic /basic buffer - These reagents will adjust the pH of a beaker/solution when added to one. If the beaker is empty it will fill it instead. Tempomyocin - This will instantly speed up any reaction added it is added to, giving it a short burst of speed. Adding this reagent to a reaction will give it a suddent speed boost up to 3x times - with the output purity of the boost modified by the Tempomyocin's purity.5u per 100u will give you 2x, 10 u per 100u will give you 3x. IIt caps at 3x for a single addition, but there is nothing preventing you from adding multiple doses for multiple boosts. Purit tester - this will fizzle if the solution it is added to has an inverse purity reagent present. A few other reactions have been tweaked to make sure they work too. An example being meth - see the wikipage linked above. A note on all reactions The one size fits all reaction for all chems generally won’t create impure chems – it is very forgiving. The only thing to remember is to avoid heating reactions over 900 or you’ll reduce your yield, and try to keep your pH between 5 -9. This PR doesn’t have specific example chems included (except for the buffers) – they will be atomised out and they use the mechanics in more depth A note on plumbing I reached out to Time Green and we worked together to make sure plumbing was fine. Time Green did some of his own tests too, and surprisingly it doesn't look like much needs to be changed.
- Loading branch information
Showing
77 changed files
with
3,913 additions
and
550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//Used for active reactions in reagents/equilibrium datums | ||
|
||
PROCESSING_SUBSYSTEM_DEF(reagents) | ||
name = "Reagents" | ||
init_order = INIT_ORDER_REAGENTS | ||
priority = FIRE_PRIORITY_REAGENTS | ||
wait = 0.25 SECONDS //You might think that rate_up_lim has to be set to half, but since everything is normalised around delta_time, it automatically adjusts it to be per second. Magic! | ||
flags = SS_KEEP_TIMING | ||
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME | ||
///What time was it when we last ticked | ||
var/previous_world_time = 0 | ||
|
||
/datum/controller/subsystem/processing/reagents/Initialize() | ||
. = ..() | ||
//So our first step isn't insane | ||
previous_world_time = world.time | ||
//Build GLOB lists - see holder.dm | ||
build_chemical_reagent_list() | ||
build_chemical_reactions_list() | ||
return | ||
|
||
/datum/controller/subsystem/processing/reagents/fire(resumed = FALSE) | ||
if (!resumed) | ||
currentrun = processing.Copy() | ||
//cache for sanic speed (lists are references anyways) | ||
var/list/current_run = currentrun | ||
|
||
//Attempt to realtime reactions in a way that doesn't make them overtly dangerous | ||
var/delta_realtime = (world.time - previous_world_time)/10 //normalise to s from ds | ||
previous_world_time = world.time | ||
|
||
while(current_run.len) | ||
var/datum/thing = current_run[current_run.len] | ||
current_run.len-- | ||
if(QDELETED(thing)) | ||
stack_trace("Found qdeleted thing in [type], in the current_run list.") | ||
processing -= thing | ||
else if(thing.process(delta_realtime) == PROCESS_KILL) //we are realtime | ||
// fully stop so that a future START_PROCESSING will work | ||
STOP_PROCESSING(src, thing) | ||
if (MC_TICK_CHECK) | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.