ignored victims + improve weapon message

This commit is contained in:
Axwabo 2023-06-30 16:34:28 +02:00
parent e3dbf1300d
commit e6a9f8f8a6
2 changed files with 8 additions and 4 deletions

View File

@ -15,14 +15,14 @@ public sealed class DeathLogPlugin
[PluginEntryPoint("DeathLog", "1.1.0", "DeathLog", "Axwabo")] [PluginEntryPoint("DeathLog", "1.1.0", "DeathLog", "Axwabo")]
public void OnEnabled() public void OnEnabled()
{ {
PluginAPI.Events.EventManager.RegisterEvents(this); EventManager.RegisterEvents(this);
Log.Info("DeathLog loaded!"); Log.Info("DeathLog loaded!");
} }
[PluginUnload] [PluginUnload]
public void OnDisabled() public void OnDisabled()
{ {
PluginAPI.Events.EventManager.UnregisterEvents(this); EventManager.UnregisterEvents(this);
Log.Info("DeathLog disabled!"); Log.Info("DeathLog disabled!");
} }
@ -36,6 +36,7 @@ public sealed class DeathLogPlugin
{ {
_spawnWaveOccurred = false; _spawnWaveOccurred = false;
_lastId = ""; _lastId = "";
LogHandler.KosIgnoredVictimNetIdList.Clear();
} }
[PluginEvent(ServerEventType.TeamRespawn)] [PluginEvent(ServerEventType.TeamRespawn)]

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using Axwabo.Helpers; using Axwabo.Helpers;
using PlayerRoles; using PlayerRoles;
@ -18,6 +19,8 @@ public static class LogHandler
private static readonly Color DntColor = new(0.59f, 0.59f, 0.59f); private static readonly Color DntColor = new(0.59f, 0.59f, 0.59f);
public static readonly HashSet<uint> KosIgnoredVictimNetIdList = new();
private static bool IsWeapon(ItemType type) => type is ItemType.GunCOM15 private static bool IsWeapon(ItemType type) => type is ItemType.GunCOM15
or ItemType.GunCOM18 or ItemType.GunCOM18
or ItemType.GunCom45 or ItemType.GunCom45
@ -56,7 +59,7 @@ public static class LogHandler
var victimRole = victim.Role; var victimRole = victim.Role;
var footprint = handler.Attacker; var footprint = handler.Attacker;
var attackerRole = footprint.Role; var attackerRole = footprint.Role;
var canBeKos = !kosPermitted && IsKos(victimRole, attackerRole); var canBeKos = !KosIgnoredVictimNetIdList.Contains(victim.NetworkId) && !kosPermitted && IsKos(victimRole, attackerRole);
var scpAttacker = PlayerRoleLoader.TryGetRoleTemplate(attackerRole, out FpcStandardScp _); var scpAttacker = PlayerRoleLoader.TryGetRoleTemplate(attackerRole, out FpcStandardScp _);
Log(sizeScalar => "KILL LOG".Bold().Color("yellow") + "#" + string.Format( Log(sizeScalar => "KILL LOG".Bold().Color("yellow") + "#" + string.Format(
GetKillMessage(handler, canBeKos, hasWeaponEquipped, isCuffed, carriesWeapon, scpAttacker, sizeScalar), GetKillMessage(handler, canBeKos, hasWeaponEquipped, isCuffed, carriesWeapon, scpAttacker, sizeScalar),
@ -130,7 +133,7 @@ public static class LogHandler
show && (carriesWeapon || hasWeaponEquipped) show && (carriesWeapon || hasWeaponEquipped)
? (hasWeaponEquipped ? (hasWeaponEquipped
? " Victim was " + "holding".Underline() + " a weapon." ? " Victim was " + "holding".Underline() + " a weapon."
: " Victim was " + "carrying".Underline() + " a weapon." : " Victim had a weapon " + "in their inventory.".Underline()
).Color(Cyan).Size(30.Scale(sizeScalar)) ).Color(Cyan).Size(30.Scale(sizeScalar))
: ""; : "";