mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2026-01-03 14:03:25 +00:00
modified chemical reactions to preserve reagent data across reagents, if it exists. also made possible reactions with multiple products
Signed-off-by: Cael_Aislinn <cael_aislinn@yahoo.com.au>
This commit is contained in:
@@ -225,13 +225,19 @@ datum
|
||||
|
||||
if(total_matching_reagents == total_required_reagents && total_matching_catalysts == total_required_catalysts && matching_container && matching_other)
|
||||
var/multiplier = min(multipliers)
|
||||
|
||||
var/preserved_data
|
||||
for(var/B in C.required_reagents)
|
||||
remove_reagent(B, (multiplier * C.required_reagents[B]), safety = 1)
|
||||
var/result = remove_reagent(B, (multiplier * C.required_reagents[B]), safety = 1)
|
||||
if(result && result != 1)
|
||||
preserved_data = result
|
||||
|
||||
var/created_volume = C.result_amount*multiplier
|
||||
if(C.result)
|
||||
multiplier = max(multiplier, 1) //this shouldnt happen ...
|
||||
add_reagent(C.result, C.result_amount*multiplier)
|
||||
for(var/secondary in C.secondary_results)
|
||||
add_reagent(secondary, C.secondary_results[secondary]*multiplier, preserved_data)
|
||||
|
||||
for(var/mob/M in viewers(4, get_turf(my_atom)) )
|
||||
M << "\blue \icon[my_atom] The solution begins to bubble."
|
||||
@@ -320,11 +326,22 @@ datum
|
||||
|
||||
for(var/A in reagent_list)
|
||||
var/datum/reagent/R = A
|
||||
if(R.id == "blood" && reagent == R.id)
|
||||
if(R.data && data)
|
||||
if(R.data["donor"] != data["donor"])
|
||||
continue
|
||||
|
||||
if (R.id == reagent)
|
||||
|
||||
//handle snowflakes
|
||||
if(R.id == "blood")
|
||||
if(R.data && data)
|
||||
if(R.data["donor"] != data["donor"])
|
||||
continue
|
||||
|
||||
else if(R.id == "ground_rock" || R.id == "density_separated_sample" || R.id == "analysis_sample")
|
||||
if(R.data && data)
|
||||
if(R.data != data)
|
||||
//a researcher mixed up a pair of rock samples, so they lose all the info stored
|
||||
var/datum/geosample/geo_data = R.data
|
||||
geo_data.scrambled = 1
|
||||
|
||||
R.volume += amount
|
||||
update_total()
|
||||
my_atom.on_reagent_change()
|
||||
@@ -371,21 +388,23 @@ datum
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
remove_reagent(var/reagent, var/amount, var/safety)//Added a safety check for the trans_id_to
|
||||
|
||||
if(!isnum(amount)) return 1
|
||||
if(!isnum(amount)) return 0
|
||||
|
||||
for(var/A in reagent_list)
|
||||
var/datum/reagent/R = A
|
||||
if (R.id == reagent)
|
||||
R.volume -= amount
|
||||
var/preserved_data = R.data
|
||||
update_total()
|
||||
// if(!safety)//So it does not handle reactions when it need not to
|
||||
// handle_reactions() this proc only removes reagents from src, no reason to check for reactions since they wont happen
|
||||
my_atom.on_reagent_change()
|
||||
return 0
|
||||
return preserved_data ? preserved_data : 1
|
||||
|
||||
return 1
|
||||
return 0
|
||||
|
||||
has_reagent(var/reagent, var/amount = -1)
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ About the Holder:
|
||||
This proc check all recipes and, on a match, uses them.
|
||||
It will also call the recipe's on_reaction proc (for explosions or w/e).
|
||||
Currently, this proc is automatically called by trans_to.
|
||||
- Modified from the original to preserve reagent data across reactions (originally for xenoarchaeology)
|
||||
|
||||
isolate_reagent(var/reagent)
|
||||
Pass it a reagent id and it will remove all reagents but that one.
|
||||
@@ -85,6 +86,7 @@ About the Holder:
|
||||
|
||||
remove_reagent(var/reagent, var/amount)
|
||||
The exact opposite of the add_reagent proc.
|
||||
- Modified from original to return the reagent's data, in order to preserve reagent data across reactions (originally for xenoarchaeology)
|
||||
|
||||
has_reagent(var/reagent, var/amount)
|
||||
Returns 1 if the holder contains this reagent.
|
||||
|
||||
@@ -4,6 +4,7 @@ datum
|
||||
var/name = null
|
||||
var/id = null
|
||||
var/result = null
|
||||
var/list/secondary_results = new/list()
|
||||
var/list/required_reagents = new/list()
|
||||
var/list/required_catalysts = new/list()
|
||||
|
||||
@@ -21,7 +22,7 @@ datum
|
||||
return
|
||||
|
||||
//I recommend you set the result amount to the total volume of all components.
|
||||
//but obviously that's not mandatory. science!
|
||||
//obviously that's not mandatory though. science!
|
||||
|
||||
explosion_potassium
|
||||
name = "Explosion"
|
||||
@@ -322,13 +323,6 @@ datum
|
||||
required_reagents = list("sodium" = 1, "chlorine" = 1)
|
||||
result_amount = 2
|
||||
|
||||
lithiumsodiumtungstate //LiNa2WO4, not the easiest chem to mix
|
||||
name = "Lithium Sodium Tungstate"
|
||||
id = "lithiumsodiumtungstate"
|
||||
result = "lithiumsodiumtungstate"
|
||||
required_reagents = list("lithium" = 1, "sodium" = 2, "tungsten" = 1, "oxygen" = 4)
|
||||
result_amount = 8
|
||||
|
||||
flash_powder
|
||||
name = "Flash powder"
|
||||
id = "flash_powder"
|
||||
|
||||
Reference in New Issue
Block a user