From 056e2c52e861205caa9859f3ce4c3373d8ea166f Mon Sep 17 00:00:00 2001 From: grungussuss <96586172+Sadboysuss@users.noreply.github.com> Date: Sun, 6 Oct 2024 22:46:55 +0300 Subject: [PATCH] Item rustling component, riot armor and swat suit sounds (#87008) ## About The Pull Request https://github.com/user-attachments/assets/665053dc-8b46-49a5-bbea-7e6bb8f81cd7 - added a new component called `item_equipped_movement_rustle` for moving in zero-g and gravity with editable variables. - gave riot suits and swat suits a new sound using this new component. ## Why It's Good For The Game makes riot suits more immersive and allows us to implement it for other items in the future. ## Changelog :cl: grungussuss sound: riot suits and swat suits now make noise when moving around in them. /:cl: --- .../item_equipped_movement_rustle.dm | 67 ++++++++++++++++++ code/game/sound.dm | 5 +- code/modules/clothing/suits/armor.dm | 10 +++ .../armor_rustle/riot_armor}/suitstep1.ogg | Bin .../armor_rustle/riot_armor}/suitstep2.ogg | Bin tgstation.dme | 1 + 6 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 code/datums/components/item_equipped_movement_rustle.dm rename sound/{effects => items/handling/armor_rustle/riot_armor}/suitstep1.ogg (100%) rename sound/{effects => items/handling/armor_rustle/riot_armor}/suitstep2.ogg (100%) diff --git a/code/datums/components/item_equipped_movement_rustle.dm b/code/datums/components/item_equipped_movement_rustle.dm new file mode 100644 index 00000000000..435914dada7 --- /dev/null +++ b/code/datums/components/item_equipped_movement_rustle.dm @@ -0,0 +1,67 @@ +/datum/component/item_equipped_movement_rustle + + ///sound that plays, use an SFX define if there is multiple. + var/rustle_sounds = SFX_SUIT_STEP + ///human that has the item equipped. + var/mob/holder + + ///what move are we on. + var/move_counter = 0 + ///how many moves to take before playing the sound. + var/move_delay = 4 + + ///volume at which the sound plays. + var/volume = 20 + ///does the sound vary? + var/sound_vary = TRUE + ///extra-range for this component's sound. + var/sound_extra_range = -1 + ///sound exponent for the rustle. + var/sound_falloff_exponent = 5 + ///when sounds start falling off for the rustle rustle. + var/sound_falloff_distance = SOUND_DEFAULT_FALLOFF_DISTANCE + +/datum/component/item_equipped_movement_rustle/Initialize(custom_sounds, move_delay_override, volume_override, extrarange, falloff_exponent, falloff_distance) + if(!isitem(parent)) + return COMPONENT_INCOMPATIBLE + + RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(on_equip)) + RegisterSignal(parent, COMSIG_ITEM_DROPPED, PROC_REF(on_unequip)) + + if(custom_sounds) + rustle_sounds = custom_sounds + if(isnum(volume_override)) + volume = volume_override + if(isnum(move_delay_override)) + move_delay = move_delay_override + if(isnum(extrarange)) + sound_extra_range = extrarange + if(isnum(falloff_exponent)) + sound_falloff_exponent = falloff_exponent + if(isnum(falloff_distance)) + sound_falloff_distance = falloff_distance + +/datum/component/item_equipped_movement_rustle/proc/on_equip(datum/source, mob/equipper, slot) + var/obj/item/our_item = parent + if(!(slot & our_item.slot_flags)) + return + SIGNAL_HANDLER + holder = equipper + RegisterSignal(holder, COMSIG_MOVABLE_MOVED, PROC_REF(try_step), override = TRUE) + +/datum/component/item_equipped_movement_rustle/proc/on_unequip(datum/source, mob/equipper, slot) + SIGNAL_HANDLER + move_counter = 0 + UnregisterSignal(equipper, COMSIG_MOVABLE_MOVED) + holder = null + +/datum/component/item_equipped_movement_rustle/proc/try_step(obj/item/clothing/source) + SIGNAL_HANDLER + + move_counter++ + if(move_counter >= move_delay) + play_rustle_sound() + move_counter = 0 + +/datum/component/item_equipped_movement_rustle/proc/play_rustle_sound() + playsound(parent, rustle_sounds, volume, sound_vary, sound_extra_range, sound_falloff_exponent, falloff_distance = sound_falloff_distance) diff --git a/code/game/sound.dm b/code/game/sound.dm index 537b0c4f2e0..070f2026955 100644 --- a/code/game/sound.dm +++ b/code/game/sound.dm @@ -229,7 +229,10 @@ if(SFX_CLOWN_STEP) soundin = pick('sound/effects/footstep/clownstep1.ogg','sound/effects/footstep/clownstep2.ogg') if(SFX_SUIT_STEP) - soundin = pick('sound/effects/suitstep1.ogg','sound/effects/suitstep2.ogg') + soundin = pick( + 'sound/items/handling/armor_rustle/riot_armor/suitstep1.ogg', + 'sound/items/handling/armor_rustle/riot_armor/suitstep2.ogg', + ) if(SFX_SWING_HIT) soundin = pick('sound/items/weapons/genhit1.ogg', 'sound/items/weapons/genhit2.ogg', 'sound/items/weapons/genhit3.ogg') if(SFX_HISS) diff --git a/code/modules/clothing/suits/armor.dm b/code/modules/clothing/suits/armor.dm index b1cbc76399b..321a59e89f7 100644 --- a/code/modules/clothing/suits/armor.dm +++ b/code/modules/clothing/suits/armor.dm @@ -321,6 +321,10 @@ /obj/item/clothing/suit/armor/riot/Initialize(mapload) . = ..() AddComponent(/datum/component/adjust_fishing_difficulty, 5) + init_rustle_component() + +/obj/item/clothing/suit/armor/riot/proc/init_rustle_component() + AddComponent(/datum/component/item_equipped_movement_rustle) /datum/armor/armor_riot melee = 50 @@ -444,6 +448,10 @@ /obj/item/clothing/suit/armor/swat/Initialize(mapload) . = ..() AddComponent(/datum/component/adjust_fishing_difficulty, 5) + init_rustle_component() + +/obj/item/clothing/suit/armor/swat/proc/init_rustle_component() + AddComponent(/datum/component/item_equipped_movement_rustle) //All of the armor below is mostly unused @@ -543,6 +551,8 @@ /obj/item/tank/internals/emergency_oxygen, /obj/item/tank/internals/plasmaman, ) +/obj/item/clothing/suit/armor/riot/knight/init_rustle_component() + return /obj/item/clothing/suit/armor/riot/knight/yellow icon_state = "knight_yellow" diff --git a/sound/effects/suitstep1.ogg b/sound/items/handling/armor_rustle/riot_armor/suitstep1.ogg similarity index 100% rename from sound/effects/suitstep1.ogg rename to sound/items/handling/armor_rustle/riot_armor/suitstep1.ogg diff --git a/sound/effects/suitstep2.ogg b/sound/items/handling/armor_rustle/riot_armor/suitstep2.ogg similarity index 100% rename from sound/effects/suitstep2.ogg rename to sound/items/handling/armor_rustle/riot_armor/suitstep2.ogg diff --git a/tgstation.dme b/tgstation.dme index 5e508b25af6..421c8dcf19b 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1265,6 +1265,7 @@ #include "code\datums\components\infective.dm" #include "code\datums\components\interaction_booby_trap.dm" #include "code\datums\components\irradiated.dm" +#include "code\datums\components\item_equipped_movement_rustle.dm" #include "code\datums\components\itembound.dm" #include "code\datums\components\itempicky.dm" #include "code\datums\components\jetpack.dm"