Skip to content

Commit

Permalink
Adding glow effects and heat retention/loss to billets/bars.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Dec 22, 2024
1 parent e392db4 commit 89bbcbd
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 53 deletions.
3 changes: 3 additions & 0 deletions code/game/objects/items/__item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,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
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
21 changes: 21 additions & 0 deletions code/game/objects/objs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,24 @@
// Stub, used by /item and /structure
/obj/proc/refresh_color()
return

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

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)

if(icon_temperature < scale_max)
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)
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_filter(pipe_air.temperature)
else
set_light(0, 0)

Expand Down
38 changes: 32 additions & 6 deletions code/modules/crafting/forging/forge_bars.dm
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
/obj/item/stack/material/bar/on_update_icon()
// Copied from billets/HE pipes.
/obj/item/stack/material/bar/set_material(new_material)
. = ..()
// if(get_amount() == 1)
// TODO: heat up, glow (replicate from billet)
if(material?.forgable)
add_filter("glow",1, list(type = "drop_shadow", x = 0, y = 0, offset = 0, size = 4))

// Also copied from billets.
/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)
animate_heat_glow_filter(temperature, scale_sub = round((material.melting_point - T20C) * 0.25) + T20C, scale_div = round(material.melting_point * 0.75), scale_max = material.melting_point)

// Copied from billets.
/obj/item/stack/material/bar/proc/hot_enough_to_forge()
return TRUE
// if(get_amount() == 1)
// TODO: check material temperature (replicate from billet)
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)
Expand All @@ -25,6 +50,7 @@
// 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
Expand Down
27 changes: 26 additions & 1 deletion code/modules/crafting/forging/forge_billet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
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 = /decl/material/solid/metal/iron
material_alteration = MAT_FLAG_ALTERATION_ALL
var/decl/forging_step/current_forging_step = /decl/forging_step/billet

/obj/item/billet/Initialize(ml, material_key)
if(ispath(current_forging_step))
set_forging_step(current_forging_step, force = TRUE)
. = ..()
add_filter("glow",1, list(type = "drop_shadow", x = 0, y = 0, offset = 0, size = 4))

/obj/item/billet/proc/set_forging_step(decl/forging_step/new_step, force)
if(ispath(new_step))
Expand All @@ -23,7 +25,10 @@
update_name()

/obj/item/billet/proc/hot_enough_to_forge()
return TRUE // TODO: compare temperature to some % of melting point of material?
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

/obj/item/billet/attackby(obj/item/used_item, mob/user)

Expand Down Expand Up @@ -139,3 +144,23 @@
desc = current_forging_step.billet_desc
if(istype(material))
desc = "[desc] This one is made of [material.solid_name]."

/obj/item/billet/ProcessAtomTemperature()
. = ..()
// 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)
animate_heat_glow_filter(temperature, scale_sub = round((material.melting_point - T20C) * 0.25) + T20C, scale_div = round(material.melting_point * 0.75), scale_max = material.melting_point)

// Arbitrary value to give people enough time to forge the bloody thing.
/obj/item/billet/get_thermal_mass_coefficient()
return hot_enough_to_forge() ? 0.1 : ..()
62 changes: 35 additions & 27 deletions code/modules/crafting/forging/forging_step.dm
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/decl/forging_step
abstract_type = /decl/forging_step
var/name

/// Base name to use for the billet at this stage.
var/billet_name
var/billet_name = "billet"
/// Name prefix to use for the billet at this stage.
var/billet_name_prefix
/// Description to use for the billet at this stage.
Expand Down Expand Up @@ -38,8 +36,6 @@

/decl/forging_step/validate()
. = ..()
if(!istext(name))
. += "null or invalid name"
if(!istext(billet_name))
. += "null or invalid billet_name"
if(!istext(billet_desc))
Expand All @@ -64,9 +60,8 @@
return billet

/decl/forging_step/billet
billet_name = "billet"
billet_desc = "An unworked or partially-worked length of metal used to forge items and tools."
steps = list(
billet_desc = "An unworked length of metal used to forge items and tools."
steps = list(
/decl/forging_action/drawing = /decl/forging_step/thin_billet,
/decl/forging_action/bending = /decl/forging_step/curved_billet,
/decl/forging_action/punching = /decl/forging_step/flat_bar,
Expand All @@ -76,7 +71,8 @@
/decl/forging_step/thin_billet
billet_name_prefix = "thin"
billet_icon_state = "thin"
steps = list(
billet_desc = "A thin, elongated length of metal used to forge items and tools."
steps = list(
/decl/forging_action/drawing = /decl/forging_step/blade_blank,
/decl/forging_action/bending = /decl/forging_step/ornate_blank,
/decl/forging_action/punching = /decl/forging_step/product/nails
Expand All @@ -85,7 +81,8 @@
/decl/forging_step/curved_billet
billet_name_prefix = "curved"
billet_icon_state = "curved"
steps = list(
billet_desc = "A curved length of metal used to forge items and tools."
steps = list(
/decl/forging_action/drawing = /decl/forging_step/product/hook,
/decl/forging_action/bending = /decl/forging_step/product/chain,
/decl/forging_action/punching = /decl/forging_step/product/rim,
Expand All @@ -96,7 +93,8 @@
billet_name = "bar"
billet_name_prefix = "flat"
billet_icon_state = "flat"
steps = list(
billet_desc = "A flattened bar of metal used to forge items and tools."
steps = list(
/decl/forging_action/drawing = /decl/forging_step/armour_base,
/decl/forging_action/bending = /decl/forging_step/helmet_base,
/decl/forging_action/punching = /decl/forging_step/product/lock_and_key,
Expand All @@ -106,37 +104,45 @@
/decl/forging_step/punched_billet
billet_name_prefix = "punched"
billet_icon_state = "punched"
steps = list(
steps = list(
/decl/forging_action/drawing = /decl/forging_step/tool_head_blank,
/decl/forging_action/bending = /decl/forging_step/product/tongs,
/decl/forging_action/punching = /decl/forging_step/product/chisel
)

/decl/forging_step/blade_blank
billet_name = "blade blank"
billet_name = "blade blank"
billet_icon_state = "blade"
billet_desc = "A roughly shaped, dull blade. It will need further refinement before it can be finished."

/decl/forging_step/ornate_blank
billet_name = "blank"
billet_name = "blank"
billet_name_prefix = "ornate"
billet_icon_state = "ornate"
billet_desc = "An ornate piece of worked metal. It still needs some last touches to be made into something useful."

/decl/forging_step/armour_base
billet_name = "armour base"
billet_desc = "A worked metal plate, a few steps and fittings away from forming some kind of armour."
billet_name = "armour base"
billet_icon_state = "armour"

/decl/forging_step/helmet_base
billet_name = "helmet base"
billet_desc = "A worked metal plate, a few steps and fittings away from forming some kind of helmet."
billet_name = "helmet base"
billet_icon_state = "helmet"

/decl/forging_step/tool_head_blank
billet_name = "tool head blank"
billet_desc = "A heavy piece of shaped metal, almost suitable for use as the head of a tool. It still needs some last touches to be made into something useful."
billet_name = "tool head blank"
billet_icon_state = "tool_head"

// There are effectively finished products.
/decl/forging_step/product
abstract_type = /decl/forging_step/product
var/product_type = /obj/item/stick
// Dummy strings to avoid validate() fails; shouldn't be used anywhere.
billet_name = "finished product"
billet_desc = "A finished product."
abstract_type = /decl/forging_step/product
var/product_type = /obj/item/stick

/decl/forging_step/product/get_product_name(decl/material/billet_material)
return atom_info_repository.get_name_for(product_type, billet_material?.type)
Expand All @@ -161,25 +167,27 @@
billet_name = "nails"

/decl/forging_step/product/hook
billet_name = "hook"
billet_name = "hook"
product_type = /obj/item/knife/hook

/decl/forging_step/product/chain
billet_name = "chain"
billet_name = "chain"

/decl/forging_step/product/rim
billet_name = "rim"
billet_name = "barrel rim"

/decl/forging_step/product/horseshoe
billet_name = "horseshoe"
billet_name = "horseshoe"

/decl/forging_step/product/lock_and_key
billet_name = "lock and key"
billet_name = "lock and key"

/decl/forging_step/product/shield_fasteners
billet_name = "shield fasteners"
billet_name = "shield fasteners"

/decl/forging_step/product/tongs
billet_name = "tongs"
billet_name = "tongs"
product_type = /obj/item/tongs

/decl/forging_step/product/chisel
billet_name = "chisl"
billet_name = "chisl"

0 comments on commit 89bbcbd

Please sign in to comment.