mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
ChemLab 13 update:
- In containers where there isn't a perfect ratio of reagents, reactions won't consume ALL of the related reagents (so if you mix 10 anti-toxin with 20 inaprovaline, you get 10 tricordrazine and 10 inaprovaline rather then just 10 tricodrazine). - NOTE TO CODERS: I couldn't find a clean way around this (and this is true with the old code) but if two reactions are possible with a given combination of reagents, the one listed first in Chemistry-Recipes.dm reacts first. However, it's been changed so that if there are reactions X and Y (in that order) and Y makes a reagent required in X, you'll still get reaction X (before, reaction X would just be ignored). I guess this is a semi-bugfix. - New reaction variable: required_catalysts. Catalysts are reagents required for a reaction to occur. However, unlike required_reagents, catalysts are NOT consumed as part of the reaction. A few reactions were changed as a result and more might be in the future. If coders want some but not all of a catalyst to be consumed in a reaction, just have the reagent appear in both required_reagents and required_catalysts. It won't break anything. - Because of the addition of catalysts, all recipes that require Universal Enzyme now require 5 units of the enzyme but the enzyme isn't consumed (So Tofu, Cheese, Moonshine, Wine, Vodka, and Kahlua recipes). - Sterilzine reaction now works properly (it's anti_toxin, not anti-toxin). git-svn-id: http://tgstation13.googlecode.com/svn/trunk@1578 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
@@ -156,33 +156,42 @@ datum
|
||||
handle_reactions()
|
||||
if(my_atom.flags & NOREACT) return //Yup, no reactions here. No siree.
|
||||
|
||||
for(var/A in typesof(/datum/chemical_reaction) - /datum/chemical_reaction)
|
||||
var/datum/chemical_reaction/C = new A()
|
||||
var/total_required_reagents = C.required_reagents.len
|
||||
var/total_matching_reagents = 0
|
||||
var/list/multipliers = new/list()
|
||||
var/reaction_occured = 0
|
||||
do
|
||||
reaction_occured = 0
|
||||
for(var/A in typesof(/datum/chemical_reaction) - /datum/chemical_reaction)
|
||||
var/datum/chemical_reaction/C = new A()
|
||||
var/total_required_reagents = C.required_reagents.len
|
||||
var/total_matching_reagents = 0
|
||||
var/total_required_catalysts = C.required_catalysts.len
|
||||
var/total_matching_catalysts= 0
|
||||
var/list/multipliers = new/list()
|
||||
|
||||
for(var/B in C.required_reagents)
|
||||
if(has_reagent(B, C.required_reagents[B]))
|
||||
total_matching_reagents++
|
||||
multipliers += round(get_reagent_amount(B) / C.required_reagents[B])
|
||||
|
||||
if(total_matching_reagents == total_required_reagents)
|
||||
var/multiplier = min(multipliers)
|
||||
for(var/B in C.required_reagents)
|
||||
del_reagent(B)
|
||||
if(has_reagent(B, C.required_reagents[B]))
|
||||
total_matching_reagents++
|
||||
multipliers += round(get_reagent_amount(B) / C.required_reagents[B])
|
||||
for(var/B in C.required_catalysts)
|
||||
if(has_reagent(B, C.required_catalysts[B]))
|
||||
total_matching_catalysts++
|
||||
|
||||
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)
|
||||
if(total_matching_reagents == total_required_reagents && total_matching_catalysts == total_required_catalysts)
|
||||
var/multiplier = min(multipliers)
|
||||
for(var/B in C.required_reagents)
|
||||
remove_reagent(B, (multiplier * C.required_reagents[B]), safety = 1)
|
||||
|
||||
for(var/mob/M in viewers(4, get_turf(my_atom)) )
|
||||
M << "\blue \icon[my_atom] The solution begins to bubble."
|
||||
playsound(get_turf(my_atom), 'bubbles.ogg', 80, 1)
|
||||
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)
|
||||
|
||||
C.on_reaction(src, created_volume)
|
||||
for(var/mob/M in viewers(4, get_turf(my_atom)) )
|
||||
M << "\blue \icon[my_atom] The solution begins to bubble."
|
||||
playsound(get_turf(my_atom), 'bubbles.ogg', 80, 1)
|
||||
|
||||
C.on_reaction(src, created_volume)
|
||||
reaction_occured = 1
|
||||
while(reaction_occured)
|
||||
update_total()
|
||||
return 0
|
||||
|
||||
|
||||
@@ -189,6 +189,12 @@ About Recipes:
|
||||
of that reagent. The handle_reaction proc can detect mutiples of the same recipes
|
||||
so for most cases you want to set the required amount to 1.
|
||||
|
||||
required_catalysts (Added May 2011)
|
||||
This is a list of the ids of the required catalysts.
|
||||
Functionally similar to required_reagents, it is a list of reagents that are required
|
||||
for the reaction. However, unlike required_reagents, catalysts are NOT consumed.
|
||||
They mearly have to be present in the container.
|
||||
|
||||
result_amount
|
||||
This is the amount of the resulting reagent this recipe will produce.
|
||||
I recommend you set this to the total volume of all required reagent.
|
||||
|
||||
@@ -5,6 +5,7 @@ datum
|
||||
var/id = null
|
||||
var/result = null
|
||||
var/list/required_reagents = new/list()
|
||||
var/list/required_catalysts = new/list()
|
||||
var/result_amount = 0
|
||||
|
||||
proc
|
||||
@@ -46,7 +47,7 @@ datum
|
||||
name = "Sterilizine"
|
||||
id = "sterilizine"
|
||||
result = "sterilizine"
|
||||
required_reagents = list("ethanol" = 1, "anti-toxin" = 1, "chlorine" = 1)
|
||||
required_reagents = list("ethanol" = 1, "anti_toxin" = 1, "chlorine" = 1)
|
||||
result_amount = 3
|
||||
|
||||
inaprovaline
|
||||
@@ -497,7 +498,8 @@ datum
|
||||
name = "Tofu"
|
||||
id = "tofu"
|
||||
result = null
|
||||
required_reagents = list("soymilk" = 10, "enzyme" = 2)
|
||||
required_reagents = list("soymilk" = 10)
|
||||
required_catalysts = list("enzyme" = 5)
|
||||
result_amount = 1
|
||||
on_reaction(var/datum/reagents/holder, var/created_volume)
|
||||
var/location = get_turf(holder.my_atom)
|
||||
@@ -516,27 +518,14 @@ datum
|
||||
name = "Cheesewheel"
|
||||
id = "cheesewheel"
|
||||
result = null
|
||||
required_reagents = list("milk" = 40, "enzyme" = 2)
|
||||
required_reagents = list("milk" = 40)
|
||||
required_catalysts = list("enzyme" = 5)
|
||||
result_amount = 1
|
||||
on_reaction(var/datum/reagents/holder, var/created_volume)
|
||||
var/location = get_turf(holder.my_atom)
|
||||
new /obj/item/weapon/reagent_containers/food/snacks/sliceable/cheesewheel(location)
|
||||
return
|
||||
|
||||
icetea
|
||||
name = "Iced Tea"
|
||||
id = "icetea"
|
||||
result = "icetea"
|
||||
required_reagents = list("ice" = 1, "tea" = 3)
|
||||
result_amount = 4
|
||||
|
||||
icecoffee
|
||||
name = "Iced Coffee"
|
||||
id = "icecoffee"
|
||||
result = "icecoffee"
|
||||
required_reagents = list("ice" = 1, "coffee" = 3)
|
||||
result_amount = 4
|
||||
|
||||
hot_ramen
|
||||
name = "Hot Ramen"
|
||||
id = "hot_ramen"
|
||||
@@ -554,34 +543,51 @@ datum
|
||||
|
||||
////////////////////////////////////////// COCKTAILS //////////////////////////////////////
|
||||
|
||||
icetea
|
||||
name = "Iced Tea"
|
||||
id = "icetea"
|
||||
result = "icetea"
|
||||
required_reagents = list("ice" = 1, "tea" = 3)
|
||||
result_amount = 4
|
||||
|
||||
icecoffee
|
||||
name = "Iced Coffee"
|
||||
id = "icecoffee"
|
||||
result = "icecoffee"
|
||||
required_reagents = list("ice" = 1, "coffee" = 3)
|
||||
result_amount = 4
|
||||
|
||||
moonshine
|
||||
name = "Moonshine"
|
||||
id = "moonshine"
|
||||
result = "moonshine"
|
||||
required_reagents = list("nutriment" = 10, "enzyme" = 2)
|
||||
required_reagents = list("nutriment" = 10)
|
||||
required_catalysts = list("enzyme" = 5)
|
||||
result_amount = 5
|
||||
|
||||
wine
|
||||
name = "Wine"
|
||||
id = "wine"
|
||||
result = "wine"
|
||||
required_reagents = list("berryjuice" = 10, "enzyme" = 2)
|
||||
required_reagents = list("berryjuice" = 10)
|
||||
required_catalysts = list("enzyme" = 5)
|
||||
result_amount = 5
|
||||
|
||||
vodka
|
||||
name = "Vodka"
|
||||
id = "vodka"
|
||||
result = "vodka"
|
||||
required_reagents = list("potato" = 10, "enzyme" = 2)
|
||||
required_reagents = list("potato" = 10)
|
||||
required_catalysts = list("enzyme" = 5)
|
||||
result_amount = 5
|
||||
|
||||
kahlua
|
||||
name = "Kahlua"
|
||||
id = "kahlua"
|
||||
result = "kahlua"
|
||||
required_reagents = list("coffee" = 5, "sugar" = 5, "enzyme" = 2)
|
||||
|
||||
|
||||
required_reagents = list("coffee" = 5, "sugar" = 5)
|
||||
required_catalysts = list("enzyme" = 5)
|
||||
result_amount = 5
|
||||
|
||||
gin_tonic
|
||||
name = "Gin and Tonic"
|
||||
|
||||
Reference in New Issue
Block a user