diff --git a/jRandomSkills - SRC Files/src/player/Debug.cs b/jRandomSkills - SRC Files/src/player/Debug.cs index c1721fb..285f837 100644 --- a/jRandomSkills - SRC Files/src/player/Debug.cs +++ b/jRandomSkills - SRC Files/src/player/Debug.cs @@ -4,6 +4,7 @@ using CounterStrikeSharp.API.Modules.Memory; using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions; using CounterStrikeSharp.API.Modules.Utils; using src.utils; +using System.Collections.Concurrent; using static CounterStrikeSharp.API.Core.Listeners; using static src.jRandomSkills; @@ -103,9 +104,25 @@ namespace src.player return HookResult.Continue; }); + Instance.RegisterEventHandler((@event, info) => + { + var victim = PlayerManager.GetPlayerEvent(@event.Userid); + if (victim == null || !victim.IsValid) return HookResult.Continue; + + if (!lastNativeHitGroup.TryRemove(victim.Index, out var native)) return HookResult.Continue; + if (native.HitGroup == @event.Hitgroup) return HookResult.Continue; + + WriteToDebug($"[HITGROUP] mismatch on {victim.PlayerName}: native={(HitGroup_t)native.HitGroup} event={(HitGroup_t)@event.Hitgroup} " + + $"weapon={@event.Weapon} rawDmg={native.Damage:0.#} appliedDmg={@event.DmgHealth}"); + + return HookResult.Continue; + }); + VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(OnTakeDamage, HookMode.Pre); } + private static readonly ConcurrentDictionary lastNativeHitGroup = []; + public static void Unload() { try { VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Unhook(OnTakeDamage, HookMode.Pre); } @@ -147,8 +164,11 @@ namespace src.player var playerInfo = PlayerManager.GetPlayerByIndex(attacker!.Index); if (playerInfo == null) return HookResult.Continue; + var nativeHitGroup = SkillUtils.GetHitGroup(param2); + lastNativeHitGroup[victim.Index] = ((int)nativeHitGroup, param2.Damage); + WriteToDebug($"{(victim.IsBot ? "Bot" : "Player")} {victim.PlayerName} took damage from {(attacker.IsBot ? "bot" : "player")} {attacker.PlayerName}. " + - $"[dmg={param2.Damage:0.#} hp={victimPawn.Health}/{victimPawn.MaxHealth} armor={victimPawn.ArmorValue} hitgroup={SkillUtils.GetHitGroup(param2)} " + + $"[dmg={param2.Damage:0.#} hp={victimPawn.Health}/{victimPawn.MaxHealth} armor={victimPawn.ArmorValue} hitgroup={nativeHitGroup} " + $"takes={victimPawn.TakesDamage} vskill={PlayerManager.GetPlayerByIndex(victim.Index)?.Skill} askill={playerInfo.Skill}" + $"{DescribeIdentitySplit(victim)}]"); return HookResult.Continue; diff --git a/jRandomSkills - SRC Files/src/player/skills/Aimbot.cs b/jRandomSkills - SRC Files/src/player/skills/Aimbot.cs index 0d12b1e..d2670f4 100644 --- a/jRandomSkills - SRC Files/src/player/skills/Aimbot.cs +++ b/jRandomSkills - SRC Files/src/player/skills/Aimbot.cs @@ -39,6 +39,8 @@ namespace src.player.skills var playerInfo = PlayerManager.GetPlayerByIndex(attacker.Index); if (playerInfo == null || playerInfo.Skill != skillName) return; + if (!SkillUtils.IsBulletDamage(param2)) return; + int offset = GameData.GetOffset("CTakeDamageInfo_HitGroup"); if (offset <= 0) return; diff --git a/jRandomSkills - SRC Files/src/utils/SkillUtils.cs b/jRandomSkills - SRC Files/src/utils/SkillUtils.cs index 9ebf612..783cd9c 100644 --- a/jRandomSkills - SRC Files/src/utils/SkillUtils.cs +++ b/jRandomSkills - SRC Files/src/utils/SkillUtils.cs @@ -275,9 +275,18 @@ namespace src.utils return null; } + public static bool IsBulletDamage(CTakeDamageInfo? info) + { + var ability = info?.Ability?.Value; + if (ability == null || !ability.IsValid) return false; + + return FiresBullets(ability.DesignerName); + } + public static HitGroup_t GetHitGroup(CTakeDamageInfo? info) { if (info == null || info.Handle == nint.Zero) return HitGroup_t.HITGROUP_GENERIC; + if (!IsBulletDamage(info)) return HitGroup_t.HITGROUP_GENERIC; int offset = GameData.GetOffset("CTakeDamageInfo_HitGroup"); if (offset <= 0) return HitGroup_t.HITGROUP_GENERIC; diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/WASDMenuAPI.dll b/jRandomSkills - Server Files/plugins/jRandomSkills/WASDMenuAPI.dll index 93c92cd..9fb186b 100644 Binary files a/jRandomSkills - Server Files/plugins/jRandomSkills/WASDMenuAPI.dll and b/jRandomSkills - Server Files/plugins/jRandomSkills/WASDMenuAPI.dll differ diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll b/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll index 0245fd7..51e4268 100644 Binary files a/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll and b/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll differ