Files
Bubberstation/code/datums/elements/falling_hazard.dm
SkyratBot 494935c2c0 [MIRROR] Fixes some bad AddElements, Fixes incompatible element runtime error text [MDB IGNORE] (#18355)
* Fixes some bad AddElements, Fixes incompatible element runtime error text (#72188)

## About The Pull Request

- `/datum/element/squish` cannot be applied to non-carbons, and the
falling hazard element works on all livings.
- It seems like squish could easily be changed to apply to all livings,
but out of scope.
- `/datum/element/fried_item` and `/datum/element/griled_item` weren't
being applied to the new item correctly
   - This one's my bad
- Changes "Incompatible element" `CRASH` to print the element type
rather than the mob's name mistakenly
- I think this was intended, but always used the wrong arguments, and no
one noticed?

## Why It's Good For The Game

Less runtimes, features work as expected, and a more clearer runtime for
element errors

## Changelog

🆑 Melbert
fix: Silver foods correctly spawn things grilled and fried
/🆑

* Fixes some bad AddElements, Fixes incompatible element runtime error text

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
2022-12-28 07:44:36 -08:00

82 lines
3.6 KiB
Plaintext

/// An element that will make a target thing do damage to any mob that it falls on from a z-level above
/datum/element/falling_hazard
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
/// The amount of damage to do when the target falls onto a mob
var/fall_damage = 5
/// The wound bonus to give damage dealt against mobs we fall on
var/fall_wound_bonus = 0
/// Does we take into consideration if the target has head protection (hardhat, or a strong enough helmet)
var/obeys_hardhats = TRUE
/// Does the target crush and flatten whoever it falls on
var/crushes_people = FALSE
/// What sound is played when the target falls onto a mob
var/impact_sound = 'sound/magic/clockwork/fellowship_armory.ogg' //CLANG
/datum/element/falling_hazard/Attach(datum/target, damage, wound_bonus, hardhat_safety, crushes, impact_sound)
. = ..()
if(!isatom(target))
return ELEMENT_INCOMPATIBLE
src.fall_damage = damage
src.fall_wound_bonus = wound_bonus
src.obeys_hardhats = hardhat_safety
src.crushes_people = crushes
src.impact_sound = impact_sound
RegisterSignal(target, COMSIG_ATOM_ON_Z_IMPACT, PROC_REF(fall_onto_stuff))
/datum/element/falling_hazard/Detach(datum/target)
. = ..()
UnregisterSignal(target, COMSIG_ATOM_ON_Z_IMPACT)
/// Gathers every mob in the turf the target falls on, and does damage/crushes them/makes a message about the target falling on them
/datum/element/falling_hazard/proc/fall_onto_stuff(datum/source, turf/impacted_turf, levels)
SIGNAL_HANDLER
var/mob/living/poor_target = locate(/mob/living) in impacted_turf
if(!poor_target)
return
var/target_head_armor = poor_target.run_armor_check(BODY_ZONE_HEAD, MELEE, silent = TRUE)
if(obeys_hardhats && target_head_armor >= 15) // 15 melee armor is enough that most head items dont have this, but anything above a hardhat should protect you
poor_target.visible_message(
span_warning("[source] falls on [poor_target], thankfully [poor_target.p_they()] had a helmet on!"),
span_userdanger("You are hit on the head by [source], good thing you had a helmet on!"),
span_hear("You hear a [crushes_people ? "crash" : "bonk"]!"),
)
if(crushes_people)
poor_target.Knockdown(0.25 SECONDS * fall_damage) // For a piano, that would be 15 seconds
playsound(poor_target, 'sound/weapons/parry.ogg', 50, TRUE) // You PARRIED the falling object with your EPIC hardhat
return
var/obj/item/bodypart/target_head = poor_target.get_bodypart(BODY_ZONE_HEAD)
// This does more damage the more levels the falling object has fallen
if(!crushes_people && target_head)
poor_target.apply_damage(fall_damage * levels, def_zone = BODY_ZONE_HEAD, forced = TRUE, wound_bonus = fall_wound_bonus)
else
poor_target.apply_damage(fall_damage * levels, forced = TRUE, spread_damage = TRUE, wound_bonus = fall_wound_bonus)
poor_target.visible_message(
span_userdanger("[source] falls on [poor_target], [crushes_people ? "crushing [poor_target.p_them()]" : "hitting [poor_target.p_them()]"] [target_head ? "on the head!" : "!"]"),
span_userdanger("You are [crushes_people ? "crushed" : "hit"] by [source]!"),
span_hear("You hear a [crushes_people ? "crash" : "bonk"]!"),
)
playsound(poor_target, impact_sound, 50, TRUE)
if(!crushes_people)
return
if(iscarbon(poor_target))
poor_target.AddElement(/datum/element/squish, 30 SECONDS)
poor_target.Paralyze(0.5 SECONDS * fall_damage) // For a piano, that would be 30 seconds
add_memory_in_range(poor_target, 7, MEMORY_VENDING_CRUSHED, list(DETAIL_PROTAGONIST = poor_target, DETAIL_WHAT_BY = src), story_value = STORY_VALUE_AMAZING, memory_flags = MEMORY_CHECK_BLINDNESS, protagonist_memory_flags = MEMORY_SKIP_UNCONSCIOUS)