IlDivinoGlade

GTA V PS3 - Entity Pool Drawing Hook for GTA V (PS3)

Jul 31st, 2025 (edited)
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.89 KB | None | 0 0
  1. #define VehiclePoolPtr          0x01CD27C8
  2. #define DrawablePoolPtr         0x01C95C3C
  3. #define ObjectPoolPtr           0x01CE6780
  4. #define PedPoolPtr              0x01CEFE50
  5. #define PickupPlacementPoolPtr  0x01CF172C
  6. #define PickupPoolPtr           0x01CF1738
  7.  
  8. #define AmmoInfoPoolPtr         0x021478E8
  9. #define CProjectilePoolPtr      0x02147CB8
  10.  
  11. #define GET_ENTITY_HANDLE       0x474054
  12.  
  13. //--- GET_ENTITY_HANDLE aka _addEntityToPoolFunc
  14.  
  15. /*oldest pool*/
  16.  
  17. struct CEntityPool
  18. {
  19.     int* iPoolEntries;      // Ptr to array of entity addresses
  20.     int  iMaxEntities;      // Max number of slots in pool
  21.     int  iFreeSlots;        // Free (unused) entries
  22.     int  iStructSize;       // Usually 4 (stride)
  23.     int  iLastAddr;         // Last valid address used
  24.     int  iActiveCount;      // Optional: active count (can be filled via CountActive())
  25.  
  26.     const char* szPoolName; // Optional: for debugging and labeling
  27.  
  28.     // Accessor
  29.     uint32_t* GetEntityAt(int index)
  30.     {
  31.         if (index < 0 || index >= iMaxEntities) return nullptr;
  32.         int addr = iPoolEntries[index];
  33.         if (addr == 0 || addr > 0x30000000) return nullptr;
  34.         return (uint32_t*)addr;
  35.     }
  36.  
  37.     // Safe Entity to Handle conversion (via GET_ENTITY_HANDLE func)
  38.     int GetHandleAt(int index) //--- GET_ENTITY_HANDLE aka _addEntityToPoolFunc
  39.     {
  40.         uint32_t* ent = GetEntityAt(index);
  41.         if (!ent) return 0;
  42.         return call<int>(0x474054)(ent);
  43.     }
  44.  
  45.     // Active counter
  46.     int CountActive()
  47.     {
  48.         int count = 0;
  49.         for (int i = 0; i < iMaxEntities; i++)
  50.         {
  51.             if (iPoolEntries[i] != 0 && iPoolEntries[i] < 0x30000000)
  52.                 count++;
  53.         }
  54.         return count;
  55.     }
  56. };
  57.  
  58.  
  59.  
  60. //--- Wrapper to get entity handle from raw pointer ---
  61.  
  62. void DrawEntitiesFromPool(int pool_base, const char* label, int r, int g, int b)
  63. {
  64.     if (!pool_base) {
  65.         printf("Invalid Pool Addr for %s\n", label);
  66.         return;
  67.     }
  68.  
  69.     CEntityPool* pool = (CEntityPool*)pool_base;
  70.     pool->szPoolName = label;
  71.  
  72.     if (!pool->iPoolEntries || pool->iMaxEntities <= 0 || pool->iFreeSlots < 0) {
  73.         printf("Pool %s invalid\n", label);
  74.         return;
  75.     }
  76.  
  77.     printf("--- Drawing %s Pool ---\n", label);
  78.     printf("Max: %d | Free: %d | Active: %d\n", pool->iMaxEntities, pool->iFreeSlots, pool->CountActive());
  79.  
  80.     for (int i = 0; i < pool->iMaxEntities; i++)
  81.     {
  82.         int handle = pool->GetHandleAt(i);
  83.         if (handle == 0) continue;
  84.  
  85.         Vector3 ent_coords = GET_ENTITY_COORDS(handle, 1);
  86.         Vector3 my_coords = GET_ENTITY_COORDS(PLAYER_PED_ID(), 1);
  87.         DrawLine(my_coords, ent_coords, r, g, b, 255);
  88.     }
  89. }
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96. //hook
  97. void debug_DrawAllEntities()
  98. {
  99.     DrawEntitiesFromPool(*(int*)VehiclePoolPtr, "Vehicle", 255, 0, 0);
  100.     DrawEntitiesFromPool(*(int*)PedPoolPtr, "Ped", 255, 255, 255);
  101.     DrawEntitiesFromPool(*(int*)ObjectPoolPtr, "Object", 0, 255, 0);
  102.     DrawEntitiesFromPool(*(int*)PickupPlacementPoolPtr, "PickupPlacement", 255, 255, 0);
  103.     DrawEntitiesFromPool(*(int*)DrawablePoolPtr, "Drawable", 64, 64, 64);
  104.     DrawEntitiesFromPool(*(int*)CProjectilePoolPtr, "Projectile", 255, 0, 255);
  105. }
  106.  
  107.  
Add Comment
Please, Sign In to add comment