diff --git a/code/__DEFINES/reagents.dm b/code/__DEFINES/reagents.dm index 6df0514b0a..b43fddadb5 100644 --- a/code/__DEFINES/reagents.dm +++ b/code/__DEFINES/reagents.dm @@ -2,7 +2,9 @@ #define LIQUID 2 #define GAS 3 -#define OPENCONTAINER 4096 // is an open container for chemistry purposes +#define INJECTABLE 1024 //Makes reagents addable through droppers and syringes +#define DRAWABLE 2048 //If a syringe can draw from it +#define OPENCONTAINER 4096 //Is an open container for chemistry purposes #define TRANSPARENT 8192 //Used for non-open containers which you still want to be able to see the reagents off. #define TOUCH 1 //splashing diff --git a/code/game/atoms.dm b/code/game/atoms.dm index efce4523bb..ae7bad7855 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -185,6 +185,19 @@ /atom/proc/is_transparent() return container_type & TRANSPARENT +/atom/proc/is_injectable(allowmobs = TRUE) + if(isliving(src) && allowmobs) + var/mob/living/L = src + return L.can_inject() + if(container_type & OPENCONTAINER) + return TRUE + return container_type & INJECTABLE + +/atom/proc/is_drawable(allowmobs = TRUE) + if(is_injectable(allowmobs)) //Everything that can be injected can also be drawn from, but not vice versa + return TRUE + return container_type & DRAWABLE + /atom/proc/allow_drop() return 1 diff --git a/code/game/objects/items/weapons/cigs_lighters.dm b/code/game/objects/items/weapons/cigs_lighters.dm index 76a44821f6..d3cf4ceb17 100644 --- a/code/game/objects/items/weapons/cigs_lighters.dm +++ b/code/game/objects/items/weapons/cigs_lighters.dm @@ -102,6 +102,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM icon_state = "cigoff" throw_speed = 0.5 item_state = "cigoff" + container_type = INJECTABLE w_class = WEIGHT_CLASS_TINY body_parts_covered = null var/lit = FALSE diff --git a/code/modules/food_and_drinks/food.dm b/code/modules/food_and_drinks/food.dm index 4a05510ff0..9d39e51e63 100644 --- a/code/modules/food_and_drinks/food.dm +++ b/code/modules/food_and_drinks/food.dm @@ -4,6 +4,7 @@ /obj/item/weapon/reagent_containers/food possible_transfer_amounts = list() volume = 50 //Sets the default container amount for all food items. + container_type = INJECTABLE resistance_flags = FLAMMABLE /obj/item/weapon/reagent_containers/food/New() diff --git a/code/modules/reagents/chemistry/readme.dm b/code/modules/reagents/chemistry/readme.md similarity index 81% rename from code/modules/reagents/chemistry/readme.dm rename to code/modules/reagents/chemistry/readme.md index 289748ccc6..f070d36067 100644 --- a/code/modules/reagents/chemistry/readme.dm +++ b/code/modules/reagents/chemistry/readme.md @@ -1,6 +1,6 @@ -/* -NOTE: IF YOU UPDATE THE REAGENT-SYSTEM, ALSO UPDATE THIS README. +**NOTE: IF YOU UPDATE THE REAGENT-SYSTEM, ALSO UPDATE THIS README.** +``` Structure: /////////////////// ////////////////////////// // Mob or object // -------> // Reagents var (datum) // Is a reference to the datum that holds the reagents. /////////////////// ////////////////////////// @@ -12,18 +12,14 @@ Structure: /////////////////// ////////////////////////// V V V reagents (datums) Reagents. I.e. Water , cryoxadone or mercury. +``` +# Random important notes: +An objects on_reagent_change will be called every time the objects reagents change. Useful if you want to update the objects icon etc. -Random important notes: - - An objects on_reagent_change will be called every time the objects reagents change. - Useful if you want to update the objects icon etc. - -About the Holder: - - The holder (reagents datum) is the datum that holds a list of all reagents - currently in the object.It also has all the procs needed to manipulate reagents - +# About the Holder: +The holder (reagents datum) is the datum that holds a list of all reagents currently in the object.It also has all the procs needed to manipulate reagents +``` remove_any(var/amount) This proc removes reagents from the holder until the passed amount is matched. It'll try to remove some of ALL reagents contained. @@ -115,13 +111,11 @@ About the Holder: my_atom This is the atom the holder is 'in'. Useful if you need to find the location. (i.e. for explosions) +``` - -About Reagents: - - Reagents are all the things you can mix and fille in bottles etc. This can be anything from - rejuvs over water to ... iron. Each reagent also has a few procs - i'll explain those below. - +# About Reagents: +Reagents are all the things you can mix and fille in bottles etc. This can be anything from rejuvs over water to ... iron. Each reagent also has a few procs - i'll explain those below. +``` reaction_mob(var/mob/M, var/method=TOUCH) This is called by the holder's reation proc. This version is only called when the reagent @@ -149,9 +143,10 @@ About Reagents: If you dont, the chemical will stay in the mob forever - unless you write your own piece of code to slowly remove it. (Should be pretty easy, 1 line of code) +``` - Important variables: - +## Important variables: +``` holder This variable contains a reference to the holder the chemical is 'in' @@ -173,17 +168,12 @@ About Reagents: This is a hexadecimal color that represents the reagent outside of containers, you define it as "#RRGGBB", or, red green blue. You can also define it using the rgb() proc, which returns a hexadecimal value too. The color is black by default. +``` +A good website for color calculations: http://www.psyclops.com/tools/rgb/ - A good website for color calculations: http://www.psyclops.com/tools/rgb/ - - - - -About Recipes: - - Recipes are simple datums that contain a list of required reagents and a result. - They also have a proc that is called when the recipe is matched. - +# About Recipes: +Recipes are simple datums that contain a list of required reagents and a result. They also have a proc that is called when the recipe is matched. +``` on_reaction(var/datum/reagents/holder, var/created_volume) This proc is called when the recipe is matched. You'll want to add explosions etc here. @@ -219,22 +209,21 @@ About Recipes: required_temp This is the required temperature. +``` - -About the Tools: - - By default, all atom have a reagents var - but its empty. if you want to use an object for the chem. - system you'll need to add something like this in its new proc: - +# About the Tools: +By default, all atom have a reagents var - but its empty. if you want to use an object for the chem. system you'll need to add something like this in its new proc: +``` var/datum/reagents/R = new/datum/reagents(100) <<<<< create a new datum , 100 is the maximum_volume of the new holder datum. reagents = R <<<<< assign the new datum to the objects reagents var R.my_atom = src <<<<< set the holders my_atom to src so that we know where we are. This can also be done by calling a convenience proc: atom/proc/create_reagents(var/max_volume) +``` - Other important stuff: - +## Other important stuff: +``` amount_per_transfer_from_this var This var is mostly used by beakers and bottles. It simply tells us how much to transfer when @@ -248,20 +237,22 @@ About the Tools: transfer code since you will not be able to use the standard tools to manipulate it. -*/ + atom/proc/is_injectable() + Checks if something can be injected to. + If this returns 1, you can use syringes and droppers + to draw from and add to the contents of this object. + + atom/proc/is_drawable() + Checks if something can be drawn from. + If this returns 1, you can use syringes and droppers + to draw from the contents of this object. +``` +# GOON CHEMS README: +Credit goes to Cogwerks, and all the other goonstation coders for the original idea and implementation of this over at goonstation. - - -/* GOON CHEMS README: - - Credit goes to Cogwerks, and all the other goonstation coders - for the original idea and implementation of this over at goonstation. - - THE REQUESTED DON'T PORT LIST: IF YOU PORT THESE THE GOONS WILL MURDER US IN OUR SLEEP SO PLEASE DON'T KTHX - Iamgoofball - Any of the Secret Chems - Goon in-joke chems (Eg. Cat Drugs, Hairgrownium) - Liquid Electricity - Rajajajah - -*/ \ No newline at end of file +- THE REQUESTED DON'T PORT LIST: IF YOU PORT THESE THE GOONS WILL MURDER US IN OUR SLEEP SO PLEASE DON'T KTHX - Iamgoofball +- Any of the Secret Chems +- Goon in-joke chems (Eg. Cat Drugs, Hairgrownium) +- Liquid Electricity +- Rajajajah \ No newline at end of file diff --git a/code/modules/reagents/reagent_containers/dropper.dm b/code/modules/reagents/reagent_containers/dropper.dm index 05c58f5db8..5729945fd3 100644 --- a/code/modules/reagents/reagent_containers/dropper.dm +++ b/code/modules/reagents/reagent_containers/dropper.dm @@ -17,7 +17,7 @@ to_chat(user, "[target] is full.") return - if(!target.is_open_container() && !ismob(target) && !istype(target,/obj/item/weapon/reagent_containers/food) && !istype(target, /obj/item/clothing/mask/cigarette)) //You can inject humans and food but you cant remove the shit. + if(!target.is_injectable()) to_chat(user, "You cannot directly fill [target]!") return @@ -74,7 +74,7 @@ else - if(!target.is_open_container() && !istype(target,/obj/structure/reagent_dispensers)) + if(!target.is_drawable(FALSE)) //No drawing from mobs here to_chat(user, "You cannot directly remove reagents from [target].") return diff --git a/code/modules/reagents/reagent_containers/syringes.dm b/code/modules/reagents/reagent_containers/syringes.dm index f4f6d3a521..5dfa28d711 100644 --- a/code/modules/reagents/reagent_containers/syringes.dm +++ b/code/modules/reagents/reagent_containers/syringes.dm @@ -96,7 +96,7 @@ to_chat(user, "[target] is empty!") return - if(!target.is_open_container() && !istype(target,/obj/structure/reagent_dispensers) && !istype(target,/obj/item/slime_extract)) + if(!target.is_drawable()) to_chat(user, "You cannot directly remove reagents from [target]!") return @@ -112,7 +112,7 @@ to_chat(user, "[src] is empty.") return - if(!target.is_open_container() && !ismob(target) && !istype(target, /obj/item/weapon/reagent_containers/food) && !istype(target, /obj/item/slime_extract) && !istype(target, /obj/item/clothing/mask/cigarette) && !istype(target, /obj/item/weapon/storage/fancy/cigarettes)) + if(!target.is_injectable()) to_chat(user, "You cannot directly fill [target]!") return if(target.reagents.total_volume >= target.reagents.maximum_volume) diff --git a/code/modules/reagents/reagent_dispenser.dm b/code/modules/reagents/reagent_dispenser.dm index b7029ab3ad..9276ff64a9 100644 --- a/code/modules/reagents/reagent_dispenser.dm +++ b/code/modules/reagents/reagent_dispenser.dm @@ -5,6 +5,7 @@ icon_state = "water" density = 1 anchored = 0 + container_type = DRAWABLE pressure_resistance = 2*ONE_ATMOSPHERE obj_integrity = 300 max_integrity = 300 diff --git a/code/modules/research/xenobiology/xenobiology.dm b/code/modules/research/xenobiology/xenobiology.dm index 4c2f1ea100..9093332bd8 100644 --- a/code/modules/research/xenobiology/xenobiology.dm +++ b/code/modules/research/xenobiology/xenobiology.dm @@ -12,6 +12,7 @@ throw_speed = 3 throw_range = 6 origin_tech = "biotech=3" + container_type = INJECTABLE var/Uses = 1 // uses before it goes inert var/qdel_timer = null // deletion timer, for delayed reactions diff --git a/tgstation.dme b/tgstation.dme index 1d854c8f5c..0b6b944260 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1993,7 +1993,6 @@ #include "code\modules\reagents\reagent_dispenser.dm" #include "code\modules\reagents\chemistry\colors.dm" #include "code\modules\reagents\chemistry\holder.dm" -#include "code\modules\reagents\chemistry\readme.dm" #include "code\modules\reagents\chemistry\reagents.dm" #include "code\modules\reagents\chemistry\recipes.dm" #include "code\modules\reagents\chemistry\machinery\chem_dispenser.dm"