Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion resources/translations/en.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@
"quake.headshot": "[blue]Headshot",
"quake.humiliation": "[green]Humiliation",
"quake.knifekill": "[green]Knife Kill",
"quake.knife_kill": "[green]Knife Kill",
"quake.taser_kill": "[green]Taser Kill",
"quake.teamkill": "[red]Team Kill",
"quake.selfkill": "[red]Self Kill",
"quake.grenadekill": "[green]Grenade Kill",
"quake.roundstart": "[default]Round Start",
"quake.round_start": "[default]Round Start",
"quake.roundend": "[default]Round End",
"quake.round_freeze_end": "[default]Freeze Time End",
"commands.common.only_player": "This command can only be used by a player.",
"commands.volume.current": "Current QuakeSounds volume: {volume}/10",
"commands.volume.usage": "Usage: !volume <0-10>",
"commands.volume.set": "QuakeSounds volume set to {volume}/10.",
"commands.quake.enabled": "QuakeSounds enabled.",
"commands.quake.disabled": "QuakeSounds disabled.",
"commands.quake.disabled": "QuakeSounds disabled."
}
4 changes: 4 additions & 0 deletions src/Configuration/QuakeSoundsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ public sealed class QuakeSoundsConfig
["holyshit"] = "holyshit.mp3",
["humiliation"] = "humiliation.mp3",
["impressive"] = "impressive.mp3",
["knife_kill"] = "knife_kill.mp3",
["killingspree"] = "killingspree.mp3",
["ludicrouskill"] = "ludicrouskill.mp3",
["monsterkill"] = "monsterkill.mp3",
["multikill"] = "multikill.mp3",
["ownage"] = "ownage.mp3",
["perfect"] = "perfect.mp3",
["rampage"] = "rampage.mp3",
["round_freeze_end"] = "round_freeze_end.mp3",
["round_start"] = "round_start.mp3",
["taser_kill"] = "taser_kill.mp3",
["triplekill"] = "triplekill.mp3",
["ultrakill"] = "ultrakill.mp3",
["unstoppable"] = "unstoppable.mp3",
Expand Down
23 changes: 18 additions & 5 deletions src/EventHandlers/PlayerDeathHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ public HookResult OnPlayerDeath(EventPlayerDeath @event)
}
}

if (@event.Weapon.Contains("taser", StringComparison.OrdinalIgnoreCase) && TryPlay(attacker, "taser_kill"))
{
return HookResult.Continue;
}

if (@event.Weapon.Contains("knife", StringComparison.OrdinalIgnoreCase))
{
if (TryPlay(attacker, "knife_kill"))
{
return HookResult.Continue;
}

if (TryPlay(attacker, "humiliation"))
{
return HookResult.Continue;
}
}

if (isMultiKill)
{
if (TryPlayKillStreak(attacker, multiKillCount))
Expand All @@ -98,11 +116,6 @@ public HookResult OnPlayerDeath(EventPlayerDeath @event)
if (playedHeadshot) return HookResult.Continue;
}

if (@event.Weapon.Contains("knife", StringComparison.OrdinalIgnoreCase) && TryPlay(attacker, "humiliation"))
{
return HookResult.Continue;
}

if (@event.Weapon.Contains("hegrenade", StringComparison.OrdinalIgnoreCase) && TryPlay(attacker, "perfect"))
{
return HookResult.Continue;
Expand Down
45 changes: 45 additions & 0 deletions src/EventHandlers/RoundStartHandler.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,48 @@
using SwiftlyS2.Shared.GameEvents;
using SwiftlyS2.Shared.GameEventDefinitions;
using SwiftlyS2.Shared.Misc;
using System.Linq;

namespace QuakeSounds;

public partial class QuakeSounds
{
private void TryPlayRoundSoundToAll(string soundKey)
{
var anyPlayer = Core.PlayerManager.GetAllPlayers()
.FirstOrDefault(p => p is { IsValid: true } && !p.IsFakeClient);

if (anyPlayer == null)
{
return;
}

var originalPlayToAll = _config.PlayToAll;
var originalCenter = _config.Messages.EnableCenterMessage;
var originalChat = _config.Messages.EnableChatMessage;

try
{
_config.PlayToAll = true;
_config.Messages.EnableCenterMessage = false;
_config.Messages.EnableChatMessage = false;

_audioService?.TryPlay(
anyPlayer,
soundKey,
_config,
id => _gameStateService.IsPlayerEnabled(id),
id => _gameStateService.GetPlayerVolume(id)
);
}
finally
{
_config.PlayToAll = originalPlayToAll;
_config.Messages.EnableCenterMessage = originalCenter;
_config.Messages.EnableChatMessage = originalChat;
}
}

[GameEventHandler(HookMode.Post)]
public HookResult OnRoundStart(EventRoundStart @event)
{
Expand All @@ -15,6 +52,14 @@ public HookResult OnRoundStart(EventRoundStart @event)
}

_gameStateService.ClearRoundState();
TryPlayRoundSoundToAll("round_start");
return HookResult.Continue;
}

[GameEventHandler(HookMode.Post)]
public HookResult OnRoundFreezeEnd(EventRoundFreezeEnd @event)
{
TryPlayRoundSoundToAll("round_freeze_end");
return HookResult.Continue;
}
}
2 changes: 1 addition & 1 deletion src/QuakeSounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace QuakeSounds;

[PluginMetadata(Id = "QuakeSounds", Version = "1.0.1", Name = "QuakeSounds", Author = "aga", Description = "No description.")]
[PluginMetadata(Id = "QuakeSounds", Version = "1.0.2", Name = "QuakeSounds", Author = "aga", Description = "No description.")]
public partial class QuakeSounds : BasePlugin {
private AudioService? _audioService;
private readonly GameStateService _gameStateService;
Expand Down