use footprint + permissions
This commit is contained in:
parent
fb2167e223
commit
7b15c5d758
@ -4,4 +4,6 @@ public sealed class DeathLogConfig {
|
||||
|
||||
public bool LogSimpleDeaths { get; set; } = true;
|
||||
|
||||
public PlayerPermissions VisibilityRequirement { get; set; } = PlayerPermissions.Overwatch;
|
||||
|
||||
}
|
@ -25,9 +25,9 @@ public sealed class DeathLogPlugin {
|
||||
[PluginEvent(ServerEventType.PlayerDying)]
|
||||
public void OnPlayerDeath(Player player, Player attacker, DamageHandlerBase handler) {
|
||||
if (attacker != null && handler is AttackerDamageHandler adh)
|
||||
LogHandler.LogAttackerDeathMessage(player, attacker, adh);
|
||||
LogHandler.LogAttackerDeathMessage(player, attacker, adh, Config.VisibilityRequirement);
|
||||
else if (Config.LogSimpleDeaths)
|
||||
LogHandler.LogSimpleDeathMessage(player, handler);
|
||||
LogHandler.LogSimpleDeathMessage(player, handler, Config.VisibilityRequirement);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ namespace DeathLog;
|
||||
|
||||
public static class LogHandler {
|
||||
|
||||
private static readonly Color DntColor = new(0.59f, 0.59f, 0.59f);
|
||||
|
||||
private static bool IsWeapon(ItemType type) => type is ItemType.GunCOM15
|
||||
or ItemType.GunCOM18
|
||||
or ItemType.GunCom45
|
||||
@ -24,10 +26,10 @@ public static class LogHandler {
|
||||
or ItemType.ParticleDisruptor
|
||||
or ItemType.Jailbird;
|
||||
|
||||
public static void LogSimpleDeathMessage(Player player, DamageHandlerBase handler) => Log("DEATH LOG" + "#" + string.Format(
|
||||
public static void LogSimpleDeathMessage(Player player, DamageHandlerBase handler, PlayerPermissions permissions) => Log("DEATH LOG" + "#" + string.Format(
|
||||
GetDeathMessage(handler),
|
||||
GetVictimStatus(player)
|
||||
), true);
|
||||
), true, permissions);
|
||||
|
||||
private static string GetDeathMessage(DamageHandlerBase handler) => handler switch {
|
||||
CustomReasonDamageHandler custom => $"{{0}} has died: {custom._deathReason.Bold().Color("orange").Size(30)}",
|
||||
@ -36,31 +38,35 @@ public static class LogHandler {
|
||||
_ => $"{{0}} has died. {"Reason is unknown".Italic()}"
|
||||
};
|
||||
|
||||
public static void LogAttackerDeathMessage(Player victim, Player attacker, AttackerDamageHandler handler) {
|
||||
public static void LogAttackerDeathMessage(Player victim, Player attacker, AttackerDamageHandler handler, PlayerPermissions permissions) {
|
||||
var isCuffed = victim.IsDisarmed;
|
||||
var inv = victim.ReferenceHub.inventory;
|
||||
var hasWeaponEquipped = IsWeapon(inv.CurItem.TypeId);
|
||||
var carriesWeapon = inv.UserInventory.Items.Any(item => IsWeapon(item.Value.ItemTypeId));
|
||||
var victimRole = victim.Role;
|
||||
var attackerRole = attacker.Role;
|
||||
var footprint = handler.Attacker;
|
||||
var attackerRole = footprint.Role;
|
||||
var canBeKos = victimRole == RoleTypeId.ClassD && attackerRole == RoleTypeId.Scientist
|
||||
|| victimRole == RoleTypeId.Scientist && attackerRole == RoleTypeId.ClassD
|
||||
|| victimRole == RoleTypeId.ClassD && attackerRole is RoleTypeId.FacilityGuard or RoleTypeId.NtfPrivate or RoleTypeId.NtfSergeant or RoleTypeId.NtfSpecialist or RoleTypeId.NtfCaptain;
|
||||
Log("KILL LOG".Bold().Color("yellow") + "#" + string.Format(
|
||||
GetKillMessage(handler, canBeKos, hasWeaponEquipped, isCuffed, carriesWeapon, attacker.Rm().CurrentRole is FpcStandardScp),
|
||||
GetKillMessage(handler, canBeKos, hasWeaponEquipped, isCuffed, carriesWeapon, PlayerRoleLoader.TryGetRoleTemplate(attackerRole, out FpcStandardScp _)),
|
||||
GetKillerStatus(attacker),
|
||||
GetVictimStatus(victim)
|
||||
), !isCuffed && (!canBeKos || !hasWeaponEquipped));
|
||||
), !isCuffed && (!canBeKos || !hasWeaponEquipped), permissions);
|
||||
}
|
||||
|
||||
private static void Log(string msg, bool success) {
|
||||
foreach (var p in Player.GetPlayers().Where(p => p.RemoteAdminAccess))
|
||||
p.ReferenceHub.queryProcessor._sender.RaReply(msg, success, true, "");
|
||||
private static void Log(string msg, bool success, PlayerPermissions playerPermissions) {
|
||||
foreach (var p in Player.GetPlayers()) {
|
||||
var sender = p.ReferenceHub.queryProcessor._sender;
|
||||
if (p.RemoteAdminAccess && PermissionsHandler.IsPermitted(sender.Permissions, playerPermissions))
|
||||
sender.RaReply(msg, success, true, "");
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetIdWithDnt(Player player) {
|
||||
var dnt = player.DoNotTrack;
|
||||
return $"{(dnt ? "(DNT)".Color(new Color(0.59f, 0.59f, 0.59f)).Size(50) + " " : "")}{player.UserId} {player.PlayerId.ToString().Bold().Color("yellow").Size(30)}";
|
||||
return $"{(dnt ? "(DNT)".Color(DntColor).Size(50) + " " : "")}{player.UserId} {player.PlayerId.ToString().Bold().Color("yellow").Size(30)}";
|
||||
}
|
||||
|
||||
private static object GetKillerStatus(Player attacker) {
|
||||
@ -111,7 +117,7 @@ public static class LogHandler {
|
||||
};
|
||||
|
||||
private static string GetScp049AttackType(Scp049DamageHandler scp049) => scp049.DamageSubType switch {
|
||||
Scp049DamageHandler.AttackType.Instakill => "Instakill",
|
||||
Scp049DamageHandler.AttackType.Instakill => "SCP-049 Instakill",
|
||||
Scp049DamageHandler.AttackType.Scp0492 => "SCP-049-2",
|
||||
Scp049DamageHandler.AttackType.CardiacArrest => "Cardiac Arrest",
|
||||
_ => "[an unknown attack type]"
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.CodeAnalysis.Analyzers" version="2.9.8" targetFramework="net48" developmentDependency="true" />
|
||||
<package id="Microsoft.CodeAnalysis.Analyzers" version="2.9.8" targetFramework="net48"
|
||||
developmentDependency="true"/>
|
||||
<package id="Microsoft.CodeAnalysis.CSharp" version="3.3.1" targetFramework="net48"/>
|
||||
<package id="Microsoft.CodeAnalysis.Common" version="3.3.1" targetFramework="net48"/>
|
||||
<package id="Northwood.PluginAPI" version="12.0.0" targetFramework="net48"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user