Skip to content

Commit

Permalink
Non-blacksmithy changes from blacksmithy PR.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Jan 24, 2025
1 parent b2b42ef commit ab56cb6
Show file tree
Hide file tree
Showing 27 changed files with 148 additions and 40 deletions.
13 changes: 11 additions & 2 deletions code/_helpers/animations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,20 @@
animate(time = 1)
animate(alpha = 0, time = 3, easing = CIRCULAR_EASING|EASE_OUT)

// Shake animation stolen from Polaris.
/atom
/// How much to shake the atom when struck.
/// Larger objs should have smaller numbers or it looks weird.
var/shake_animation_degrees = 4

/atom/proc/shake_animation(var/intensity = 8)
var/init_px = pixel_x
var/shake_dir = pick(-1, 1)
animate(src, transform=turn(matrix(), intensity*shake_dir), pixel_x=init_px + 2*shake_dir, time=1)
animate(transform=null, pixel_x=init_px, time=6, easing=ELASTIC_EASING)
var/matrix/M = matrix()
M.Scale(icon_scale_x, icon_scale_y)
M.Translate(0, 16*(icon_scale_y-1))
animate(src, transform=turn(M, shake_animation_degrees * shake_dir), pixel_x=init_px + 2*shake_dir, time=1)
animate(transform=M, pixel_x=init_px, time=6, easing=ELASTIC_EASING)

/atom/proc/SpinAnimation(speed = 10, loops = -1, clockwise = 1, segments = 3, parallel = TRUE)
if(!segments)
Expand Down
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
3 changes: 2 additions & 1 deletion code/_onclick/other_mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@

user.visible_message(
SPAN_DANGER("\The [user] shakes \the [src]!"),
SPAN_DANGER("You shake \the [src]!"))
SPAN_DANGER("You shake \the [src]!")
)

object_shaken()
return TRUE
Expand Down
2 changes: 1 addition & 1 deletion code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@
/atom/proc/get_thermal_mass()
return 0

/atom/proc/get_thermal_mass_coefficient()
/atom/proc/get_thermal_mass_coefficient(delta)
return 1

/atom/proc/spark_act(obj/effect/sparks/sparks)
Expand Down
2 changes: 1 addition & 1 deletion code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@
return 0
return max(ITEM_SIZE_MIN, get_object_size()) * THERMAL_MASS_CONSTANT

/atom/movable/get_thermal_mass_coefficient()
/atom/movable/get_thermal_mass_coefficient(delta)
if(!simulated)
return 0
return (max(ITEM_SIZE_MIN, MOB_SIZE_MIN) * THERMAL_MASS_CONSTANT) / get_thermal_mass()
Expand Down
6 changes: 3 additions & 3 deletions code/game/atoms_temperature.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
if(user && heated_by)
visible_message(SPAN_NOTICE("\The [user] carefully heats \the [src] with \the [heated_by]."))
// Update our own heat.
var/altered_temp = max(temperature + (get_thermal_mass_coefficient() * diff_temp * (heated_by ? heated_by.get_manual_heat_source_coefficient() : 1)), 0)
var/altered_temp = max(temperature + (get_thermal_mass_coefficient(diff_temp) * diff_temp * (heated_by ? heated_by.get_manual_heat_source_coefficient() : 1)), 0)
ADJUST_ATOM_TEMPERATURE(src, min(adjust_temp, altered_temp))
return TRUE

Expand Down Expand Up @@ -51,11 +51,11 @@

// Get our ambient temperature if possible.
var/adjust_temp = get_ambient_temperature()
var/thermal_mass_coefficient = get_thermal_mass_coefficient() * get_ambient_temperature_coefficient()
var/diff_temp = adjust_temp - temperature
var/thermal_mass_coefficient = get_thermal_mass_coefficient(diff_temp) * get_ambient_temperature_coefficient()

// Determine if our temperature needs to change.
var/old_temp = temperature
var/diff_temp = adjust_temp - temperature
if(abs(diff_temp) >= (thermal_mass_coefficient * ATOM_TEMPERATURE_EQUILIBRIUM_THRESHOLD))
var/altered_temp = max(temperature + (thermal_mass_coefficient * diff_temp), 0)
ADJUST_ATOM_TEMPERATURE(src, (diff_temp > 0) ? min(adjust_temp, altered_temp) : max(adjust_temp, altered_temp))
Expand Down
59 changes: 59 additions & 0 deletions code/game/objects/__objs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
if(isnull(current_health))
current_health = get_max_health()

/obj/object_shaken()
shake_animation()
return ..()

/obj/hitby(atom/movable/AM, var/datum/thrownthing/TT)
. = ..()
if(. && !anchored)
Expand Down Expand Up @@ -415,3 +419,58 @@
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, anim_time = 2 SECONDS)

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
if(anim_time > 0)
animate(AM, color = scale_color, time = anim_time, easing = SINE_EASING)
else
color = scale_color
if(!skip_filter)
animate_filter("glow", list(color = scale_color, time = anim_time, easing = LINEAR_EASING))

set_light(min(3, scale*2.5), min(3, scale*2.5), scale_color)

/obj/proc/update_heat_glow(anim_time)

// We have no real way to find temperature bounds without a material that has a melting point.
var/decl/material/my_material = get_material()
if(!istype(my_material) || !my_material.glows_with_heat || isnull(my_material.melting_point) || QDELETED(src))
set_light(0, 0)
if(isatom(loc))
loc.update_icon()
return

var/temperature_percentage
if(temperature >= my_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 = (my_material.melting_point - T20C) / (temperature - T20C)
if(temperature_percentage < 0.25)
set_light(0, 0)
else
animate_heat_glow(temperature, scale_sub = round((my_material.melting_point - T20C) * 0.25) + T20C, scale_div = round(my_material.melting_point * 0.75), scale_max = my_material.melting_point, skip_filter = TRUE, anim_time = anim_time)
if(isatom(loc))
loc.update_icon()
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 @@ -391,6 +391,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.
3 changes: 3 additions & 0 deletions code/game/objects/items/blades/knife.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
item_flags = ITEM_FLAG_CAN_HIDE_IN_SHOES | ITEM_FLAG_IS_WEAPON
w_class = ITEM_SIZE_SMALL
base_parry_chance = 20

/obj/item/bladed/knife/iron
material = /decl/material/solid/metal/iron
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
5 changes: 3 additions & 2 deletions code/game/objects/structures/__structure.dm
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@
else
damage *= STRUCTURE_BRITTLE_MATERIAL_DAMAGE_MULTIPLIER

playsound(loc, hitsound, 60, 1)
if(!silent)
playsound(loc, hitsound, 60, 1)

var/current_max_health = get_max_health()
current_health = clamp(current_health - damage, 0, current_max_health)
show_damage_message(current_health/current_max_health)
Expand Down Expand Up @@ -340,4 +342,3 @@ Note: This proc can be overwritten to allow for different types of auto-alignmen
visible_message(SPAN_DANGER("\The [src] was hit by \the [AM]."))
playsound(src.loc, hitsound, 100, 1)
take_damage(AM.get_thrown_attack_force() * (TT.speed/THROWFORCE_SPEED_DIVISOR), AM.atom_damage_type)

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) && (material_alteration & MAT_FLAG_ALTERATION_NAME))
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 @@ -202,6 +202,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
20 changes: 3 additions & 17 deletions code/game/objects/structures/flora/tree.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
var/protects_against_weather = TRUE
/// What kind of tree stump we leaving behind.
var/stump_type
/// How much to shake the tree when struck.
/// Larger trees should have smaller numbers or it looks weird.
var/shake_animation_degrees = 4
/// Marker for repeating the cut sound effect and animation.
var/someone_is_cutting = FALSE

Expand Down Expand Up @@ -55,32 +52,21 @@
/obj/structure/flora/tree/take_damage(damage, damage_type = BRUTE, damage_flags, inflicter, armor_pen = 0, silent, do_update_health)
. = ..()
if(!QDELETED(src) && damage >= 5)
shake()
shake_animation()

// We chop several times to cut down a tree.
/obj/structure/flora/tree/play_cut_sound(mob/user)
shake()
shake_animation()
while(someone_is_cutting)
sleep(1 SECOND)
if(QDELETED(src))
return
shake()
shake_animation()
playsound(src, 'sound/items/axe_wood.ogg', 40, TRUE)
if(QDELETED(src) || QDELETED(user) || !user.Adjacent(src))
return
return ..()

// Tree shake animation stolen from Polaris.
/obj/structure/flora/tree/proc/shake()
set waitfor = FALSE
var/init_px = pixel_x
var/shake_dir = pick(-1, 1)
var/matrix/M = matrix()
M.Scale(icon_scale_x, icon_scale_y)
M.Translate(0, 16*(icon_scale_y-1))
animate(src, transform=turn(M, shake_animation_degrees * shake_dir), pixel_x=init_px + 2*shake_dir, time=1)
animate(transform=M, pixel_x=init_px, time=6, easing=ELASTIC_EASING)

/obj/structure/flora/tree/create_dismantled_products(turf/T)
if(log_type)
LAZYADD(., new log_type(T, rand(max(1,round(log_amount*0.5)), log_amount), material?.type, reinf_material?.type))
Expand Down
7 changes: 7 additions & 0 deletions code/modules/atmospherics/he_pipes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@
else
set_light(0, 0)

//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(pipe_air.temperature)
else
set_light(0, 0)

/obj/machinery/atmospherics/pipe/simple/heat_exchanging/junction
icon = 'icons/atmos/junction.dmi'
icon_state = "11"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/crafting/forging/bellows.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
to_chat(user, SPAN_NOTICE("You begin working \the [src], stoking \the [stoking] to a hotter flame."))
start_working()
while(user.do_skilled(3 SECONDS, work_skill, src))
if(QDELETED(src) || QDELETED(user) || user.get_stamina() <= 0)
if(QDELETED(src) || QDELETED(user) || user.get_stamina() < 25 || !user.get_empty_hand_slot())
break
stoking = locate() in get_step(loc, EAST)
if(!istype(stoking) || !stoking.lit)
Expand Down
6 changes: 6 additions & 0 deletions code/modules/crafting/stack_recipes/recipes_soft.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
result_type = /obj/item/stack/material/brick
test_result_type = /obj/item/stack/material/brick/clay

/decl/stack_recipe/soft/bar
name = "bar"
name_plural = "bars"
result_type = /obj/item/stack/material/bar
test_result_type = /obj/item/stack/material/bar/wax

/decl/stack_recipe/soft/stack/spawn_result(mob/user, location, amount, decl/material/mat, decl/material/reinf_mat, paint_color, spent_type, spent_amount = 1)
var/obj/item/stack/S = ..()
if(istype(S))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,5 @@
/datum/fabricator_recipe/chipboard/yew/get_resources()
resources = list(
/decl/material/solid/organic/wood/yew = ceil((SHEET_MATERIAL_AMOUNT * FABRICATOR_EXTRA_COST_FACTOR)/2),
/decl/material/solid/organic/plastic = ceil((SHEET_MATERIAL_AMOUNT * FABRICATOR_EXTRA_COST_FACTOR)/2)
/decl/material/solid/organic/plastic = ceil((SHEET_MATERIAL_AMOUNT * FABRICATOR_EXTRA_COST_FACTOR)/2)
)
5 changes: 5 additions & 0 deletions code/modules/materials/_materials.dm
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ INITIALIZE_IMMEDIATE(/obj/effect/gas_overlay)
var/max_fluid_opacity = FLUID_MAX_ALPHA
/// Point at which the fluid will proc turf interaction logic. Workaround for mops being ruined forever by 1u of anything else being added.
var/turf_touch_threshold = FLUID_QDEL_POINT
/// Whether or not billets of this material will glow with heat.
var/glows_with_heat = FALSE

// Damage values.
var/hardness = MAT_VALUE_HARD // Used for edge damage in weapons.
Expand Down Expand Up @@ -371,6 +373,8 @@ INITIALIZE_IMMEDIATE(/obj/effect/gas_overlay)
/// Assoc weighted list of gemstone material types to weighting.
var/list/gemstone_types

var/forgable = FALSE // Can this material be forged in bar/billet form?

// Placeholders for light tiles and rglass.
/decl/material/proc/reinforce(var/mob/user, var/obj/item/stack/material/used_stack, var/obj/item/stack/material/target_stack, var/use_sheets = 1)
if(!used_stack.can_use(use_sheets))
Expand Down Expand Up @@ -444,6 +448,7 @@ INITIALIZE_IMMEDIATE(/obj/effect/gas_overlay)
burn_product = null
vapor_products = null
compost_value = 0
forgable = FALSE
else if(isnull(temperature_damage_threshold))
var/new_temperature_damage_threshold = max(melting_point, boiling_point, heating_point)
// Don't let the threshold be lower than the ignition point.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
icon_reinf = 'icons/turf/walls/reinforced_metal.dmi'
exoplanet_rarity_gas = MAT_RARITY_NOWHERE
tensile_strength = 0.8 // metal wire is probably better than plastic?
forgable = TRUE
glows_with_heat = TRUE

/decl/material/solid/metal/uranium
name = "uranium"
Expand Down
Loading

0 comments on commit ab56cb6

Please sign in to comment.