Merge pull request #11025 from VOREStation/Arokha/crafty

Fix crafting menu, add plant fiber crafting things
This commit is contained in:
Aronai Sieyes
2021-07-11 15:15:34 -04:00
committed by GitHub
12 changed files with 97 additions and 18 deletions
+1
View File
@@ -34,6 +34,7 @@
#define MAT_CHITIN "chitin"
#define MAT_CLOTH "cloth"
#define MAT_SYNCLOTH "syncloth"
#define MAT_FIBERS "fibers"
#define MAT_COPPER "copper"
#define MAT_QUARTZ "quartz"
#define MAT_TIN "tin"
+18 -1
View File
@@ -49,6 +49,7 @@
var/datum/action/innate/crafting/button
var/display_craftable_only = FALSE
var/display_compact = TRUE
var/tgui_category_hint
/* This is what procs do:
get_environment - gets a list of things accessable for crafting by user
@@ -357,7 +358,7 @@
container.close_all()
qdel(DL)
/datum/component/personal_crafting/proc/component_ui_interact(/obj/screen/craft/image, location, control, params, user)
/datum/component/personal_crafting/proc/component_ui_interact(source, location, control, params, user)
// SIGNAL_HANDLER
if(user == parent)
@@ -380,6 +381,18 @@
ui.open()
/datum/component/personal_crafting/tgui_data(mob/user)
// ANNOYING. We won't know what category will be on top (and thus first selected) in the UI
// until we crunch all the resources in tgui_static_data. So it just sets a hint and we
// consume it and set the category on the first UI open
if(tgui_category_hint)
cur_category = tgui_category_hint
tgui_category_hint = null
if(islist(categories[cur_category]))
var/list/subcats = categories[cur_category]
cur_subcategory = subcats[1]
else
cur_subcategory = CAT_NONE
var/list/data = list()
data["busy"] = busy
data["category"] = cur_category
@@ -411,6 +424,7 @@
var/datum/crafting_recipe/R = rec
if(R.name == "") //This is one of the invalid parents that sneaks in
GLOB.crafting_recipes -= rec
continue
if(!R.always_available && !(R.type in user?.mind?.learned_recipes)) //User doesn't actually know how to make this.
@@ -427,6 +441,9 @@
crafting_recipes[R.category]["has_subcats"] = TRUE
crafting_recipes[R.category][R.subcategory] += list(build_recipe_data(R))
if(crafting_recipes.len)
tgui_category_hint = crafting_recipes[1]
data["crafting_recipes"] = crafting_recipes
return data
+4 -11
View File
@@ -5,7 +5,10 @@
/datum/crafting_recipe
var/name = "" //in-game display name
var/list/reqs = list() //type paths of items consumed associated with how many are needed
/// type paths of items consumed associated with how many are needed
/// Note that stacks have special handling: the logic accounts for having '23' available
/// in the case of just having one stack of 23 amount, so stack/steel = 23 is fine
var/list/reqs = list()
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.
@@ -44,13 +47,3 @@
/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
@@ -0,0 +1,13 @@
/datum/crafting_recipe/cloth
name = "Cloth bolt"
result = /obj/item/stack/material/cloth
reqs = list(/obj/item/stack/material/fiber = 3)
time = 40
category = CAT_PRIMAL
/datum/crafting_recipe/crude_bandage
name = "Crude bandages (x10)"
result = /obj/item/stack/medical/crude_pack
reqs = list(/obj/item/stack/material/cloth = 2)
time = 40
category = CAT_PRIMAL
@@ -0,0 +1,9 @@
/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
+20 -4
View File
@@ -15,6 +15,7 @@
var/harvest_tool = null // The type of item used to harvest the plant.
var/harvest_count = 0
var/destroy_on_harvest = FALSE
var/randomize_harvest_count = TRUE
var/max_harvests = 0
@@ -53,6 +54,8 @@
else
to_chat(user, "<span class='notice'>You harvest \the [AM] from \the [src].</span>")
if(harvest_count >= max_harvests && destroy_on_harvest)
qdel(src)
return
..(W, user)
@@ -66,11 +69,12 @@
/obj/structure/flora/proc/spawn_harvest(var/path = null, var/mob/user = null)
if(!ispath(path))
return 0
var/turf/Target = get_turf(src)
var/atom/movable/AM = new path()
if(user)
Target = get_turf(user)
var/atom/movable/AM = new path(Target)
user.put_in_hands(AM)
else
AM.forceMove(drop_location())
harvest_count++
return AM
@@ -80,6 +84,12 @@
name = "bush"
icon = 'icons/obj/flora/snowflora.dmi'
icon_state = "snowbush1"
destroy_on_harvest = TRUE
harvest_tool = /obj/item/weapon/material/knife
randomize_harvest_count = FALSE
harvest_loot = list(/obj/item/stack/material/fiber = 1)
max_harvests = 1
/obj/structure/flora/bush/New()
..()
@@ -99,6 +109,12 @@
name = "bush"
icon = 'icons/obj/flora/ausflora.dmi'
icon_state = "firstbush_1"
destroy_on_harvest = TRUE
harvest_tool = /obj/item/weapon/material/knife
randomize_harvest_count = FALSE
harvest_loot = list(/obj/item/stack/material/fiber = 1)
max_harvests = 1
/obj/structure/flora/ausbushes/New()
..()
@@ -104,6 +104,10 @@
name = "stack of cloth"
type_to_spawn = /obj/item/stack/material/cloth
/obj/fiftyspawner/fiber
name = "stack of plant fibers"
type_to_spawn = /obj/item/stack/material/fiber
/obj/fiftyspawner/cardboard
name = "stack of cardboard"
type_to_spawn = /obj/item/stack/material/cardboard
@@ -123,4 +123,17 @@
ignition_point = T0C+232
melting_point = T0C+300
protectiveness = 1 // 4%
conductive = 0
conductive = 0
/datum/material/fibers
name = MAT_FIBERS
display_name = "plant"
sheet_singular_name = "fiber"
sheet_singular_name = "fibers"
icon_colour = "#006b0e"
flags = MATERIAL_PADDING
ignition_point = T0C+232
melting_point = T0C+300
protectiveness = 1 // 4%
conductive = 0
pass_stack_colors = TRUE
@@ -11,6 +11,7 @@
/obj/item/stack/material/cloth
name = "cloth"
desc = "Individual fibers woven into a cloth."
icon_state = "sheet-cloth"
default_type = "cloth"
no_variants = FALSE
@@ -21,3 +22,13 @@
/obj/item/stack/material/cloth/diyaab
color = "#c6ccf0"
/obj/item/stack/material/fiber
name = "plant fiber"
desc = "Some all-natural plant fibers."
icon_state = "sheet-fiber"
default_type = MAT_FIBERS
pass_color = TRUE
apply_colour = TRUE
drop_sound = 'sound/items/drop/clothing.ogg'
pickup_sound = 'sound/items/pickup/clothing.ogg'
+1 -1
View File
@@ -60,7 +60,7 @@
user.verbs |= /mob/living/carbon/human/proc/nif_menu
/datum/component/nif_menu/proc/nif_menu_click(obj/screen/nif/image, location, control, params, user)
/datum/component/nif_menu/proc/nif_menu_click(source, location, control, params, user)
var/mob/living/carbon/human/H = user
if(istype(H) && H.nif)
INVOKE_ASYNC(H.nif, .proc/tgui_interact, user)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 62 KiB

+2
View File
@@ -356,6 +356,8 @@
#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\components\crafting\recipes\primitive.dm"
#include "code\datums\components\crafting\recipes\weapons.dm"
#include "code\datums\elements\_element.dm"
#include "code\datums\elements\light_blocking.dm"
#include "code\datums\elements\turf_transparency.dm"