use footprint + permissions
This commit is contained in:
parent
fb2167e223
commit
7b15c5d758
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\build\Microsoft.CodeAnalysis.Analyzers.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\build\Microsoft.CodeAnalysis.Analyzers.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Import Project="..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\build\Microsoft.CodeAnalysis.Analyzers.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\build\Microsoft.CodeAnalysis.Analyzers.props')"/>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@ -37,91 +37,91 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\..\assemblies\Assembly-CSharp.dll</HintPath>
|
||||
<HintPath>..\..\assemblies\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp-firstpass">
|
||||
<HintPath>..\..\assemblies\Assembly-CSharp-firstpass.dll</HintPath>
|
||||
<HintPath>..\..\assemblies\Assembly-CSharp-firstpass.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Axwabo.Helpers.NWAPI">
|
||||
<HintPath>..\..\assemblies\Axwabo.Helpers.dll</HintPath>
|
||||
<HintPath>..\..\assemblies\Axwabo.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis, Version=3.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.Common.3.3.1\lib\netstandard2.0\Microsoft.CodeAnalysis.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.Common.3.3.1\lib\netstandard2.0\Microsoft.CodeAnalysis.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.CSharp, Version=3.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.3.3.1\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.3.3.1\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mirror">
|
||||
<HintPath>..\..\assemblies\Mirror.dll</HintPath>
|
||||
<HintPath>..\..\assemblies\Mirror.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mirror.Components">
|
||||
<HintPath>..\..\assemblies\Mirror.Components.dll</HintPath>
|
||||
<HintPath>..\..\assemblies\Mirror.Components.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="mscorlib"/>
|
||||
<Reference Include="NwPluginAPI.Analyzers, Version=12.0.0.0, Culture=neutral, processorArchitecture=Amd64">
|
||||
<HintPath>..\packages\Northwood.PluginAPI.Analyzers.12.0.0\lib\netstandard2.0\NwPluginAPI.Analyzers.dll</HintPath>
|
||||
<HintPath>..\packages\Northwood.PluginAPI.Analyzers.12.0.0\lib\netstandard2.0\NwPluginAPI.Analyzers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PluginAPI, Version=12.0.0.0, Culture=neutral, processorArchitecture=Amd64">
|
||||
<HintPath>..\packages\Northwood.PluginAPI.12.0.0\lib\net48\PluginAPI.dll</HintPath>
|
||||
<HintPath>..\packages\Northwood.PluginAPI.12.0.0\lib\net48\PluginAPI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System"/>
|
||||
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
|
||||
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Collections.Immutable, Version=1.2.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath>
|
||||
<HintPath>..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Core"/>
|
||||
<Reference Include="System.Data"/>
|
||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
|
||||
<HintPath>..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics"/>
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Reflection.Metadata, Version=1.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll</HintPath>
|
||||
<HintPath>..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encoding.CodePages.4.5.1\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
|
||||
<HintPath>..\packages\System.Text.Encoding.CodePages.4.5.1\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml"/>
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>..\..\assemblies\UnityEngine.dll</HintPath>
|
||||
<HintPath>..\..\assemblies\UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>..\..\assemblies\UnityEngine.CoreModule.dll</HintPath>
|
||||
<HintPath>..\..\assemblies\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\YamlDotNet.11.0.1\lib\net45\YamlDotNet.dll</HintPath>
|
||||
<HintPath>..\packages\YamlDotNet.11.0.1\lib\net45\YamlDotNet.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DeathLogConfig.cs" />
|
||||
<Compile Include="DeathLogPlugin.cs" />
|
||||
<Compile Include="LogHandler.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="DeathLogConfig.cs"/>
|
||||
<Compile Include="DeathLogPlugin.cs"/>
|
||||
<Compile Include="LogHandler.cs"/>
|
||||
<Compile Include="Properties\AssemblyInfo.cs"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="packages.config"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
|
||||
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
|
||||
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll"/>
|
||||
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll"/>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\build\Microsoft.CodeAnalysis.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\build\Microsoft.CodeAnalysis.Analyzers.props'))" />
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\build\Microsoft.CodeAnalysis.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\build\Microsoft.CodeAnalysis.Analyzers.props'))"/>
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
@ -1,7 +1,9 @@
|
||||
namespace DeathLog;
|
||||
namespace DeathLog;
|
||||
|
||||
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,17 +1,18 @@
|
||||
<?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.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" />
|
||||
<package id="Northwood.PluginAPI.Analyzers" version="12.0.0" targetFramework="net48" />
|
||||
<package id="System.Buffers" version="4.4.0" targetFramework="net48" />
|
||||
<package id="System.Collections.Immutable" version="1.5.0" targetFramework="net48" />
|
||||
<package id="System.Memory" version="4.5.3" targetFramework="net48" />
|
||||
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net48" />
|
||||
<package id="System.Reflection.Metadata" version="1.6.0" targetFramework="net48" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net48" />
|
||||
<package id="System.Text.Encoding.CodePages" version="4.5.1" targetFramework="net48" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.3" targetFramework="net48" />
|
||||
<package id="YamlDotNet" version="11.0.1" targetFramework="net48" />
|
||||
<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"/>
|
||||
<package id="Northwood.PluginAPI.Analyzers" version="12.0.0" targetFramework="net48"/>
|
||||
<package id="System.Buffers" version="4.4.0" targetFramework="net48"/>
|
||||
<package id="System.Collections.Immutable" version="1.5.0" targetFramework="net48"/>
|
||||
<package id="System.Memory" version="4.5.3" targetFramework="net48"/>
|
||||
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net48"/>
|
||||
<package id="System.Reflection.Metadata" version="1.6.0" targetFramework="net48"/>
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net48"/>
|
||||
<package id="System.Text.Encoding.CodePages" version="4.5.1" targetFramework="net48"/>
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.3" targetFramework="net48"/>
|
||||
<package id="YamlDotNet" version="11.0.1" targetFramework="net48"/>
|
||||
</packages>
|
Loading…
x
Reference in New Issue
Block a user