Skip to content

Commit

Permalink
Falling onto stairs from height, or falling onto obstacles, will now …
Browse files Browse the repository at this point in the history
…apply fall damage.
  • Loading branch information
MistakeNot4892 authored and comma committed Jan 30, 2025
1 parent 7a889bc commit a295725
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion code/modules/lighting/lighting_overlay.dm
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
SHOULD_CALL_PARENT(FALSE)
return

/atom/movable/lighting_overlay/can_fall()
/atom/movable/lighting_overlay/can_fall(anchor_bypass = FALSE, turf/location_override = loc)
return FALSE

// Override here to prevent things accidentally moving around overlays.
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mechs/mech_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
return ..(dir)
return ..(ndir)

/mob/living/exosuit/can_fall(var/anchor_bypass = FALSE, var/turf/location_override = src.loc)
/mob/living/exosuit/can_fall(anchor_bypass = FALSE, turf/location_override = loc)
//mechs are always anchored, so falling should always ignore it
if(..(TRUE, location_override))
if((. = ..(TRUE, location_override)))
return !(can_overcome_gravity())

//For swimming
Expand Down
15 changes: 8 additions & 7 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1174,13 +1174,14 @@ default behaviour is:
client.screen += hud_used.hide_actions_toggle

/mob/living/handle_fall_effect(var/turf/landing)
..()
if(istype(landing) && !landing.is_open())
apply_fall_damage(landing)
if(client)
var/area/A = get_area(landing)
if(A)
A.alert_on_fall(src)
if(!(. = ..()) || !istype(landing))
return
apply_fall_damage(landing)
if(!client)
return
var/area/landing_area = get_area(landing)
if(landing_area)
landing_area.alert_on_fall(src)

/mob/living/proc/apply_fall_damage(var/turf/landing)
take_damage(rand(max(1, ceil(mob_size * 0.33)), max(1, ceil(mob_size * 0.66))) * get_fall_height())
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/silicon/robot/flying/flying.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
/mob/living/silicon/robot/flying/Process_Spacemove()
return (pass_flags & PASS_FLAG_TABLE) || ..()

/mob/living/silicon/robot/flying/can_fall(var/anchor_bypass = FALSE, var/turf/location_override = loc)
/mob/living/silicon/robot/flying/can_fall(anchor_bypass = FALSE, turf/location_override = loc)
return !Process_Spacemove()

/mob/living/silicon/robot/flying/can_overcome_gravity()
Expand Down
41 changes: 25 additions & 16 deletions code/modules/multiz/movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
moving = FALSE

//For children to override
/atom/movable/proc/can_fall(var/anchor_bypass = FALSE, var/turf/location_override = loc)
/atom/movable/proc/can_fall(anchor_bypass = FALSE, turf/location_override = loc)
if(immune_to_floor_hazards())
return FALSE

Expand All @@ -137,16 +137,16 @@

return TRUE

/obj/can_fall(var/anchor_bypass = FALSE, var/turf/location_override = loc)
return ..(anchor_fall)
/obj/can_fall(anchor_bypass = FALSE, turf/location_override = loc)
return ..(anchor_fall, location_override)

/obj/effect/can_fall(var/anchor_bypass = FALSE, var/turf/location_override = loc)
/obj/effect/can_fall(anchor_bypass = FALSE, turf/location_override = loc)
return FALSE

/obj/effect/decal/cleanable/can_fall(var/anchor_bypass = FALSE, var/turf/location_override = loc)
/obj/effect/decal/cleanable/can_fall(anchor_bypass = FALSE, turf/location_override = loc)
return TRUE

/obj/item/pipe/can_fall(var/anchor_bypass = FALSE, var/turf/location_override = loc)
/obj/item/pipe/can_fall(anchor_bypass = FALSE, turf/location_override = loc)
var/turf/open/below = loc
below = below.below

Expand All @@ -158,18 +158,21 @@
if((locate(/obj/structure/disposalpipe/up) in below) || locate(/obj/machinery/atmospherics/pipe/zpipe/up) in below)
return FALSE

/mob/living/can_fall(var/anchor_bypass = FALSE, var/turf/location_override = loc)
/mob/living/can_fall(anchor_bypass = FALSE, turf/location_override = loc)
if((. = ..()))
var/decl/species/my_species = get_species()
if(my_species)
return my_species.can_fall(src)

/atom/movable/proc/protected_from_fall_damage(var/turf/landing)
if(!!(locate(/obj/structure/stairs) in landing))
return TRUE
var/turf/wall/natural/ramp = landing
if(istype(ramp) && ramp.ramp_slope_direction) // walking down a ramp
return TRUE
// Stairs and ramps will not save you from a high drop.
if(get_fall_height() <= 1)
if(!!(locate(/obj/structure/stairs) in landing))
return TRUE
var/turf/wall/natural/ramp = landing
if(istype(ramp) && ramp.ramp_slope_direction) // walking down a ramp
return TRUE
return FALSE

/mob/protected_from_fall_damage(var/turf/landing)
. = ..()
Expand Down Expand Up @@ -213,10 +216,16 @@

/atom/movable/proc/handle_fall_effect(var/turf/landing)
SHOULD_CALL_PARENT(TRUE)
if(istype(landing) && landing.is_open())
visible_message("\The [src] falls through \the [landing]!", "You hear a whoosh of displaced air.")
if(istype(landing) && can_fall() && landing.CanZPass(src, DOWN))
visible_message(
SPAN_NOTICE("\The [src] falls through \the [landing]!"),
"You hear a whoosh of displaced air."
)
else
visible_message("\The [src] slams into \the [landing]!", "You hear something slam into the [global.using_map.ground_noun].")
visible_message(
SPAN_DANGER("\The [src] slams into [landing.is_open() ? "\the [landing]" : "an obstacle"]!"),
"You hear something slam into the [global.using_map.ground_noun]."
)
var/fall_damage = fall_damage() * get_fall_height()
if(fall_damage > 0)
for(var/mob/living/M in landing.contents)
Expand Down Expand Up @@ -421,7 +430,7 @@
owner = null
. = ..()

/atom/movable/z_observer/can_fall()
/atom/movable/z_observer/can_fall(anchor_bypass = FALSE, turf/location_override = loc)
return FALSE

/atom/movable/z_observer/explosion_act()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/multiz/zmimic/mimic_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
mouse_opacity = FALSE
abstract_type = /atom/movable/openspace // unsure if this is valid, check with Lohi -- Yes, it's valid.

/atom/movable/openspace/can_fall()
/atom/movable/openspace/can_fall(anchor_bypass = FALSE, turf/location_override = loc)
return FALSE

// No blowing up abstract objects.
Expand Down

0 comments on commit a295725

Please sign in to comment.