Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #213 from w1tcherrr/dev
Browse files Browse the repository at this point in the history
Add penalties for team-kill assists and team-flash-assists (BUG #211)
  • Loading branch information
K4ryuu authored Aug 20, 2024
2 parents 3ee8698 + 869db0b commit f4bdb42
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
26 changes: 21 additions & 5 deletions K4-System/src/Module/Rank/RankEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public void Initialize_Events()
}
else
{

RankData k4attackerRankData = k4attacker.rankData;
if (Config.RankSettings.PointsForBots || k4attacker.IsPlayer)
{
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions K4-System/src/Plugin/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions K4-System/src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f4bdb42

Please sign in to comment.