From 41641a592a4a4ffa243a06e15dfe56d690b11dfb Mon Sep 17 00:00:00 2001 From: MisterY52 <11368116+MisterY52@users.noreply.github.com> Date: Fri, 28 May 2021 17:58:32 +0200 Subject: [PATCH] Added function to get entity type --- apex_dma/Game.cpp | 29 +++++++++++++++++++++++++++-- apex_dma/Game.h | 13 ++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/apex_dma/Game.cpp b/apex_dma/Game.cpp index 901a62f..1bafa22 100644 --- a/apex_dma/Game.cpp +++ b/apex_dma/Game.cpp @@ -20,6 +20,25 @@ bool Entity::Observing(uint64_t entitylist) return *(bool*)(buffer + OFFSET_OBSERVER_MODE); } +//https://github.com/CasualX/apexbot/blob/master/src/state.cpp#L104 +void get_class_name(uint64_t entity_ptr, char* out_str) +{ + uint64_t client_networkable_vtable; + apex_mem.Read(entity_ptr + 8 * 3, client_networkable_vtable); + + uint64_t get_client_class; + apex_mem.Read(client_networkable_vtable + 8 * 3, get_client_class); + + uint32_t disp; + apex_mem.Read(get_client_class + 3, disp); + const uint64_t client_class_ptr = get_client_class + disp + 7; + + ClientClass client_class; + apex_mem.Read(client_class_ptr, client_class); + + apex_mem.ReadArray(client_class.pNetworkName, out_str, 32); +} + int Entity::getTeamId() { return *(int*)(buffer + OFFSET_TEAM); @@ -52,7 +71,10 @@ bool Entity::isPlayer() bool Entity::isDummy() { - return *(int*)(buffer + OFFSET_TEAM) == 97; + char class_name[33] = {}; + get_class_name(ptr, class_name); + + return strncmp(class_name, "CAI_BaseNPC", 11) == 0; } bool Entity::isKnocked() @@ -155,7 +177,10 @@ void Entity::get_name(uint64_t g_Base, uint64_t index, char* name) bool Item::isItem() { - return *(int*)(buffer + OFFSET_ITEM_GLOW) >= 1358917120; + char class_name[33] = {}; + get_class_name(ptr, class_name); + + return strncmp(class_name, "CPropSurvival", 13) == 0; } bool Item::isGlowing() diff --git a/apex_dma/Game.h b/apex_dma/Game.h index 5355fec..9477c22 100644 --- a/apex_dma/Game.h +++ b/apex_dma/Game.h @@ -74,8 +74,19 @@ private: float zoom_fov; }; +struct ClientClass { + uint64_t pCreateFn; + uint64_t pCreateEventFn; + uint64_t pNetworkName; + uint64_t pRecvTable; + uint64_t pNext; + uint32_t ClassID; + uint32_t ClassSize; +}; + Entity getEntity(uintptr_t ptr); Item getItem(uintptr_t ptr); bool WorldToScreen(Vector from, float* m_vMatrix, int targetWidth, int targetHeight, Vector& to); float CalculateFov(Entity& from, Entity& target); -QAngle CalculateBestBoneAim(Entity& from, uintptr_t target, float max_fov); \ No newline at end of file +QAngle CalculateBestBoneAim(Entity& from, uintptr_t target, float max_fov); +void get_class_name(uint64_t entity_ptr, char* out_str); \ No newline at end of file