From 1dad66101d498eeed8aad73d17f142b631cc0f0e Mon Sep 17 00:00:00 2001 From: TheSmallBlue Date: Tue, 14 Mar 2023 19:36:47 -0300 Subject: [PATCH] All hail The Pickle Jar, harbringer of better crafting (#73939) ## About The Pull Request Fixes #73841 --- _It is the 12th of March, 2023. Around 3am. I have published a Pull Request which involves circuits, and got reminded of my low GBP. I go into the issues tab to see if there's anything someone of my low skill caliber could tackle. I see it; Pickles. "How hard could I be?" I ask myself, foolishly unaware of the dangers that would soon overcome me. Surely it must've been a mistype, I thought. Surely someone accidentally confused pickles and cucumbers. "Wait, the pickles are supposed to be created on the jar when the jar is created", I say foolishly. "Wait, its putting the ingredients used for the jar in the jar, that doesn't explain why the pickles aren't there though", I say foolishly "Wait, whoever tried fixing this earlier fucking qdel'd the beaker and called it a day????", I say, foolishly._ --- Anyways I changed how the crafting menu distincts between categories, instead of checking whether or not the path is for food, it checks the actual categories themselves (why didn't it do this already), meaning that you can have non-food items on the food tab if it has a food category. Did this by adding a list that includes all crafting categories, so in the future when adding new categories you'll have to add them twice, which sucks, but oh well. Also added a new variable to craftable items, which makes it so that you can not delete a container's contents if you so wish (why was this the default). All this so that when you craft pickles, it actually crafts pickles instead of cucumbers. I spent hours on this, its 6:30am as I'm typing this. I'm tired. Fucking pickles. Super duper ultra thanks to FinalPotato for guiding me and suffering with me through this and teaching me so much about DM and BYOND. I cannot emphasize just how helpful and awesome they were thank you thank you thank you <3 ## Why It's Good For The Game Bug fixing be good ## Changelog :cl: fix: The jar of pickles, after millenia, finally actually contains pickles. All hail the jar of pickles. /:cl: --- code/__DEFINES/construction.dm | 48 ++++++++++++++++++- code/__HELPERS/global_lists.dm | 2 +- code/datums/components/crafting/_recipes.dm | 2 + code/datums/components/crafting/crafting.dm | 10 ++-- .../recipes/tablecraft/recipes_misc.dm | 28 +++++------ 5 files changed, 66 insertions(+), 24 deletions(-) diff --git a/code/__DEFINES/construction.dm b/code/__DEFINES/construction.dm index d627e668bed..6ce1810a75d 100644 --- a/code/__DEFINES/construction.dm +++ b/code/__DEFINES/construction.dm @@ -80,7 +80,8 @@ //maximum amount of cable in a coil #define MAXCOIL 30 -//tablecrafting defines +//food/drink crafting defines +//When adding new defines, please make sure to also add them to the encompassing list #define CAT_FOOD "Foods" #define CAT_BREAD "Breads" #define CAT_BURGER "Burgers" @@ -102,7 +103,31 @@ #define CAT_ICE "Frozen" #define CAT_DRINK "Drinks" +GLOBAL_LIST_INIT(crafting_category_food, list( + CAT_FOOD, + CAT_BREAD, + CAT_BURGER, + CAT_CAKE, + CAT_EGG, + CAT_LIZARD, + CAT_MEAT, + CAT_SEAFOOD, + CAT_MISCFOOD, + CAT_MEXICAN, + CAT_MOTH, + CAT_PASTRY, + CAT_PIE, + CAT_PIZZA, + CAT_SALAD, + CAT_SANDWICH, + CAT_SOUP, + CAT_SPAGHETTI, + CAT_ICE, + CAT_DRINK, +)) + //crafting defines +//When adding new defines, please make sure to also add them to the encompassing list #define CAT_WEAPON_RANGED "Weapons Ranged" #define CAT_WEAPON_MELEE "Weapons Melee" #define CAT_WEAPON_AMMO "Weapon Ammo" @@ -122,6 +147,27 @@ #define CAT_TOOLS "Tools" #define CAT_CULT "Blood Cult" +GLOBAL_LIST_INIT(crafting_category, list( + CAT_WEAPON_RANGED, + CAT_WEAPON_MELEE, + CAT_WEAPON_AMMO, + CAT_ROBOT, + CAT_MISC, + CAT_CLOTHING, + CAT_CHEMISTRY, + CAT_ATMOSPHERIC, + CAT_STRUCTURE, + CAT_TILES, + CAT_WINDOWS, + CAT_DOORS, + CAT_FURNITURE, + CAT_EQUIPMENT, + CAT_CONTAINERS, + CAT_ENTERTAINMENT, + CAT_TOOLS, + CAT_CULT, +)) + //rcd modes #define RCD_FLOORWALL 0 #define RCD_AIRLOCK 1 diff --git a/code/__HELPERS/global_lists.dm b/code/__HELPERS/global_lists.dm index a48c0f7ff47..05d6be65214 100644 --- a/code/__HELPERS/global_lists.dm +++ b/code/__HELPERS/global_lists.dm @@ -65,8 +65,8 @@ for(var/path in subtypesof(/datum/crafting_recipe)) if(ispath(path, /datum/crafting_recipe/stack)) continue - var/is_cooking = ispath(path, /datum/crafting_recipe/food/) var/datum/crafting_recipe/recipe = new path() + var/is_cooking = (recipe.category in GLOB.crafting_category_food) recipe.reqs = sort_list(recipe.reqs, GLOBAL_PROC_REF(cmp_crafting_req_priority)) if(recipe.name != "" && recipe.result) if(is_cooking) diff --git a/code/datums/components/crafting/_recipes.dm b/code/datums/components/crafting/_recipes.dm index 5d248b04ba3..9239ac07244 100644 --- a/code/datums/components/crafting/_recipes.dm +++ b/code/datums/components/crafting/_recipes.dm @@ -44,6 +44,8 @@ var/datum/chemical_reaction/reaction /// Resulting amount (for stacks only) var/result_amount + /// Whether we should delete the contents of the crafted storage item (Only works with storage items, used for ammo boxes, donut boxes, internals boxes, etc) + var/delete_contents = TRUE /datum/crafting_recipe/New() if(!(result in reqs)) diff --git a/code/datums/components/crafting/crafting.dm b/code/datums/components/crafting/crafting.dm index b3babfeae88..51f74fd389e 100644 --- a/code/datums/components/crafting/crafting.dm +++ b/code/datums/components/crafting/crafting.dm @@ -77,7 +77,7 @@ for(var/machinery_path in R.machinery) if(!machines[machinery_path])//We don't care for volume with machines, just if one is there or not return FALSE - + for(var/required_structure_path in R.structures) // Check for the presence of the required structure. Allow for subtypes to be used if not blacklisted var/needed_amount = R.structures[required_structure_path] @@ -89,7 +89,7 @@ requirements_list[required_structure_path] = structures[structure_path] // Store an instance of what we are using for check_requirements if(needed_amount <= 0) break - + // We didn't find the required item if(needed_amount > 0) return FALSE @@ -204,7 +204,7 @@ I = new R.result (get_turf(a.loc), R.result_amount || 1) else I = new R.result (get_turf(a.loc)) - if(I.atom_storage) + if(I.atom_storage && R.delete_contents) for(var/obj/item/thing in I) qdel(thing) I.CheckParts(parts, R) @@ -361,8 +361,6 @@ /datum/component/personal_crafting/proc/is_recipe_available(datum/crafting_recipe/recipe, mob/user) if(!recipe.always_available && !(recipe.type in user?.mind?.learned_recipes)) //User doesn't actually know how to make this. return FALSE - if (ispath(recipe.type, /datum/crafting_recipe/food/) != mode) // Skip if food and mode is crafting / Skip if not food and mode is cooking - return FALSE if (recipe.category == CAT_CULT && !IS_CULTIST(user)) // Skip blood cult recipes if not cultist return FALSE return TRUE @@ -563,7 +561,7 @@ data["machinery"] = list() for(var/req_atom as anything in recipe.machinery) data["machinery"] += atoms.Find(req_atom) - + // Structures if(recipe.structures) data["structures"] = list() diff --git a/code/modules/food_and_drinks/recipes/tablecraft/recipes_misc.dm b/code/modules/food_and_drinks/recipes/tablecraft/recipes_misc.dm index 663411be013..263cddc3b84 100644 --- a/code/modules/food_and_drinks/recipes/tablecraft/recipes_misc.dm +++ b/code/modules/food_and_drinks/recipes/tablecraft/recipes_misc.dm @@ -291,22 +291,6 @@ result = /obj/item/food/pacoca category = CAT_MISCFOOD -/datum/crafting_recipe/food/pickles_jar - name = "Jar of pickles" - reqs = list( - /obj/item/reagent_containers/cup/beaker/large = 1, - /obj/item/food/grown/cucumber = 10, - /datum/reagent/water = 10, - /datum/reagent/consumable/salt = 10, - ) - result = /obj/item/storage/fancy/pickles_jar - category = CAT_MISCFOOD - -/datum/crafting_recipe/food/pickles_jar/on_craft_completion(mob/user, atom/result) - . = ..() - var/obj/item/storage/fancy/pickles_jar/jar = result - qdel(locate(/obj/item/reagent_containers/cup/beaker/large) in jar.contents) - /datum/crafting_recipe/food/springroll name = "Spring roll" reqs = list( @@ -412,3 +396,15 @@ ) result = /obj/item/food/bonbon/peanut_butter_cup category = CAT_MISCFOOD + +/datum/crafting_recipe/pickles_jar + name = "Jar of pickles" + reqs = list( + /obj/item/reagent_containers/cup/beaker/large = 1, + /obj/item/food/grown/cucumber = 10, + /datum/reagent/water = 10, + /datum/reagent/consumable/salt = 10, + ) + result = /obj/item/storage/fancy/pickles_jar + category = CAT_MISCFOOD + delete_contents = FALSE