mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 05:00:55 +01:00
Unit test material checks are now performed on all crafting recipes by default. All stack recipes now transfer mats to the results (#92620)
## About The Pull Request Extends the part of the crafting unit test that ensures consistency between the total mats of the components of a recipe (or rather, the result of said recipe) and a generic instance of the same type as its result, previously only implemented on food recipes. ## Why It's Good For The Game This ensures a degree of consistency with the material composition of various objects in the game. I couldn't do it in the original PR as that one was too big already and it took months to get it merged, and have the relative bugs fixed. Currently a WIP as I slowly deal with the unit test reports. ## Changelog 🆑 refactor: Follow-up to the crafting/material refactor from months ago. All objects crafted with stacks now inherit their mat composition (not necessarily the effects and color) by default, while previously only a few things like chair, sinks and toilets did. Report any object looking or behaving weirdly as a result. fix: The material composition of ammo boxes is no longer a 1/10 of what it's supposed to be. It was a shitty hack to make it harder to recycle empty ammo boxes. Instead, they lose materials as they're emptied now. /🆑
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
var/atom/result = new bake_result
|
||||
if(!item_target.compare_materials(result))
|
||||
var/warning = "custom_materials of [result.type] when baked compared to just spawned don't match"
|
||||
var/what_it_should_be = item_target.get_materials_english_list()
|
||||
var/what_it_should_be = item_target.transcribe_materials_list()
|
||||
stack_trace("[warning]. custom_materials should be [what_it_should_be].")
|
||||
qdel(result)
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
var/list/parts = list()
|
||||
///items, structures and machineries of types that are in this list won't transfer their materials to the result
|
||||
var/list/requirements_mats_blacklist
|
||||
///if set, the materials in this list and their values will be subtracted from the result.
|
||||
var/list/removed_mats
|
||||
///like tool_behaviors but for reagents
|
||||
var/list/chem_catalysts = list()
|
||||
///where it shows up in the crafting UI
|
||||
@@ -102,9 +104,9 @@
|
||||
src.reqs[material] = stack_recipe.req_amount
|
||||
src.category = stack_recipe.category || CAT_MISC
|
||||
src.placement_checks = stack_recipe.placement_checks
|
||||
src.crafting_flags = stack_recipe.crafting_flags
|
||||
|
||||
if(!(stack_recipe.crafting_flags & CRAFT_APPLIES_MATS))
|
||||
requirements_mats_blacklist = list(material) //the item is not intended to have mats :shrug:
|
||||
src.removed_mats = stack_recipe.removed_mats
|
||||
|
||||
/**
|
||||
* Run custom pre-craft checks for this recipe, don't add feedback messages in this because it will spam the client
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
)
|
||||
time = 5 SECONDS
|
||||
category = CAT_CHEMISTRY
|
||||
crafting_flags = parent_type::crafting_flags | CRAFT_SKIP_MATERIALS_PARITY //there are two ways to make a chem bombcore. We go with the first one for mats check
|
||||
|
||||
/datum/crafting_recipe/alcohol_burner
|
||||
name = "Burner (Ethanol)"
|
||||
|
||||
@@ -27,8 +27,9 @@
|
||||
/obj/item/stack/sheet/mineral/bamboo = 20
|
||||
)
|
||||
result = /obj/item/storage/basket
|
||||
crafting_flags = CRAFT_SKIP_MATERIALS_PARITY
|
||||
category = CAT_CONTAINERS
|
||||
crafting_flags = parent_type::crafting_flags | CRAFT_MUST_BE_LEARNED
|
||||
crafting_flags = parent_type::crafting_flags | CRAFT_MUST_BE_LEARNED | CRAFT_SKIP_MATERIALS_PARITY
|
||||
steps = list(
|
||||
"master the art of underwater basketweaving",
|
||||
"be underwater"
|
||||
|
||||
@@ -244,15 +244,30 @@
|
||||
//used to gather the material composition of the utilized requirements to transfer to the result
|
||||
var/list/total_materials = list()
|
||||
var/list/stuff_to_use = get_used_reqs(recipe, crafter, total_materials)
|
||||
|
||||
for(var/mat in recipe.removed_mats)
|
||||
var/to_remove = recipe.removed_mats[mat]
|
||||
var/datum/material/ref_mat = locate(mat) in total_materials
|
||||
if(!ref_mat)
|
||||
continue
|
||||
if(total_materials[ref_mat] < to_remove)
|
||||
total_materials -= ref_mat
|
||||
else
|
||||
total_materials[ref_mat] -= to_remove
|
||||
|
||||
var/atom/result
|
||||
var/turf/craft_turf = get_turf(crafter.loc)
|
||||
var/set_materials = TRUE
|
||||
var/set_materials = !(recipe.crafting_flags & CRAFT_NO_MATERIALS)
|
||||
if(ispath(recipe.result, /turf))
|
||||
result = craft_turf.place_on_top(recipe.result)
|
||||
else if(ispath(recipe.result, /obj/item/stack))
|
||||
var/res_amount = recipe.result_amount || 1
|
||||
//we don't merge the stack right away but try to put it in the hand of the crafter
|
||||
result = new recipe.result(craft_turf, recipe.result_amount || 1, /*merge =*/FALSE)
|
||||
set_materials = FALSE //stacks are bit too complex for it for now, but you're free to change that.
|
||||
if(set_materials)
|
||||
result = new recipe.result(craft_turf, res_amount, /*merge =*/ FALSE, /*mat_override =*/ total_materials, /*mat_amt =*/ 1 / res_amount)
|
||||
set_materials = FALSE //We've already set the materials on init. Don't do it again
|
||||
else
|
||||
result = new recipe.result(craft_turf, res_amount, FALSE)
|
||||
else
|
||||
result = new recipe.result(craft_turf)
|
||||
if(result.atom_storage && recipe.delete_contents)
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
)
|
||||
time = 10 SECONDS
|
||||
category = CAT_EQUIPMENT
|
||||
removed_mats = list(/datum/material/iron = SHEET_MATERIAL_AMOUNT * 2)
|
||||
|
||||
/datum/crafting_recipe/motorized_wheelchair
|
||||
name = "Motorized Wheelchair"
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
desc = "A prototype modular receiver and trigger assembly for a firearm."
|
||||
icon = 'icons/obj/weapons/improvised.dmi'
|
||||
icon_state = "receiver"
|
||||
custom_materials = list(/datum/material/iron = SHEET_MATERIAL_AMOUNT * 5.5, /datum/material/cardboard = SHEET_MATERIAL_AMOUNT)
|
||||
|
||||
/obj/item/weaponcrafting/receiver/create_slapcraft_component()
|
||||
var/static/list/slapcraft_recipe_list = list(/datum/crafting_recipe/pipegun)
|
||||
@@ -28,7 +29,7 @@
|
||||
/obj/item/weaponcrafting/stock
|
||||
name = "rifle stock"
|
||||
desc = "A classic rifle stock that doubles as a grip, roughly carved out of wood."
|
||||
custom_materials = list(/datum/material/wood = SHEET_MATERIAL_AMOUNT * 6)
|
||||
custom_materials = list(/datum/material/wood = SHEET_MATERIAL_AMOUNT * 8)
|
||||
resistance_flags = FLAMMABLE
|
||||
icon = 'icons/obj/weapons/improvised.dmi'
|
||||
icon_state = "riflestock"
|
||||
@@ -68,31 +69,61 @@
|
||||
/obj/item/weaponcrafting/gunkit/nuclear
|
||||
name = "advanced energy gun parts kit (lethal/nonlethal)"
|
||||
desc = "A suitcase containing the necessary gun parts to transform a standard energy gun into an advanced energy gun."
|
||||
custom_materials = list(
|
||||
/datum/material/iron = SHEET_MATERIAL_AMOUNT * 5,
|
||||
/datum/material/glass = SHEET_MATERIAL_AMOUNT,
|
||||
/datum/material/uranium = SHEET_MATERIAL_AMOUNT * 1.5,
|
||||
/datum/material/titanium = HALF_SHEET_MATERIAL_AMOUNT,
|
||||
)
|
||||
|
||||
/obj/item/weaponcrafting/gunkit/tesla
|
||||
name = "tesla cannon parts kit (lethal)"
|
||||
desc = "A suitcase containing the necessary gun parts to construct a tesla cannon around a stabilized flux anomaly. Handle with care."
|
||||
icon_state = "weaponskit_tesla"
|
||||
custom_materials = list(/datum/material/iron = SHEET_MATERIAL_AMOUNT * 5, /datum/material/glass = SHEET_MATERIAL_AMOUNT * 5, /datum/material/silver = SHEET_MATERIAL_AMOUNT * 5)
|
||||
|
||||
/obj/item/weaponcrafting/gunkit/xray
|
||||
name = "x-ray laser gun parts kit (lethal)"
|
||||
desc = "A suitcase containing the necessary gun parts to turn a laser gun into a x-ray laser gun. Do not point most parts directly towards face."
|
||||
custom_materials = list(
|
||||
/datum/material/gold = SHEET_MATERIAL_AMOUNT * 2.5,
|
||||
/datum/material/uranium = SHEET_MATERIAL_AMOUNT * 2,
|
||||
/datum/material/iron = SHEET_MATERIAL_AMOUNT * 2.5,
|
||||
/datum/material/titanium = SHEET_MATERIAL_AMOUNT,
|
||||
/datum/material/bluespace = SHEET_MATERIAL_AMOUNT,
|
||||
)
|
||||
|
||||
/obj/item/weaponcrafting/gunkit/ion
|
||||
name = "ion carbine parts kit (nonlethal/highly destructive/very lethal (silicons))"
|
||||
desc = "A suitcase containing the necessary gun parts to transform a standard laser gun into a ion carbine. Perfect against lockers you don't have access to."
|
||||
custom_materials = list(/datum/material/silver = SHEET_MATERIAL_AMOUNT * 3, /datum/material/iron = SHEET_MATERIAL_AMOUNT * 4, /datum/material/uranium = SHEET_MATERIAL_AMOUNT)
|
||||
|
||||
/obj/item/weaponcrafting/gunkit/temperature
|
||||
name = "temperature gun parts kit (less lethal/very lethal (lizardpeople))"
|
||||
desc = "A suitcase containing the necessary gun parts to transform a standard energy gun into a temperature gun. Fantastic at birthday parties and killing indigenous populations of lizardpeople."
|
||||
custom_materials = list(/datum/material/iron = SHEET_MATERIAL_AMOUNT * 2.5, /datum/material/glass = SMALL_MATERIAL_AMOUNT * 5, /datum/material/silver = SHEET_MATERIAL_AMOUNT * 1.5)
|
||||
|
||||
/obj/item/weaponcrafting/gunkit/beam_rifle
|
||||
name = "\improper Event Horizon anti-existential beam rifle part kit (DOOMSDAY DEVICE, DO NOT CONSTRUCT)"
|
||||
desc = "What fevered minds wrought this terrible construction kit? To create a frame to harness the strange energies that flow through the Spinward Sector towards such horrible acts of violence?"
|
||||
custom_materials = list(
|
||||
/datum/material/iron = SHEET_MATERIAL_AMOUNT * 5,
|
||||
/datum/material/glass =SHEET_MATERIAL_AMOUNT * 2.5,
|
||||
/datum/material/diamond = SHEET_MATERIAL_AMOUNT * 2.5,
|
||||
/datum/material/uranium = SHEET_MATERIAL_AMOUNT * 4,
|
||||
/datum/material/silver = SHEET_MATERIAL_AMOUNT * 2.25,
|
||||
/datum/material/gold = SHEET_MATERIAL_AMOUNT * 2.5,
|
||||
)
|
||||
|
||||
/obj/item/weaponcrafting/gunkit/ebow
|
||||
name = "energy crossbow part kit (less lethal)"
|
||||
desc = "Highly illegal weapons refurbishment kit that allows you to turn the standard proto-kinetic accelerator into a near-duplicate energy crossbow. Almost like the real thing!"
|
||||
custom_materials = list(
|
||||
/datum/material/iron = SHEET_MATERIAL_AMOUNT * 2.5,
|
||||
/datum/material/glass = HALF_SHEET_MATERIAL_AMOUNT * 1.5,
|
||||
/datum/material/uranium = HALF_SHEET_MATERIAL_AMOUNT * 1.5,
|
||||
/datum/material/silver = HALF_SHEET_MATERIAL_AMOUNT * 1.5,
|
||||
)
|
||||
|
||||
/obj/item/weaponcrafting/gunkit/hellgun
|
||||
name = "hellfire laser gun degradation kit (warcrime lethal)"
|
||||
@@ -101,6 +132,7 @@
|
||||
/obj/item/weaponcrafting/gunkit/photon
|
||||
name = "photon cannon parts kit (nonlethal)"
|
||||
desc = "A suitcase containing the necessary gun parts to construct a photon cannon around a stabilized flux anomaly. Harness the power of the sun, in the palms of your hands."
|
||||
custom_materials = list(/datum/material/iron = SHEET_MATERIAL_AMOUNT * 3, /datum/material/glass = SHEET_MATERIAL_AMOUNT * 7, /datum/material/gold = SHEET_MATERIAL_AMOUNT * 5)
|
||||
|
||||
/obj/item/weaponcrafting/gunkit/sks
|
||||
name = "\improper Sakhno SKS semi-automatic rifle parts kit (lethal)"
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
/obj/item/melee/baton/security = 1,
|
||||
)
|
||||
tool_behaviors = list(TOOL_WELDER)
|
||||
crafting_flags = parent_type::crafting_flags | CRAFT_SKIP_MATERIALS_PARITY
|
||||
time = 10 SECONDS
|
||||
category = CAT_WEAPON_MELEE
|
||||
|
||||
@@ -73,6 +74,7 @@
|
||||
/obj/item/melee/baton/telescopic/contractor_baton = 1,
|
||||
)
|
||||
tool_behaviors = list(TOOL_WELDER)
|
||||
crafting_flags = parent_type::crafting_flags | CRAFT_SKIP_MATERIALS_PARITY
|
||||
time = 10 SECONDS
|
||||
category = CAT_WEAPON_MELEE
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
result = /obj/item/stack/sheet/paperframes
|
||||
result_amount = 5
|
||||
category = CAT_STRUCTURE
|
||||
requirements_mats_blacklist = list(/obj/item/stack/sheet/mineral/wood)
|
||||
|
||||
/datum/crafting_recipe/rib
|
||||
name = "Colossal Rib"
|
||||
@@ -118,6 +119,12 @@
|
||||
)
|
||||
tool_behaviors = list(TOOL_SCREWDRIVER, TOOL_WELDER, TOOL_DRILL)
|
||||
time = 30 SECONDS
|
||||
removed_mats = list(
|
||||
/datum/material/alloy/plasteel = SHEET_MATERIAL_AMOUNT * 2,
|
||||
/datum/material/iron = SHEET_MATERIAL_AMOUNT * 1.55,
|
||||
/datum/material/titanium = SHEET_MATERIAL_AMOUNT,
|
||||
/datum/material/glass = SHEET_MATERIAL_AMOUNT,
|
||||
)
|
||||
category = CAT_STRUCTURE
|
||||
|
||||
/datum/crafting_recipe/vault
|
||||
@@ -132,6 +139,14 @@
|
||||
)
|
||||
tool_behaviors = list(TOOL_SCREWDRIVER, TOOL_WELDER, TOOL_DRILL)
|
||||
time = 90 SECONDS
|
||||
removed_mats = list(
|
||||
/datum/material/metalhydrogen = SHEET_MATERIAL_AMOUNT * 5,
|
||||
/datum/material/alloy/plastitanium = SHEET_MATERIAL_AMOUNT * 2,
|
||||
/datum/material/alloy/plasteel = SHEET_MATERIAL_AMOUNT * 2,
|
||||
/datum/material/iron = SHEET_MATERIAL_AMOUNT * 1.5,
|
||||
/datum/material/titanium = SHEET_MATERIAL_AMOUNT,
|
||||
/datum/material/glass = SHEET_MATERIAL_AMOUNT,
|
||||
)
|
||||
category = CAT_STRUCTURE
|
||||
crafting_flags = CRAFT_CHECK_DENSITY | CRAFT_ON_SOLID_GROUND
|
||||
|
||||
@@ -147,4 +162,10 @@
|
||||
tool_behaviors = list(TOOL_SCREWDRIVER, TOOL_WELDER, TOOL_DRILL)
|
||||
time = 90 SECONDS
|
||||
category = CAT_STRUCTURE
|
||||
removed_mats = list(
|
||||
/datum/material/metalhydrogen = SHEET_MATERIAL_AMOUNT * 5,
|
||||
/datum/material/alloy/plastitanium = SHEET_MATERIAL_AMOUNT * 2,
|
||||
/datum/material/iron = SHEET_MATERIAL_AMOUNT,
|
||||
/datum/material/glass = SHEET_MATERIAL_AMOUNT,
|
||||
)
|
||||
crafting_flags = CRAFT_CHECK_DENSITY | CRAFT_ON_SOLID_GROUND
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
tool_behaviors = list(TOOL_SCREWDRIVER, TOOL_WIRECUTTER)
|
||||
reqs = list(/obj/item/clothing/glasses/hud/security/sunglasses = 1)
|
||||
category = CAT_EQUIPMENT
|
||||
crafting_flags = parent_type::crafting_flags | CRAFT_SKIP_MATERIALS_PARITY
|
||||
|
||||
/datum/crafting_recipe/hudsunmed
|
||||
name = "Medical HUDsunglasses"
|
||||
@@ -168,6 +169,7 @@
|
||||
tool_behaviors = list(TOOL_SCREWDRIVER, TOOL_WIRECUTTER)
|
||||
reqs = list(/obj/item/clothing/glasses/hud/health/sunglasses = 1)
|
||||
category = CAT_EQUIPMENT
|
||||
crafting_flags = parent_type::crafting_flags | CRAFT_SKIP_MATERIALS_PARITY
|
||||
|
||||
/datum/crafting_recipe/hudsundiag
|
||||
name = "Diagnostic HUDsunglasses"
|
||||
@@ -186,6 +188,7 @@
|
||||
tool_behaviors = list(TOOL_SCREWDRIVER, TOOL_WIRECUTTER)
|
||||
reqs = list(/obj/item/clothing/glasses/hud/diagnostic/sunglasses = 1)
|
||||
category = CAT_EQUIPMENT
|
||||
crafting_flags = parent_type::crafting_flags | CRAFT_SKIP_MATERIALS_PARITY
|
||||
|
||||
/datum/crafting_recipe/scienceglasses
|
||||
name = "Science Glasses"
|
||||
@@ -204,6 +207,7 @@
|
||||
tool_behaviors = list(TOOL_SCREWDRIVER, TOOL_WIRECUTTER)
|
||||
reqs = list(/obj/item/clothing/glasses/sunglasses/chemical = 1)
|
||||
category = CAT_EQUIPMENT
|
||||
crafting_flags = parent_type::crafting_flags | CRAFT_SKIP_MATERIALS_PARITY
|
||||
|
||||
/datum/crafting_recipe/ghostsheet
|
||||
name = "Ghost Sheet"
|
||||
@@ -539,6 +543,7 @@
|
||||
/obj/item/stack/sheet/mineral/metal_hydrogen = 1,
|
||||
/obj/item/stack/sheet/mineral/zaukerite = 1,
|
||||
)
|
||||
crafting_flags = parent_type::crafting_flags | CRAFT_SKIP_MATERIALS_PARITY // stupid recipe, don't give every atmos gas mask these mats.
|
||||
|
||||
category = CAT_CLOTHING
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
blacklist = list(/obj/item/grown/log/steel)
|
||||
result = /obj/structure/bonfire
|
||||
category = CAT_TOOLS
|
||||
crafting_flags = parent_type::crafting_flags | CRAFT_SKIP_MATERIALS_PARITY
|
||||
|
||||
/datum/crafting_recipe/boneshovel
|
||||
name = "Serrated Bone Shovel"
|
||||
|
||||
@@ -101,6 +101,7 @@
|
||||
tool_behaviors = list(TOOL_SCREWDRIVER)
|
||||
time = 1.2 SECONDS
|
||||
category = CAT_WEAPON_AMMO
|
||||
crafting_flags = CRAFT_SKIP_MATERIALS_PARITY
|
||||
|
||||
/datum/crafting_recipe/trashball
|
||||
name = "Trashball"
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
var/atom/result = new cook_result
|
||||
if(!item_parent.compare_materials(result))
|
||||
var/warning = "custom_materials of [result.type] when grilled compared to just spawned don't match"
|
||||
var/what_it_should_be = item_parent.get_materials_english_list()
|
||||
var/what_it_should_be = item_parent.transcribe_materials_list()
|
||||
stack_trace("[warning]. custom_materials should be [what_it_should_be].")
|
||||
qdel(result)
|
||||
|
||||
|
||||
@@ -377,6 +377,7 @@
|
||||
icon = 'icons/obj/devices/remote.dmi'
|
||||
icon_state = "trapdoor_remote"
|
||||
COOLDOWN_DECLARE(trapdoor_cooldown)
|
||||
custom_materials = list(/datum/material/iron = SMALL_MATERIAL_AMOUNT * 1.5, /datum/material/glass = SMALL_MATERIAL_AMOUNT * 0.5)
|
||||
var/trapdoor_cooldown_time = 2 SECONDS
|
||||
var/obj/item/assembly/trapdoor/internals
|
||||
|
||||
@@ -474,6 +475,7 @@
|
||||
desc = "A kit containing all the parts needed to build a trapdoor. Can only be used on open space."
|
||||
icon = 'icons/obj/weapons/improvised.dmi'
|
||||
icon_state = "kitsuitcase"
|
||||
custom_materials = list(/datum/material/iron = SHEET_MATERIAL_AMOUNT * 6.5, /datum/material/glass = SMALL_MATERIAL_AMOUNT * 2.2)
|
||||
var/in_use = FALSE
|
||||
|
||||
/obj/item/trapdoor_kit/Initialize(mapload)
|
||||
|
||||
Reference in New Issue
Block a user