Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.77 KB | None | 0 0
  1.  
  2. #define BEGIN_WITH(x) { \
  3.         auto &_ = x;
  4. #define END_WITH() }
  5.  
  6.  
  7. std::vector<Entity> GetAnimals(std::vector<Player> players , bool zombies , bool animals, bool corpses, bool vehicles) {
  8.  
  9.     std::vector<Entity> ret;
  10.    
  11.     ULONG64     gTable;
  12.     ULONG64     gEntity;
  13.     ULONG64     gEntityType;
  14.     ULONG64     gEntityTypeName;
  15.     ULONG64     gWorldInfo;
  16.     BYTE        gIsAlive;
  17.     uint32_t    gID;
  18.     DWORD       gSize;
  19.     uint32_t    gStance = 0;
  20.     float       gHealth = 0.0f;
  21.     float       gMovement = 0.0f;
  22.  
  23.     float CenterX = static_cast<float>(Width / 2);
  24.     float CenterY = static_cast<float>(Height / 2);
  25.  
  26.     // Near Animals //
  27.  
  28.     for( int n = 0; n <= 1; n++){
  29.  
  30.         if (ReadMemory((ULONG64)(World + ( n == 0 ? OFFSET_WORLD_FARANIMALTABLE : OFFSET_WORLD_NEARANIMALTABLE)), &gTable)) {
  31.             ReadMemory((ULONG64)(World + ( n == 0 ? OFFSET_WORLD_FARANIMALTABLE : OFFSET_WORLD_NEARANIMALTABLE) + 0x8), &gSize);
  32.            
  33.             if (gSize) {
  34.  
  35.                 //BYTE bytes[130172];
  36.                 //ReadMemoryEx((ULONG64)(gTable), &bytes);
  37.  
  38.                 for (size_t i = 0; i < gSize; i++) {
  39.  
  40.                     Entity entity;
  41.  
  42.                     ZeroMemory(entity.model, sizeof(entity.model));
  43.                     ZeroMemory(entity.uid, sizeof(entity.uid));
  44.                     ZeroMemory(entity.inhands, sizeof(entity.inhands));
  45.  
  46.                     if (!ReadMemory((ULONG64)(gTable + (i * 0x8)), &gEntity))
  47.                         continue;
  48.  
  49.                     if (!IsValid(gEntity))
  50.                         continue;
  51.  
  52.                     if (gEntity + 0xA8 == LocalPlayer)
  53.                         continue;
  54.  
  55.                     if (!ReadMemory((ULONG64)(gEntity + OFFSET_ENTITY_NETWORKID), &gID))
  56.                         continue;
  57.                     if (gID == 0)
  58.                         continue;
  59.  
  60.                     if (!ReadMemory((ULONG64)(gEntity + OFFSET_ENTITY_RENDERERENTITYTYPE), &gEntityType))
  61.                         continue;
  62.                     if (gEntityType == 0)
  63.                         continue;
  64.  
  65.                     if (!ReadMemory((ULONG64)(gEntityType + OFFSET_ENTITYTYPE_CONFIGNAME), &gEntityTypeName))
  66.                         continue;
  67.                     if (gEntityTypeName == 0)
  68.                         continue;
  69.  
  70.                     if (!ReadMemory((ULONG64)(gEntity + OFFSET_ENTITY_ALIVE), &gIsAlive))
  71.                         continue;
  72.  
  73.                     char gName[20] = { 0 };
  74.                     if (!ReadMemory((ULONG64)(gEntityTypeName + 0x10), &gName))
  75.                         continue;
  76.  
  77.                     if (strcmp(gName, "dayzinfected") == 0) {
  78.                         if (!zombies)
  79.                             continue;
  80.                         entity.type = zombie;
  81.                     }
  82.                     else if (strcmp(gName, "dayzplayer") == 0) {
  83.                         entity.type = player;
  84.                     }
  85.                     else if (strcmp(gName, "dayzanimal") == 0) {
  86.                         if (!animals)
  87.                             continue;
  88.                         entity.type = animal;
  89.                     }
  90.                     else if (strcmp(gName, "car") == 0) {
  91.                         if (!vehicles)
  92.                             continue;
  93.                         entity.type = Vehicle;
  94.                     }
  95.  
  96.  
  97.                     if (entity.type == player) {
  98.  
  99.                         MultiPtr((ULONG64)(gEntity), { 0x6B8, 0x98, 0x10 , 0x8 }, &gStance);
  100.                         MultiPtr((ULONG64)(gEntity), { 0x6B8, 0x98, 0x10 , 0x0 }, &gMovement);
  101.  
  102.                         for (int i = 0; i < players.size(); i++) {
  103.                             if (players[i].id == gID) {
  104.                                 ZeroMemory(entity.name, sizeof(entity.name));
  105.                                 CopyMemory(entity.name, players[i].name, strlen(players[i].name));
  106.                                 CopyMemory(entity.uid, players[i].uid, sizeof(entity.uid));
  107.                                 entity.friendly = players[i].friendly;
  108.                                 break;
  109.                             }
  110.                         }
  111.  
  112.                         std::string ret = GetItemInHands(gEntity);
  113.                         //std::string mag = GetChambered(gEntity);
  114.                         //if (mag.size() > 1) {
  115.                         //  ret += mag;
  116.                         //}
  117.  
  118.                         CopyMemory(entity.inhands, ret.c_str(), ret.size());
  119.  
  120.                     }
  121.  
  122.                     Vector6 Position;
  123.                     if(!MultiPtrEx((ULONG64)(gEntity) ,
  124.                         {
  125.                             OFFSET_ENTITY_RENDERERVISUALSTATE,
  126.                             OFFSET_VISUALSTATE_DIRECTION
  127.                         }, &Position))
  128.                         continue;
  129.  
  130.                     Vector3  gDirection = Vector3(Position.x1, Position.y1, Position.z1);
  131.                     Vector3  gPosition  = Vector3(Position.x2, Position.y2, Position.z2);
  132.  
  133.                     float fHead = 0.0f;
  134.                     if (gStance == Stance::SStanding) {
  135.                         fHead = 1.5f;
  136.                     }
  137.                     else if (gStance == Stance::SCrouching) {
  138.                         fHead = 1.0f;
  139.                     }
  140.                     else if (gStance == Stance::SProne) {
  141.                         fHead = 0.0f;
  142.                     }
  143.  
  144.                     Vector3  gHead      = Vector3(Position.x2, Position.y2 + fHead, Position.z2);
  145.  
  146.                     BEGIN_WITH(entity)
  147.                         _.id = gID;
  148.                         _.Health = gHealth;
  149.                         _.Movement = gMovement;
  150.                         _.Stance = static_cast<Stance>(gStance);
  151.                         _.Direction = gDirection;
  152.                         _.Position = gPosition;
  153.                         _.Foot = WorldToScreen(&VM, gPosition);;
  154.                         _.IsDead = gIsAlive;
  155.                         _.Distance = entity.Position.Distance(Me.Position);
  156.                         _.Head = WorldToScreen(&VM, gHead);
  157.                         _.CenterDistance = dfc(entity.Head, Vector3(CenterX, CenterY, 0.0f));
  158.                     END_WITH();
  159.  
  160.                     ret.push_back(entity);
  161.  
  162.  
  163.                 }
  164.             }
  165.         }
  166.    
  167.     }
  168.  
  169.     std::sort(ret.begin(), ret.end(), predCenter());
  170.  
  171.     for (int i = 0; i < ret.size(); i++) {
  172.         if (!ret[i].type == player)
  173.             continue;
  174.         if (ret[i].IsDead == 1)
  175.             continue;
  176.         if (ret[i].friendly == true)
  177.             continue;
  178.         if (ret[i].Foot.z <= 0.0f)
  179.             continue;
  180.         ret[i].Target = true;
  181.         break;
  182.     }
  183.  
  184.     return ret;
  185.  
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement