Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <vector>
- #include <string>
- #include <map>
- #include <set>
- #include "Vectors.h"
- #include <iostream>
- #include "Memory.h"
- #include <math.h>
- #include <algorithm>
- namespace Game
- {
- enum EntityType {
- UNKNOWN = 0,
- PLAYER,
- ZOMBIE,
- CAR,
- BOAT,
- ANIMAL,
- RARE,
- BACKPACK,
- CLOTHING,
- WEAPON,
- PROXYMAGAZINES,
- FOOD,
- AMMO,
- GROUNDITEM,
- OPTICS,
- BASE,
- MELEE,
- EXPLOSIVES,
- BUILDING
- };
- std::string ReadArmaString(uint64_t address)
- {
- constexpr size_t MaxLength = 256;
- char buffer[MaxLength] = { 0 };
- SIZE_T bytesRead = 0;
- if (ReadProcessMemory(Memory::hProcess, reinterpret_cast<LPCVOID>(address), buffer, MaxLength - 1, &bytesRead))
- {
- buffer[bytesRead < MaxLength ? bytesRead : MaxLength - 1] = '\0';
- return std::string(buffer);
- }
- return "";
- }
- uint64_t NearEntityTable()
- {
- return Memory::ReadMemory<uint64_t>(globals.World + 0xF48);
- }
- uint32_t NearEntityTableSize()
- {
- return Memory::ReadMemory<uint32_t>(globals.World + 0xF48 + 0x8);
- }
- uint64_t GetEntity(uint64_t PlayerList, uint64_t SelectedPlayer)
- {
- return Memory::ReadMemory<uint64_t>(PlayerList + SelectedPlayer * 0x8);
- }
- uint64_t GetLocalPlayerFromNearTable()
- {
- uint32_t nearSize = NearEntityTableSize();
- uint64_t nearTable = NearEntityTable();
- if (nearTable && nearSize > 0)
- {
- // Индекс 0 - это локальный игрок
- return GetEntity(nearTable, 0);
- }
- return 0;
- }
- std::string GetEntityTypeName(uint64_t Entity)
- {
- uint64_t entityTypePtr = Memory::ReadMemory<uint64_t>(Entity + 0x180);
- if (!entityTypePtr) return "";
- uint64_t configNamePtr = Memory::ReadMemory<uint64_t>(entityTypePtr + 0xA8);
- if (!configNamePtr) return "";
- return ReadArmaString(configNamePtr + 0x10);
- }
- std::string GetEntityName(uint64_t Entity)
- {
- uint64_t entityTypePtr = Memory::ReadMemory<uint64_t>(Entity + 0x180);
- if (!entityTypePtr) return "";
- uint64_t configNamePtr = Memory::ReadMemory<uint64_t>(entityTypePtr + 0x4F0);
- if (!configNamePtr) return "";
- return ReadArmaString(configNamePtr + 0x10);
- }
- std::string GetEntityModelName(uint64_t Entity)
- {
- uint64_t entityTypePtr = Memory::ReadMemory<uint64_t>(Entity + 0x180);
- if (!entityTypePtr) return "";
- uint64_t configNamePtr = Memory::ReadMemory<uint64_t>(entityTypePtr + 0x88);
- if (!configNamePtr) return "";
- std::string fullPath = ReadArmaString(configNamePtr + 0x10);
- size_t lastSlash = fullPath.find_last_of("\\/");
- std::string fileName = (lastSlash != std::string::npos) ?
- fullPath.substr(lastSlash + 1) : fullPath;
- size_t dotPos = fileName.find_last_of('.');
- std::string nameWithoutExt = (dotPos != std::string::npos) ?
- fileName.substr(0, dotPos) : fileName;
- std::string result = nameWithoutExt;
- std::replace(result.begin(), result.end(), '_', ' ');
- return result;
- }
- uint64_t FarEntityTable()
- {
- return Memory::ReadMemory<uint64_t>(globals.World + 0x1090);
- }
- uint32_t FarEntityTableSize()
- {
- return Memory::ReadMemory<uint32_t>(globals.World + 0x1090 + 0x08);
- }
- Vector3 GetCoordinate(uint64_t Entity)
- {
- uint64_t visualState = Memory::ReadMemory<uint64_t>(Entity + 0x1C8);
- if (!visualState) return Vector3();
- return Vector3(Memory::ReadMemory<Vector3>(visualState + 0x2C));
- }
- Vector3 GetCoordinateItem(uint64_t Entity)
- {
- uint64_t visualState = Memory::ReadMemory<uint64_t>(Entity + 0x1C8);
- if (!visualState) return Vector3();
- Vector3 coordinate = Memory::ReadMemory<Vector3>(visualState + 0x2C);
- return Vector3(coordinate.x, coordinate.z, coordinate.y);
- }
- uint64_t GetCamera()
- {
- return Memory::ReadMemory<uint64_t>(globals.World + 0x1B8);
- }
- Vector3 GetInvertedViewTranslation()
- {
- uint64_t camera = GetCamera();
- if (!camera) return Vector3();
- return Vector3(Memory::ReadMemory<Vector3>(camera + 0x2C));
- }
- Vector3 GetInvertedViewRight()
- {
- uint64_t camera = GetCamera();
- if (!camera) return Vector3();
- return Vector3(Memory::ReadMemory<Vector3>(camera + 0x8));
- }
- Vector3 GetInvertedViewUp()
- {
- uint64_t camera = GetCamera();
- if (!camera) return Vector3();
- return Vector3(Memory::ReadMemory<Vector3>(camera + 0x14));
- }
- Vector3 GetInvertedViewForward()
- {
- uint64_t camera = GetCamera();
- if (!camera) return Vector3();
- return Vector3(Memory::ReadMemory<Vector3>(camera + 0x20));
- }
- Vector3 GetViewportSize()
- {
- uint64_t camera = GetCamera();
- if (!camera) return Vector3();
- return Vector3(Memory::ReadMemory<Vector3>(camera + 0x58));
- }
- Vector3 GetProjectionD1()
- {
- uint64_t camera = GetCamera();
- if (!camera) return Vector3();
- return Vector3(Memory::ReadMemory<Vector3>(camera + 0xD0));
- }
- Vector3 GetProjectionD2()
- {
- uint64_t camera = GetCamera();
- if (!camera) return Vector3();
- return Vector3(Memory::ReadMemory<Vector3>(camera + 0xDC));
- }
- Vector3 WorldToScreen(Vector3 Position)
- {
- uint64_t camera = GetCamera();
- if (!camera) return Vector3();
- Vector3 temp = Position - GetInvertedViewTranslation();
- float x = temp.Dot(GetInvertedViewRight());
- float y = temp.Dot(GetInvertedViewUp());
- float z = temp.Dot(GetInvertedViewForward());
- if (z > 0)
- {
- return Vector3(
- GetViewportSize().x * (1 + (x / GetProjectionD1().x / z)),
- GetViewportSize().y * (1 - (y / GetProjectionD2().y / z)),
- z);
- }
- return Vector3();
- }
- float GetDistanceToMe(Vector3 Entity)
- {
- return Entity.Distance(GetCoordinate(GetLocalPlayerFromNearTable()));
- }
- uint64_t GetSlowEntityTable()
- {
- return Memory::ReadMemory<uint64_t>(globals.World + 0x2010);
- }
- uint32_t GetSlowEntityTableSize()
- {
- return Memory::ReadMemory<uint32_t>(globals.World + 0x2010 + 0x08);
- }
- uint32_t GetItemTableCountAlloc()
- {
- return Memory::ReadMemory<uint32_t>(globals.World + 0x2060 + 0x8);
- }
- uint32_t GetItemTableCount()
- {
- return Memory::ReadMemory<uint32_t>(globals.World + 0x2060 + 0x8 + 0x8);
- }
- uint64_t GetItemTable()
- {
- return Memory::ReadMemory<uint64_t>(globals.World + 0x2060);
- }
- EntityType GetEntityType(uint64_t Entity)
- {
- std::string entityTypeName = GetEntityTypeName(Entity);
- std::string modelName = GetEntityModelName(Entity);
- std::string lowerTypeName = entityTypeName;
- std::transform(lowerTypeName.begin(), lowerTypeName.end(), lowerTypeName.begin(), ::tolower);
- std::string lowerModelName = modelName;
- std::transform(lowerModelName.begin(), lowerModelName.end(), lowerModelName.begin(), ::tolower);
- if (lowerTypeName == "dayzplayer") return PLAYER;
- if (lowerTypeName == "dayzinfected") return ZOMBIE;
- if (lowerTypeName == "car") return CAR;
- if (lowerTypeName == "boat") return BOAT;
- if (lowerTypeName == "dayzanimal") return ANIMAL;
- if (lowerTypeName == "clothing") return CLOTHING;
- if (lowerTypeName == "proxymagazines") return PROXYMAGAZINES;
- if (lowerTypeName == "weapon") return WEAPON;
- if (lowerTypeName == "itemoptics") return OPTICS;
- if (lowerModelName.find("backpack") != std::string::npos ||
- lowerModelName.find("bag") != std::string::npos) return BACKPACK;
- if (lowerModelName.find("food") != std::string::npos) return FOOD;
- if (lowerModelName.find("ammo") != std::string::npos ||
- lowerModelName.find("magazine") != std::string::npos) return AMMO;
- if (lowerModelName.find("camping") != std::string::npos ||
- lowerModelName.find("tent") != std::string::npos) return BASE;
- if (lowerModelName.find("melee") != std::string::npos) return MELEE;
- if (lowerModelName.find("explosive") != std::string::npos) return EXPLOSIVES;
- return UNKNOWN;
- }
- ImColor GetColorByEntityType(EntityType type)
- {
- switch (type)
- {
- case PLAYER: return ImColor(0, 255, 255, 255); // Голубой
- case ZOMBIE: return ImColor(255, 0, 0, 255); // Красный
- case CAR: return ImColor(255, 0, 245, 255); // Розовый
- case BOAT: return ImColor(255, 0, 245, 255); // Розовый
- case ANIMAL: return ImColor(0, 255, 0, 255); // Зеленый
- case RARE: return ImColor(255, 0, 255, 255); // Фиолетовый
- case BACKPACK: return ImColor(175, 255, 0, 255); // Лаймовый
- case CLOTHING: return ImColor(255, 255, 0, 255); // Желтый
- case WEAPON: return ImColor(255, 0, 100, 255); // Темно-розовый
- case PROXYMAGAZINES: return ImColor(255, 117, 50, 255); // Оранжевый
- case FOOD: return ImColor(50, 140, 50, 255); // Темно-зеленый
- case AMMO: return ImColor(255, 117, 50, 255); // Оранжевый
- case GROUNDITEM: return ImColor(255, 255, 255, 255); // Белый
- case OPTICS: return ImColor(0, 150, 255, 255); // Синий
- case BASE: return ImColor(0, 150, 255, 255); // Синий
- case MELEE: return ImColor(0, 150, 255, 255); // Синий
- case EXPLOSIVES: return ImColor(255, 0, 50, 255); // Темно-красный
- default: return ImColor(255, 255, 255, 255); // Белый по умолчанию
- }
- }
- std::string GetEntityTypeString(EntityType type)
- {
- switch (type)
- {
- case PLAYER: return "Player";
- case ZOMBIE: return "Zombie";
- case CAR: return "Car";
- case BOAT: return "Boat";
- case ANIMAL: return "Animal";
- case RARE: return "Rare";
- case BACKPACK: return "Backpack";
- case CLOTHING: return "Clothing";
- case WEAPON: return "Weapon";
- case PROXYMAGAZINES: return "Magazine";
- case FOOD: return "Food";
- case AMMO: return "Ammo";
- case GROUNDITEM: return "Item";
- case OPTICS: return "Optic";
- case BASE: return "Base";
- case MELEE: return "Melee";
- case EXPLOSIVES: return "Explosive";
- default: return "Unknown";
- }
- }
- std::vector<uint64_t> EntityList()
- {
- std::vector<uint64_t> arrayList;
- // --- Near entities ---
- uint32_t nearSize = NearEntityTableSize();
- uint64_t nearTable = NearEntityTable();
- for (uint32_t i = 1; i < nearSize; ++i) {
- uint64_t entity = GetEntity(nearTable, i);
- if (entity) arrayList.push_back(entity);
- }
- // --- Far entities ---
- uint32_t farSize = FarEntityTableSize();
- uint64_t farTable = FarEntityTable();
- for (uint32_t i = 0; i < farSize; ++i) {
- uint64_t entity = GetEntity(farTable, i);
- if (entity) arrayList.push_back(entity);
- }
- // --- Slow entities ---
- uint64_t slowTable = GetSlowEntityTable();
- uint32_t slowAllocSize = GetSlowEntityTableSize();
- uint32_t slowValidSize = Memory::ReadMemory<uint32_t>(globals.World + 0x1F90 + 0x8 + 0x8);
- uint32_t addedCount = 0;
- for (uint32_t i = 0; i < slowAllocSize; ++i) {
- uint16_t flag = Memory::ReadMemory<uint16_t>(slowTable + i * 0x18);
- if (flag != 1) continue;
- uint64_t entity = Memory::ReadMemory<uint64_t>(slowTable + i * 0x18 + 0x8);
- if (!entity) continue;
- arrayList.push_back(entity);
- addedCount++;
- if (addedCount >= slowValidSize) break;
- }
- // --- Item table ---
- uint64_t itemTable = GetItemTable();
- uint32_t itemAllocSize = GetItemTableCountAlloc();
- uint32_t itemValidSize = GetItemTableCount();
- addedCount = 0;
- for (uint32_t i = 0; i < itemAllocSize; ++i) {
- uint16_t flag = Memory::ReadMemory<uint16_t>(itemTable + i * 0x18);
- if (flag != 1) continue;
- uint64_t entity = Memory::ReadMemory<uint64_t>(itemTable + i * 0x18 + 0x8);
- if (!entity) continue;
- uint64_t visualState = Memory::ReadMemory<uint64_t>(entity + 0x1C8);
- uint64_t typePtr = Memory::ReadMemory<uint64_t>(entity + 0x180);
- if (!visualState || !typePtr) continue;
- arrayList.push_back(entity);
- addedCount++;
- if (addedCount >= itemValidSize) break;
- }
- return arrayList;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment