Skip to content

Commit

Permalink
Falling now tracks fall distance and multiplies damage accordingly.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Oct 17, 2023
1 parent 1a54996 commit fcc3669
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ default behaviour is:
A.alert_on_fall(src)

/mob/living/proc/apply_fall_damage(var/turf/landing)
adjustBruteLoss(rand(max(1, CEILING(mob_size * 0.33)), max(1, CEILING(mob_size * 0.66))))
adjustBruteLoss(rand(max(1, CEILING(mob_size * 0.33)), max(1, CEILING(mob_size * 0.66))) * get_fall_height())

/mob/living/proc/get_toxin_resistance()
var/decl/species/species = get_species()
Expand Down
3 changes: 2 additions & 1 deletion code/modules/multiz/level_data.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
/datum/level_data
///Name displayed to the player to refer to this level in user interfaces and etc. If null, one will be generated.
var/name

/// Multiplier applied to damage when falling through this level.
var/fall_depth = 1
/// The z-level that was assigned to this level_data
var/level_z
/// A unique string identifier for this particular z-level. Used to fetch a level without knowing its z-level.
Expand Down
33 changes: 25 additions & 8 deletions code/modules/multiz/movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -198,36 +198,52 @@
parachute.packed = FALSE
return TRUE

/atom/movable/proc/handle_fall(var/turf/landing)
/atom/movable
var/started_falling_from_z

/atom/movable/proc/get_fall_height()
. = 0
var/turf/T = get_turf(src)
if(istype(T) && T.z <= started_falling_from_z)
for(var/fall_z in T.z to started_falling_from_z)
var/datum/level_data/level_data = SSmapping.levels_by_z[fall_z]
. += max(1, level_data?.fall_depth)

/atom/movable/proc/handle_fall(var/turf/landing, var/fall_distance)
var/turf/previous = get_turf(loc)
Move(landing, get_dir(previous, landing))
started_falling_from_z = max(started_falling_from_z, landing.z)
if(protected_from_fall_damage(landing))
return TRUE
if(landing.get_fluid_depth() >= FLUID_DEEP)
. = TRUE
else if(landing.get_fluid_depth() >= FLUID_DEEP)
var/primary_fluid = landing.get_fluid_name()
if(previous.get_fluid_depth() >= FLUID_DEEP) //We're sinking further
visible_message(SPAN_NOTICE("\The [src] sinks deeper down into \the [primary_fluid]!"), SPAN_NOTICE("\The [primary_fluid] rushes around you as you sink!"))
playsound(previous, pick(SSfluids.gurgles), 50, 1)
else
visible_message(SPAN_NOTICE("\The [src] falls into the [primary_fluid]!"), SPAN_NOTICE("What a splash!"))
playsound(src, 'sound/effects/watersplash.ogg', 30, TRUE)
return TRUE
. = TRUE
else
handle_fall_effect(landing)
. = handle_fall_effect(landing)
if(.)
started_falling_from_z = 0

/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.")
else
visible_message("\The [src] slams into \the [landing]!", "You hear something slam into the [global.using_map.ground_noun].")
var/fall_damage = fall_damage()
var/fall_damage = fall_damage() * get_fall_height()
if(fall_damage > 0)
for(var/mob/living/M in landing.contents)
if(M == src)
continue
visible_message("\The [src] hits \the [M.name]!")
M.take_overall_damage(fall_damage)
return TRUE
return FALSE

/atom/movable/proc/fall_damage()
return 0
Expand All @@ -244,8 +260,9 @@
return
if(species && species.handle_fall_special(src, landing))
return
var/min_damage = 7
var/max_damage = 14
var/fall_height = get_fall_height()
var/min_damage = 7 * fall_height
var/max_damage = 14 * fall_height
apply_damage(rand(min_damage, max_damage), BRUTE, BP_HEAD, armor_pen = 50)
apply_damage(rand(min_damage, max_damage), BRUTE, BP_CHEST, armor_pen = 50)
apply_damage(rand(min_damage, max_damage), BRUTE, BP_GROIN, armor_pen = 75)
Expand Down

0 comments on commit fcc3669

Please sign in to comment.