Fix Aimbot
This commit is contained in:
parent
a6db93d19d
commit
2c8a8f77ed
5 changed files with 32 additions and 1 deletions
|
|
@ -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<EventPlayerHurt>((@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<uint, (int HitGroup, float Damage)> 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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue