Skip to content

Commit

Permalink
Working commit for metalwork.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Mar 21, 2024
1 parent dda7db3 commit 7c07f22
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 7 deletions.
14 changes: 13 additions & 1 deletion code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@
/atom/movable/proc/get_object_size()
return ITEM_SIZE_NORMAL

// TODO: account for reagents and matter.
/atom/movable/get_thermal_mass()
if(!simulated)
return 0
Expand All @@ -491,7 +492,18 @@
if(!held_slot || !istype(holder) || QDELETED(holder) || loc != holder)
return

// TODO: check protective gear
// TODO: put these flags on the inventory slot or something.
var/check_slots
if(held_slot in global.all_hand_slots)
check_slots = SLOT_HANDS
else if(held_slot == BP_MOUTH || held_slot == BP_HEAD)
check_slots = SLOT_FACE

if(check_slots)
for(var/obj/item/covering in holder.get_covering_equipped_items(check_slots))
if(covering.max_heat_protection_temperature >= temperature)
return

// TODO: less simplistic messages and logic
var/datum/inventory_slot/slot = held_slot && holder.get_inventory_slot_datum(held_slot)
var/check_organ = slot?.requires_organ_tag
Expand Down
16 changes: 16 additions & 0 deletions code/game/objects/objs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,19 @@

/obj/proc/get_blend_objects()
return

// Used to determine if something can be used as the basis of a mold.
/obj/proc/is_complex_mould_item()
return FALSE // length(matter) <= 1

// Used to determine what a mold made from this item produces.
/obj/proc/get_mould_product_type()
return type

// Used to pass an associative list of data to the mold to pass to the product.
/obj/proc/get_mould_metadata()
return

// Called when passing the metadata back to the item.
/obj/proc/take_mould_metadata(list/metadata)
return
32 changes: 32 additions & 0 deletions code/modules/crafting/metalwork/metalwork_items.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/obj/item/storage/crucible
name = "crucible"
icon = 'icons/obj/metalworking/crucible.dmi'
icon_state = ICON_STATE_WORLD
material = /decl/material/solid/stone/pottery
atom_flags = ATOM_FLAG_OPEN_CONTAINER
w_class = ITEM_SIZE_NO_CONTAINER
material_alteration = MAT_FLAG_ALTERATION_COLOR | MAT_FLAG_ALTERATION_NAME
max_w_class = ITEM_SIZE_LARGE
max_storage_space = BASE_STORAGE_CAPACITY(ITEM_SIZE_LARGE)

/obj/item/storage/crucible/Initialize()
. = ..()
initialize_reagents()

/obj/item/storage/crucible/on_reagent_change()
. = ..()
queue_icon_update()

/obj/item/storage/crucible/on_update_icon()
. = ..()
var/decl/material/primary_reagent = reagents?.get_primary_reagent_decl()
if(primary_reagent)
var/image/I = image(icon, "[icon_state]-filled")
I.color = primary_reagent.color
I.alpha = 255 * primary_reagent.opacity
I.appearance_flags |= RESET_COLOR
add_overlay(I)

/obj/item/storage/crucible/initialize_reagents()
create_reagents(15 * REAGENT_UNITS_PER_MATERIAL_SHEET)
return ..()
134 changes: 134 additions & 0 deletions code/modules/crafting/pottery/pottery_moulds.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/obj/item/mould
name = "mould"
material = /decl/material/solid/stone/pottery
material_alteration = MAT_FLAG_ALTERATION_COLOR | MAT_FLAG_ALTERATION_NAME
abstract_type = /obj/item/mould
max_health = 100
var/product_type
var/list/product_metadata

/obj/item/mould/Initialize()
. = ..()
var/datum/extension/labels/lext = get_or_create_extension(src, /datum/extension/labels)
if(ispath(product_type, /obj))
var/obj/product = product_type
lext.AttachLabel(null, initial(product.name))
update_icon()
else
lext.AttachLabel(null, "blank")

/obj/item/mould/Destroy()
product_metadata = null
return ..()

/obj/item/mould/populate_reagents()
if(!ispath(product_type, /obj))
return
var/required_volume = 0
var/list/matter_for_product = atom_info_repository.get_matter_for(product_type)
for(var/mat in matter_for_product)
required_volume += matter_for_product[mat]
required_volume = CEILING(required_volume * REAGENT_UNITS_PER_MATERIAL_UNIT)
if(required_volume > 0)
if(reagents)
reagents.maximum_volume = required_volume
reagents.update_total()
else
create_reagents(required_volume)

/*
/obj/item/mould/get_max_health()
return max_health * some material hardness or integrity constant
*/

/obj/item/mould/attackby(obj/item/W, mob/user)
. = ..()
if(!. && user.a_intent != I_HURT)
if(try_crack_mold(user, W))
return TRUE
if(try_take_impression(user, W))
return TRUE

/obj/item/mould/proc/try_crack_mold(mob/user, obj/item/hammer)

if(!product_type)
return FALSE

if(reagents?.total_volume <= 0)
to_chat(user, SPAN_WARNING("\The [src] is empty!"))
return TRUE

if(reagents.total_volume < reagents.maximum_volume)
to_chat(user, SPAN_WARNING("\The [src] is not full yet!"))
return TRUE

for(var/reagent_type in reagents.reagent_volumes)
var/decl/material/reagent = GET_DECL(reagent_type)
if(reagent.melting_point && temperature >= reagent.melting_point)
to_chat(user, SPAN_WARNING("The contents of \the [src] are still molten! Wait for it to cool down."))
return TRUE

if(user && !IS_HAMMER(hammer))
to_chat(user, SPAN_WARNING("You will need a hammer to crack open \the [src]."))
return TRUE

crack_mold(user, hammer)
return TRUE

/obj/item/mould/proc/crack_mold(mob/user, obj/item/hammer)

var/decl/material/product_mat = reagents?.get_primary_reagent_decl()
var/obj/product = new product_type(get_turf(src), product_mat?.type)
product.dropInto(loc)

reagents.remove_reagent(product_mat.type, REAGENT_VOLUME(reagents, product_mat.type))
for(var/reagent_type in reagents.reagent_volumes)
if(reagent_type == product_mat.type)
continue
LAZYINITLIST(product.matter)
product.matter[reagent_type] += max(1, round(reagents.reagent_volumes[reagent_type] / REAGENT_UNITS_PER_MATERIAL_UNIT))
reagents.clear_reagents()
if(length(product_metadata))
product.take_mould_metadata(product_metadata)
product.update_icon()
. = product

// TODO: hardness check?
if(istype(material, /decl/material/solid/clay) || istype(material, /decl/material/solid/stone/pottery))
physically_destroyed(src)
else
take_damage(rand(10, 20))

/obj/item/mould/proc/try_take_impression(mob/user, obj/item/thing)

// TODO: hardness check?
if(!istype(material, /decl/material/solid/clay))
to_chat(user, SPAN_WARNING("\The [src] has already been fired - it's too hard to take another impression."))
return TRUE

// TODO: pottery skill check?
if(thing.is_complex_mould_item())
to_chat(user, SPAN_WARNING("\The [thing] is too complex to be replicated with a mold."))
return TRUE

// TODO: pottery skill
if(user.do_skilled(5 SECONDS, SKILL_CONSTRUCTION, src) && !QDELETED(thing) && (thing.loc == user || thing.Adjacent(user)))
user.visible_message("\The [src] shapes [material.use_name] around \the [thing], creating a mold.")
var/datum/extension/labels/lext = get_or_create_extension(src, /datum/extension/labels)
lext.RemoveAllLabels()
lext.AttachLabel(null, initial(thing.name))
product_type = thing.get_mould_product_type()
product_metadata = thing.get_mould_metadata()
update_icon()

return TRUE

// TODO: silhouette impression of the product_type
/*
/obj/item/mould/on_update_icon()
return ..()
*/

// Crucible is premade as you can't reasonably be expected to find one in the wild to take an impression.
/obj/item/mould/crucible
product_type = /obj/item/storage/crucible
18 changes: 18 additions & 0 deletions code/modules/crafting/stack_recipes/recipes_clay.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,21 @@
if(user)
S.add_to_stacks(user, 1)
return S

/decl/stack_recipe/clay/crucible
result_type = /obj/item/storage/crucible
on_floor = TRUE
time = 3 SECONDS

/decl/stack_recipe/clay/mould
name = "mould, blank"
result_type = /obj/item/mould
time = 5 SECONDS

/decl/stack_recipe/clay/mould/anvil
name = "mould, anvil"
result_type = /obj/item/mould/anvil

/decl/stack_recipe/clay/mould/crucible
name = "mould, crucible"
result_type = /obj/item/mould/crucible
25 changes: 19 additions & 6 deletions code/modules/crafting/stack_recipes/recipes_textiles.dm
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
/decl/stack_recipe/textiles
craft_stack_types = list(
craft_stack_types = list(
/obj/item/stack/material/bolt,
/obj/item/stack/material/skin
)
abstract_type = /decl/stack_recipe/textiles
abstract_type = /decl/stack_recipe/textiles

/decl/stack_recipe/textiles/cloak
result_type = /obj/item/clothing/accessory/cloak/hide
result_type = /obj/item/clothing/accessory/cloak/hide

/decl/stack_recipe/textiles/banner
result_type = /obj/item/banner
result_type = /obj/item/banner

/decl/stack_recipe/textiles/shoes
result_type = /obj/item/clothing/shoes/craftable
result_type = /obj/item/clothing/shoes/craftable

/decl/stack_recipe/textiles/boots
result_type = /obj/item/clothing/shoes/craftable/boots
result_type = /obj/item/clothing/shoes/craftable/boots

/decl/stack_recipe/textiles/gloves
result_type = /obj/item/clothing/gloves

/decl/stack_recipe/textiles/leather
abstract_type = /decl/stack_recipe/textiles/leather
required_material = /decl/material/solid/organic/leather

/decl/stack_recipe/textiles/leather/whip
result_type = /obj/item/whip

/decl/stack_recipe/textiles/leather/gloves
result_type = /obj/item/clothing/gloves/thick
11 changes: 11 additions & 0 deletions code/modules/locks/key.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
. = ..(mapload, material_key)
key_data = _data

/obj/item/key/get_mould_product_type()
return /obj/item/key

/obj/item/key/take_mould_metadata(list/metadata)
if("key_data" in metadata)
key_data = metadata["key_data"]
return ..()

/obj/item/key/get_mould_metadata()
. = list("key_data" = get_data())

/obj/item/key/temporary
name = "key"
desc = "A fragile key with limited uses."
Expand Down
1 change: 1 addition & 0 deletions code/modules/materials/material_sheets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
// Extra subtype defined for the clay stack recipes to not freak out about null material.
/obj/item/stack/material/brick/clay
material = /decl/material/solid/clay
is_spawnable_type = TRUE

/obj/item/stack/material/bolt
name = "bolts"
Expand Down
3 changes: 3 additions & 0 deletions code/modules/tools/components/_component.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
material_alteration = MAT_FLAG_ALTERATION_COLOR | MAT_FLAG_ALTERATION_NAME | MAT_FLAG_ALTERATION_DESC
w_class = ITEM_SIZE_SMALL

/obj/item/tool_component/is_complex_mould_item()
return TRUE

/*
todo
- binding
Expand Down
3 changes: 3 additions & 0 deletions nebula.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2002,7 +2002,10 @@
#include "code\modules\codex\entries\tools.dm"
#include "code\modules\codex\entries\turfs.dm"
#include "code\modules\codex\entries\weapons.dm"
#include "code\modules\crafting\metalwork\metalwork_items.dm"
#include "code\modules\crafting\metalwork\metalwork_structures.dm"

Check failure on line 2006 in nebula.dme

View workflow job for this annotation

GitHub Actions / DreamChecker

failed to find #include "code/modules/crafting/metalwork/metalwork_structures.dm"
#include "code\modules\crafting\pottery\pottery_items.dm"
#include "code\modules\crafting\pottery\pottery_moulds.dm"
#include "code\modules\crafting\pottery\pottery_structures.dm"
#include "code\modules\crafting\slapcrafting\_crafting_holder.dm"
#include "code\modules\crafting\slapcrafting\_crafting_stage.dm"
Expand Down

0 comments on commit 7c07f22

Please sign in to comment.