Skip to content

Commit

Permalink
Adding sparks and stamina use to forging.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Dec 22, 2024
1 parent 89bbcbd commit cce8d61
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 20 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
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
5 changes: 3 additions & 2 deletions code/game/objects/objs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@
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)
/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)
Expand All @@ -422,5 +422,6 @@
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))
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)
2 changes: 1 addition & 1 deletion code/modules/atmospherics/he_pipes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +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)
animate_heat_glow_filter(pipe_air.temperature)
animate_heat_glow(pipe_air.temperature)
else
set_light(0, 0)

Expand Down
14 changes: 6 additions & 8 deletions code/modules/crafting/forging/forge_bars.dm
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
// Copied from billets/HE pipes.
/obj/item/stack/material/bar/set_material(new_material)
. = ..()
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 : ..()

Expand All @@ -24,7 +17,12 @@
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)
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()
Expand Down
36 changes: 30 additions & 6 deletions code/modules/crafting/forging/forge_billet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
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 @@ -37,7 +36,7 @@
var/obj/item/tongs/tongs = used_item
if(tongs.holding_bar)
return ..()
var/mob/holder = tongs.loc
var/mob/holder = loc
if(istype(holder))
if(!holder.try_unequip(src, tongs))
return TRUE
Expand Down Expand Up @@ -73,9 +72,20 @@
// Handle the actual forging process.
var/last_step = current_forging_step
var/decl/forging_action/next_action = show_radial_menu(user, src, current_forging_step.get_radial_choices(), radius = 42, use_labels = RADIAL_LABELS_CENTERED, require_near = TRUE, check_locs = list(src))

if(!standard_forging_checks(user, used_item, last_step, next_action, anvil))
return TRUE
playsound(src, 'sound/effects/clang.ogg', 100, 1) // shake the billet? do attack animation?

if(user.get_stamina() < 10)
to_chat(user, SPAN_WARNING("You are too exhausted to swing \the [used_item]."))
return TRUE
user.adjust_stamina(-10)

playsound(src, 'sound/effects/clang.ogg', 100, 1)
user.do_attack_animation(anvil, used_item)
spark_at(get_turf(loc), amount = 1, spark_type = /datum/effect/effect/system/spark_spread/silent)
// TODO: shake the billet/anvil?


// Skill checks!
var/decl/forging_step/next_step = current_forging_step.steps[next_action]
Expand All @@ -88,8 +98,16 @@
// Since we have a sleep() above, we recheck our basic conditions.
if(!standard_forging_checks(user, used_item, last_step, next_action, anvil))
return TRUE
playsound(src, 'sound/effects/clang.ogg', 100, 1) // shake the billet? do attack animation?
// TODO Use some stamina.

if(user.get_stamina() < 10)
to_chat(user, SPAN_WARNING("You are too exhausted to keep swinging \the [used_item]."))
return TRUE
user.adjust_stamina(-10)

playsound(src, 'sound/effects/clang.ogg', 100, 1)
user.do_attack_animation(anvil, used_item)
spark_at(get_turf(loc), amount = 1, spark_type = /datum/effect/effect/system/spark_spread/silent)
// TODO: shake the billet/anvil?

// Update the billet (which may produce an item!)
var/obj/item/forged_thing = set_forging_step(next_step)
Expand Down Expand Up @@ -149,6 +167,9 @@
. = ..()
// 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))
set_light(0, 0)
if(istype(loc, /obj/item/tongs))
loc.update_icon()
return
var/temperature_percentage
if(temperature >= material.melting_point) // We should have melted...
Expand All @@ -159,7 +180,10 @@
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)
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)
if(istype(loc, /obj/item/tongs))
loc.update_icon()

// Arbitrary value to give people enough time to forge the bloody thing.
/obj/item/billet/get_thermal_mass_coefficient()
Expand Down
3 changes: 2 additions & 1 deletion code/modules/crafting/forging/forge_tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
/obj/item/tongs/on_update_icon()
. = ..()
if(holding_bar)
add_overlay(overlay_image(icon, "[icon_state]-bar", holding_bar.get_color(), RESET_COLOR))
// Note, not get_color(); heat color is temporarily applied over the top of base color.
add_overlay(overlay_image(icon, "[icon_state]-bar", holding_bar.color, RESET_COLOR))

/obj/item/tongs/Exited(atom/movable/AM, atom/new_loc)
. = ..()
Expand Down

0 comments on commit cce8d61

Please sign in to comment.