Files
Bubberstation/code/datums/components/item_killsound.dm
Ghom 11d82b7995 You can now interact with held mobs beside wearing them (feat: "minor" melee attack chain cleanup) (#90080)
People can now pet held mothroaches and pugs if they want to, or use
items on them, hopefully without causing many issues. After all, it only
took about a couple dozen lines of code to make...

...Oh, did the 527 files changed or the 850~ lines added/removed perhaps
catch your eye? Made you wonder if I accidentally pushed the wrong
branch? or skewed something up big time? Well, nuh uh. I just happen to
be fed up with the melee attack chain still using stringized params
instead of an array/list. It was frankly revolting to see how I'd have
had to otherwise call `list2params` for what I'm trying to accomplish
here, and make this PR another tessera to the immense stupidity of our
attack chain procs calling `params2list` over and over and over instead
of just using that one call instance from `ClickOn` as an argument. It's
2025, honey, wake up!

I also tried to replace some of those single letter vars/args but there
are just way too many of them.

Improving old code. And I want to be able to pet mobroaches while
holding them too.

🆑
qol: You can now interact with held mobs in more ways beside wearing
them.
/🆑
2025-04-29 18:22:44 -06:00

42 lines
1.3 KiB
Plaintext

/datum/component/item_killsound
/// list of allowed types, not null/empty
var/list/allowed_mobs
/// list of blacklisted types
var/list/blacklisted_mobs
var/killsound
var/killsound_volume = 100
/**
* on true will act as replacement for mob's death sound,
* otherwise it will just play sound on death
*/
var/replace_default_death_sound
/datum/component/item_killsound/Initialize(
allowed_mobs,
blacklisted_mobs,
killsound,
killsound_volume = 100,
replace_default_death_sound = FALSE
)
src.allowed_mobs = allowed_mobs
src.blacklisted_mobs = blacklisted_mobs
src.killsound = killsound
src.killsound_volume = killsound_volume
src.replace_default_death_sound = replace_default_death_sound
/datum/component/item_killsound/RegisterWithParent()
var/obj/item/item_parent = parent
RegisterSignal(item_parent, COMSIG_ITEM_ATTACK, PROC_REF(on_attack))
/datum/component/item_killsound/proc/on_attack(host, target_mob, user, list/modifiers)
SIGNAL_HANDLER
if(!allowed_mobs || is_type_in_list(target_mob, allowed_mobs))
if(is_type_in_list(target_mob, blacklisted_mobs))
return
var/mob/living/mob = target_mob
if(replace_default_death_sound)
mob.apply_status_effect(/datum/status_effect/replace_death_sound, 1 SECONDS, killsound)
else
mob.apply_status_effect(/datum/status_effect/death_sound, 1 SECONDS, killsound, killsound_volume)