From bc3b0757fcbab84a175aff29236d3507b5e84ba2 Mon Sep 17 00:00:00 2001 From: Cael_Aislinn Date: Wed, 5 Dec 2012 04:46:45 +1000 Subject: [PATCH] added functional bunsen burner (with placeholder sprite), added capability for heated chem recipes, added preservation of data across chemical reactions for xenoarch (not sure if it actually works, seemed a bit buggy), added tungsten as a dispensable reagent for xenoarch Signed-off-by: Cael_Aislinn --- baystation12.dme | 1 + code/modules/reagents/Chemistry-Holder.dm | 37 +++++++++++- code/modules/reagents/Chemistry-Machinery.dm | 21 ++++++- code/modules/reagents/Chemistry-Recipes.dm | 2 + .../reagents/reagent_containers/glass.dm | 4 ++ .../research/xenoarchaeology/archaeo_chem.dm | 11 ++-- .../research/xenoarchaeology/bunsen_burner.dm | 58 +++++++++++++++++++ 7 files changed, 125 insertions(+), 9 deletions(-) create mode 100644 code/modules/research/xenoarchaeology/bunsen_burner.dm diff --git a/baystation12.dme b/baystation12.dme index 5ab7609868a..70310f66450 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -1301,6 +1301,7 @@ #include "code\modules\research\xenoarchaeology\artifact_harvester.dm" #include "code\modules\research\xenoarchaeology\artifact_misc.dm" #include "code\modules\research\xenoarchaeology\artifact_synthetic.dm" +#include "code\modules\research\xenoarchaeology\bunsen_burner.dm" #include "code\modules\research\xenoarchaeology\core_sampler.dm" #include "code\modules\research\xenoarchaeology\finds.dm" #include "code\modules\research\xenoarchaeology\geosample.dm" diff --git a/code/modules/reagents/Chemistry-Holder.dm b/code/modules/reagents/Chemistry-Holder.dm index f73c1797fa4..9065c68d7fb 100644 --- a/code/modules/reagents/Chemistry-Holder.dm +++ b/code/modules/reagents/Chemistry-Holder.dm @@ -204,6 +204,14 @@ datum do reaction_occured = 0 for(var/datum/chemical_reaction/C in chemical_reactions_list) + //check if this recipe needs to be heated to mix + if(C.requires_heating) + if(istype(my_atom.loc, /obj/machinery/bunsen_burner)) + if(!my_atom.loc:heated) + continue + else + continue + var/total_required_reagents = C.required_reagents.len var/total_matching_reagents = 0 var/total_required_catalysts = C.required_catalysts.len @@ -242,7 +250,14 @@ datum if(total_matching_reagents == total_required_reagents && total_matching_catalysts == total_required_catalysts && matching_container && matching_other) var/multiplier = min(multipliers) - for(var/B in C.required_reagents) + //try and grab any data so we can preserve it across reactions + //added for xenoarchaeology, might be used for other things but this is a bit dodge + var/preserved_data = null + for(var/B in src.reagent_list) + if(!preserved_data) + var/temp_data = get_data(B) + if(temp_data) + preserved_data = temp_data remove_reagent(B, (multiplier * C.required_reagents[B]), safety = 1) var/created_volume = C.result_amount*multiplier @@ -250,6 +265,11 @@ datum feedback_add_details("chemical_reaction","[C.result]|[C.result_amount*multiplier]") multiplier = max(multiplier, 1) //this shouldnt happen ... add_reagent(C.result, C.result_amount*multiplier) + set_data(C.result, preserved_data) + + //add secondary products + for(var/S in C.secondary_results) + add_reagent(S, C.result_amount * C.secondary_results[S] * multiplier) if(!isliving(my_atom)) for(var/mob/M in viewers(4, get_turf(my_atom)) ) @@ -442,6 +462,21 @@ datum return res + //two slightly dodge helper functions to preserve data across reactions (needed for xenoarch) + get_data(var/reagent_id) + for(var/R in reagent_list) + var/datum/reagent/D = reagent_list[R] + if(D.id == reagent_id) + world << "proffering a data-carrying reagent ([reagent_id])" + return D.data + + set_data(var/reagent_id, var/new_data) + for(var/R in reagent_list) + var/datum/reagent/D = reagent_list[R] + if(D.id == reagent_id) + world << "reagent data set ([reagent_id])" + D.data = new_data + /////////////////////////////////////////////////////////////////////////////////// diff --git a/code/modules/reagents/Chemistry-Machinery.dm b/code/modules/reagents/Chemistry-Machinery.dm index f8d22288bd5..01eef07caf0 100644 --- a/code/modules/reagents/Chemistry-Machinery.dm +++ b/code/modules/reagents/Chemistry-Machinery.dm @@ -17,7 +17,7 @@ var/recharged = 0 var/list/dispensable_reagents = list("hydrogen","lithium","carbon","nitrogen","oxygen","fluorine", "sodium","aluminum","silicon","phosphorus","sulfur","chlorine","potassium","iron", - "copper","mercury","radium","water","ethanol","sugar","sacid","milk") + "copper","mercury","radium","water","ethanol","sugar","sacid","tungsten","milk") /obj/machinery/chem_dispenser/proc/recharge() if(stat & (BROKEN|NOPOWER)) return @@ -734,6 +734,8 @@ /obj/item/weapon/reagent_containers/food/snacks/grown/wheat = list("flour" = -5), /obj/item/weapon/reagent_containers/food/snacks/grown/cherries = list("cherryjelly" = 0), + //archaeology! + /obj/item/weapon/rocksliver = list("ground_rock" = 50), //All types that you can put into the grinder to transfer the reagents to the beaker. !Put all recipes above this.! @@ -995,7 +997,8 @@ inuse = 1 spawn(60) inuse = 0 - interact(usr) + if(get_dist(usr,src) < 2) + interact(usr) //Snacks and Plants for (var/obj/item/weapon/reagent_containers/food/snacks/O in holdingitems) if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume) @@ -1061,6 +1064,20 @@ break remove_object(O) + //xenoarch + for(var/obj/item/weapon/rocksliver/O in holdingitems) + if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume) + break + var/allowed = get_allowed_by_id(O) + for (var/r_id in allowed) + var/space = beaker.reagents.maximum_volume - beaker.reagents.total_volume + var/amount = allowed[r_id] + beaker.reagents.add_reagent(r_id,min(amount, space), O.geological_data) + + if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume) + break + remove_object(O) + //Everything else - Transfers reagents from it into beaker for (var/obj/item/weapon/reagent_containers/O in holdingitems) if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume) diff --git a/code/modules/reagents/Chemistry-Recipes.dm b/code/modules/reagents/Chemistry-Recipes.dm index b1e972b502d..0c849879d05 100644 --- a/code/modules/reagents/Chemistry-Recipes.dm +++ b/code/modules/reagents/Chemistry-Recipes.dm @@ -13,6 +13,8 @@ datum var/result_amount = 0 var/secondary = 0 // set to nonzero if secondary reaction + var/list/secondary_results = list() //additional reagents produced by the reaction + var/requires_heating = 0 proc on_reaction(var/datum/reagents/holder, var/created_volume) diff --git a/code/modules/reagents/reagent_containers/glass.dm b/code/modules/reagents/reagent_containers/glass.dm index 3a89cef6dd4..5f2db222668 100644 --- a/code/modules/reagents/reagent_containers/glass.dm +++ b/code/modules/reagents/reagent_containers/glass.dm @@ -83,6 +83,10 @@ else if(istype(target, /obj/item/clothing/suit/space/space_ninja)) return + //bunsen burner handles all of this as well + else if(istype(target, /obj/machinery/bunsen_burner)) + return + else if(reagents.total_volume) user << "\blue You splash the solution onto [target]." src.reagents.reaction(target, TOUCH) diff --git a/code/modules/research/xenoarchaeology/archaeo_chem.dm b/code/modules/research/xenoarchaeology/archaeo_chem.dm index 4b81fd774b1..a39120e7864 100644 --- a/code/modules/research/xenoarchaeology/archaeo_chem.dm +++ b/code/modules/research/xenoarchaeology/archaeo_chem.dm @@ -1,6 +1,5 @@ //chemistry stuff here so that it can be easily viewed/modified -/* datum reagent tungsten //used purely to make lith-sodi-tungs @@ -20,18 +19,18 @@ datum ground_rock name = "Ground Rock" id = "ground_rock" - description = "A fine dust made of ground up geological samples." + description = "A fine dust made of ground up rock." reagent_state = SOLID color = "#C81040" //rgb: 200, 16, 64 //todo: make this brown density_separated_sample - name = "Density separated sample" + name = "Analysis sample" id = "density_separated_sample" - description = "A watery paste which has had density separation applied to its contents." + description = "A watery paste used in chemical analysis." reagent_state = LIQUID color = "#C81040" //rgb: 200, 16, 64 - //todo: make this white + //todo: make this browny-white analysis_sample name = "Analysis sample" @@ -57,6 +56,7 @@ datum result = "lithiumsodiumtungstate" required_reagents = list("lithium" = 1, "sodium" = 2, "tungsten" = 1, "oxygen" = 4) result_amount = 8 + requires_heating = 1 density_separated_liquid name = "Density separated sample" @@ -74,4 +74,3 @@ datum required_reagents = list("density_separated_sample" = 5) result_amount = 4 requires_heating = 1 -*/ \ No newline at end of file diff --git a/code/modules/research/xenoarchaeology/bunsen_burner.dm b/code/modules/research/xenoarchaeology/bunsen_burner.dm new file mode 100644 index 00000000000..bbb3d0c9c94 --- /dev/null +++ b/code/modules/research/xenoarchaeology/bunsen_burner.dm @@ -0,0 +1,58 @@ + +/obj/machinery/bunsen_burner + name = "bunsen burner" + desc = "A flat, self-heating device designed for bringing chemical mixtures to boil." + icon = 'icons/obj/device.dmi' + icon_state = "bunsen0" + var/heating = 0 //whether the bunsen is turned on + var/heated = 0 //whether the bunsen has been on long enough to let stuff react + var/obj/item/weapon/reagent_containers/held_container + var/heat_time = 50 + +/obj/machinery/bunsen_burner/attackby(obj/item/weapon/W as obj, mob/user as mob) + if(istype(W, /obj/item/weapon/reagent_containers)) + if(held_container) + user << "\red You must remove the [held_container] first." + else + user.drop_item(src) + held_container = W + held_container.loc = src + user << "\blue You put the [held_container] onto the [src]." + var/image/I = image("icon"=W, "layer"=FLOAT_LAYER) + underlays += I + if(heating) + spawn(heat_time) + try_heating() + else + user << "\red You can't put the [W] onto the [src]." + + + +/obj/machinery/bunsen_burner/attack_hand(mob/user as mob) + if(held_container) + underlays = null + user << "\blue You remove the [held_container] from the [src]." + held_container.loc = src.loc + held_container.attack_hand(user) + held_container = null + else + user << "\red There is nothing on the [src]." + +/obj/machinery/bunsen_burner/proc/try_heating() + if(held_container && heating) + heated = 1 + held_container.reagents.handle_reactions() + heated = 0 + spawn(heat_time) + try_heating() + +/obj/machinery/bunsen_burner/verb/toggle() + set src in oview(1) + set name = "Toggle bunsen burner" + set category = "IC" + + heating = !heating + icon_state = "bunsen[heating]" + if(heating) + spawn(heat_time) + try_heating()