mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-13 00:55:20 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
115 lines
4.2 KiB
Plaintext
115 lines
4.2 KiB
Plaintext
/**
|
|
* # Sound Emitter Component
|
|
*
|
|
* A component that emits a sound when it receives an input.
|
|
*/
|
|
/obj/item/circuit_component/soundemitter
|
|
display_name = "Sound Emitter"
|
|
desc = "A component that emits a sound when it receives an input. The frequency is a multiplier which determines the speed at which the sound is played"
|
|
category = "Action"
|
|
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
|
|
|
/// Sound to play
|
|
var/datum/port/input/option/sound_file
|
|
|
|
/// Volume of the sound when played
|
|
var/datum/port/input/volume
|
|
|
|
/// Whether to play the sound backwards
|
|
var/datum/port/input/backwards
|
|
|
|
/// Frequency of the sound when played
|
|
var/datum/port/input/frequency
|
|
|
|
/// The cooldown for this component of how often it can play sounds.
|
|
var/sound_cooldown = 2 SECONDS
|
|
|
|
/// The maximum pitch this component can play sounds at.
|
|
var/max_pitch = 50
|
|
/// The minimum pitch this component can play sounds at.
|
|
var/min_pitch = -50
|
|
/// The maximum volume this component can play sounds at.
|
|
var/max_volume = 30
|
|
|
|
var/list/options_map
|
|
|
|
/obj/item/circuit_component/soundemitter/Initialize(mapload)
|
|
if(CONFIG_GET(flag/disallow_circuit_sounds))
|
|
update_ui_alerts(new_flag=CIRCUIT_FLAG_DISABLED)
|
|
. = ..()
|
|
|
|
/obj/item/circuit_component/soundemitter/get_ui_notices()
|
|
. = ..()
|
|
. += create_ui_notice("Sound Cooldown: [DisplayTimeText(sound_cooldown)]", "orange", "stopwatch")
|
|
if(CONFIG_GET(flag/disallow_circuit_sounds))
|
|
. += create_ui_notice("Non-functional", "red", "exclamation")
|
|
update_ui_alerts(new_flag=CIRCUIT_FLAG_DISABLED)
|
|
else
|
|
update_ui_alerts(remove_flag=CIRCUIT_FLAG_DISABLED)
|
|
|
|
|
|
/obj/item/circuit_component/soundemitter/populate_ports()
|
|
volume = add_input_port("Volume", PORT_TYPE_NUMBER, default = 35)
|
|
frequency = add_input_port("Frequency", PORT_TYPE_NUMBER, default = 0)
|
|
backwards = add_input_port("Play Backwards", PORT_TYPE_BOOLEAN, default = FALSE)
|
|
|
|
/obj/item/circuit_component/soundemitter/populate_options()
|
|
var/static/component_options = list(
|
|
"Buzz" = 'sound/machines/buzz/buzz-sigh.ogg',
|
|
"Buzz Twice" = 'sound/machines/buzz/buzz-two.ogg',
|
|
"Chime" = 'sound/machines/chime.ogg',
|
|
"Honk" = 'sound/items/bikehorn.ogg',
|
|
"Ping" = 'sound/machines/ping.ogg',
|
|
"Sad Trombone" = 'sound/misc/sadtrombone.ogg',
|
|
"Warn" = 'sound/machines/warning-buzzer.ogg',
|
|
"Slow Clap" = 'sound/machines/slowclap.ogg',
|
|
"Moth Buzz" = 'sound/mobs/humanoids/moth/scream_moth.ogg',
|
|
"Squeak" = 'sound/items/toy_squeak/toysqueak1.ogg',
|
|
"Rip" = 'sound/items/poster/poster_ripped.ogg',
|
|
"Coinflip" = 'sound/items/coinflip.ogg',
|
|
"Megaphone" = 'sound/items/megaphone.ogg',
|
|
"Warpwhistle" = 'sound/effects/magic/warpwhistle.ogg',
|
|
"Hiss" = 'sound/mobs/non-humanoids/hiss/hiss1.ogg',
|
|
"Lizard" = 'sound/mobs/humanoids/lizard/lizard_scream_1.ogg',
|
|
"Flashbang" = 'sound/items/weapons/flashbang.ogg',
|
|
"Flash" = 'sound/items/weapons/flash.ogg',
|
|
"Whip" = 'sound/items/weapons/whip.ogg',
|
|
"Laugh Track" = 'sound/items/sitcom_laugh/sitcomLaugh1.ogg',
|
|
"Gavel" = 'sound/items/gavel.ogg',
|
|
)
|
|
sound_file = add_option_port("Sound Option", component_options)
|
|
options_map = component_options
|
|
|
|
/obj/item/circuit_component/soundemitter/pre_input_received(datum/port/input/port)
|
|
volume.set_value(clamp(volume.value, 0, 100))
|
|
frequency.set_value(clamp(frequency.value, min_pitch, max_pitch))
|
|
backwards.set_value(clamp(backwards.value, 0, 1))
|
|
|
|
/obj/item/circuit_component/soundemitter/input_received(datum/port/input/port)
|
|
if(CONFIG_GET(flag/disallow_circuit_sounds))
|
|
// Without constantly checking the config 24/7 or sending a signal to every circuit, best we can do to update existing emitters is this.
|
|
update_ui_alerts(new_flag=CIRCUIT_FLAG_DISABLED)
|
|
return
|
|
else
|
|
update_ui_alerts(remove_flag=CIRCUIT_FLAG_DISABLED)
|
|
|
|
if(!parent.shell)
|
|
return
|
|
|
|
if(TIMER_COOLDOWN_RUNNING(parent.shell, COOLDOWN_CIRCUIT_SOUNDEMITTER))
|
|
return
|
|
|
|
var/sound_to_play = options_map[sound_file.value]
|
|
if(!sound_to_play)
|
|
return
|
|
|
|
var/actual_frequency = 1 + (frequency.value/100)
|
|
var/actual_volume = max_volume * (volume.value/100)
|
|
|
|
if(backwards.value)
|
|
actual_frequency = -actual_frequency
|
|
|
|
playsound(src, sound_to_play, actual_volume, TRUE, frequency = actual_frequency)
|
|
|
|
TIMER_COOLDOWN_START(parent.shell, COOLDOWN_CIRCUIT_SOUNDEMITTER, sound_cooldown)
|