Skip to content

Commit

Permalink
Added an option to disable sfx on blunders, bugfix where the same sfx…
Browse files Browse the repository at this point in the history
… would play twice if player died between two GCDs
  • Loading branch information
Felscream committed Aug 31, 2024
1 parent 49ddc02 commit 3d29936
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 17 deletions.
Binary file modified DragoonMayCry/Assets/Audio/dead_weight.wav
Binary file not shown.
3 changes: 1 addition & 2 deletions DragoonMayCry/Audio/AudioService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public AudioService()

public void PlaySfx(SoundId key, bool force = false)
{
if (!SfxPaths.ContainsKey(key))
if (!Plugin.Configuration.PlaySoundEffects || !SfxPaths.ContainsKey(key))
{
return;
}
Expand All @@ -47,7 +47,6 @@ public void PlaySfx(SoundId key, bool force = false)
return;
}

Service.Log.Debug($"Playing SFX {key}");
audioEngine.PlaySfx(key, SfxPaths[key], GetSfxVolume());

if (!soundIdsNextAvailability.ContainsKey(key) || force || soundIdsNextAvailability[key] == 0)
Expand Down
1 change: 1 addition & 0 deletions DragoonMayCry/Configuration/DmcConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class DmcConfiguration : IPluginConfiguration
public int Version { get; set; } = 0;
public int SfxVolume { get; set; } = 80;
public bool PlaySoundEffects { get; set; } = true;
public bool PlaySoundEffectsOnBlunder { get; set; } = true;
public int PlaySfxEveryOccurrences { get; set; } = 3;
public bool ApplyGameVolume { get; set; } = true;
public bool ActiveOutsideInstance { get; set; } = false;
Expand Down
2 changes: 1 addition & 1 deletion DragoonMayCry/DragoonMayCry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Configurations>Debug;Release</Configurations>
</PropertyGroup>
<PropertyGroup>
<Version>0.4.3</Version>
<Version>0.5.0</Version>
<Description>DragoonMayCry</Description>
<PackageProjectUrl>https://github.com/Felscream/DragoonMayCry</PackageProjectUrl>
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
Expand Down
2 changes: 1 addition & 1 deletion DragoonMayCry/DragoonMayCry.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"ApplicableVersion": "any",
"LoadPriority": 0,
"InternalName": "DragoonMayCry",
"AssemblyVersion": "0.4.3",
"AssemblyVersion": "0.5.0",
"RepoUrl": "https://github.com/Felscream/DragoonMayCry",
"Tags": [ "dmc", "style", "dragoon", "combo", "cry", "greed" ],
"DalamudApiLevel": 10
Expand Down
3 changes: 2 additions & 1 deletion DragoonMayCry/Score/Action/PlayerActionTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,10 @@ private unsafe void DetectClipping()

private unsafe void DetectWastedGCD()
{
// do not track dropped GCDs if the LB is being cast
// or the player died between 2 GCDs
if (limitBreakCast != null)
{
// do not track dropped GCDs if the LB is being cast
return;
}
if (!actionManager->isGCDRecastActive && !actionManager->isQueued)
Expand Down
3 changes: 0 additions & 3 deletions DragoonMayCry/Score/ScoreProgressBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,18 @@ private void HandleDemotion()

private void StartDemotionAlert()
{
Service.Log.Debug("Starting demotion");
demotionApplicationStopwatch.Restart();
DemotionStart?.Invoke(this, DemotionTimerDuration);
}

private void ApplyDemotion()
{
Service.Log.Debug("Applying demotion");
demotionApplicationStopwatch.Reset();
DemotionApplied?.Invoke(this, false);
}

private void CancelDemotion()
{
Service.Log.Debug("Cancelling demotion");
demotionApplicationStopwatch.Reset();
DemotionCanceled?.Invoke(this, EventArgs.Empty);
}
Expand Down
25 changes: 17 additions & 8 deletions DragoonMayCry/Score/Style/StyleRankHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ public RankChangeData(
StyleType.SSS);

private readonly AudioService audioService;
private readonly PlayerState playerState;

public StyleRankHandler(PlayerActionTracker playerActionTracker)
{
Reset();
audioService = new AudioService();
var playerState = PlayerState.GetInstance();
playerState = PlayerState.GetInstance();
playerState.RegisterCombatStateChangeHandler(OnCombatChange!);
playerState.RegisterDeathStateChangeHandler(OnDeath);
playerState.RegisterDamageDownHandler(OnDamageDown);
Expand Down Expand Up @@ -76,7 +77,7 @@ private void GoToNextRank(bool playSfx, bool loop = false, bool forceSfx = false
{
if (CurrentStyle.Next == null)
{
if (Plugin.Configuration!.PlaySoundEffects && playSfx && forceSfx)
if (playSfx && forceSfx)
{
audioService.PlaySfx(CurrentStyle.Value);
}
Expand All @@ -91,7 +92,7 @@ private void GoToNextRank(bool playSfx, bool loop = false, bool forceSfx = false
StyleRankChange?.Invoke(this, new(CurrentStyle.Value, CurrentStyle.Next.Value, false));
CurrentStyle = CurrentStyle.Next;
Service.Log.Debug($"New rank reached {CurrentStyle.Value}");
if (Plugin.Configuration!.PlaySoundEffects && playSfx)
if (playSfx)
{
audioService.PlaySfx(CurrentStyle.Value);
}
Expand Down Expand Up @@ -165,7 +166,11 @@ private void OnCombatChange(object send, bool enteringCombat)

private void OnGcdDropped(object? sender, EventArgs args)
{
if (CurrentStyle.Value != StyleType.NoStyle && Plugin.Configuration!.PlaySoundEffects)
if (playerState.IsDead)
{
return;
}
if (CurrentStyle.Value != StyleType.NoStyle && Plugin.Configuration!.PlaySoundEffectsOnBlunder)
{
audioService.PlaySfx(SoundId.DeadWeight);
}
Expand All @@ -175,14 +180,18 @@ private void OnGcdDropped(object? sender, EventArgs args)

private void OnLimitBreakCanceled(object? sender, EventArgs args)
{
ForceRankTo(StyleType.D, true);
if (playerState.IsDead)
{
return;
}
ForceRankTo(StyleType.D, Plugin.Configuration!.PlaySoundEffectsOnBlunder);
}

private void OnDeath(object? sender, bool isDead)
{
if (isDead)
{
ForceRankTo(StyleType.D, true);
ForceRankTo(StyleType.D, Plugin.Configuration!.PlaySoundEffectsOnBlunder);
}
}

Expand All @@ -197,12 +206,12 @@ private void OnLimitBreak(

private void OnDamageDown(object? sender, bool hasDamageDown)
{
if(!hasDamageDown)
if(!hasDamageDown || playerState.IsDead)
{
return;
}

ForceRankTo(StyleType.D, true);
ForceRankTo(StyleType.D, Plugin.Configuration!.PlaySoundEffectsOnBlunder);
}
}
}
9 changes: 8 additions & 1 deletion DragoonMayCry/UI/ConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void Dispose() { }
public override void Draw()
{
var lockScoreWindow = configuration.StyleRankUiConfiguration.LockScoreWindow;
if (ImGui.Checkbox("Lock Score Window", ref lockScoreWindow))
if (ImGui.Checkbox("Lock score window", ref lockScoreWindow))
{
configuration.StyleRankUiConfiguration.LockScoreWindow = lockScoreWindow;
configuration.Save();
Expand All @@ -53,6 +53,13 @@ public override void Draw()
configuration.Save();
}

var playSoundEffectsOnBlunder = configuration.PlaySoundEffectsOnBlunder;
if (ImGui.Checkbox("Play sound effect on blunders", ref playSoundEffectsOnBlunder))
{
configuration.PlaySoundEffectsOnBlunder = playSoundEffectsOnBlunder;
configuration.Save();
}

var applyGameVolume = configuration.ApplyGameVolume;
if (ImGui.Checkbox("Apply game volume", ref applyGameVolume))
{
Expand Down

0 comments on commit 3d29936

Please sign in to comment.