From 869db0b2344b67cf970d0336f7584ffb1e55f3e3 Mon Sep 17 00:00:00 2001 From: EmielRegis <70418164+w1tcherrr@users.noreply.github.com> Date: Tue, 20 Aug 2024 23:45:07 +0200 Subject: [PATCH] Add penalties for team-kill assists and team-flash-assists --- K4-System/src/Module/Rank/RankEvents.cs | 26 ++++++++++++++++++++----- K4-System/src/Plugin/PluginConfig.cs | 6 ++++++ K4-System/src/lang/en.json | 2 ++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/K4-System/src/Module/Rank/RankEvents.cs b/K4-System/src/Module/Rank/RankEvents.cs index 1665c98..0aa69d8 100644 --- a/K4-System/src/Module/Rank/RankEvents.cs +++ b/K4-System/src/Module/Rank/RankEvents.cs @@ -251,7 +251,7 @@ public void Initialize_Events() } else { - + RankData k4attackerRankData = k4attacker.rankData; if (Config.RankSettings.PointsForBots || k4attacker.IsPlayer) { @@ -270,9 +270,12 @@ public void Initialize_Events() else { string? extraInfo; - if (k4attacker.IsPlayer && k4victimRankData != null) { + if (k4attacker.IsPlayer && k4victimRankData != null) + { extraInfo = Config.RankSettings.PlayerNameKillMessages ? plugin.Localizer["k4.phrases.kill.extra", k4victim.PlayerName, k4victimRankData.Points] : null!; - } else { + } + else + { extraInfo = Config.RankSettings.PlayerNameKillMessages ? plugin.Localizer["k4.phrases.kill.extra", k4victim.PlayerName, 0] : null!; } ModifyPlayerPoints(k4attacker, CalculateDynamicPoints(k4attacker, k4victim, Config.PointSettings.Kill), "k4.phrases.kill", extraInfo); @@ -383,12 +386,25 @@ public void Initialize_Events() K4Player? k4assister = plugin.GetK4Player(@event.Assister); if (k4assister?.IsValid == true && k4assister.IsPlayer && (Config.RankSettings.PointsForBots || k4victim.IsPlayer)) { - ModifyPlayerPoints(k4assister, Config.PointSettings.Assist, "k4.phrases.assist"); + bool isFFAMode = Config.GeneralSettings.FFAMode; + bool victimIsEnemy = isFFAMode || (k4assister.Controller.Team != k4victim.Controller.Team); - if (@event.Assistedflash) + if (victimIsEnemy && !@event.Assistedflash) + { + ModifyPlayerPoints(k4assister, Config.PointSettings.Assist, "k4.phrases.assist"); + } + else if (!victimIsEnemy && !@event.Assistedflash) + { + ModifyPlayerPoints(k4assister, Config.PointSettings.TeamAssist, "k4.phrases.teamassist"); + } + else if (victimIsEnemy && @event.Assistedflash) { ModifyPlayerPoints(k4assister, Config.PointSettings.AssistFlash, "k4.phrases.assistflash"); } + else if (!victimIsEnemy && @event.Assistedflash) + { + ModifyPlayerPoints(k4assister, Config.PointSettings.TeamAssistFlash, "k4.phrases.teamassistflash"); + } } return HookResult.Continue; diff --git a/K4-System/src/Plugin/PluginConfig.cs b/K4-System/src/Plugin/PluginConfig.cs index a9c6e0b..9dd3754 100644 --- a/K4-System/src/Plugin/PluginConfig.cs +++ b/K4-System/src/Plugin/PluginConfig.cs @@ -267,9 +267,15 @@ public sealed class PointSettings [JsonPropertyName("assist")] public int Assist { get; set; } = 5; + [JsonPropertyName("team-assist")] + public int TeamAssist { get; set; } = -5; + [JsonPropertyName("assist-flash")] public int AssistFlash { get; set; } = 7; + [JsonPropertyName("team-assist-flash")] + public int TeamAssistFlash { get; set; } = -7; + [JsonPropertyName("round-win")] public int RoundWin { get; set; } = 5; diff --git a/K4-System/src/lang/en.json b/K4-System/src/lang/en.json index f908cdc..1fec701 100644 --- a/K4-System/src/lang/en.json +++ b/K4-System/src/lang/en.json @@ -116,6 +116,8 @@ "k4.phrases.godlike": "Godlike", "k4.phrases.assist": "Assist", "k4.phrases.assistflash": "Assist Flash", + "k4.phrases.teamassist": "Team Assist", + "k4.phrases.teamassistflash": "Team Assist Flash", "k4.phrases.shortyear": "y", "k4.phrases.shortmonth": "mo", "k4.phrases.shortday": "d",