mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-07-06 03:50:18 -05:00
removed reload command
prevent control characters from being used in name added MOD_HEAD_SHOT to hit location increment css fix for alias dropdown testing view angle analysis
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
using SharedLibrary.Interfaces;
|
||||
using SharedLibrary.Helpers;
|
||||
using SharedLibrary.Interfaces;
|
||||
using SharedLibrary.Objects;
|
||||
using StatsPlugin.Helpers;
|
||||
using StatsPlugin.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -34,7 +36,8 @@ namespace StatsPlugin.Cheat
|
||||
public DetectionPenaltyResult ProcessKill(EFClientKill kill)
|
||||
{
|
||||
if ((kill.DeathType != IW4Info.MeansOfDeath.MOD_PISTOL_BULLET &&
|
||||
kill.DeathType != IW4Info.MeansOfDeath.MOD_RIFLE_BULLET) ||
|
||||
kill.DeathType != IW4Info.MeansOfDeath.MOD_RIFLE_BULLET &&
|
||||
kill.DeathType != IW4Info.MeansOfDeath.MOD_HEAD_SHOT) ||
|
||||
kill.HitLoc == IW4Info.HitLocation.none)
|
||||
return new DetectionPenaltyResult()
|
||||
{
|
||||
@ -46,7 +49,19 @@ namespace StatsPlugin.Cheat
|
||||
Kills++;
|
||||
AverageKillTime = (AverageKillTime + (DateTime.UtcNow - LastKill).TotalSeconds) / Kills;
|
||||
|
||||
#region SESSION_RATIOS
|
||||
#region VIEWANGLES
|
||||
double distance = Vector3.Distance(kill.KillOrigin, kill.DeathOrigin);
|
||||
double x = kill.KillOrigin.X + distance * Math.Cos(kill.ViewAngles.Y.ToRadians()) * Math.Cos(kill.ViewAngles.X.ToRadians());
|
||||
double y = kill.KillOrigin.Y + (distance * Math.Sin((360.0f - kill.ViewAngles.Y).ToRadians()));
|
||||
double z = kill.KillOrigin.Z + (distance * Math.Cos(kill.ViewAngles.Y.ToRadians()) * Math.Sin((360.0f - kill.ViewAngles.X).ToRadians()));
|
||||
var trueVector = Vector3.Subtract(kill.KillOrigin, kill.DeathOrigin);
|
||||
var calculatedVector = Vector3.Subtract(kill.KillOrigin, new Vector3((float)x, (float)y, (float)z));
|
||||
double angle = trueVector.AngleBetween(calculatedVector);
|
||||
Console.WriteLine(((float)angle).ToDegrees());
|
||||
|
||||
#endregion
|
||||
|
||||
#region SESSION_RATIOS
|
||||
if (Kills >= Thresholds.LowSampleMinKills)
|
||||
{
|
||||
double marginOfError = Thresholds.GetMarginOfError(Kills);
|
||||
|
26
Plugins/SimpleStats/Helpers/Extensions.cs
Normal file
26
Plugins/SimpleStats/Helpers/Extensions.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using SharedLibrary.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StatsPlugin.Helpers
|
||||
{
|
||||
static class Extensions
|
||||
{
|
||||
|
||||
public static Vector3 FixIW4Angles(this Vector3 vector)
|
||||
{
|
||||
float X = vector.X > 0 ? 360.0f - vector.X : Math.Abs(vector.X);
|
||||
float Y = vector.Y > 0 ? 360.0f - vector.Y : Math.Abs(vector.Y);
|
||||
float Z = vector.Z > 0 ? 360.0f - vector.Z : Math.Abs(vector.Z);
|
||||
|
||||
return new Vector3(X, Y, Z);
|
||||
}
|
||||
|
||||
public static float ToRadians(this float value) => (float)Math.PI * value / 180.0f;
|
||||
|
||||
public static float ToDegrees(this float value) => value * 180.0f / (float)Math.PI;
|
||||
}
|
||||
}
|
@ -205,7 +205,7 @@ namespace StatsPlugin.Helpers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task AddScriptKill(Player attacker, Player victim, int serverId, string map, string hitLoc, string type,
|
||||
string damage, string weapon, string killOrigin, string deathOrigin)
|
||||
string damage, string weapon, string killOrigin, string deathOrigin, string viewAngles, string offset)
|
||||
{
|
||||
var statsSvc = ContextThreads[serverId];
|
||||
|
||||
@ -221,7 +221,10 @@ namespace StatsPlugin.Helpers
|
||||
DeathType = ParseEnum<IW4Info.MeansOfDeath>.Get(type, typeof(IW4Info.MeansOfDeath)),
|
||||
Damage = Int32.Parse(damage),
|
||||
HitLoc = ParseEnum<IW4Info.HitLocation>.Get(hitLoc, typeof(IW4Info.HitLocation)),
|
||||
Weapon = ParseEnum<IW4Info.WeaponName>.Get(weapon, typeof(IW4Info.WeaponName))
|
||||
Weapon = ParseEnum<IW4Info.WeaponName>.Get(weapon, typeof(IW4Info.WeaponName)),
|
||||
ViewAngles = Vector3.Parse(viewAngles).FixIW4Angles(),
|
||||
TimeOffset = Int64.Parse(offset),
|
||||
When = DateTime.UtcNow
|
||||
};
|
||||
|
||||
if (kill.DeathType == IW4Info.MeansOfDeath.MOD_SUICIDE &&
|
||||
@ -238,15 +241,17 @@ namespace StatsPlugin.Helpers
|
||||
|
||||
// increment their hit count
|
||||
if (kill.DeathType == IW4Info.MeansOfDeath.MOD_PISTOL_BULLET ||
|
||||
kill.DeathType == IW4Info.MeansOfDeath.MOD_RIFLE_BULLET)
|
||||
kill.DeathType == IW4Info.MeansOfDeath.MOD_RIFLE_BULLET ||
|
||||
kill.DeathType == IW4Info.MeansOfDeath.MOD_HEAD_SHOT)
|
||||
{
|
||||
playerStats.HitLocations.Single(hl => hl.Location == kill.HitLoc).HitCount += 1;
|
||||
await statsSvc.ClientStatSvc.SaveChangesAsync();
|
||||
}
|
||||
|
||||
//statsSvc.KillStatsSvc.Insert(kill);
|
||||
//await statsSvc.KillStatsSvc.SaveChangesAsync();
|
||||
if(Plugin.Config.Configuration().EnableAntiCheat)
|
||||
statsSvc.KillStatsSvc.Insert(kill);
|
||||
await statsSvc.KillStatsSvc.SaveChangesAsync();
|
||||
|
||||
if (Plugin.Config.Configuration().EnableAntiCheat)
|
||||
{
|
||||
async Task executePenalty(Cheat.DetectionPenaltyResult penalty)
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ namespace StatsPlugin.Helpers
|
||||
var deathstreakMessage = Plugin.Config.Configuration().DeathstreakMessages;
|
||||
|
||||
string message = killstreakMessage.FirstOrDefault(m => m.Count == killStreak)?.Message;
|
||||
message = (message == null) ? deathstreakMessage.FirstOrDefault(m => m.Count == deathStreak)?.Message : message;
|
||||
message = message ?? deathstreakMessage.FirstOrDefault(m => m.Count == deathStreak)?.Message;
|
||||
return message ?? "";
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ namespace StatsPlugin
|
||||
left_leg_lower,
|
||||
right_foot,
|
||||
left_foot,
|
||||
gun,
|
||||
}
|
||||
|
||||
public enum WeaponName
|
||||
|
@ -11,7 +11,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace StatsPlugin.Models
|
||||
{
|
||||
public class EFClientKill : SharedEntity
|
||||
public class EFClientKill : SharedEntity
|
||||
{
|
||||
public EFClientKill() { }
|
||||
|
||||
@ -36,5 +36,9 @@ namespace StatsPlugin.Models
|
||||
[NotMapped]
|
||||
public double Distance => Vector3.Distance(KillOrigin, DeathOrigin) * 0.0254;
|
||||
public IW4Info.MapName Map { get; set; }
|
||||
[NotMapped]
|
||||
public long TimeOffset { get; set; }
|
||||
public Vector3 ViewAngles { get; set; }
|
||||
public DateTime When { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,8 @@ namespace StatsPlugin
|
||||
case Event.GType.Kill:
|
||||
string[] killInfo = (E.Data != null) ? E.Data.Split(';') : new string[0];
|
||||
if (killInfo.Length >= 9 && killInfo[0].Contains("ScriptKill") && E.Owner.CustomCallback)
|
||||
await Manager.AddScriptKill(E.Origin, E.Target, S.GetHashCode(), S.CurrentMap.Name, killInfo[7], killInfo[8], killInfo[5], killInfo[6], killInfo[3], killInfo[4]);
|
||||
await Manager.AddScriptKill(E.Origin, E.Target, S.GetHashCode(), S.CurrentMap.Name, killInfo[7], killInfo[8],
|
||||
killInfo[5], killInfo[6], killInfo[3], killInfo[4], killInfo[9], killInfo[10]);
|
||||
else if (!E.Owner.CustomCallback)
|
||||
await Manager.AddStandardKill(E.Origin, E.Target);
|
||||
break;
|
||||
@ -87,7 +88,7 @@ namespace StatsPlugin
|
||||
{
|
||||
// load custom configuration
|
||||
Config = new BaseConfigurationHandler<StatsConfiguration>("StatsPluginSettings");
|
||||
if (Config.Configuration()== null)
|
||||
if (Config.Configuration() == null)
|
||||
{
|
||||
Config.Set((StatsConfiguration)new StatsConfiguration().Generate());
|
||||
await Config.Save();
|
||||
@ -105,6 +106,7 @@ namespace StatsPlugin
|
||||
double skill = Math.Round(clientStats.Sum(c => c.Skill) / clientStats.Count, 2);
|
||||
double spm = Math.Round(clientStats.Sum(c => c.SPM), 1);
|
||||
|
||||
double headRatio = 0;
|
||||
double chestRatio = 0;
|
||||
double abdomenRatio = 0;
|
||||
double chestAbdomenRatio = 0;
|
||||
@ -122,6 +124,10 @@ namespace StatsPlugin
|
||||
|
||||
chestAbdomenRatio = Math.Round(clientStats.Where(c => c.HitLocations.Count > 0).Sum(cs => cs.HitLocations.First(hl => hl.Location == IW4Info.HitLocation.torso_upper).HitCount) /
|
||||
(double)clientStats.Where(c => c.HitLocations.Count > 0).Sum(cs => cs.HitLocations.First(hl => hl.Location == IW4Info.HitLocation.torso_lower).HitCount), 2);
|
||||
|
||||
headRatio = Math.Round(clientStats.Where(c => c.HitLocations.Count > 0).Sum(cs => cs.HitLocations.First(hl => hl.Location == IW4Info.HitLocation.head).HitCount) /
|
||||
(double)clientStats.Where(c => c.HitLocations.Count > 0)
|
||||
.Sum(c => c.HitLocations.Where(hl => hl.Location != IW4Info.HitLocation.none).Sum(f => f.HitCount)), 2);
|
||||
}
|
||||
|
||||
return new List<ProfileMeta>()
|
||||
@ -168,6 +174,12 @@ namespace StatsPlugin
|
||||
Key = "Chest To Abdomen Ratio",
|
||||
Value = chestAbdomenRatio,
|
||||
Sensitive = true
|
||||
},
|
||||
new ProfileMeta()
|
||||
{
|
||||
Key = "Headshot Ratio",
|
||||
Value = headRatio,
|
||||
Sensitive = true
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -191,7 +203,10 @@ namespace StatsPlugin
|
||||
return messageMeta;
|
||||
}
|
||||
|
||||
MetaService.AddMeta(getStats);
|
||||
if (Config.Configuration().EnableAntiCheat)
|
||||
{
|
||||
MetaService.AddMeta(getStats);
|
||||
}
|
||||
MetaService.AddMeta(getMessages);
|
||||
|
||||
// todo: is this fast? make async?
|
||||
|
@ -126,6 +126,7 @@
|
||||
<Compile Include="Commands\ViewStats.cs" />
|
||||
<Compile Include="Config\StreakMessageConfiguration.cs" />
|
||||
<Compile Include="Config\StatsConfiguration.cs" />
|
||||
<Compile Include="Helpers\Extensions.cs" />
|
||||
<Compile Include="Helpers\ServerStats.cs" />
|
||||
<Compile Include="Helpers\StatManager.cs" />
|
||||
<Compile Include="Helpers\StreakMessage.cs" />
|
||||
|
Reference in New Issue
Block a user