Skip to content

Commit

Permalink
Window damage overlays (goonstation#13764)
Browse files Browse the repository at this point in the history
Co-authored-by: pali <[email protected]>
  • Loading branch information
Flaborized and pali6 authored Apr 21, 2023
1 parent b6343fd commit 2ce7103
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion code/obj/window.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ADMIN_INTERACT_PROCS(/obj/window, proc/smash)
var/reinf = 0 // cant figure out how to remove this without the map crying aaaaa - ISN
var/deconstruct_time = 1 SECOND
var/image/connect_image = null
var/image/damage_image = null
pressure_resistance = 4*ONE_ATMOSPHERE
gas_impermeable = TRUE
anchored = ANCHORED
Expand Down Expand Up @@ -176,6 +177,7 @@ ADMIN_INTERACT_PROCS(/obj/window, proc/smash)
qdel(src)
else if (src.health == 0 && !nosmash)
smash()
UpdateIcon()

damage_slashing(var/amount)
if (!isnum(amount))
Expand All @@ -189,6 +191,7 @@ ADMIN_INTERACT_PROCS(/obj/window, proc/smash)
src.health = clamp(src.health - amount, 0, src.health_max)
if (src.health == 0)
smash()
UpdateIcon()

damage_piercing(var/amount)
if (!isnum(amount))
Expand All @@ -202,6 +205,7 @@ ADMIN_INTERACT_PROCS(/obj/window, proc/smash)
src.health = clamp(src.health - amount, 0, src.health_max)
if (src.health == 0)
smash()
UpdateIcon()

damage_corrosive(var/amount)
if (!isnum(amount) || amount <= 0)
Expand All @@ -213,6 +217,7 @@ ADMIN_INTERACT_PROCS(/obj/window, proc/smash)
src.health = clamp(src.health - amount, 0, src.health_max)
if (src.health == 0)
smash()
UpdateIcon()

damage_heat(var/amount, var/nosmash)
if (!isnum(amount) || amount <= 0)
Expand All @@ -231,6 +236,7 @@ ADMIN_INTERACT_PROCS(/obj/window, proc/smash)
qdel(src)
else
smash()
UpdateIcon()

ex_act(severity)
// Current windows have 30 HP
Expand Down Expand Up @@ -751,6 +757,7 @@ ADMIN_INTERACT_PROCS(/obj/window, proc/smash)
flags = FPRINT | USEDELAY | ON_BORDER | ALWAYS_SOLID_FLUID | IS_PERSPECTIVE_FLUID

var/mod = "W-"
var/connectdir
var/static/list/connects_to = typecacheof(list(
/obj/machinery/door,
/obj/window,
Expand Down Expand Up @@ -813,9 +820,10 @@ ADMIN_INTERACT_PROCS(/obj/window, proc/smash)
if (!src.anchored)
icon_state = "[mod]0"
src.UpdateOverlays(null, "connect")
update_damage_overlay()
return

var/connectdir = get_connected_directions_bitflag(connects_to, connects_to_exceptions, connect_diagonal=1)
connectdir = get_connected_directions_bitflag(connects_to, connects_to_exceptions, connect_diagonal=1)
var/overlaydir = get_connected_directions_bitflag(connects_to, (connects_to_exceptions + connects_with_overlay_exceptions), connect_diagonal=1)

src.icon_state = "[mod][connectdir]"
Expand All @@ -827,6 +835,7 @@ ADMIN_INTERACT_PROCS(/obj/window, proc/smash)
src.UpdateOverlays(src.connect_image, "connect")
else
src.UpdateOverlays(null, "connect")
src.update_damage_overlay()

proc/update_neighbors()
for (var/turf/simulated/wall/auto/T in orange(1,src))
Expand All @@ -836,6 +845,26 @@ ADMIN_INTERACT_PROCS(/obj/window, proc/smash)
for (var/obj/grille/G in orange(1,src))
G.UpdateIcon()

proc/update_damage_overlay()
var/health_percentage = health/health_max
if (!src.damage_image)
src.damage_image = image('icons/obj/window_damage.dmi')
src.damage_image.appearance_flags = PIXEL_SCALE | RESET_COLOR | RESET_ALPHA
if(src.material?.mat_id == "plasmaglass") //plasmaglass gets hand-picked alpha since it's so common and looks odd with default
src.damage_image.alpha = 85
else
src.damage_image.alpha = 180

if(health_percentage < 0.15) //only look very broken when it's about to break
src.damage_image.icon_state = "heavy-[connectdir]"
else if(health_percentage < 0.6)
src.damage_image.icon_state = "medium-[connectdir]"
else if(health_percentage < 0.9)
src.damage_image.icon_state = "light-[connectdir]"
else
src.damage_image.icon_state = null
src.UpdateOverlays(src.damage_image, "damage")

/obj/window/auto/the_tuff_stuff
explosion_resistance = 3

Expand Down
Binary file added icons/obj/window_damage.dmi
Binary file not shown.

0 comments on commit 2ce7103

Please sign in to comment.