Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define BEGIN_WITH(x) { \
- auto &_ = x;
- #define END_WITH() }
- std::vector<Entity> GetAnimals(std::vector<Player> players , bool zombies , bool animals, bool corpses, bool vehicles) {
- std::vector<Entity> ret;
- ULONG64 gTable;
- ULONG64 gEntity;
- ULONG64 gEntityType;
- ULONG64 gEntityTypeName;
- ULONG64 gWorldInfo;
- BYTE gIsAlive;
- uint32_t gID;
- DWORD gSize;
- uint32_t gStance = 0;
- float gHealth = 0.0f;
- float gMovement = 0.0f;
- float CenterX = static_cast<float>(Width / 2);
- float CenterY = static_cast<float>(Height / 2);
- // Near Animals //
- for( int n = 0; n <= 1; n++){
- if (ReadMemory((ULONG64)(World + ( n == 0 ? OFFSET_WORLD_FARANIMALTABLE : OFFSET_WORLD_NEARANIMALTABLE)), &gTable)) {
- ReadMemory((ULONG64)(World + ( n == 0 ? OFFSET_WORLD_FARANIMALTABLE : OFFSET_WORLD_NEARANIMALTABLE) + 0x8), &gSize);
- if (gSize) {
- //BYTE bytes[130172];
- //ReadMemoryEx((ULONG64)(gTable), &bytes);
- for (size_t i = 0; i < gSize; i++) {
- Entity entity;
- ZeroMemory(entity.model, sizeof(entity.model));
- ZeroMemory(entity.uid, sizeof(entity.uid));
- ZeroMemory(entity.inhands, sizeof(entity.inhands));
- if (!ReadMemory((ULONG64)(gTable + (i * 0x8)), &gEntity))
- continue;
- if (!IsValid(gEntity))
- continue;
- if (gEntity + 0xA8 == LocalPlayer)
- continue;
- if (!ReadMemory((ULONG64)(gEntity + OFFSET_ENTITY_NETWORKID), &gID))
- continue;
- if (gID == 0)
- continue;
- if (!ReadMemory((ULONG64)(gEntity + OFFSET_ENTITY_RENDERERENTITYTYPE), &gEntityType))
- continue;
- if (gEntityType == 0)
- continue;
- if (!ReadMemory((ULONG64)(gEntityType + OFFSET_ENTITYTYPE_CONFIGNAME), &gEntityTypeName))
- continue;
- if (gEntityTypeName == 0)
- continue;
- if (!ReadMemory((ULONG64)(gEntity + OFFSET_ENTITY_ALIVE), &gIsAlive))
- continue;
- char gName[20] = { 0 };
- if (!ReadMemory((ULONG64)(gEntityTypeName + 0x10), &gName))
- continue;
- if (strcmp(gName, "dayzinfected") == 0) {
- if (!zombies)
- continue;
- entity.type = zombie;
- }
- else if (strcmp(gName, "dayzplayer") == 0) {
- entity.type = player;
- }
- else if (strcmp(gName, "dayzanimal") == 0) {
- if (!animals)
- continue;
- entity.type = animal;
- }
- else if (strcmp(gName, "car") == 0) {
- if (!vehicles)
- continue;
- entity.type = Vehicle;
- }
- if (entity.type == player) {
- MultiPtr((ULONG64)(gEntity), { 0x6B8, 0x98, 0x10 , 0x8 }, &gStance);
- MultiPtr((ULONG64)(gEntity), { 0x6B8, 0x98, 0x10 , 0x0 }, &gMovement);
- for (int i = 0; i < players.size(); i++) {
- if (players[i].id == gID) {
- ZeroMemory(entity.name, sizeof(entity.name));
- CopyMemory(entity.name, players[i].name, strlen(players[i].name));
- CopyMemory(entity.uid, players[i].uid, sizeof(entity.uid));
- entity.friendly = players[i].friendly;
- break;
- }
- }
- std::string ret = GetItemInHands(gEntity);
- //std::string mag = GetChambered(gEntity);
- //if (mag.size() > 1) {
- // ret += mag;
- //}
- CopyMemory(entity.inhands, ret.c_str(), ret.size());
- }
- Vector6 Position;
- if(!MultiPtrEx((ULONG64)(gEntity) ,
- {
- OFFSET_ENTITY_RENDERERVISUALSTATE,
- OFFSET_VISUALSTATE_DIRECTION
- }, &Position))
- continue;
- Vector3 gDirection = Vector3(Position.x1, Position.y1, Position.z1);
- Vector3 gPosition = Vector3(Position.x2, Position.y2, Position.z2);
- float fHead = 0.0f;
- if (gStance == Stance::SStanding) {
- fHead = 1.5f;
- }
- else if (gStance == Stance::SCrouching) {
- fHead = 1.0f;
- }
- else if (gStance == Stance::SProne) {
- fHead = 0.0f;
- }
- Vector3 gHead = Vector3(Position.x2, Position.y2 + fHead, Position.z2);
- BEGIN_WITH(entity)
- _.id = gID;
- _.Health = gHealth;
- _.Movement = gMovement;
- _.Stance = static_cast<Stance>(gStance);
- _.Direction = gDirection;
- _.Position = gPosition;
- _.Foot = WorldToScreen(&VM, gPosition);;
- _.IsDead = gIsAlive;
- _.Distance = entity.Position.Distance(Me.Position);
- _.Head = WorldToScreen(&VM, gHead);
- _.CenterDistance = dfc(entity.Head, Vector3(CenterX, CenterY, 0.0f));
- END_WITH();
- ret.push_back(entity);
- }
- }
- }
- }
- std::sort(ret.begin(), ret.end(), predCenter());
- for (int i = 0; i < ret.size(); i++) {
- if (!ret[i].type == player)
- continue;
- if (ret[i].IsDead == 1)
- continue;
- if (ret[i].friendly == true)
- continue;
- if (ret[i].Foot.z <= 0.0f)
- continue;
- ret[i].Target = true;
- break;
- }
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement