From ca5a77f9901d728b34035686126df025474632fd Mon Sep 17 00:00:00 2001 From: MisterY52 <11368116+MisterY52@users.noreply.github.com> Date: Sat, 13 Aug 2022 09:37:05 +0200 Subject: [PATCH] Added get bone position by hitbox --- apex_dma/Game.cpp | 38 +++++++++++++++++++++++++++++++++++++- apex_dma/Game.h | 1 + apex_dma/apex_dma.cpp | 4 ++-- apex_dma/offsets.h | 2 ++ 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/apex_dma/Game.cpp b/apex_dma/Game.cpp index 3742226..67a6e6b 100644 --- a/apex_dma/Game.cpp +++ b/apex_dma/Game.cpp @@ -125,6 +125,42 @@ Vector Entity::getBonePosition(int id) return bone; } +//https://www.unknowncheats.me/forum/apex-legends/496984-getting-hitbox-positions-cstudiohdr-externally.html +//https://www.unknowncheats.me/forum/3499185-post1334.html +Vector Entity::getBonePositionByHitbox(int id) +{ + Vector origin = getPosition(); + + //BoneByHitBox + uint64_t Model = *(uint64_t*)(buffer + OFFSET_STUDIOHDR); + + //get studio hdr + uint64_t StudioHdr; + apex_mem.Read(Model + 0x8, StudioHdr); + + //get hitbox array + int HitBoxsArray_set; + apex_mem.Read(StudioHdr + 0xB4,HitBoxsArray_set); + uint64_t HitBoxsArray = StudioHdr + HitBoxsArray_set; + + int HitboxIndex; + apex_mem.Read(HitBoxsArray + 0x8, HitboxIndex); + + int Bone; + apex_mem.Read(HitBoxsArray + HitboxIndex + (id * 0x2C), Bone); + + if(Bone < 0 || Bone > 255) + return Vector(); + + //hitpos + uint64_t BoneArray = *(uint64_t*)(buffer + OFFSET_BONES); + + matrix3x4_t Matrix = {}; + apex_mem.Read(BoneArray + Bone * sizeof(matrix3x4_t), Matrix); + + return Vector(Matrix.m_flMatVal[0][3] + origin.x, Matrix.m_flMatVal[1][3] + origin.y, Matrix.m_flMatVal[2][3] + origin.z); +} + QAngle Entity::GetSwayAngles() { return *(QAngle*)(buffer + OFFSET_BREATH_ANGLES); @@ -264,7 +300,7 @@ QAngle CalculateBestBoneAim(Entity& from, uintptr_t t, float max_fov) } Vector LocalCamera = from.GetCamPos(); - Vector TargetBonePosition = target.getBonePosition(bone); + Vector TargetBonePosition = target.getBonePositionByHitbox(bone); QAngle CalculatedAngles = QAngle(0, 0, 0); WeaponXEntity curweap = WeaponXEntity(); diff --git a/apex_dma/Game.h b/apex_dma/Game.h index a39c0cc..7b3c4bc 100644 --- a/apex_dma/Game.h +++ b/apex_dma/Game.h @@ -44,6 +44,7 @@ public: void SetViewAngles(SVector angles); void SetViewAngles(QAngle& angles); Vector getBonePosition(int id); + Vector getBonePositionByHitbox(int id); bool Observing(uint64_t entitylist); void get_name(uint64_t g_Base, uint64_t index, char* name); }; diff --git a/apex_dma/apex_dma.cpp b/apex_dma/apex_dma.cpp index b147a65..dfa881a 100644 --- a/apex_dma/apex_dma.cpp +++ b/apex_dma/apex_dma.cpp @@ -387,7 +387,7 @@ static void EspLoop() if (bs.x > 0 && bs.y > 0) { Vector hs = Vector(); - Vector HeadPosition = Target.getBonePosition(8); + Vector HeadPosition = Target.getBonePositionByHitbox(0); WorldToScreen(HeadPosition, m.matrix, 1920, 1080, hs); float height = abs(abs(hs.y) - abs(bs.y)); float width = height / 2.0f; @@ -462,7 +462,7 @@ static void EspLoop() if (bs.x > 0 && bs.y > 0) { Vector hs = Vector(); - Vector HeadPosition = Target.getBonePosition(8); + Vector HeadPosition = Target.getBonePositionByHitbox(0); WorldToScreen(HeadPosition, m.matrix, 1920, 1080, hs); float height = abs(abs(hs.y) - abs(bs.y)); float width = height / 2.0f; diff --git a/apex_dma/offsets.h b/apex_dma/offsets.h index 7c10803..c5cb4bf 100644 --- a/apex_dma/offsets.h +++ b/apex_dma/offsets.h @@ -27,6 +27,7 @@ #define OFFSET_ORIGIN 0x014c //m_vecAbsOrigin #define OFFSET_BONES 0x0e88 + 0x48 //m_nForceBone + 0x48 + #define OFFSET_STUDIOHDR 0x10d8 #define OFFSET_AIMPUNCH 0x23f8 //m_currentFrameLocalPlayer.m_vecPunchWeapon_Angle #define OFFSET_CAMERAPOS 0x1ea0 //CPlayer!camera_origin #define OFFSET_VIEWANGLES 0x24f4 - 0x14 //m_ammoPoolCapacity - 0x14 @@ -74,6 +75,7 @@ #define OFFSET_ORIGIN 0x014c //m_vecAbsOrigin #define OFFSET_BONES 0x0e88 + 0x48 //m_nForceBone + 0x48 + #define OFFSET_STUDIOHDR 0x10d8 #define OFFSET_AIMPUNCH 0x23f8 //m_currentFrameLocalPlayer.m_vecPunchWeapon_Angle #define OFFSET_CAMERAPOS 0x1ea0 //CPlayer!camera_origin #define OFFSET_VIEWANGLES 0x24f4 - 0x14 //m_ammoPoolCapacity - 0x14