Skip to content

Commit

Permalink
Working commit for blacksmithy.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Jan 9, 2025
1 parent b4d74cb commit 688ef32
Show file tree
Hide file tree
Showing 39 changed files with 941 additions and 24 deletions.
5 changes: 4 additions & 1 deletion code/_helpers/visual_filters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
// All of this ported from TG.
// And then ported to Nebula from Polaris.
/atom/movable
var/list/filter_data // For handling persistent filters
VAR_PRIVATE/list/filter_data // For handling persistent filters

// Defining this for future proofing and ease of searching for erroneous usage.
/image/proc/add_filter(filter_name, priority, list/params)
filters += filter(arglist(params))
return TRUE

/atom/movable/proc/has_filter(filter_name)
return (name in filter_data)

/atom/movable/proc/add_filter(filter_name, priority, list/params, force_update = FALSE)

// Check if we already have a filter and hence don't need to rebuild filters.
Expand Down
27 changes: 27 additions & 0 deletions code/game/objects/__objs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,30 @@
if(dumped_reagents && last_loc && !QDELETED(last_loc) && last_loc.reagents?.total_volume)
last_loc.reagents.handle_update()
HANDLE_REACTIONS(last_loc.reagents)

// Used by HE pipes and forging bars/billets. Defaults are for HE pipes.
/obj/proc/animate_heat_glow(icon_temperature, scale_sub = 500, scale_div = 1500, scale_max = 2000, skip_filter = FALSE)

var/scale = max((icon_temperature - scale_sub) / scale_div, 0)
var/h_r = heat2color_r(icon_temperature)
var/h_g = heat2color_g(icon_temperature)
var/h_b = heat2color_b(icon_temperature)

var/base_color = get_color()
var/b_r = HEX_RED(base_color)
var/b_g = HEX_GREEN(base_color)
var/b_b = HEX_BLUE(base_color)

if(icon_temperature < scale_max)
h_r = b_r + (h_r - b_r)*scale
h_g = b_g + (h_g - b_g)*scale
h_b = b_b + (h_b - b_b)*scale

var/scale_color = rgb(h_r, h_g, h_b)
var/list/animate_targets = get_above_oo() + src
for (var/thing in animate_targets)
var/atom/movable/AM = thing
animate(AM, color = scale_color, time = 2 SECONDS, easing = SINE_EASING)
if(!skip_filter)
animate_filter("glow", list(color = scale_color, time = 2 SECONDS, easing = LINEAR_EASING))
set_light(min(3, scale*2.5), min(3, scale*2.5), scale_color)
9 changes: 8 additions & 1 deletion code/game/objects/effects/effect_system.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,16 @@ steam.start() -- spawns the effect
/obj/effect/sparks/struck
spark_sound = "light_bic"

/obj/effect/sparks/silent
spark_sound = null

/obj/effect/sparks/Initialize()
. = ..()
// this is 2 seconds so that it doesn't appear to freeze after its last move, which ends up making it look like timers are broken
// if you change the number of or delay between moves in spread(), this may need to be changed
QDEL_IN(src, 2 SECONDS)
playsound(loc, spark_sound, 100, 1)
if(spark_sound)
playsound(loc, spark_sound, 100, 1)
set_light(lit_light_range, lit_light_power, lit_light_color)
if(isturf(loc))
var/turf/T = loc
Expand Down Expand Up @@ -140,6 +144,9 @@ steam.start() -- spawns the effect
/datum/effect/effect/system/spark_spread
var/spark_type = /obj/effect/sparks

/datum/effect/effect/system/spark_spread/silent
spark_type = /obj/effect/sparks/silent

/datum/effect/effect/system/spark_spread/non_electrical
spark_type = /obj/effect/sparks/struck

Expand Down
3 changes: 3 additions & 0 deletions code/game/objects/items/__item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@
if(drying_wetness > 0 && drying_wetness != initial(drying_wetness))
desc_comp += "\The [src] is [get_dryness_text()]."

if(check_rights(R_DEBUG, 0, user))
to_chat(user, "\The [src] has a temperature of [temperature]K.")

return ..(user, distance, "", jointext(desc_comp, "<br/>"))

/obj/item/check_mousedrop_adjacency(var/atom/over, var/mob/user)
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions code/game/objects/items/crafting/barrel_rim.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Stub for forging. TODO barrel crafting.
/obj/item/barrel_rim
name = "barrel rim"
desc = "A circular brace used to hold a barrel together."
icon_state = ICON_STATE_WORLD
icon = 'icons/obj/items/barrel_rim.dmi'
material = /decl/material/solid/metal/iron
material_alteration = MAT_FLAG_ALTERATION_ALL
8 changes: 8 additions & 0 deletions code/game/objects/items/crafting/shield_fasteners.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Stub for forging. TODO shield crafting.
/obj/item/shield_fasteners
name = "shield fasteners"
desc = "A handful of shaped fasteners used to hold a buckler or shield together."
icon_state = ICON_STATE_WORLD
icon = 'icons/obj/items/shield_fasteners.dmi'
material = /decl/material/solid/metal/iron
material_alteration = MAT_FLAG_ALTERATION_ALL
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/material/knives.dm
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@

//random stuff
/obj/item/knife/hook
name = "meat hook"
name = "hook"
desc = "A sharp, metal hook what sticks into things."
icon = 'icons/obj/items/weapon/knives/hook.dmi'
sharp = FALSE
Expand Down
9 changes: 7 additions & 2 deletions code/game/objects/structures/_structure_materials.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var/decl/material/reinf_material
var/material_alteration
var/dismantled
var/name_prefix

/obj/structure/get_material()
RETURN_TYPE(/decl/material)
Expand Down Expand Up @@ -37,10 +38,14 @@

/obj/structure/proc/update_material_name(var/override_name)
var/base_name = override_name || initial(name)
var/new_name
if(istype(material))
SetName("[material.adjective_name] [base_name]")
new_name = "[material.adjective_name] [base_name]"
else
SetName(base_name)
new_name = base_name
if(name_prefix)
new_name = "[name_prefix] [new_name]"
SetName(new_name)

/obj/structure/proc/update_material_desc(var/override_desc)
var/base_desc = override_desc || initial(desc)
Expand Down
3 changes: 3 additions & 0 deletions code/game/objects/structures/fires.dm
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@
else
to_chat(user, "\The [src] is empty.")

if(check_rights(R_DEBUG, 0, user))
to_chat(user, "\The [src] has a temperature of [temperature]K, an effective burn temperature of [get_effective_burn_temperature()]K and a fuel value of [fuel].")

/obj/structure/fire_source/attack_hand(var/mob/user)

var/list/removable_atoms = get_removable_atoms()
Expand Down
19 changes: 1 addition & 18 deletions code/modules/atmospherics/he_pipes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,7 @@
//fancy radiation glowing
if(pipe_air.temperature && (icon_temperature > 500 || pipe_air.temperature > 500)) //start glowing at 500K
if(abs(pipe_air.temperature - icon_temperature) > 10)
icon_temperature = pipe_air.temperature
var/scale = max((icon_temperature - 500) / 1500, 0)

var/h_r = heat2color_r(icon_temperature)
var/h_g = heat2color_g(icon_temperature)
var/h_b = heat2color_b(icon_temperature)

if(icon_temperature < 2000) //scale up overlay until 2000K
h_r = 64 + (h_r - 64)*scale
h_g = 64 + (h_g - 64)*scale
h_b = 64 + (h_b - 64)*scale
var/scale_color = rgb(h_r, h_g, h_b)
var/list/animate_targets = get_above_oo() + src
for (var/thing in animate_targets)
var/atom/movable/AM = thing
animate(AM, color = scale_color, time = 2 SECONDS, easing = SINE_EASING)
animate_filter("glow", list(color = scale_color, time = 2 SECONDS, easing = LINEAR_EASING))
set_light(min(3, scale*2.5), min(3, scale*2.5), scale_color)
animate_heat_glow(pipe_air.temperature)
else
set_light(0, 0)

Expand Down
82 changes: 82 additions & 0 deletions code/modules/crafting/forging/forge_anvil.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/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
max_health = 1000
structure_flags = STRUCTURE_FLAG_SURFACE
material_alteration = MAT_FLAG_ALTERATION_ALL

/obj/structure/anvil/on_update_icon()
. = ..()
icon_state = initial(icon_state)
switch(get_health_percent())
if(0 to 0.35)
icon_state = "[icon_state]-damage-heavy"
if(0.35 to 0.65)
icon_state = "[icon_state]-damage-light"

/obj/structure/anvil/attackby(obj/item/used_item, mob/user, click_params)

// Put the hammer on the forge.
if(!user.check_intent(I_FLAG_HARM) && istype(used_item, /obj/item/tool/hammer/forge))
if(user.try_unequip(used_item, get_turf(src)))
auto_align(used_item, click_params)
return TRUE

// Put the bar onto the anvil (need to do this to avoid repairs in ..())
if(istype(used_item, /obj/item/stack/material/bar))
var/obj/item/stack/material/bar/bar = used_item
if(used_item.material != material || current_health >= get_max_health())
if(bar.get_amount() > 1)
bar = bar.split(1)
if(bar.loc == user)
user.try_unequip(bar, get_turf(src))
else
bar.dropInto(get_turf(src))
auto_align(bar, click_params)
return TRUE

// Place a partially worked billet onto the anvil.
if(istype(used_item, /obj/item/billet))
if(used_item.loc == user)
user.try_unequip(used_item, get_turf(src))
else
used_item.dropInto(get_turf(src))
auto_align(used_item, click_params)
return TRUE

// Put the bar from tongs onto the anvil.
if(istype(used_item, /obj/item/tongs))
var/obj/item/tongs/tongs = used_item
if(tongs.holding_bar)
return attackby(tongs.holding_bar, user)

. = ..()

// 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
max_health = 500

/obj/structure/anvil/boulder/Initialize(ml, _mat, _reinf_mat)
. = ..()
if(prob(50))
set_icon('icons/obj/structures/anvil_crude_alt.dmi')

// Improvised with spaceman materials.
/obj/structure/anvil/improvised
name_prefix = "improvised"
icon = 'icons/obj/structures/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
62 changes: 62 additions & 0 deletions code/modules/crafting/forging/forge_bars.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/obj/item/stack/material/bar/get_thermal_mass_coefficient()
return hot_enough_to_forge() ? 0.1 : ..()

// Also copied from billets.
/obj/item/stack/material/bar/ProcessAtomTemperature()
. = ..()
if(get_amount() == 1 && istype(material) && material.forgable)
// We have no real way to find temperature bounds without a material that has a melting point.
if(!istype(material) || isnull(material.melting_point) || QDELETED(src))
return
var/temperature_percentage
if(temperature >= material.melting_point) // We should have melted...
temperature_percentage = 1
else if(temperature <= T20C) // Arbitrary point for the sake of not trying to find a proportional temperature delta with ice
temperature_percentage = 0
else
temperature_percentage = (material.melting_point - T20C) / (temperature - T20C)
if(temperature_percentage < 0.25)
set_light(0, 0)
else
animate_heat_glow(temperature, scale_sub = round((material.melting_point - T20C) * 0.25) + T20C, scale_div = round(material.melting_point * 0.75), scale_max = material.melting_point, skip_filter = TRUE)
else
set_light(0, 0)
if(istype(loc, /obj/item/tongs))
loc.update_icon()

// Copied from billets.
/obj/item/stack/material/bar/proc/hot_enough_to_forge()
if(!istype(material) || isnull(material.melting_point) || !material.forgable)
return FALSE
// Needs to be halfway to melting to count as forgable.
return temperature >= ((material.melting_point - T20C) * 0.5) + T20C

// Some bar overrides to allow for the raw form, before they become billets.
/obj/item/stack/material/bar/attackby(obj/item/used_item, mob/user)
// Turn this into a billet for step 1 of forging.
if(isturf(loc) && get_amount() == 1)

// Picking up in tongs.
if(istype(used_item, /obj/item/tongs))
var/obj/item/tongs/tongs = used_item
if(!tongs.holding_bar)
forceMove(tongs)
tongs.holding_bar = src
tongs.update_icon()
return TRUE

// Hammering into a billet.
if(istype(used_item, /obj/item/tool/hammer/forge) && (locate(/obj/structure/anvil) in loc) && material?.forgable)
var/obj/item/billet/billet = new(get_turf(src), material?.type)
billet.matter = matter?.Copy() // Avoid creating or losing matter via reshaping.
billet.pixel_x = pixel_x
billet.pixel_y = pixel_y
billet.pixel_w = pixel_w
billet.pixel_z = pixel_z
billet.temperature = temperature
if(paint_color)
billet.paint_color = paint_color
billet.update_icon()
qdel(src)
return billet.attackby(used_item, user)
. = ..()
Loading

0 comments on commit 688ef32

Please sign in to comment.