Skip to content

Commit

Permalink
[MIRROR] Updates floorlight damage
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelbassil authored and SuhEugene committed Dec 19, 2023
1 parent 0aadbe6 commit 2704989
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 42 deletions.
2 changes: 1 addition & 1 deletion code/game/machinery/_machines_base/machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
// If you don't call parent in this proc, you must make all appropriate checks yourself.
// If you do, you must respect the return value.
/obj/machinery/attack_hand(mob/user)
if((. = ..())) // Buckling, climbers; unlikely to return true.
if((. = ..())) // Buckling, climbers, punching on harm; unlikely to return true.
return
if(MUTATION_FERAL in user.mutations)
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN*2)
Expand Down
52 changes: 14 additions & 38 deletions code/game/machinery/floor_light.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ var/global/list/floor_light_cache = list()
desc = "A backlit floor panel."
layer = ABOVE_TILE_LAYER
anchored = FALSE
use_power = POWER_USE_ACTIVE
use_power = POWER_USE_OFF
idle_power_usage = 2
active_power_usage = 20
power_channel = LIGHT
matter = list(MATERIAL_STEEL = 250, MATERIAL_GLASS = 250)
health_max = 5
damage_hitsound = 'sound/effects/Glasshit.ogg'

var/damaged
var/default_light_power = 0.75
Expand Down Expand Up @@ -42,7 +44,7 @@ var/global/list/floor_light_cache = list()
update_use_power(POWER_USE_OFF)
queue_icon_update()
visible_message(SPAN_NOTICE("\The [user] has [anchored ? "attached" : "detached"] \the [src]."))
else if(isWelder(W) && (damaged || MACHINE_IS_BROKEN(src)))
else if(isWelder(W) && (health_damaged() || MACHINE_IS_BROKEN(src)))
var/obj/item/weldingtool/WT = W
if(!WT.can_use(1, user))
return
Expand All @@ -53,28 +55,19 @@ var/global/list/floor_light_cache = list()
return
visible_message(SPAN_NOTICE("\The [user] has repaired \the [src]."))
set_broken(FALSE)
damaged = null
revive_health()
else if(isWrench(W))
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
to_chat(user, SPAN_NOTICE("You dismantle the floor light."))
new /obj/item/stack/material/steel(src.loc, 1)
new /obj/item/stack/material/glass(src.loc, 1)
qdel(src)
else if(W.force && user.a_intent == "hurt")
attack_hand(user)
return

/obj/machinery/floor_light/physical_attack_hand(mob/user)
if(user.a_intent == I_HURT && !issmall(user))
if(!isnull(damaged) && !MACHINE_IS_BROKEN(src))
visible_message(SPAN_DANGER("\The [user] smashes \the [src]!"))
playsound(src, "shatter", 70, 1)
set_broken(TRUE)
else
visible_message(SPAN_DANGER("\The [user] attacks \the [src]!"))
playsound(src.loc, 'sound/effects/Glasshit.ogg', 75, 1)
if(isnull(damaged)) damaged = 0
return TRUE
/obj/machinery/floor_light/on_death()
..()
playsound(src, "shatter", 70, 1)
visible_message(SPAN_DANGER("\The [src] is smashed into many pieces!"))

/obj/machinery/floor_light/interface_interact(mob/user)
if(!CanInteract(user, DefaultTopicState()))
Expand Down Expand Up @@ -113,7 +106,7 @@ var/global/list/floor_light_cache = list()
/obj/machinery/floor_light/on_update_icon()
ClearOverlays()
if((use_power == POWER_USE_ACTIVE) && operable())
if(isnull(damaged))
if (!health_damaged())
var/cache_key = "floorlight-[default_light_colour]"
if(!floor_light_cache[cache_key])
var/image/I = image("on")
Expand All @@ -123,8 +116,7 @@ var/global/list/floor_light_cache = list()
floor_light_cache[cache_key] = I
AddOverlays(floor_light_cache[cache_key])
else
if(damaged == 0) //Needs init.
damaged = rand(1,4)
damaged = rand(1,4)
var/cache_key = "floorlight-broken[damaged]-[default_light_colour]"
if(!floor_light_cache[cache_key])
var/image/I = image("flicker[damaged]")
Expand All @@ -133,23 +125,7 @@ var/global/list/floor_light_cache = list()
I.layer = layer+0.001
floor_light_cache[cache_key] = I
AddOverlays(floor_light_cache[cache_key])
update_brightness()
if (MACHINE_IS_BROKEN(src))
AddOverlays("broken")

/obj/machinery/floor_light/ex_act(severity)
switch(severity)
if(EX_ACT_DEVASTATING)
qdel(src)
if(EX_ACT_HEAVY)
if (prob(50))
qdel(src)
else if(prob(20))
set_broken(TRUE)
else
if(isnull(damaged))
damaged = 0
if(EX_ACT_LIGHT)
if (prob(5))
qdel(src)
else if(isnull(damaged))
damaged = 0
return
update_brightness()
6 changes: 3 additions & 3 deletions code/game/objects/objs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -256,21 +256,21 @@
var/attack_verb = "[pick(attack.attack_verb)]"

if (!can_damage_health(damage, attack.get_damage_type()))
playsound(loc, attack.attack_sound, 25, TRUE, -1)
playsound(loc, use_weapon_hitsound? attack.attack_sound : damage_hitsound, 25, TRUE, -1)
user.visible_message(
SPAN_WARNING("\The [user] hits \the [src], but doesn't even leave a dent!"),
SPAN_WARNING("You hit \the [src], but cause no visible damage and hurt yourself!")
)
user.apply_damage(3, DAMAGE_BRUTE, user.hand ? BP_L_HAND : BP_R_HAND)
return TRUE

playsound(loc, attack.attack_sound, 25, TRUE, -1)
playsound(loc, use_weapon_hitsound? attack.attack_sound : damage_hitsound, 25, TRUE, -1)
assailant.visible_message(
SPAN_WARNING("\The [assailant] [attack_verb] \the [src]!"),
SPAN_WARNING("You [attack_verb] \the [src]!")
)
damage_health(damage, attack.get_damage_type(), attack.damage_flags())
return
return TRUE
..()

/obj/is_fluid_pushable(amt)
Expand Down
Binary file modified icons/obj/machines/floor_light.dmi
Binary file not shown.

0 comments on commit 2704989

Please sign in to comment.