kill log
This commit is contained in:
parent
9d2d6a51e6
commit
9799fdd8a7
@ -106,6 +106,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="DeathLogConfig.cs" />
|
||||
<Compile Include="DeathLogPlugin.cs" />
|
||||
<Compile Include="LogHandler.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -3,35 +3,31 @@ using PluginAPI.Core;
|
||||
using PluginAPI.Core.Attributes;
|
||||
using PluginAPI.Enums;
|
||||
|
||||
namespace DeathLog;
|
||||
namespace DeathLog;
|
||||
|
||||
public sealed class DeathLogPlugin {
|
||||
|
||||
[PluginEntryPoint("DeathLog", "1.0.0", "DeathLog", "Axwabo")]
|
||||
public void OnEnabled() {
|
||||
PluginAPI.Events.EventManager.RegisterEvents(this);
|
||||
Log.Debug("DeathLog loaded!");
|
||||
}
|
||||
|
||||
[PluginUnload]
|
||||
public void OnDisabled() {
|
||||
PluginAPI.Events.EventManager.UnregisterEvents(this);
|
||||
Log.Debug("DeathLog disabled!");
|
||||
}
|
||||
|
||||
[PluginConfig]
|
||||
public DeathLogConfig Config = new();
|
||||
|
||||
[PluginEvent(ServerEventType.PlayerDeath)]
|
||||
[PluginEvent(ServerEventType.PlayerDying)]
|
||||
public void OnPlayerDeath(Player player, Player attacker, DamageHandlerBase handler) {
|
||||
if (attacker == null)
|
||||
LogSimpleDeathMessage(player, handler);
|
||||
else
|
||||
LogAttackerDeathMessage(player, attacker, handler);
|
||||
}
|
||||
|
||||
private void LogSimpleDeathMessage(Player player, DamageHandlerBase handler) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
private void LogAttackerDeathMessage(Player player, Player attacker, DamageHandlerBase handler) {
|
||||
throw new System.NotImplementedException();
|
||||
if (attacker != null && handler is AttackerDamageHandler adh)
|
||||
LogHandler.LogAttackerDeathMessage(player, attacker, adh);
|
||||
else if (Config.LogSimpleDeaths)
|
||||
LogHandler.LogSimpleDeathMessage(player, handler);
|
||||
}
|
||||
|
||||
}
|
||||
|
119
DeathLog/LogHandler.cs
Normal file
119
DeathLog/LogHandler.cs
Normal file
@ -0,0 +1,119 @@
|
||||
using System.Linq;
|
||||
using Axwabo.Helpers;
|
||||
using PlayerRoles;
|
||||
using PlayerRoles.PlayableScps;
|
||||
using PlayerRoles.PlayableScps.Scp939;
|
||||
using PlayerStatsSystem;
|
||||
using PluginAPI.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DeathLog;
|
||||
|
||||
public static class LogHandler {
|
||||
|
||||
private static bool IsWeapon(ItemType type) => type is ItemType.GunCOM15
|
||||
or ItemType.GunCOM18
|
||||
or ItemType.GunCom45
|
||||
or ItemType.GunFSP9
|
||||
or ItemType.GunCrossvec
|
||||
or ItemType.GunE11SR
|
||||
or ItemType.GunAK
|
||||
or ItemType.GunRevolver
|
||||
or ItemType.GunShotgun
|
||||
or ItemType.GunLogicer
|
||||
or ItemType.ParticleDisruptor
|
||||
or ItemType.Jailbird;
|
||||
|
||||
public static void LogSimpleDeathMessage(Player player, DamageHandlerBase handler) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static void LogAttackerDeathMessage(Player victim, Player attacker, AttackerDamageHandler handler) {
|
||||
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 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),
|
||||
GetKillerStatus(attacker),
|
||||
GetVictimStatus(victim)
|
||||
), !isCuffed && (!canBeKos || !hasWeaponEquipped));
|
||||
}
|
||||
|
||||
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 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)}";
|
||||
}
|
||||
|
||||
private static object GetKillerStatus(Player attacker) {
|
||||
var role = attacker.Rm().CurrentRole;
|
||||
return GetIdWithDnt(attacker)
|
||||
+ " "
|
||||
+ role.RoleName.Color(role.RoleColor.ToHex(true, false)).Size(35)
|
||||
+ " " + attacker.Nickname.Bold().Size(35);
|
||||
}
|
||||
|
||||
private static object GetVictimStatus(Player victim) {
|
||||
var role = victim.Rm().CurrentRole;
|
||||
return GetIdWithDnt(victim).Size(25)
|
||||
+ " "
|
||||
+ role.RoleName.Color(role.RoleColor.ToHex(true, false)).Size(35)
|
||||
+ " " + victim.Nickname.Bold().Size(30);
|
||||
}
|
||||
|
||||
private static string GetKillMessage(AttackerDamageHandler handler, bool canBeKos, bool hasWeaponEquipped, bool cuffed, bool carriesWeapon, bool scpAttacker) =>
|
||||
(canBeKos && !hasWeaponEquipped ? "POSSIBLE KOS".Color("red").Size(50) + " " : "")
|
||||
+ (cuffed ? "DETAINED KILL ".Color("#00fff6").Size(50) + " " : "")
|
||||
+ handler switch {
|
||||
RecontainmentDamageHandler => $"{{0}} {"recontained".Bold().Color("orange").Size(35)} {{1}}",
|
||||
FirearmDamageHandler firearm => GetFirearmKillLog(firearm),
|
||||
ScpDamageHandler => $"{{0}} killed {{1}} using the {"default SCP attack".Bold().Color("orange").Size(35)}",
|
||||
Scp096DamageHandler scp096 => $"{{0}} killed {{1}} using {GetScp096AttackType(scp096).Bold().Color("orange").Size(35)}",
|
||||
Scp049DamageHandler scp049 => $"{{0}} killed {{1}} using {GetScp049AttackType(scp049).Bold().Color("orange").Size(35)}",
|
||||
Scp939DamageHandler scp939 => $"{{0}} killed {{1}} using {GetScp939AttackType(scp939).Bold().Color("orange").Size(35)}",
|
||||
MicroHidDamageHandler => $"{{0}} fried {{1}} with the {"Micro H.I.D.".Bold().Color("orange").Size(35)}",
|
||||
ExplosionDamageHandler => $"{{0}} {"exploded".Bold().Color("orange").Size(35)} {{1}}",
|
||||
Scp018DamageHandler => $"{{0}} killed {{1}} with {"SCP-018".Bold().Color("orange").Size(35)}",
|
||||
DisruptorDamageHandler => $"{{0}} killed {{1}} with the {"3-X Particle Disruptor".Bold().Color("orange").Size(35)}",
|
||||
JailbirdDamageHandler => $"{{0}} killed {{1}} with the {"Jailbird".Bold().Color("orange").Size(35)}",
|
||||
_ => $"{{0}} killed {{1}}. {"Reason is unknown".Italic()}"
|
||||
}
|
||||
+ WeaponStatusMessage(!scpAttacker, hasWeaponEquipped, carriesWeapon);
|
||||
|
||||
private static string WeaponStatusMessage(bool show, bool hasWeaponEquipped, bool carriesWeapon) => show && (carriesWeapon || hasWeaponEquipped) ? (hasWeaponEquipped ? " Victim was " + "holding".Underline() + " a weapon." : " Victim was " + "carrying".Underline() + " a weapon.").Color("orange").Size(30) : "";
|
||||
|
||||
private static string GetFirearmKillLog(FirearmDamageHandler firearm) => $"{{0}} shot {{1}} with {firearm.WeaponType.ToString().Bold().Color("red").Size(35)} to the hitbox " + firearm.Hitbox.ToString().Color("red").Bold().Size(35);
|
||||
|
||||
private static string GetScp096AttackType(Scp096DamageHandler scp096) => scp096._attackType switch {
|
||||
Scp096DamageHandler.AttackType.Charge => "Charge",
|
||||
Scp096DamageHandler.AttackType.SlapLeft => "Left Slap",
|
||||
Scp096DamageHandler.AttackType.SlapRight => "Right Slap",
|
||||
Scp096DamageHandler.AttackType.GateKill => "Gate Kill",
|
||||
_ => "[an unknown attack type]"
|
||||
};
|
||||
|
||||
private static string GetScp049AttackType(Scp049DamageHandler scp049) => scp049.DamageSubType switch {
|
||||
Scp049DamageHandler.AttackType.Instakill => "Instakill",
|
||||
Scp049DamageHandler.AttackType.Scp0492 => "SCP-049-2",
|
||||
Scp049DamageHandler.AttackType.CardiacArrest => "Cardiac Arrest",
|
||||
_ => "[an unknown attack type]"
|
||||
};
|
||||
|
||||
private static string GetScp939AttackType(Scp939DamageHandler scp939) => scp939._damageType switch {
|
||||
Scp939DamageType.Claw => "Claw",
|
||||
Scp939DamageType.LungeSecondary => "Lunge Secondary",
|
||||
Scp939DamageType.LungeTarget => "Lunge Target",
|
||||
_ => "[an unknown attack type]"
|
||||
};
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user