Skip to content

Commit

Permalink
Adding improvised anvil alt interaction to boulders.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Dec 22, 2024
1 parent dd36b38 commit e392db4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 21 deletions.
39 changes: 25 additions & 14 deletions code/modules/crafting/forging/forge_anvil.dm
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/obj/structure/anvil
name = "anvil"
desc = "A heavy block of material used as support for hammering things into shape."
icon = 'icons/obj/structures/anvil.dmi'
icon_state = ICON_STATE_WORLD
anchored = TRUE
density = TRUE
opacity = FALSE
atom_flags = ATOM_FLAG_CLIMBABLE
w_class = ITEM_SIZE_STRUCTURE //_LARGE
material = /decl/material/solid/metal/iron
name = "anvil"
desc = "A heavy block of material used as support for hammering things into shape."
icon = 'icons/obj/structures/anvil.dmi'
icon_state = ICON_STATE_WORLD
anchored = TRUE
density = TRUE
opacity = FALSE
atom_flags = ATOM_FLAG_CLIMBABLE
w_class = ITEM_SIZE_STRUCTURE //_LARGE
material = /decl/material/solid/metal/iron
max_health = 1000
structure_flags = STRUCTURE_FLAG_SURFACE
material_alteration = MAT_FLAG_ALTERATION_ALL

Expand Down Expand Up @@ -48,8 +49,18 @@

. = ..()

// Chipped out of a boulder with a pick.
/obj/structure/anvil/boulder
name_prefix = "crude"
icon = 'icons/obj/structures/anvil_crude.dmi'
desc = "A crude anvil chipped out of a chunk of stone. It probably won't last very long."
material = /decl/material/solid/stone/granite
name_prefix = "crude"
icon = 'icons/obj/structures/anvil_crude.dmi'
desc = "A crude anvil chipped out of a chunk of stone. It probably won't last very long."
material = /decl/material/solid/stone/granite
max_health = 500

// Improvised with spaceman materials.
/obj/structure/anvil/improvised
name_prefix = "improvised"
icon = 'icons/obj/structures/anvil_crude.dmi' // anvil_improvised.dmi'
desc = "A anvil roughly improvised out of scrap metal. It probably won't last very long."
material = /decl/material/solid/metal/steel
max_health = 500
14 changes: 7 additions & 7 deletions code/modules/crafting/forging/forge_billet.dm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/obj/item/billet
name = "billet"
desc = "An unworked or partially-worked length of metal used to forge items and tools."
icon = 'icons/obj/items/billet.dmi'
icon_state = ICON_STATE_WORLD
name = "billet"
desc = "An unworked or partially-worked length of metal used to forge items and tools."
icon = 'icons/obj/items/billet.dmi'
icon_state = ICON_STATE_WORLD
material_alteration = MAT_FLAG_ALTERATION_ALL
var/decl/forging_step/current_forging_step = /decl/forging_step/billet

Expand Down Expand Up @@ -90,6 +90,9 @@
var/obj/item/forged_thing = set_forging_step(next_step)
if(istype(forged_thing))
user.visible_message(SPAN_NOTICE("\The [user] has [next_action.work_verb] the billet into \a [forged_thing]."))
// Forging gradually degrades anvils.
if(!QDELETED(anvil))
anvil.take_damage(rand(10, 20), BRUTE)
return TRUE

/obj/item/billet/examine(mob/user, distance, infix, suffix)
Expand All @@ -102,15 +105,12 @@
/obj/item/billet/proc/standard_forging_checks(mob/user, obj/item/used_item, decl/forging_step/last_step, decl/forging_action/next_action, obj/structure/anvil/anvil)
// We cancelled or changed state, abort.
if(!next_action || current_forging_step != last_step || !(next_action in current_forging_step.steps))
world << "fail 1 ![next_action] || [current_forging_step] != [last_step] || !([next_action] in [current_forging_step.steps])"
return FALSE
// Something has been destroyed since we started forging.
if(QDELETED(src) || QDELETED(used_item) || QDELETED(anvil) || QDELETED(user))
world << "fail 2 qdel"
return FALSE
// Something else has changed, very unfortunate.
if(loc != anvil.loc || !CanPhysicallyInteract(user) || user.get_active_held_item() != used_item)
world << "fail 3 loc"
return FALSE
return hot_enough_to_forge()

Expand Down
4 changes: 4 additions & 0 deletions code/modules/crafting/stack_recipes/recipes_steel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,7 @@
/decl/stack_recipe/steel/furniture/target_stake
result_type = /obj/structure/target_stake
difficulty = MAT_VALUE_NORMAL_DIY

/decl/stack_recipe/steel/furniture
result_type = /obj/structure/anvil/improvised
difficulty = MAT_VALUE_HARD_DIY
24 changes: 24 additions & 0 deletions code/modules/xenoarcheaology/boulder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,27 @@
var/mob/living/silicon/robot/R = AM
if(IS_PICK(R.module_active))
attackby(R.module_active,R)

/obj/structure/boulder/get_alt_interactions(mob/user)
. = ..()
LAZYADD(., /decl/interaction_handler/chip_anvil)

/decl/interaction_handler/chip_anvil
name = "Chip Into Anvil"
expected_target_type = /obj/structure/boulder
var/work_skill = SKILL_CONSTRUCTION

/decl/interaction_handler/chip_anvil/is_possible(atom/target, mob/user, obj/item/prop)
. = ..() && istype(prop) && IS_PICK(prop) && prop.material?.hardness >= target.get_material()?.hardness && user.skill_check(work_skill, SKILL_BASIC)

/decl/interaction_handler/chip_anvil/invoked(atom/target, mob/user, obj/item/prop)
user.visible_message(SPAN_NOTICE("\The [user] begins chipping \the [target] into a rough anvil using \the [prop]."))
if(!user.do_skilled(10 SECONDS, work_skill, target))
return FALSE
if(QDELETED(user) || QDELETED(target) || QDELETED(prop) || user.get_active_held_item() != prop || !CanPhysicallyInteractWith(user, target))
return FALSE
if(!is_possible(target, user, prop))
return FALSE
user.visible_message(SPAN_NOTICE("\The [user] chips \the [target] into a rough anvil using \the [prop]."))
new /obj/structure/anvil/boulder(get_turf(target), target.get_material()?.type)
return TRUE

0 comments on commit e392db4

Please sign in to comment.