diff --git a/code/__defines/_lists.dm b/code/__defines/_lists.dm
index 016d1a89d4f..247e9dfeb0e 100644
--- a/code/__defines/_lists.dm
+++ b/code/__defines/_lists.dm
@@ -32,6 +32,12 @@
// Reads the length of L, returning 0 if null
#define LAZYLEN(L) length(L)
+#define LAZYADDASSOC(L, K, V) if(!L) { L = list(); } L[K] += V;
+///This is used to add onto lazy assoc list when the value you're adding is a /list/. This one has extra safety over lazyaddassoc because the value could be null (and thus cant be used to += objects)
+#define LAZYADDASSOCLIST(L, K, V) if(!L) { L = list(); } L[K] += list(V);
+#define LAZYREMOVEASSOC(L, K, V) if(L) { if(L[K]) { L[K] -= V; if(!length(L[K])) L -= K; } if(!length(L)) L = null; }
+#define LAZYACCESSASSOC(L, I, K) L ? L[I] ? L[I][K] ? L[I][K] : null : null : null
+
// Null-safe L.Cut()
#define LAZYCLEARLIST(L) if(L) L.Cut()
diff --git a/code/__defines/crafting.dm b/code/__defines/crafting.dm
new file mode 100644
index 00000000000..583c5abe467
--- /dev/null
+++ b/code/__defines/crafting.dm
@@ -0,0 +1,27 @@
+//tablecrafting defines
+#define CAT_NONE ""
+#define CAT_WEAPONRY "Weaponry"
+#define CAT_WEAPON "Weapons"
+#define CAT_AMMO "Ammunition"
+#define CAT_ROBOT "Robots"
+#define CAT_MISC "Misc"
+#define CAT_PRIMAL "Tribal"
+#define CAT_CLOTHING "Clothing"
+#define CAT_FOOD "Foods"
+#define CAT_BREAD "Breads"
+#define CAT_BURGER "Burgers"
+#define CAT_CAKE "Cakes"
+#define CAT_EGG "Egg-Based Food"
+#define CAT_MEAT "Meats"
+#define CAT_MISCFOOD "Misc. Food"
+#define CAT_MEXICAN "Mexican Food"
+#define CAT_PASTRY "Pastries"
+#define CAT_PIE "Pies"
+#define CAT_PIZZA "Pizzas"
+#define CAT_SALAD "Salads"
+#define CAT_SANDWICH "Sandwiches"
+#define CAT_SOUP "Soups"
+#define CAT_SPAGHETTI "Spaghettis"
+#define CAT_ICE "Frozen"
+#define CAT_DRINK "Drinks"
+#define CAT_CHEMISTRY "Chemistry"
\ No newline at end of file
diff --git a/code/__defines/dcs/signals.dm b/code/__defines/dcs/signals.dm
index 017c92c9222..c6edaa80e4a 100644
--- a/code/__defines/dcs/signals.dm
+++ b/code/__defines/dcs/signals.dm
@@ -97,6 +97,10 @@
#define COMSIG_ATOM_FIRE_ACT "atom_fire_act"
///from base of atom/bullet_act(): (/obj/projectile, def_zone)
#define COMSIG_ATOM_BULLET_ACT "atom_bullet_act"
+///from base of atom/CheckParts(): (list/parts_list, datum/crafting_recipe/R)
+#define COMSIG_ATOM_CHECKPARTS "atom_checkparts"
+///from base of atom/CheckParts(): (atom/movable/new_craft) - The atom has just been used in a crafting recipe and has been moved inside new_craft.
+#define COMSIG_ATOM_USED_IN_CRAFT "atom_used_in_craft"
///from base of atom/blob_act(): (/obj/structure/blob)
#define COMSIG_ATOM_BLOB_ACT "atom_blob_act"
///from base of atom/acid_act(): (acidpwr, acid_volume)
@@ -732,3 +736,5 @@
///SSalarm signals
#define COMSIG_TRIGGERED_ALARM "ssalarm_triggered"
#define COMSIG_CANCELLED_ALARM "ssalarm_cancelled"
+
+#define COMSIG_REAGENTS_CRAFTING_PING "reagents_crafting_ping"
\ No newline at end of file
diff --git a/code/__defines/tools.dm b/code/__defines/tools.dm
new file mode 100644
index 00000000000..d7b5e1cdba6
--- /dev/null
+++ b/code/__defines/tools.dm
@@ -0,0 +1,21 @@
+// Tool types, if you add new ones please add them to /obj/item/debug/omnitool in code/game/objects/items/debug_items.dm
+#define TOOL_CROWBAR "crowbar"
+#define TOOL_MULTITOOL "multitool"
+#define TOOL_SCREWDRIVER "screwdriver"
+#define TOOL_WIRECUTTER "wirecutter"
+#define TOOL_WRENCH "wrench"
+#define TOOL_WELDER "welder"
+#define TOOL_CABLE_COIL "cablecoil"
+#define TOOL_ANALYZER "analyzer"
+#define TOOL_MINING "mining"
+#define TOOL_SHOVEL "shovel"
+#define TOOL_RETRACTOR "retractor"
+#define TOOL_HEMOSTAT "hemostat"
+#define TOOL_CAUTERY "cautery"
+#define TOOL_DRILL "drill"
+#define TOOL_SCALPEL "scalpel"
+#define TOOL_SAW "saw"
+#define TOOL_BONESET "bonesetter"
+#define TOOL_KNIFE "knife"
+#define TOOL_BLOODFILTER "bloodfilter"
+#define TOOL_ROLLINGPIN "rollingpin"
\ No newline at end of file
diff --git a/code/_global_vars/lists/misc.dm b/code/_global_vars/lists/misc.dm
index 742708face2..ee320056bec 100644
--- a/code/_global_vars/lists/misc.dm
+++ b/code/_global_vars/lists/misc.dm
@@ -8,4 +8,5 @@ GLOBAL_LIST_EMPTY(wire_color_directory) // This is an associative list with the
GLOBAL_LIST_EMPTY(tagger_locations)
GLOBAL_LIST_INIT(char_directory_tags, list("Pred", "Prey", "Switch", "Non-Vore", "Unset"))
-GLOBAL_LIST_INIT(char_directory_erptags, list("Top", "Bottom", "Switch", "No ERP", "Unset"))
\ No newline at end of file
+GLOBAL_LIST_INIT(char_directory_erptags, list("Top", "Bottom", "Switch", "No ERP", "Unset"))
+GLOBAL_LIST_EMPTY(crafting_recipes) //list of all table craft recipes
diff --git a/code/_helpers/_lists.dm b/code/_helpers/_lists.dm
index 124f69f45e3..abe05b5141f 100644
--- a/code/_helpers/_lists.dm
+++ b/code/_helpers/_lists.dm
@@ -416,13 +416,9 @@ This actually tests if they have the same entries and values.
-
-//Mergesort: any value in a list
-/proc/sortList(var/list/L)
- if(L.len < 2)
- return L
- var/middle = L.len / 2 + 1 // Copy is first,second-1
- return mergeLists(sortList(L.Copy(0,middle)), sortList(L.Copy(middle))) //second parameter null = to end of list
+//any value in a list
+/proc/sortList(list/L, cmp=/proc/cmp_text_asc)
+ return sortTim(L.Copy(), cmp)
//Mergsorge: uses sortList() but uses the var's name specifically. This should probably be using mergeAtom() instead
/proc/sortNames(var/list/L)
diff --git a/code/_helpers/global_lists.dm b/code/_helpers/global_lists.dm
index 1c0d5f23932..868f69fde82 100644
--- a/code/_helpers/global_lists.dm
+++ b/code/_helpers/global_lists.dm
@@ -242,6 +242,7 @@ GLOBAL_LIST_EMPTY(mannequins)
var/datum/digest_mode/DM = new T
GLOB.digest_modes[DM.id] = DM
// VOREStation Add End
+ init_crafting_recipes(GLOB.crafting_recipes)
/*
// Custom species traits
@@ -278,8 +279,13 @@ GLOBAL_LIST_EMPTY(mannequins)
return 1 // Hooks must return 1
- return 1
-
+/// Inits the crafting recipe list, sorting crafting recipe requirements in the process.
+/proc/init_crafting_recipes(list/crafting_recipes)
+ for(var/path in subtypesof(/datum/crafting_recipe))
+ var/datum/crafting_recipe/recipe = new path()
+ recipe.reqs = sortList(recipe.reqs, /proc/cmp_crafting_req_priority)
+ crafting_recipes += recipe
+ return crafting_recipes
/* // Uncomment to debug chemical reaction list.
/client/verb/debug_chemical_list()
diff --git a/code/_helpers/sorts/comparators.dm b/code/_helpers/sorts/comparators.dm
index 704042531a2..c192d19008c 100644
--- a/code/_helpers/sorts/comparators.dm
+++ b/code/_helpers/sorts/comparators.dm
@@ -64,4 +64,23 @@
return b_score - a_score
/proc/cmp_typepaths_asc(A, B)
- return sorttext("[B]","[A]")
\ No newline at end of file
+ return sorttext("[B]","[A]")
+
+/**
+ * Sorts crafting recipe requirements before the crafting recipe is inserted into GLOB.crafting_recipes
+ *
+ * Prioritises [/datum/reagent] to ensure reagent requirements are always processed first when crafting.
+ * This prevents any reagent_containers from being consumed before the reagents they contain, which can
+ * lead to runtimes and item duplication when it happens.
+ */
+/proc/cmp_crafting_req_priority(A, B)
+ var/lhs
+ var/rhs
+
+ lhs = ispath(A, /datum/reagent) ? 0 : 1
+ rhs = ispath(B, /datum/reagent) ? 0 : 1
+
+ return lhs - rhs
+
+/proc/cmp_text_asc(a,b)
+ return sorttext(b,a)
diff --git a/code/_helpers/string_lists.dm b/code/_helpers/string_lists.dm
new file mode 100644
index 00000000000..6e2dc2c3180
--- /dev/null
+++ b/code/_helpers/string_lists.dm
@@ -0,0 +1,14 @@
+GLOBAL_LIST_EMPTY(string_lists)
+
+/**
+ * Caches lists with non-numeric stringify-able values (text or typepath).
+ */
+/proc/string_list(list/values)
+ var/string_id = values.Join("-")
+
+ . = GLOB.string_lists[string_id]
+
+ if(.)
+ return
+
+ return GLOB.string_lists[string_id] = values
\ No newline at end of file
diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm
index 0cdda2e9939..076a0d740c2 100644
--- a/code/_onclick/click.dm
+++ b/code/_onclick/click.dm
@@ -18,6 +18,7 @@
/atom/Click(var/location, var/control, var/params) // This is their reaction to being clicked on (standard proc)
if(src)
+ SEND_SIGNAL(src, COMSIG_CLICK, location, control, params, usr)
usr.ClickOn(src, params)
/atom/DblClick(var/location, var/control, var/params)
diff --git a/code/_onclick/hud/_defines.dm b/code/_onclick/hud/_defines.dm
index 247d1d3f8bf..df78fd5df8f 100644
--- a/code/_onclick/hud/_defines.dm
+++ b/code/_onclick/hud/_defines.dm
@@ -187,3 +187,5 @@
#define ui_mech_airtoggle "WEST+1:-7, SOUTH+8"
#define ui_mech_deco1_f "WEST+2:-7, SOUTH+8"
#define ui_mech_deco2_f "WEST+2:-7, SOUTH+9"
+
+#define ui_crafting "EAST-4:22,SOUTH:5"
\ No newline at end of file
diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm
index 5e5f044ac24..d53c44e0f3e 100644
--- a/code/_onclick/hud/screen_objects.dm
+++ b/code/_onclick/hud/screen_objects.dm
@@ -246,6 +246,7 @@
add_overlay(selecting_appearance)
/obj/screen/Click(location, control, params)
+ ..() // why the FUCK was this not called before
if(!usr) return 1
switch(name)
if("toggle")
diff --git a/code/datums/components/crafting/crafting.dm b/code/datums/components/crafting/crafting.dm
new file mode 100644
index 00000000000..4ff5dadb7c0
--- /dev/null
+++ b/code/datums/components/crafting/crafting.dm
@@ -0,0 +1,507 @@
+/datum/component/personal_crafting/Initialize()
+ if(ismob(parent))
+ RegisterSignal(parent, COMSIG_MOB_CLIENT_LOGIN, .proc/create_mob_button)
+
+/datum/component/personal_crafting/proc/create_mob_button(mob/user, client/CL)
+ // SIGNAL_HANDLER
+
+ var/datum/hud/H = user.hud_used
+ var/obj/screen/craft/C = new()
+ C.icon = H.ui_style
+ H.other += C
+ CL.screen += C
+ RegisterSignal(C, COMSIG_CLICK, .proc/component_ui_interact)
+
+/datum/component/personal_crafting
+ var/busy
+ var/viewing_category = 1 //typical powergamer starting on the Weapons tab
+ var/viewing_subcategory = 1
+ var/list/categories = list(
+ CAT_WEAPONRY = list(
+ CAT_WEAPON,
+ CAT_AMMO,
+ ),
+ CAT_ROBOT = CAT_NONE,
+ CAT_MISC = CAT_NONE,
+ CAT_PRIMAL = CAT_NONE,
+ CAT_FOOD = list(
+ CAT_BREAD,
+ CAT_BURGER,
+ CAT_CAKE,
+ CAT_EGG,
+ CAT_ICE,
+ CAT_MEAT,
+ CAT_MISCFOOD,
+ CAT_PASTRY,
+ CAT_PIE,
+ CAT_PIZZA,
+ CAT_SALAD,
+ CAT_SANDWICH,
+ CAT_SOUP,
+ CAT_SPAGHETTI,
+ ),
+ CAT_DRINK = CAT_NONE,
+ CAT_CLOTHING = CAT_NONE,
+ )
+
+ var/cur_category = CAT_NONE
+ var/cur_subcategory = CAT_NONE
+ var/datum/action/innate/crafting/button
+ var/display_craftable_only = FALSE
+ var/display_compact = TRUE
+
+/* This is what procs do:
+ get_environment - gets a list of things accessable for crafting by user
+ get_surroundings - takes a list of things and makes a list of key-types to values-amounts of said type in the list
+ check_contents - takes a recipe and a key-type list and checks if said recipe can be done with available stuff
+ check_tools - takes recipe, a key-type list, and a user and checks if there are enough tools to do the stuff, checks bugs one level deep
+ construct_item - takes a recipe and a user, call all the checking procs, calls do_after, checks all the things again, calls del_reqs, creates result, calls CheckParts of said result with argument being list returned by deel_reqs
+ del_reqs - takes recipe and a user, loops over the recipes reqs var and tries to find everything in the list make by get_environment and delete it/add to parts list, then returns the said list
+*/
+
+/**
+ * Check that the contents of the recipe meet the requirements.
+ *
+ * user: The /mob that initated the crafting.
+ * R: The /datum/crafting_recipe being attempted.
+ * contents: List of items to search for R's reqs.
+ */
+/datum/component/personal_crafting/proc/check_contents(atom/a, datum/crafting_recipe/R, list/contents)
+ var/list/item_instances = contents["instances"]
+ var/list/machines = contents["machinery"]
+ contents = contents["other"]
+
+
+ var/list/requirements_list = list()
+
+ // Process all requirements
+ for(var/requirement_path in R.reqs)
+ // Check we have the appropriate amount available in the contents list
+ var/needed_amount = R.reqs[requirement_path]
+ for(var/content_item_path in contents)
+ // Right path and not blacklisted
+ if(!ispath(content_item_path, requirement_path) || R.blacklist.Find(content_item_path))
+ continue
+
+ needed_amount -= contents[content_item_path]
+ if(needed_amount <= 0)
+ break
+
+ if(needed_amount > 0)
+ return FALSE
+
+ // Store the instances of what we will use for R.check_requirements() for requirement_path
+ var/list/instances_list = list()
+ for(var/instance_path in item_instances)
+ if(ispath(instance_path, requirement_path))
+ instances_list += item_instances[instance_path]
+
+ requirements_list[requirement_path] = instances_list
+
+ for(var/requirement_path in R.chem_catalysts)
+ if(contents[requirement_path] < R.chem_catalysts[requirement_path])
+ return FALSE
+
+ 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
+
+ return R.check_requirements(a, requirements_list)
+
+/datum/component/personal_crafting/proc/get_environment(atom/a, list/blacklist = null, radius_range = 1)
+ . = list()
+
+ if(!isturf(a.loc))
+ return
+
+ for(var/atom/movable/AM in range(radius_range, a))
+ if(/*(AM.flags_1 & HOLOGRAM_1) ||*/ (blacklist && (AM.type in blacklist)))
+ continue
+ . += AM
+
+
+/datum/component/personal_crafting/proc/get_surroundings(atom/a, list/blacklist=null)
+ . = list()
+ .["tool_qualities"] = list()
+ .["other"] = list()
+ .["instances"] = list()
+ .["machinery"] = list()
+ for(var/obj/object in get_environment(a, blacklist))
+ if(isitem(object))
+ var/obj/item/item = object
+ LAZYADDASSOCLIST(.["instances"], item.type, item)
+ if(istype(item, /obj/item/stack))
+ var/obj/item/stack/stack = item
+ .["other"][item.type] += stack.amount
+ else if(item.tool_qualities)
+ .["tool_qualities"] |= item.tool_qualities
+ .["other"][item.type] += 1
+ else
+ if(istype(item, /obj/item/weapon/reagent_containers))
+ var/obj/item/weapon/reagent_containers/container = item
+ // if(container.is_drainable())
+ if(container.is_open_container()) // this isn't exactly the same
+ for(var/datum/reagent/reagent in container.reagents.reagent_list)
+ .["other"][reagent.type] += reagent.volume
+ .["other"][item.type] += 1
+ else if (istype(object, /obj/machinery))
+ LAZYADDASSOCLIST(.["machinery"], object.type, object)
+
+
+
+/// Returns a boolean on whether the tool requirements of the input recipe are satisfied by the input source and surroundings.
+/datum/component/personal_crafting/proc/check_tools(atom/source, datum/crafting_recipe/recipe, list/surroundings)
+ if(!length(recipe.tool_behaviors) && !length(recipe.tool_paths))
+ return TRUE
+ var/list/available_tools = list()
+ var/list/present_qualities = list()
+
+ for(var/obj/item/contained_item in source.contents)
+ // if(contained_item.GetComponent(/datum/component/storage))
+ if(istype(contained_item, /obj/item/weapon/storage)) // cursed
+ for(var/obj/item/subcontained_item in contained_item.contents)
+ available_tools[subcontained_item.type] = TRUE
+ for(var/behavior in subcontained_item.tool_qualities)
+ present_qualities[behavior] = TRUE
+ available_tools[contained_item.type] = TRUE
+ for(var/behavior in contained_item.tool_qualities)
+ present_qualities[behavior] = TRUE
+
+ for(var/quality in surroundings["tool_behaviour"])
+ present_qualities[quality] = TRUE
+
+ for(var/path in surroundings["other"])
+ available_tools[path] = TRUE
+
+ for(var/required_quality in recipe.tool_behaviors)
+ if(present_qualities[required_quality])
+ continue
+ return FALSE
+
+ for(var/required_path in recipe.tool_paths)
+ var/found_this_tool = FALSE
+ for(var/tool_path in available_tools)
+ if(!ispath(required_path, tool_path))
+ continue
+ found_this_tool = TRUE
+ break
+ if(found_this_tool)
+ continue
+ return FALSE
+
+ return TRUE
+
+
+/datum/component/personal_crafting/proc/construct_item(atom/a, datum/crafting_recipe/R)
+ var/list/contents = get_surroundings(a,R.blacklist)
+ // var/send_feedback = 1
+ if(check_contents(a, R, contents))
+ if(check_tools(a, R, contents))
+ if(R.one_per_turf)
+ for(var/content in get_turf(a))
+ if(istype(content, R.result))
+ return ", object already present."
+ //If we're a mob we'll try a do_after; non mobs will instead instantly construct the item
+ if(ismob(a) && !do_after(a, R.time, target = a))
+ return "."
+ contents = get_surroundings(a,R.blacklist)
+ if(!check_contents(a, R, contents))
+ return ", missing component."
+ if(!check_tools(a, R, contents))
+ return ", missing tool."
+ var/list/parts = del_reqs(R, a)
+ var/atom/movable/I = new R.result (get_turf(a.loc))
+ I.CheckParts(parts, R)
+ // if(send_feedback)
+ // SSblackbox.record_feedback("tally", "object_crafted", 1, I.type)
+ return I //Send the item back to whatever called this proc so it can handle whatever it wants to do with the new item
+ return ", missing tool."
+ return ", missing component."
+
+/*Del reqs works like this:
+
+ Loop over reqs var of the recipe
+ Set var amt to the value current cycle req is pointing to, its amount of type we need to delete
+ Get var/surroundings list of things accessable to crafting by get_environment()
+ Check the type of the current cycle req
+ If its reagent then do a while loop, inside it try to locate() reagent containers, inside such containers try to locate needed reagent, if there isn't remove thing from surroundings
+ If there is enough reagent in the search result then delete the needed amount, create the same type of reagent with the same data var and put it into deletion list
+ If there isn't enough take all of that reagent from the container, put into deletion list, substract the amt var by the volume of reagent, remove the container from surroundings list and keep searching
+ While doing above stuff check deletion list if it already has such reagnet, if yes merge instead of adding second one
+ If its stack check if it has enough amount
+ If yes create new stack with the needed amount and put in into deletion list, substract taken amount from the stack
+ If no put all of the stack in the deletion list, substract its amount from amt and keep searching
+ While doing above stuff check deletion list if it already has such stack type, if yes try to merge them instead of adding new one
+ If its anything else just locate() in in the list in a while loop, each find --s the amt var and puts the found stuff in deletion loop
+
+ Then do a loop over parts var of the recipe
+ Do similar stuff to what we have done above, but now in deletion list, until the parts conditions are satisfied keep taking from the deletion list and putting it into parts list for return
+
+ After its done loop over deletion list and delete all the shit that wasn't taken by parts loop
+
+ del_reqs return the list of parts resulting object will receive as argument of CheckParts proc, on the atom level it will add them all to the contents, on all other levels it calls ..() and does whatever is needed afterwards but from contents list already
+*/
+
+/datum/component/personal_crafting/proc/del_reqs(datum/crafting_recipe/R, atom/a)
+ var/list/surroundings
+ var/list/Deletion = list()
+ . = list()
+ var/data
+ var/amt
+ var/list/requirements = list()
+ if(R.reqs)
+ requirements += R.reqs
+ if(R.machinery)
+ requirements += R.machinery
+ main_loop:
+ for(var/path_key in requirements)
+ amt = R.reqs[path_key] || R.machinery[path_key]
+ if(!amt)//since machinery can have 0 aka CRAFTING_MACHINERY_USE - i.e. use it, don't consume it!
+ continue main_loop
+ surroundings = get_environment(a, R.blacklist)
+ surroundings -= Deletion
+ if(ispath(path_key, /datum/reagent))
+ var/datum/reagent/RG = new path_key
+ var/datum/reagent/RGNT
+ while(amt > 0)
+ var/obj/item/weapon/reagent_containers/RC = locate() in surroundings
+ RG = RC.reagents.get_reagent(path_key)
+ if(RG)
+ if(!locate(RG.type) in Deletion)
+ Deletion += new RG.type()
+ if(RG.volume > amt)
+ RG.volume -= amt
+ data = RG.data
+ RC.reagents.conditional_update(RC)
+ RG = locate(RG.type) in Deletion
+ RG.volume = amt
+ RG.data += data
+ continue main_loop
+ else
+ surroundings -= RC
+ amt -= RG.volume
+ RC.reagents.reagent_list -= RG
+ RC.reagents.conditional_update(RC)
+ RGNT = locate(RG.type) in Deletion
+ RGNT.volume += RG.volume
+ RGNT.data += RG.data
+ qdel(RG)
+ SEND_SIGNAL(RC.reagents, COMSIG_REAGENTS_CRAFTING_PING) // - [] TODO: Make this entire thing less spaghetti
+ else
+ surroundings -= RC
+ else if(ispath(path_key, /obj/item/stack))
+ var/obj/item/stack/S
+ var/obj/item/stack/SD
+ while(amt > 0)
+ S = locate(path_key) in surroundings
+ if(S.amount >= amt)
+ if(!locate(S.type) in Deletion)
+ SD = new S.type()
+ Deletion += SD
+ S.use(amt)
+ SD = locate(S.type) in Deletion
+ SD.amount += amt
+ continue main_loop
+ else
+ amt -= S.amount
+ if(!locate(S.type) in Deletion)
+ Deletion += S
+ else
+ data = S.amount
+ S = locate(S.type) in Deletion
+ S.add(data)
+ surroundings -= S
+ else
+ var/atom/movable/I
+ while(amt > 0)
+ I = locate(path_key) in surroundings
+ Deletion += I
+ surroundings -= I
+ amt--
+ var/list/partlist = list(R.parts.len)
+ for(var/M in R.parts)
+ partlist[M] = R.parts[M]
+ for(var/part in R.parts)
+ if(istype(part, /datum/reagent))
+ var/datum/reagent/RG = locate(part) in Deletion
+ if(RG.volume > partlist[part])
+ RG.volume = partlist[part]
+ . += RG
+ Deletion -= RG
+ continue
+ else if(istype(part, /obj/item/stack))
+ var/obj/item/stack/ST = locate(part) in Deletion
+ if(ST.amount > partlist[part])
+ ST.amount = partlist[part]
+ . += ST
+ Deletion -= ST
+ continue
+ else
+ while(partlist[part] > 0)
+ var/atom/movable/AM = locate(part) in Deletion
+ . += AM
+ Deletion -= AM
+ partlist[part] -= 1
+ while(Deletion.len)
+ var/DL = Deletion[Deletion.len]
+ Deletion.Cut(Deletion.len)
+ // Snowflake handling of reagent containers and storage atoms.
+ // If we consumed them in our crafting, we should dump their contents out before qdeling them.
+ if(istype(DL, /obj/item/weapon/reagent_containers))
+ var/obj/item/weapon/reagent_containers/container = DL
+ container.reagents.clear_reagents()
+ // container.reagents.expose(container.loc, TOUCH)
+ else if(istype(DL, /obj/item/weapon/storage))
+ var/obj/item/weapon/storage/container = DL
+ container.spill()
+ container.close_all()
+ qdel(DL)
+
+/datum/component/personal_crafting/proc/component_ui_interact(atom/movable/screen/craft/image, location, control, params, user)
+ // SIGNAL_HANDLER
+
+ if(user == parent)
+ INVOKE_ASYNC(src, .proc/tgui_interact, user)
+
+/datum/component/personal_crafting/tgui_state(mob/user)
+ return GLOB.tgui_not_incapacitated_turf_state
+
+//For the UI related things we're going to assume the user is a mob rather than typesetting it to an atom as the UI isn't generated if the parent is an atom
+/datum/component/personal_crafting/tgui_interact(mob/user, datum/tgui/ui)
+ ui = SStgui.try_update_ui(user, src, ui)
+ if(!ui)
+ cur_category = categories[1]
+ if(islist(categories[cur_category]))
+ var/list/subcats = categories[cur_category]
+ cur_subcategory = subcats[1]
+ else
+ cur_subcategory = CAT_NONE
+ ui = new(user, src, "PersonalCrafting")
+ ui.open()
+
+/datum/component/personal_crafting/tgui_data(mob/user)
+ var/list/data = list()
+ data["busy"] = busy
+ data["category"] = cur_category
+ data["subcategory"] = cur_subcategory
+ data["display_craftable_only"] = display_craftable_only
+ data["display_compact"] = display_compact
+
+ var/list/surroundings = get_surroundings(user)
+ var/list/craftability = list()
+ for(var/rec in GLOB.crafting_recipes)
+ var/datum/crafting_recipe/R = rec
+
+ if(!R.always_available && !(R.type in user?.mind?.learned_recipes)) //User doesn't actually know how to make this.
+ continue
+
+ if((R.category != cur_category) || (R.subcategory != cur_subcategory))
+ continue
+
+ craftability["[REF(R)]"] = check_contents(user, R, surroundings)
+
+ data["craftability"] = craftability
+ return data
+
+/datum/component/personal_crafting/tgui_static_data(mob/user)
+ var/list/data = list()
+
+ var/list/crafting_recipes = list()
+ for(var/rec in GLOB.crafting_recipes)
+ var/datum/crafting_recipe/R = rec
+
+ if(R.name == "") //This is one of the invalid parents that sneaks in
+ continue
+
+ if(!R.always_available && !(R.type in user?.mind?.learned_recipes)) //User doesn't actually know how to make this.
+ continue
+
+ if(isnull(crafting_recipes[R.category]))
+ crafting_recipes[R.category] = list()
+
+ if(R.subcategory == CAT_NONE)
+ crafting_recipes[R.category] += list(build_recipe_data(R))
+ else
+ if(isnull(crafting_recipes[R.category][R.subcategory]))
+ crafting_recipes[R.category][R.subcategory] = list()
+ crafting_recipes[R.category]["has_subcats"] = TRUE
+ crafting_recipes[R.category][R.subcategory] += list(build_recipe_data(R))
+
+ data["crafting_recipes"] = crafting_recipes
+ return data
+
+/datum/component/personal_crafting/tgui_act(action, params)
+ . = ..()
+ if(.)
+ return
+ switch(action)
+ if("make")
+ var/mob/user = usr
+ var/datum/crafting_recipe/TR = locate(params["recipe"]) in GLOB.crafting_recipes
+ busy = TRUE
+ tgui_interact(user)
+ var/atom/movable/result = construct_item(user, TR)
+ if(!istext(result)) //We made an item and didn't get a fail message
+ if(ismob(user) && isitem(result)) //In case the user is actually possessing a non mob like a machine
+ user.put_in_hands(result)
+ else
+ result.forceMove(user.drop_location())
+ to_chat(user, "[TR.name] constructed.")
+ TR.on_craft_completion(user, result)
+ else
+ to_chat(user, "Construction failed[result]")
+ busy = FALSE
+ if("toggle_recipes")
+ display_craftable_only = !display_craftable_only
+ . = TRUE
+ if("toggle_compact")
+ display_compact = !display_compact
+ . = TRUE
+ if("set_category")
+ cur_category = params["category"]
+ cur_subcategory = params["subcategory"] || ""
+ . = TRUE
+
+/datum/component/personal_crafting/proc/build_recipe_data(datum/crafting_recipe/R)
+ var/list/data = list()
+ data["name"] = R.name
+ data["ref"] = "[REF(R)]"
+ var/list/req_text = list()
+ var/list/tool_list = list()
+ var/list/catalyst_text = list()
+
+ for(var/atom/req_atom as anything in R.reqs)
+ //We just need the name, so cheat-typecast to /atom for speed (even tho Reagents are /datum they DO have a "name" var)
+ //Also these are typepaths so sadly we can't just do "[a]"
+ req_text += "[R.reqs[req_atom]] [initial(req_atom.name)]"
+ for(var/obj/machinery/content as anything in R.machinery)
+ req_text += "[R.reqs[content]] [initial(content.name)]"
+ if(R.additional_req_text)
+ req_text += R.additional_req_text
+ data["req_text"] = req_text.Join(", ")
+
+ for(var/atom/req_catalyst as anything in R.chem_catalysts)
+ catalyst_text += "[R.chem_catalysts[req_catalyst]] [initial(req_catalyst.name)]"
+ data["catalyst_text"] = catalyst_text.Join(", ")
+
+ for(var/required_quality in R.tool_behaviors)
+ tool_list += required_quality
+ for(var/obj/item/required_path as anything in R.tool_paths)
+ tool_list += initial(required_path.name)
+ data["tool_text"] = tool_list.Join(", ")
+
+ return data
+
+//Mind helpers
+
+/datum/mind/proc/teach_crafting_recipe(R)
+ if(!learned_recipes)
+ learned_recipes = list()
+ learned_recipes |= R
+
+// Screen objects
+/obj/screen/craft
+ name = "crafting menu"
+ icon = 'icons/mob/screen/midnight.dmi'
+ icon_state = "craft"
+ screen_loc = ui_crafting
\ No newline at end of file
diff --git a/code/datums/components/crafting/crafting_external.dm b/code/datums/components/crafting/crafting_external.dm
new file mode 100644
index 00000000000..e40d5011329
--- /dev/null
+++ b/code/datums/components/crafting/crafting_external.dm
@@ -0,0 +1,34 @@
+/**
+ * Ensure a list of atoms/reagents exists inside this atom
+ *
+ * Goes throught he list of passed in parts, if they're reagents, adds them to our reagent holder
+ * creating the reagent holder if it exists.
+ *
+ * If the part is a moveable atom and the previous location of the item was a mob/living,
+ * it calls the inventory handler transferItemToLoc for that mob/living and transfers the part
+ * to this atom
+ *
+ * Otherwise it simply forceMoves the atom into this atom
+ */
+/atom/proc/CheckParts(list/parts_list, datum/crafting_recipe/R)
+ SEND_SIGNAL(src, COMSIG_ATOM_CHECKPARTS, parts_list, R)
+ if(parts_list)
+ for(var/A in parts_list)
+ if(istype(A, /datum/reagent))
+ if(!reagents)
+ reagents = new()
+ reagents.reagent_list.Add(A)
+ reagents.conditional_update()
+ else if(ismovable(A))
+ var/atom/movable/M = A
+ if(isliving(M.loc))
+ var/mob/living/L = M.loc
+ L.unEquip(M, target = src)
+ else
+ M.forceMove(src)
+ SEND_SIGNAL(M, COMSIG_ATOM_USED_IN_CRAFT, src)
+ parts_list.Cut()
+
+/obj/machinery/CheckParts(list/parts_list)
+ ..()
+ RefreshParts()
\ No newline at end of file
diff --git a/code/datums/components/crafting/recipes.dm b/code/datums/components/crafting/recipes.dm
new file mode 100644
index 00000000000..5d4cd12c613
--- /dev/null
+++ b/code/datums/components/crafting/recipes.dm
@@ -0,0 +1,56 @@
+///If the machine is used/deleted in the crafting process
+#define CRAFTING_MACHINERY_CONSUME 1
+///If the machine is only "used" i.e. it checks to see if it's nearby and allows crafting, but doesn't delete it
+#define CRAFTING_MACHINERY_USE 0
+
+/datum/crafting_recipe
+ var/name = "" //in-game display name
+ var/list/reqs = list() //type paths of items consumed associated with how many are needed
+ var/list/blacklist = list() //type paths of items explicitly not allowed as an ingredient
+ var/result //type path of item resulting from this craft
+ /// String defines of items needed but not consumed. Lazy list.
+ var/list/tool_behaviors
+ /// Type paths of items needed but not consumed. Lazy list.
+ var/list/tool_paths
+ var/time = 30 //time in deciseconds
+ var/list/parts = list() //type paths of items that will be placed in the result
+ var/list/chem_catalysts = list() //like tool_behaviors but for reagents
+ var/category = CAT_NONE //where it shows up in the crafting UI
+ var/subcategory = CAT_NONE
+ var/always_available = TRUE //Set to FALSE if it needs to be learned first.
+ /// Additonal requirements text shown in UI
+ var/additional_req_text
+ ///Required machines for the craft, set the assigned value of the typepath to CRAFTING_MACHINERY_CONSUME or CRAFTING_MACHINERY_USE. Lazy associative list: type_path key -> flag value.
+ var/list/machinery
+ ///Should only one object exist on the same turf?
+ var/one_per_turf = FALSE
+
+/datum/crafting_recipe/New()
+ if(!(result in reqs))
+ blacklist += result
+ if(tool_behaviors)
+ tool_behaviors = string_list(tool_behaviors)
+ if(tool_paths)
+ tool_paths = string_list(tool_paths)
+
+/**
+ * Run custom pre-craft checks for this recipe
+ *
+ * user: The /mob that initiated the crafting
+ * collected_requirements: A list of lists of /obj/item instances that satisfy reqs. Top level list is keyed by requirement path.
+ */
+/datum/crafting_recipe/proc/check_requirements(mob/user, list/collected_requirements)
+ return TRUE
+
+/datum/crafting_recipe/proc/on_craft_completion(mob/user, atom/result)
+ return
+
+/datum/crafting_recipe/stunprod
+ name = "Stunprod"
+ result = /obj/item/weapon/melee/baton/cattleprod
+ reqs = list(/obj/item/weapon/handcuffs/cable = 1,
+ /obj/item/stack/rods = 1,
+ /obj/item/weapon/tool/wirecutters = 1)
+ time = 40
+ category = CAT_WEAPONRY
+ subcategory = CAT_WEAPON
\ No newline at end of file
diff --git a/code/datums/components/crafting/tool_quality.dm b/code/datums/components/crafting/tool_quality.dm
new file mode 100644
index 00000000000..119469310a7
--- /dev/null
+++ b/code/datums/components/crafting/tool_quality.dm
@@ -0,0 +1,29 @@
+/obj/item
+ var/list/tool_qualities
+
+/// Used to check for a specific tool quality on an item.
+/// Returns TRUE or FALSE depending on whether `tool_quality` is found.
+/obj/item/proc/has_tool_quality(tool_quality)
+ return !!LAZYFIND(tool_qualities, tool_quality)
+
+/* Legacy Support */
+
+/// DEPRECATED PROC: DO NOT USE IN NEW CODE
+/obj/item/proc/is_screwdriver()
+ return has_tool_quality(TOOL_SCREWDRIVER)
+
+/// DEPRECATED PROC: DO NOT USE IN NEW CODE
+/obj/item/proc/is_wrench()
+ return has_tool_quality(TOOL_WRENCH)
+
+/// DEPRECATED PROC: DO NOT USE IN NEW CODE
+/obj/item/proc/is_crowbar()
+ return has_tool_quality(TOOL_CROWBAR)
+
+/// DEPRECATED PROC: DO NOT USE IN NEW CODE
+/obj/item/proc/is_wirecutter()
+ return has_tool_quality(TOOL_WIRECUTTER)
+
+/// DEPRECATED PROC: DO NOT USE IN NEW CODE
+/obj/item/proc/is_multitool()
+ return has_tool_quality(TOOL_MULTITOOL)
diff --git a/code/datums/mind.dm b/code/datums/mind.dm
index 82e5f1f78bd..c8897514754 100644
--- a/code/datums/mind.dm
+++ b/code/datums/mind.dm
@@ -58,6 +58,7 @@
var/list/purchase_log = new
var/used_TC = 0
+ var/list/learned_recipes //List of learned recipe TYPES.
// the world.time since the mob has been brigged, or -1 if not at all
var/brigged_since = -1
diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm
index 21775d0403c..3dfef3a98cd 100644
--- a/code/game/objects/items.dm
+++ b/code/game/objects/items.dm
@@ -908,31 +908,6 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.
/obj/item/proc/apply_accessories(var/image/standing)
return standing
-/*
- * Assorted tool procs, so any item can emulate any tool, if coded
-*/
-/obj/item/proc/is_screwdriver()
- return FALSE
-
-/obj/item/proc/is_wrench()
- return FALSE
-
-/obj/item/proc/is_crowbar()
- return FALSE
-
-/obj/item/proc/is_wirecutter()
- return FALSE
-
-// These next three might bug out or runtime, unless someone goes back and finds a way to generalize their specific code
-/obj/item/proc/is_cable_coil()
- return FALSE
-
-/obj/item/proc/is_multitool()
- return FALSE
-
-/obj/item/proc/is_welder()
- return FALSE
-
/obj/item/MouseEntered(location,control,params)
. = ..()
if(usr.is_preference_enabled(/datum/client_preference/inv_tooltips) && ((src in usr) || isstorage(loc))) // If in inventory or in storage we're looking at
diff --git a/code/game/objects/items/devices/multitool.dm b/code/game/objects/items/devices/multitool.dm
index 8ac7a071996..5cd2faf2d5c 100644
--- a/code/game/objects/items/devices/multitool.dm
+++ b/code/game/objects/items/devices/multitool.dm
@@ -29,6 +29,7 @@
var/obj/machinery/connectable //Used to connect machinery.
var/weakref_wiring //Used to store weak references for integrated circuitry. This is now the Omnitool.
toolspeed = 1
+ tool_qualities = list(TOOL_MULTITOOL)
/obj/item/device/multitool/attack_self(mob/living/user)
var/choice = alert("What do you want to do with \the [src]?","Multitool Menu", "Switch Mode", "Clear Buffers", "Cancel")
@@ -65,9 +66,6 @@
return
-/obj/item/device/multitool/is_multitool()
- return TRUE
-
/obj/item/device/multitool/cyborg
name = "multitool"
desc = "Optimised and stripped-down version of a regular multitool."
diff --git a/code/game/objects/items/weapons/handcuffs.dm b/code/game/objects/items/weapons/handcuffs.dm
index 0f7405096dc..1dca4b4caf6 100644
--- a/code/game/objects/items/weapons/handcuffs.dm
+++ b/code/game/objects/items/weapons/handcuffs.dm
@@ -176,17 +176,6 @@ var/last_chew = 0
/obj/item/weapon/handcuffs/cable/white
color = "#FFFFFF"
-/obj/item/weapon/handcuffs/cable/attackby(var/obj/item/I, mob/user as mob)
- ..()
- if(istype(I, /obj/item/stack/rods))
- var/obj/item/stack/rods/R = I
- if (R.use(1))
- var/obj/item/weapon/material/wirerod/W = new(get_turf(user))
- user.put_in_hands(W)
- to_chat(user, "You wrap the cable restraint around the top of the rod.")
- qdel(src)
- update_icon(user)
-
/obj/item/weapon/handcuffs/cyborg
dispenser = 1
diff --git a/code/game/objects/items/weapons/improvised_components.dm b/code/game/objects/items/weapons/improvised_components.dm
index bfd059f74d6..928a7c1a5d2 100644
--- a/code/game/objects/items/weapons/improvised_components.dm
+++ b/code/game/objects/items/weapons/improvised_components.dm
@@ -38,33 +38,3 @@
qdel(W)
qdel(src)
return
-
-/obj/item/weapon/material/wirerod
- name = "wired rod"
- desc = "A rod with some wire wrapped around the top. It'd be easy to attach something to the top bit."
- icon_state = "wiredrod"
- item_state = "rods"
- force = 8
- throwforce = 10
- w_class = ITEMSIZE_NORMAL
- attack_verb = list("hit", "bludgeoned", "whacked", "bonked")
- force_divisor = 0.1
- thrown_force_divisor = 0.1
-
-/obj/item/weapon/material/wirerod/attackby(var/obj/item/I, mob/user as mob)
- ..()
- var/obj/item/finished
- if(istype(I, /obj/item/weapon/material/shard) || istype(I, /obj/item/weapon/material/butterflyblade))
- var/obj/item/weapon/material/tmp_shard = I
- finished = new /obj/item/weapon/material/twohanded/spear(get_turf(user), tmp_shard.material.name)
- to_chat(user, "You fasten \the [I] to the top of the rod with the cable.")
- else if(I.is_wirecutter())
- finished = new /obj/item/weapon/melee/baton/cattleprod(get_turf(user))
- to_chat(user, "You fasten the wirecutters to the top of the rod with the cable, prongs outward.")
- if(finished)
- user.drop_from_inventory(src)
- user.drop_from_inventory(I)
- qdel(I)
- qdel(src)
- user.put_in_hands(finished)
- update_icon(user)
\ No newline at end of file
diff --git a/code/game/objects/items/weapons/tools/crowbar.dm b/code/game/objects/items/weapons/tools/crowbar.dm
index f1ff2dd642f..de84168ddf7 100644
--- a/code/game/objects/items/weapons/tools/crowbar.dm
+++ b/code/game/objects/items/weapons/tools/crowbar.dm
@@ -20,9 +20,7 @@
drop_sound = 'sound/items/drop/crowbar.ogg'
pickup_sound = 'sound/items/pickup/crowbar.ogg'
toolspeed = 1
-
-/obj/item/weapon/tool/crowbar/is_crowbar()
- return TRUE
+ tool_qualities = list(TOOL_CROWBAR)
/obj/item/weapon/tool/crowbar/red
icon = 'icons/obj/tools.dmi'
diff --git a/code/game/objects/items/weapons/tools/screwdriver.dm b/code/game/objects/items/weapons/tools/screwdriver.dm
index 6ea222b6ac5..5252aa63ba1 100644
--- a/code/game/objects/items/weapons/tools/screwdriver.dm
+++ b/code/game/objects/items/weapons/tools/screwdriver.dm
@@ -21,6 +21,7 @@
attack_verb = list("stabbed")
sharp = 1
toolspeed = 1
+ tool_qualities = list(TOOL_SCREWDRIVER)
var/random_color = TRUE
/obj/item/weapon/tool/screwdriver/suicide_act(mob/user)
@@ -67,10 +68,6 @@
M = user
return eyestab(M,user)
-/obj/item/weapon/tool/screwdriver/is_screwdriver()
- return TRUE
-
-
/datum/category_item/catalogue/anomalous/precursor_a/alien_screwdriver
name = "Precursor Alpha Object - Hard Light Torgue Tool"
desc = "This appears to be a tool, with a solid handle, and a thin hard light \
diff --git a/code/game/objects/items/weapons/tools/wirecutters.dm b/code/game/objects/items/weapons/tools/wirecutters.dm
index 1ef130e13f8..36459852ef2 100644
--- a/code/game/objects/items/weapons/tools/wirecutters.dm
+++ b/code/game/objects/items/weapons/tools/wirecutters.dm
@@ -22,6 +22,7 @@
sharp = 1
edge = 1
toolspeed = 1
+ tool_qualities = list(TOOL_WIRECUTTER)
var/random_color = TRUE
/obj/item/weapon/tool/wirecutters/New()
@@ -43,10 +44,6 @@
else
..()
-/obj/item/weapon/tool/wirecutters/is_wirecutter()
- return TRUE
-
-
/datum/category_item/catalogue/anomalous/precursor_a/alien_wirecutters
name = "Precursor Alpha Object - Wire Seperator"
desc = "An object appearing to have a tool shape. It has two handles, and two \
diff --git a/code/game/objects/items/weapons/tools/wrench.dm b/code/game/objects/items/weapons/tools/wrench.dm
index 300a3c8c6b8..220ddb667da 100644
--- a/code/game/objects/items/weapons/tools/wrench.dm
+++ b/code/game/objects/items/weapons/tools/wrench.dm
@@ -17,9 +17,7 @@
toolspeed = 1
drop_sound = 'sound/items/drop/wrench.ogg'
pickup_sound = 'sound/items/pickup/wrench.ogg'
-
-/obj/item/weapon/tool/wrench/is_wrench()
- return TRUE
+ tool_qualities = list(TOOL_WRENCH)
/obj/item/weapon/tool/wrench/cyborg
name = "automatic wrench"
diff --git a/code/game/objects/random/misc.dm b/code/game/objects/random/misc.dm
index f7a3b499331..5b160c1b905 100644
--- a/code/game/objects/random/misc.dm
+++ b/code/game/objects/random/misc.dm
@@ -266,7 +266,6 @@
prob(4);/obj/item/weapon/material/butterfly,
prob(6);/obj/item/weapon/material/butterflyblade,
prob(6);/obj/item/weapon/material/butterflyhandle,
- prob(6);/obj/item/weapon/material/wirerod,
prob(2);/obj/item/weapon/material/butterfly/switchblade,
prob(2);/obj/item/clothing/gloves/knuckledusters,
prob(1);/obj/item/weapon/material/knife/tacknife,
diff --git a/code/game/objects/structures/loot_piles.dm b/code/game/objects/structures/loot_piles.dm
index 01069b8e234..55ebb62b1ad 100644
--- a/code/game/objects/structures/loot_piles.dm
+++ b/code/game/objects/structures/loot_piles.dm
@@ -255,7 +255,6 @@ Loot piles can be depleted, if loot_depleted is turned on. Note that players wh
/obj/item/stack/material/cardboard{amount = 5},
/obj/item/weapon/contraband/poster,
/obj/item/weapon/contraband/poster/custom,
- /obj/item/weapon/material/wirerod,
/obj/item/weapon/newspaper,
/obj/item/weapon/paper/crumpled,
/obj/item/weapon/paper/crumpled/bloody
diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm
index b351c3d79be..1e4a40eedbd 100644
--- a/code/modules/mob/living/carbon/human/human.dm
+++ b/code/modules/mob/living/carbon/human/human.dm
@@ -53,6 +53,7 @@
sync_organ_dna()
//verbs |= /mob/living/proc/toggle_selfsurgery //VOREStation Removal
+ AddComponent(/datum/component/personal_crafting)
/mob/living/carbon/human/Destroy()
human_mob_list -= src
diff --git a/code/modules/mob/login.dm b/code/modules/mob/login.dm
index d6f04cd0d59..1c1321a715d 100644
--- a/code/modules/mob/login.dm
+++ b/code/modules/mob/login.dm
@@ -44,6 +44,7 @@
disconnect_time = null //VOREStation Addition: clear the disconnect time
sight |= SEE_SELF
..()
+ SEND_SIGNAL(src, COMSIG_MOB_LOGIN)
if(loc && !isturf(loc))
client.eye = loc
@@ -81,4 +82,5 @@
update_client_z(T.z)
if(cloaked && cloaked_selfimage)
- client.images += cloaked_selfimage
\ No newline at end of file
+ client.images += cloaked_selfimage
+ SEND_SIGNAL(src, COMSIG_MOB_CLIENT_LOGIN, client)
\ No newline at end of file
diff --git a/code/modules/projectiles/broken.dm b/code/modules/projectiles/broken.dm
index f972d1f6bdb..f46f7f34e50 100644
--- a/code/modules/projectiles/broken.dm
+++ b/code/modules/projectiles/broken.dm
@@ -80,7 +80,7 @@
material_needs[component_needed] = rand(1,3)
if(ispath(my_guntype, /obj/item/weapon/gun/launcher) && prob(50))
- var/component_needed = pick(/obj/item/weapon/tape_roll, /obj/item/weapon/material/wirerod)
+ var/component_needed = pick(/obj/item/weapon/tape_roll, /obj/item/stack/rods, /obj/item/weapon/handcuffs/cable)
material_needs[component_needed] = 1
if(ispath(my_guntype, /obj/item/weapon/gun/magnetic) && prob(70))
diff --git a/code/modules/projectiles/guns/modular_guns.dm b/code/modules/projectiles/guns/modular_guns.dm
index 4eb990c0cae..f384c7975d0 100644
--- a/code/modules/projectiles/guns/modular_guns.dm
+++ b/code/modules/projectiles/guns/modular_guns.dm
@@ -37,7 +37,8 @@
CheckParts()
FireModeModify()
-/obj/item/weapon/gun/energy/modular/proc/CheckParts() //What parts do we have inside us, and how good are they?
+/obj/item/weapon/gun/energy/modular/CheckParts() //What parts do we have inside us, and how good are they?
+ ..()
capacitor_rating = 0
laser_rating = 0
manipulator_rating = 0
diff --git a/code/modules/reagents/holder/holder.dm b/code/modules/reagents/holder/holder.dm
index 923ffb6bc97..cdb602ad70b 100644
--- a/code/modules/reagents/holder/holder.dm
+++ b/code/modules/reagents/holder/holder.dm
@@ -516,4 +516,16 @@
trans_to(M, mobportion, multiplier, copy)
trans_to(T, total_volume, multiplier, copy)
if (total_volume <= 0)
- qdel(src)
\ No newline at end of file
+ qdel(src)
+
+/**
+ * Calls [/datum/reagent/proc/on_update] on every reagent in this holder
+ *
+ * Arguments:
+ * * atom/A - passed to on_update
+ */
+/datum/reagents/proc/conditional_update(atom/A)
+ var/list/cached_reagents = reagent_list
+ for(var/datum/reagent/reagent as anything in cached_reagents)
+ reagent.on_update(A)
+ update_total()
diff --git a/code/modules/reagents/reagents/_reagents.dm b/code/modules/reagents/reagents/_reagents.dm
index 00bb509b7f6..9ab8b125daa 100644
--- a/code/modules/reagents/reagents/_reagents.dm
+++ b/code/modules/reagents/reagents/_reagents.dm
@@ -235,3 +235,7 @@
/datum/reagent/proc/reaction_mob(var/mob/target)
touch_mob(target)
+
+/// Called by [/datum/reagents/proc/conditional_update]
+/datum/reagent/proc/on_update(atom/A)
+ return
diff --git a/icons/mob/screen/midnight.dmi b/icons/mob/screen/midnight.dmi
index 842554a84bb..b1f37cb2239 100644
Binary files a/icons/mob/screen/midnight.dmi and b/icons/mob/screen/midnight.dmi differ
diff --git a/tgui/packages/tgui/interfaces/PersonalCrafting.js b/tgui/packages/tgui/interfaces/PersonalCrafting.js
new file mode 100644
index 00000000000..c59cd5ead32
--- /dev/null
+++ b/tgui/packages/tgui/interfaces/PersonalCrafting.js
@@ -0,0 +1,187 @@
+import { useBackend, useLocalState } from '../backend';
+import { Button, Dimmer, Flex, Icon, LabeledList, Section, Tabs } from '../components';
+import { Window } from '../layouts';
+
+export const PersonalCrafting = (props, context) => {
+ const { act, data } = useBackend(context);
+ const {
+ busy,
+ display_craftable_only,
+ display_compact,
+ } = data;
+ const crafting_recipes = data.crafting_recipes || {};
+ // Sort everything into flat categories
+ const categories = [];
+ const recipes = [];
+ for (let category of Object.keys(crafting_recipes)) {
+ const subcategories = crafting_recipes[category];
+ if ('has_subcats' in subcategories) {
+ for (let subcategory of Object.keys(subcategories)) {
+ if (subcategory === 'has_subcats') {
+ continue;
+ }
+ // Push category
+ categories.push({
+ name: subcategory,
+ category,
+ subcategory,
+ });
+ // Push recipes
+ const _recipes = subcategories[subcategory];
+ for (let recipe of _recipes) {
+ recipes.push({
+ ...recipe,
+ category: subcategory,
+ });
+ }
+ }
+ continue;
+ }
+ // Push category
+ categories.push({
+ name: category,
+ category,
+ });
+ // Push recipes
+ const _recipes = crafting_recipes[category];
+ for (let recipe of _recipes) {
+ recipes.push({
+ ...recipe,
+ category,
+ });
+ }
+ }
+ // Sort out the tab state
+ const [tab, setTab] = useLocalState(
+ context, 'tab', categories[0]?.name);
+ const shownRecipes = recipes
+ .filter(recipe => recipe.category === tab);
+ return (
+
+
+ {!!busy && (
+
+
+ {' Crafting...'}
+
+ )}
+
+ act('toggle_compact')} />
+ act('toggle_recipes')} />
+ >
+ )}>
+
+
+
+ {categories.map(category => (
+ {
+ setTab(category.name);
+ act('set_category', {
+ category: category.category,
+ subcategory: category.subcategory,
+ });
+ }}>
+ {category.name}
+
+ ))}
+
+
+
+
+
+
+
+
+
+ );
+};
+
+const CraftingList = (props, context) => {
+ const {
+ craftables = [],
+ } = props;
+ const { act, data } = useBackend(context);
+ const {
+ craftability = {},
+ display_compact,
+ display_craftable_only,
+ } = data;
+ return craftables.map(craftable => {
+ if (display_craftable_only && !craftability[craftable.ref]) {
+ return null;
+ }
+ // Compact display
+ if (display_compact) {
+ return (
+ act('make', {
+ recipe: craftable.ref,
+ })} />
+ )}>
+ {craftable.req_text}
+
+ );
+ }
+ // Full display
+ return (
+ act('make', {
+ recipe: craftable.ref,
+ })} />
+ )}>
+
+ {!!craftable.req_text && (
+
+ {craftable.req_text}
+
+ )}
+ {!!craftable.catalyst_text && (
+
+ {craftable.catalyst_text}
+
+ )}
+ {!!craftable.tool_text && (
+
+ {craftable.tool_text}
+
+ )}
+
+
+ );
+ });
+};
diff --git a/vorestation.dme b/vorestation.dme
index e834755c4ab..0a6152d8732 100644
--- a/vorestation.dme
+++ b/vorestation.dme
@@ -40,6 +40,7 @@
#include "code\__defines\chemistry_vr.dm"
#include "code\__defines\color.dm"
#include "code\__defines\construction.dm"
+#include "code\__defines\crafting.dm"
#include "code\__defines\damage_organs.dm"
#include "code\__defines\dna.dm"
#include "code\__defines\exosuit_fab.dm"
@@ -90,6 +91,7 @@
#include "code\__defines\tgs.config.dm"
#include "code\__defines\tgs.dm"
#include "code\__defines\tgui.dm"
+#include "code\__defines\tools.dm"
#include "code\__defines\turfs.dm"
#include "code\__defines\typeids.dm"
#include "code\__defines\unit_tests.dm"
@@ -133,6 +135,7 @@
#include "code\_helpers\names.dm"
#include "code\_helpers\sanitize_values.dm"
#include "code\_helpers\storage.dm"
+#include "code\_helpers\string_lists.dm"
#include "code\_helpers\text.dm"
#include "code\_helpers\text_vr.dm"
#include "code\_helpers\time.dm"
@@ -338,6 +341,10 @@
#include "code\datums\autolathe\tools_vr.dm"
#include "code\datums\components\_component.dm"
#include "code\datums\components\resize_guard.dm"
+#include "code\datums\components\crafting\crafting.dm"
+#include "code\datums\components\crafting\crafting_external.dm"
+#include "code\datums\components\crafting\recipes.dm"
+#include "code\datums\components\crafting\tool_quality.dm"
#include "code\datums\elements\_element.dm"
#include "code\datums\game_masters\_common.dm"
#include "code\datums\helper_datums\construction_datum.dm"