diff --git a/CalamityConfig.cs b/CalamityConfig.cs index 7c72d2f83d..1a959bd5de 100644 --- a/CalamityConfig.cs +++ b/CalamityConfig.cs @@ -154,6 +154,10 @@ namespace CalamityMod [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] public bool FlightBar { get; set; } + + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + public bool MisophoniaSupport { get; set; } #endregion #region Meter Positions diff --git a/Items/Potions/Food/LavaChickenBroth.cs b/Items/Potions/Food/LavaChickenBroth.cs index f418a525e5..8d2e220d43 100644 --- a/Items/Potions/Food/LavaChickenBroth.cs +++ b/Items/Potions/Food/LavaChickenBroth.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Items.Potions.Food player.AddBuff(ModContent.BuffType(), time); } - if (SoundEngine.TryGetActiveSound(DrinkSoundSlot, out var drinkSound) && drinkSound.IsPlaying) + if (SoundEngine.TryGetActiveSound(DrinkSoundSlot, out var drinkSound) && drinkSound.IsPlaying && !CalamityClientConfig.Instance.MisophoniaSupport) drinkSound.Position = player.Center; } } diff --git a/Localization/en-US/Mods.CalamityMod.Configs.hjson b/Localization/en-US/Mods.CalamityMod.Configs.hjson index d4d7fac81b..2981483fe1 100644 --- a/Localization/en-US/Mods.CalamityMod.Configs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Configs.hjson @@ -187,6 +187,15 @@ CalamityClientConfig: { ''' } + MisophoniaSupport: { + Label: "[i:Megaphone] Disable Potentially Triggering Audio" + Tooltip: + ''' + Disables multiple repetitive sound effects. + Highly recommended for those with misophonia. + ''' + } + ParticleLimit: { Label: "[i:FragmentStardust] Max Particle Limit" Tooltip: diff --git a/NPCs/NormalNPCs/DivineSwine.cs b/NPCs/NormalNPCs/DivineSwine.cs index 8743051f3b..ee698f3b0b 100644 --- a/NPCs/NormalNPCs/DivineSwine.cs +++ b/NPCs/NormalNPCs/DivineSwine.cs @@ -59,6 +59,12 @@ namespace CalamityMod.NPCs.NormalNPCs PauseBehavior = PauseBehavior.PauseWithGame, MaxInstances = 0, }; + private static SoundStyle MisophoniaSwineSpeakLoopingSound = new("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneMonsterDrone") + { + IsLooped = true, + PauseBehavior = PauseBehavior.PauseWithGame, + MaxInstances = 0, + }; public int FrameY; @@ -294,7 +300,9 @@ namespace CalamityMod.NPCs.NormalNPCs } SoundEngine.PlaySound(SoundID.Item29 with { Volume = 0.1f }, NPC.Center); - SoundEngine.PlaySound(IdleSound, NPC.Center); + if (!CalamityClientConfig.Instance.MisophoniaSupport) + SoundEngine.PlaySound(IdleSound, NPC.Center); + if (SoundEngine.TryGetActiveSound(SwineSpeakSoundSlot, out ActiveSound swineSpeakInstance)) swineSpeakInstance.Stop(); @@ -468,7 +476,10 @@ namespace CalamityMod.NPCs.NormalNPCs } SoundEngine.PlaySound(SoundID.Item29 with { Volume = 0.1f }, NPC.Center); - SoundEngine.PlaySound(IdleSound, NPC.Center); + + if (!CalamityClientConfig.Instance.MisophoniaSupport) + SoundEngine.PlaySound(IdleSound, NPC.Center); + if (SoundEngine.TryGetActiveSound(SwineSpeakSoundSlot, out ActiveSound swineSpeakInstance)) swineSpeakInstance.Stop(); @@ -586,7 +597,9 @@ namespace CalamityMod.NPCs.NormalNPCs { if (NPC.soundDelay == 0 && Main.rand.NextBool(200) && AIState == (int)BehaviorState.IdleAndFly) { - SoundEngine.PlaySound(IdleSound, NPC.Center); + if (!CalamityClientConfig.Instance.MisophoniaSupport) + SoundEngine.PlaySound(IdleSound, NPC.Center); + SquashVector = Utils.SelectRandom(Main.rand, new Vector2(1.4f, 0.7f), new Vector2(0.7f, 1.4f)); AdditionalBrightness = Main.rand.NextFloat(0.3f, 0.4f); NPC.soundDelay = Main.rand.Next(60, 120); @@ -594,7 +607,14 @@ namespace CalamityMod.NPCs.NormalNPCs } if (!SoundEngine.TryGetActiveSound(SwineSpeakSoundSlot, out _)) - SwineSpeakSoundSlot = SoundEngine.PlaySound(SwineSpeakLoopingSound, NPC.Center, SoundCallbackMethod); + { + if (!CalamityClientConfig.Instance.MisophoniaSupport) + { + SwineSpeakSoundSlot = SoundEngine.PlaySound(SwineSpeakLoopingSound, NPC.Center, SoundCallbackMethod); + } + else + SwineSpeakSoundSlot = SoundEngine.PlaySound(MisophoniaSwineSpeakLoopingSound, NPC.Center, SoundCallbackMethod); + } // Fade the music depending on the distance between the player and Divine Swine. float musicVolumeInterpolant = Utils.Remap(NPC.Distance(Main.LocalPlayer.Center), 600f, 100f, 1f, 0.2f, true); diff --git a/NPCs/NormalNPCs/HorribleHog/HorribleHog.AI.Transitionals.cs b/NPCs/NormalNPCs/HorribleHog/HorribleHog.AI.Transitionals.cs index 0dd70afbc7..b32b03a445 100644 --- a/NPCs/NormalNPCs/HorribleHog/HorribleHog.AI.Transitionals.cs +++ b/NPCs/NormalNPCs/HorribleHog/HorribleHog.AI.Transitionals.cs @@ -353,7 +353,10 @@ namespace CalamityMod.NPCs.NormalNPCs.HorribleHog if (NPC.soundDelay == 0f && Main.rand.NextBool(250)) { SetSquashVectors(squashVector: new Vector2(1.24f, 0.84f)); - SoundEngine.PlaySound(IdleSound, NPC.Center); + + if (!CalamityClientConfig.Instance.MisophoniaSupport) + SoundEngine.PlaySound(IdleSound, NPC.Center); + NPC.soundDelay = Main.rand.Next(30, 45); } diff --git a/NPCs/NormalNPCs/HorribleHog/HorribleHog.cs b/NPCs/NormalNPCs/HorribleHog/HorribleHog.cs index a91458e006..76b5007c36 100644 --- a/NPCs/NormalNPCs/HorribleHog/HorribleHog.cs +++ b/NPCs/NormalNPCs/HorribleHog/HorribleHog.cs @@ -81,6 +81,12 @@ namespace CalamityMod.NPCs.NormalNPCs.HorribleHog PauseBehavior = PauseBehavior.PauseWithGame, MaxInstances = 0 }; + private static SoundStyle MisophoniaDevilsTongueLoopingSound = new("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneMonsterDrone") + { + IsLooped = true, + PauseBehavior = PauseBehavior.PauseWithGame, + MaxInstances = 0 + }; public Dictionary PreviousAttackCounters = []; @@ -646,8 +652,16 @@ namespace CalamityMod.NPCs.NormalNPCs.HorribleHog // "Devil's Tongue" looping sound. // Similar to Divine Swine; gets louder and lowers music volume based on proximity. + if (!SoundEngine.TryGetActiveSound(DevilsTongueSlot, out _)) - DevilsTongueSlot = SoundEngine.PlaySound(DevilsTongueLoopingSound, NPC.Center, DevilsTongueLoopCallback); + { + if (!CalamityClientConfig.Instance.MisophoniaSupport) + { + DevilsTongueSlot = SoundEngine.PlaySound(DevilsTongueLoopingSound, NPC.Center, DevilsTongueLoopCallback); + } + else + DevilsTongueSlot = SoundEngine.PlaySound(MisophoniaDevilsTongueLoopingSound, NPC.Center, DevilsTongueLoopCallback); + } float idealVolume = Utils.Remap(NPC.Distance(Main.LocalPlayer.Center), 800f, 400f, 1f, 0.05f, true); Main.musicFade[Main.curMusic] = MathHelper.Lerp(1f, idealVolume, DevilsTongueVolumeMultiplier); diff --git a/NPCs/NormalNPCs/Piggy.cs b/NPCs/NormalNPCs/Piggy.cs index 20f8127463..b8178297fe 100644 --- a/NPCs/NormalNPCs/Piggy.cs +++ b/NPCs/NormalNPCs/Piggy.cs @@ -51,6 +51,13 @@ namespace CalamityMod.NPCs.NormalNPCs MaxInstances = 0, }; + private static SoundStyle DivineSwine_MisophoniaSwineSpeakLoopingSound = new("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneMonsterDrone") + { + IsLooped = true, + PauseBehavior = PauseBehavior.PauseWithGame, + MaxInstances = 0, + }; + private static SoundStyle HorribleHog_CackleSound = new("CalamityMod/Sounds/Custom/HorribleHog/HorribleHogCackle"); private static SoundStyle HorribleHog_IdleSound = new("CalamityMod/Sounds/Custom/HorribleHog/HorribleHogIdle", 2) { @@ -63,6 +70,13 @@ namespace CalamityMod.NPCs.NormalNPCs MaxInstances = 0 }; + private static SoundStyle HorribleHog_MisophoniaDevilsTongueLoopingSound = new("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneMonsterDrone") + { + IsLooped = true, + PauseBehavior = PauseBehavior.PauseWithGame, + MaxInstances = 0 + }; + public Vector2 SquashVector; public SlotId NearbySoundSlot; @@ -168,8 +182,17 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.velocity.X *= 0.9f; NPC.rotation = 0f; + + if (Timer < 2 && !SoundEngine.TryGetActiveSound(NearbySoundSlot, out _)) - NearbySoundSlot = SoundEngine.PlaySound(DivineSwine_SwineSpeakLoopingSound, NPC.Center, NearbySoundCallbackMethod); + { + if (!CalamityClientConfig.Instance.MisophoniaSupport) + { + NearbySoundSlot = SoundEngine.PlaySound(DivineSwine_SwineSpeakLoopingSound, NPC.Center, NearbySoundCallbackMethod); + } + else + NearbySoundSlot = SoundEngine.PlaySound(DivineSwine_MisophoniaSwineSpeakLoopingSound, NPC.Center, NearbySoundCallbackMethod); + } float lightSpawnDistance = MathHelper.Lerp(52f, 84f, Timer / 180f); int lightAmt = Main.rand.Next(1, 2); @@ -239,8 +262,16 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.velocity.X *= 0.9f; NPC.rotation = 0f; + if (Timer < 2 && !SoundEngine.TryGetActiveSound(NearbySoundSlot, out _)) - NearbySoundSlot = SoundEngine.PlaySound(HorribleHog_DevilsTongueLoopingSound, NPC.Center, NearbySoundCallbackMethod); + { + if (!CalamityClientConfig.Instance.MisophoniaSupport) + { + NearbySoundSlot = SoundEngine.PlaySound(HorribleHog_DevilsTongueLoopingSound, NPC.Center, NearbySoundCallbackMethod); + } + else + NearbySoundSlot = SoundEngine.PlaySound(HorribleHog_MisophoniaDevilsTongueLoopingSound, NPC.Center, NearbySoundCallbackMethod); + } float smokeOpacity = Utils.GetLerpValue(0f, 45f, Timer, true); int circlingSmokeAmount = Main.rand.Next(2, 5); @@ -327,8 +358,11 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.netUpdate = true; } - var chosenSoundStyle = Utils.SelectRandom(Main.rand, IdleSound_Grunt, IdleSound_SnortYip, IdleSound_Yip); - SoundEngine.PlaySound(chosenSoundStyle, NPC.Center); + if (!CalamityClientConfig.Instance.MisophoniaSupport) + { + var chosenSoundStyle = Utils.SelectRandom(Main.rand, IdleSound_Grunt, IdleSound_SnortYip, IdleSound_Yip); + SoundEngine.PlaySound(chosenSoundStyle, NPC.Center); + } NPC.soundDelay = Main.rand.Next(60, 120); } @@ -362,7 +396,9 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.collideX) { SoundEngine.PlaySound(SoundID.Dig with { Volume = 0.7f }, NPC.Center); - SoundEngine.PlaySound(IdleSound_Grunt with { Volume = 1.2f }, NPC.Center); + if (!CalamityClientConfig.Instance.MisophoniaSupport) + SoundEngine.PlaySound(IdleSound_Grunt with { Volume = 1.2f }, NPC.Center); + SquashVector = new Vector2(0.6f, 1f); NPC.velocity.X = NPC.oldVelocity.X * -0.86f; @@ -389,7 +425,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.velocity.Y == 0f) { NPC.velocity.X *= 0.9f; - if (MathF.Abs(NPC.velocity.X) >= 0.08f && MathF.Abs(NPC.velocity.X) < 0.09f) + if (MathF.Abs(NPC.velocity.X) >= 0.08f && MathF.Abs(NPC.velocity.X) < 0.09f && !CalamityClientConfig.Instance.MisophoniaSupport) { NPC.velocity.Y = -4f; var soundStyle = Utils.SelectRandom(Main.rand, IdleSound_SnortYip, IdleSound_Yip);