add basic misophonia support

This commit is contained in:
Nathanael Overton committed 2026-07-09 04:02:46 -04:00
1 parent a20204d47f
commit fa20e6ce7e
7 files changed
+99 -13

No files matched your search

+4
View File
@@ -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
+1 -1
View File
@@ -64,7 +64,7 @@ namespace CalamityMod.Items.Potions.Food
player.AddBuff(ModContent.BuffType<VulnerabilityHex>(), 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;
}
}
@@ -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:
+24 -4
View File
@@ -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);
@@ -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);
}
+15 -1
View File
@@ -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<BehaviorState, int> 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);
+42 -6
View File
@@ -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);