Skip to content

Commit 624ca0f

Browse files
committed
fix: re-add GetHitGroup with GameData backed offset
1 parent 592acc2 commit 624ca0f

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

configs/addons/counterstrikesharp/gamedata/gamedata.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@
132132
"linux": 26
133133
}
134134
},
135+
"CTakeDamageInfo_HitGroup": {
136+
"offsets": {
137+
"windows": 104,
138+
"linux": 104
139+
}
140+
},
135141
"UTIL_CreateEntityByName": {
136142
"signatures": {
137143
"library": "server",

managed/CounterStrikeSharp.API/Core/Model/CTakeDamageInfo.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,22 @@ public partial class CTakeDamageInfo
1111
/// Returns a <see cref="HitGroup_t"/> enumeration representing the player's current hit group,
1212
/// or <see cref="HitGroup_t.HITGROUP_INVALID"/> if the hit group cannot be determined.
1313
/// </returns>
14-
[Obsolete("Use HitGroupId instead.")]
1514
public HitGroup_t GetHitGroup()
1615
{
17-
return HitGroupId;
16+
IntPtr v4 = Marshal.ReadIntPtr(Handle, GameData.GetOffset("CTakeDamageInfo_HitGroup"));
17+
18+
if (v4 == nint.Zero)
19+
{
20+
return HitGroup_t.HITGROUP_INVALID;
21+
}
22+
23+
IntPtr v1 = Marshal.ReadIntPtr(v4, 16);
24+
25+
if (v1 == nint.Zero)
26+
{
27+
return HitGroup_t.HITGROUP_GENERIC;
28+
}
29+
30+
return (HitGroup_t)Marshal.ReadInt32(v1, 56);
1831
}
1932
}

0 commit comments

Comments
 (0)