From cdc71b248d67fa5d1ac10a4a35ac3a58f757255e Mon Sep 17 00:00:00 2001 From: BDKPlayer Date: Fri, 31 Jul 2020 16:14:55 +0200 Subject: Working minimal version --- ESP.cpp | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'ESP.cpp') diff --git a/ESP.cpp b/ESP.cpp index 3cd3122..8e8b1b3 100644 --- a/ESP.cpp +++ b/ESP.cpp @@ -12,24 +12,24 @@ uint32_t ESP::colors_hex[8] = { 0xff0000ff, 0xffff0000,0xff00ff00,0xffffff00,0xf void ESP::DrawBox(Unit* unit, int32_t color, bool drawName = false) { - Vector3 one3 = unit->position; - one3.x -= unit->pUnitData->collisionX; - one3.y -= unit->pUnitData->collisionY; + Vector3 one3 = unit->GetPosition(); + one3.x -= unit->GetUnitData()->GetCollision().x; + one3.y -= unit->GetUnitData()->GetCollision().y; Vector2 one = Engine::Get()->worldToScreen(one3); - Vector3 two3 = unit->position; - two3.x += unit->pUnitData->collisionX; - two3.y += unit->pUnitData->collisionY; + Vector3 two3 = unit->GetPosition(); + two3.x += unit->GetUnitData()->GetCollision().x; + two3.y += unit->GetUnitData()->GetCollision().y; Vector2 two = Engine::Get()->worldToScreen(two3); - Vector3 three3 = unit->position; - three3.x -= unit->pUnitData->collisionX; - three3.y += unit->pUnitData->collisionY; + Vector3 three3 = unit->GetPosition(); + three3.x -= unit->GetUnitData()->GetCollision().x; + three3.y += unit->GetUnitData()->GetCollision().y; Vector2 three = Engine::Get()->worldToScreen(three3); - Vector3 four3 = unit->position; - four3.x += unit->pUnitData->collisionX; - four3.y -= unit->pUnitData->collisionY; + Vector3 four3 = unit->GetPosition(); + four3.x += unit->GetUnitData()->GetCollision().x; + four3.y -= unit->GetUnitData()->GetCollision().y; Vector2 four = Engine::Get()->worldToScreen(four3); ImVec2 ivOne = ImVec2(one.x, one.y); @@ -42,10 +42,10 @@ void ESP::DrawBox(Unit* unit, int32_t color, bool drawName = false) if (drawName) { - Vector3 textPos = unit->position; + Vector3 textPos = unit->GetPosition(); Vector2 screenTextPos = Engine::Get()->worldToScreen(textPos); ImVec2 ivTextPos = ImVec2(screenTextPos.x, screenTextPos.y); - Renderer::Get()->RenderText(unit->pUnitData->name, ivTextPos, 16, color, false); + Renderer::Get()->RenderText(std::string(unit->GetUnitData()->GetName()), ivTextPos, 16, color, false); } } @@ -84,7 +84,7 @@ void ESP::DrawCircle(Unit* unit, int radius, int32_t color, int smoothness = 16, { static const float PI = 3.14159265358979323846f; int32_t tileSize = Engine::Get()->GetWorld()->pMap->GetTileSize(); - Vector3 center = unit->position; + Vector3 center = unit->GetPosition(); std::vector screeenPoints; @@ -106,7 +106,7 @@ void ESP::DrawCircle(Unit* unit, int radius, int32_t color, int smoothness = 16, { Vector2 screenTextPos = Engine::Get()->worldToScreen(center); ImVec2 ivTextPos = ImVec2(screenTextPos.x, screenTextPos.y); - Renderer::Get()->RenderText(unit->pUnitData->name, ivTextPos, 16, color, false); + Renderer::Get()->RenderText(unit->GetUnitData()->GetName(), ivTextPos, 16, color, false); } } @@ -135,12 +135,12 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) { if (playerUnitEsp[playerIndex]) { - if (strcmp(unit->pUnitData->name, "FLARE") == 0) + if (strcmp(unit->GetUnitData()->GetName(), "FLARE") == 0) { return; //Dont display annoying flares that Bots use } - if (siegeImpactLocation) + /*if (siegeImpactLocation) { if (std::string(unit->pUnitData->name).find("Projectile Scorpion") != std::string::npos) { @@ -171,14 +171,15 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) Renderer::Get()->RenderCircleFilled(ImVec2(screenDestinationPos.x, screenDestinationPos.y), 30, colors_hex[*player->pColor] & 0x77ffffff); } } - } + }*/ - if (unit->pUnitData->Class == (int16_t)EnumUnitDataClass::Miscellaneous) + /*if (unit->pUnitData->Class == (int16_t)EnumUnitDataClass::Miscellaneous) { return; } - if (strcmp(unit->pUnitData->name, "CSTL") == 0) + */ + if (strcmp(unit->GetUnitData()->GetName(), "CSTL") == 0) { DrawBox(unit, colors_hex[*player->pColor], true); return; @@ -186,12 +187,12 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) DrawBox(unit, colors_hex[*player->pColor], playerUnitNameEsp[playerIndex]); - if (trebuchetESP && (std::string(unit->pUnitData->name).find("TREBU") != std::string::npos || std::string(unit->pUnitData->name).find("PTREB") != std::string::npos)) + if (trebuchetESP && (std::string(unit->GetUnitData()->GetName()).find("TREBU") != std::string::npos || std::string(unit->GetUnitData()->GetName()).find("PTREB") != std::string::npos)) { DrawCircle(unit, 16, colors_hex[*player->pColor], 100, 2, true); } - if (playerUnitDestinationEsp[playerIndex]) + /*if (playerUnitDestinationEsp[playerIndex]) { Vector3* targetPosition = unit->GetTargetPosition(); if (!targetPosition || targetPosition->x <= 0 || targetPosition->y <= 0) { return; } @@ -199,7 +200,7 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) Vector2 screenPos = Engine::Get()->worldToScreen(unit); Vector2 screenTargetPos = Engine::Get()->worldToScreen(*targetPosition); Renderer::Get()->RenderLine(ImVec2(screenPos.x, screenPos.y), ImVec2(screenTargetPos.x, screenTargetPos.y), colors_hex[*player->pColor]); - } + }*/ } } @@ -219,7 +220,7 @@ void ESP::OnNeutralUnit(Unit* unit) { if (gaiaESP || goldESP || stoneESP) { - std::string unitName = unit->pUnitData->name; + std::string unitName = unit->GetUnitData()->GetName(); Vector2 screenPos = Engine::Get()->worldToScreen(unit); if (goldESP && strcmp(unitName.c_str(), "GOLDM") == 0) @@ -290,7 +291,7 @@ void ESP::OnMenuMainWindow() { ImGui::Separator(); ImGui::Text("Siege ESP"); - ImGui::Checkbox("Siege Impact", &siegeImpactLocation); + //ImGui::Checkbox("Siege Impact", &siegeImpactLocation); ImGui::Checkbox("Trebuchet range", &trebuchetESP); ImGui::Separator(); ImGui::Text("Resource ESP"); -- cgit v1.2.3 From ac611e09cf668329703b43c4b88bab63a3398148 Mon Sep 17 00:00:00 2001 From: BDKPlayer Date: Sat, 1 Aug 2020 14:45:52 +0200 Subject: Added support for ManualMap by removing TLS callbacks --- Classes.h | 3 +-- Core.cpp | 5 +++-- ESP.cpp | 2 +- Engine.cpp | 10 +++++----- FeatureManager.cpp | 2 -- Source.cpp | 7 ++++++- 6 files changed, 16 insertions(+), 13 deletions(-) (limited to 'ESP.cpp') diff --git a/Classes.h b/Classes.h index 8f91625..a38687f 100644 --- a/Classes.h +++ b/Classes.h @@ -220,8 +220,7 @@ class Map public: int32_t GetTileSize() { - static int32_t tileOffset = 0x5B38; - return *reinterpret_cast((int64_t)this + tileOffset); + return *reinterpret_cast((int64_t)this + 0x5B38); } }; //Size=0x5CC8 diff --git a/Core.cpp b/Core.cpp index 17f0f03..74ad230 100644 --- a/Core.cpp +++ b/Core.cpp @@ -31,6 +31,9 @@ MidfunctionHook onGameStartHook = MidfunctionHook(); MidfunctionHook onTurnHook = MidfunctionHook(); MidfunctionHook onCreateUnitHook = MidfunctionHook(); + +bool openOverlay = true; + void __fastcall OnGameStartHook(Registers* registers) { FeatureManager::Get()->OnGameStart(); @@ -176,7 +179,6 @@ void createPlayerTreeNode(Player* player, int playerIndex) ImGui::PopStyleColor(); } - void Core::OnPresent() { __try @@ -202,7 +204,6 @@ void Core::OnPresent() //printf(" playerArray %p", playerArray); int64_t totalPlayers = Engine::Get()->GetTotalPlayers(); - static bool openOverlay = true; if (GetAsyncKeyState(VK_INSERT) & 1) { openOverlay = !openOverlay; } Renderer::Get()->BeginScene(); diff --git a/ESP.cpp b/ESP.cpp index 8e8b1b3..dd50c6e 100644 --- a/ESP.cpp +++ b/ESP.cpp @@ -82,7 +82,7 @@ void ESP::DrawBox(Vector3 position, Vector2 edgeSize, int32_t color) void ESP::DrawCircle(Unit* unit, int radius, int32_t color, int smoothness = 16, float thickness = 1.f, bool drawName = false) { - static const float PI = 3.14159265358979323846f; + const float PI = 3.14159265358979323846f; int32_t tileSize = Engine::Get()->GetWorld()->pMap->GetTileSize(); Vector3 center = unit->GetPosition(); diff --git a/Engine.cpp b/Engine.cpp index bb3db2a..f59e68e 100644 --- a/Engine.cpp +++ b/Engine.cpp @@ -72,7 +72,7 @@ PlayerArray* Engine::GetPlayerArray() const Vector2 Engine::worldToScreen(Vector3 position) const { MainScreen* mainScreen = GetMainScreen(); - static int tileSize = GetWorld()->pMap->GetTileSize(); + int tileSize = GetWorld()->pMap->GetTileSize(); float tile_width = tileSize * mainScreen->pGameScreen->pMainView->ScreenPosZ; float tile_height = tileSize * mainScreen->pGameScreen->pMainView->ScreenPosZ; @@ -213,8 +213,8 @@ Player* Engine::GetLocalPlayer() const void Engine::SendChat(const char* message, bool teamchat) const { typedef void(__fastcall* tSendChat) (int64_t game, const char* text); - static tSendChat fSendChat = (tSendChat)(base + Offsets::sendChat); - static int64_t game = *(int64_t*)(base + Offsets::pAVGame); + tSendChat fSendChat = (tSendChat)(base + Offsets::sendChat); + int64_t game = *(int64_t*)(base + Offsets::pAVGame); if (teamchat) { @@ -230,13 +230,13 @@ void Engine::SendChat(const char* message, bool teamchat) const void Engine::PrintNotification(const char* message) const { typedef void(__fastcall* tPrintNotification) (GameScreen* AVGameScreen, const char* message, int unknown); - static tPrintNotification fPrintNotification = (tPrintNotification)(base + Offsets::printNotification); + tPrintNotification fPrintNotification = (tPrintNotification)(base + Offsets::printNotification); fPrintNotification(GetMainScreen()->pGameScreen, message, 0); } void Engine::PrintBottomNotification(const char* message, unsigned int hexcolor) const { typedef void(__fastcall* tPrintBottomText) (GameScreen* AVGameScreen, const char* message, unsigned int hexcolor, int64_t unused); - static tPrintBottomText fPrintBottomText = (tPrintBottomText)(base + Offsets::printBottomText); + tPrintBottomText fPrintBottomText = (tPrintBottomText)(base + Offsets::printBottomText); fPrintBottomText(GetMainScreen()->pGameScreen, message, hexcolor, 0xffffffffffffffff); //Color format: RBGA } diff --git a/FeatureManager.cpp b/FeatureManager.cpp index 8d9b71f..ca7cf66 100644 --- a/FeatureManager.cpp +++ b/FeatureManager.cpp @@ -22,8 +22,6 @@ FeatureManager* FeatureManager::Get() void FeatureManager::RegisterFeature(Feature* feature) { - static int feature_numer = 0; - printf("Registered feature %d\n", feature_numer++); features.push_back(feature); } diff --git a/Source.cpp b/Source.cpp index 7bfb773..045300f 100644 --- a/Source.cpp +++ b/Source.cpp @@ -24,6 +24,8 @@ ID3D11DeviceContext* pContext = nullptr; DWORD_PTR* pSwapChainVtable = nullptr; +Core* core = nullptr; + #include "main.h" //helper funcs @@ -184,7 +186,10 @@ HRESULT __stdcall hookD3D11Present(IDXGISwapChain* pSwapChain, UINT SyncInterval ImGui_ImplDX11_NewFrame(); ImGui::NewFrame(); - static Core* core = new Core(); + if (!core) + { + core = new Core(); + } core->OnPresent(); ImGui::EndFrame(); -- cgit v1.2.3 From 344570fdb59f01ef1f3e9f47c8313660c39f6f8f Mon Sep 17 00:00:00 2001 From: BDKPlayer Date: Sat, 1 Aug 2020 15:12:35 +0200 Subject: Updated all features --- Classes.h | 12 ++++++++++++ ESP.cpp | 21 ++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) (limited to 'ESP.cpp') diff --git a/Classes.h b/Classes.h index a38687f..61c5fcf 100644 --- a/Classes.h +++ b/Classes.h @@ -329,6 +329,18 @@ public: { return Vector3(GetPosX(), GetPosY(), GetPosZ()); } + + Vector3* GetTargetPosition() + { + uint64_t actionList = *reinterpret_cast((uint64_t)this + 0x648); + if (!actionList) { return NULL; } + uint64_t targetDataWrapper = *reinterpret_cast(actionList + 0x10); + if (!targetDataWrapper) { return NULL; } + uint64_t actionMoveTo = *reinterpret_cast(targetDataWrapper); + if (!actionMoveTo) { return NULL; } + return reinterpret_cast(actionMoveTo + 0x38); + } + }; class ObjectManager diff --git a/ESP.cpp b/ESP.cpp index dd50c6e..11bf487 100644 --- a/ESP.cpp +++ b/ESP.cpp @@ -101,7 +101,7 @@ void ESP::DrawCircle(Unit* unit, int radius, int32_t color, int smoothness = 16, { Renderer::Get()->RenderLine(screeenPoints[i], screeenPoints[i - 1], color, thickness); } - Renderer::Get()->RenderLine(screeenPoints[0], screeenPoints[screeenPoints.size()-1], color, thickness); + Renderer::Get()->RenderLine(screeenPoints[0], screeenPoints[screeenPoints.size() - 1], color, thickness); if (drawName) { Vector2 screenTextPos = Engine::Get()->worldToScreen(center); @@ -117,7 +117,7 @@ void ESP::LoadConfig() trebuchetESP = config->ReadInt("ESP", "trebuchetESP"); gaiaESP = config->ReadInt("ESP", "gaiaESP"); goldESP = config->ReadInt("ESP", "goldESP"); - stoneESP = config->ReadInt("ESP", "stoneESP"); + stoneESP = config->ReadInt("ESP", "stoneESP"); } void ESP::SaveConfig() @@ -140,9 +140,9 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) return; //Dont display annoying flares that Bots use } - /*if (siegeImpactLocation) + if (siegeImpactLocation) { - if (std::string(unit->pUnitData->name).find("Projectile Scorpion") != std::string::npos) + if (std::string(unit->GetUnitData()->GetName()).find("Projectile Scorpion") != std::string::npos) { Vector3* destination = unit->GetTargetPosition(); if (destination) @@ -152,7 +152,7 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) } } - if (std::string(unit->pUnitData->name).find("Projectile Mangonel") != std::string::npos) + if (std::string(unit->GetUnitData()->GetName()).find("Projectile Mangonel") != std::string::npos) { Vector3* destination = unit->GetTargetPosition(); if (destination) @@ -162,7 +162,7 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) } } - if (std::string(unit->pUnitData->name).find("Projectile Trebuchet") != std::string::npos) + if (std::string(unit->GetUnitData()->GetName()).find("Projectile Trebuchet") != std::string::npos) { Vector3* destination = unit->GetTargetPosition(); if (destination) @@ -171,13 +171,12 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) Renderer::Get()->RenderCircleFilled(ImVec2(screenDestinationPos.x, screenDestinationPos.y), 30, colors_hex[*player->pColor] & 0x77ffffff); } } - }*/ + } /*if (unit->pUnitData->Class == (int16_t)EnumUnitDataClass::Miscellaneous) { return; } - */ if (strcmp(unit->GetUnitData()->GetName(), "CSTL") == 0) { @@ -192,7 +191,7 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) DrawCircle(unit, 16, colors_hex[*player->pColor], 100, 2, true); } - /*if (playerUnitDestinationEsp[playerIndex]) + if (playerUnitDestinationEsp[playerIndex]) { Vector3* targetPosition = unit->GetTargetPosition(); if (!targetPosition || targetPosition->x <= 0 || targetPosition->y <= 0) { return; } @@ -200,7 +199,7 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) Vector2 screenPos = Engine::Get()->worldToScreen(unit); Vector2 screenTargetPos = Engine::Get()->worldToScreen(*targetPosition); Renderer::Get()->RenderLine(ImVec2(screenPos.x, screenPos.y), ImVec2(screenTargetPos.x, screenTargetPos.y), colors_hex[*player->pColor]); - }*/ + } } } @@ -278,7 +277,7 @@ void ESP::OnNeutralUnit(Unit* unit) Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff); return; } - + if (strcmp(unitName.c_str(), "RELIC") == 0) { Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 50, 0x40ffffff); -- cgit v1.2.3 From a927cae5522db4eadc250a6cda03494f7a8c2a83 Mon Sep 17 00:00:00 2001 From: BDKPlayer Date: Sat, 1 Aug 2020 17:25:01 +0200 Subject: added diplomacy ESP --- Classes.h | 24 ++++++++++++++++++++++++ ESP.cpp | 21 +++++++++++++++++++++ ESP.h | 3 +++ Engine.cpp | 25 +++++++++++++++++++++++++ Engine.h | 1 + 5 files changed, 74 insertions(+) (limited to 'ESP.cpp') diff --git a/Classes.h b/Classes.h index 61c5fcf..872a627 100644 --- a/Classes.h +++ b/Classes.h @@ -1,6 +1,7 @@ #pragma once // Generated using ReClass 2016 #include +#include "Engine.h" struct Vector4 { @@ -191,6 +192,29 @@ public: yScreenPos = pos.y; } + bool IsAllied(Player* other) + { + int32_t playerNumber = Engine::Get()->GetPlayerNumber(other); + int32_t* diplomacy = (int32_t*)((int64_t)this + 0xd0); + return *(diplomacy + playerNumber) == 2; + } + + bool IsEnemy(Player* other) + { + int32_t playerNumber = Engine::Get()->GetPlayerNumber(other); + int32_t* diplomacy = (int32_t*)((int64_t)this + 0xd0); + return *(diplomacy + playerNumber) == 4; + } + + bool IsNeutral(Player* other) + { + int32_t playerNumber = Engine::Get()->GetPlayerNumber(other); + int32_t* diplomacy = (int32_t*)((int64_t)this + 0xd0); + + //TODO is 0 correct? + return *(diplomacy + playerNumber) == 1; + } + }; //Size=0x93A0 class World diff --git a/ESP.cpp b/ESP.cpp index 11bf487..1df2f68 100644 --- a/ESP.cpp +++ b/ESP.cpp @@ -135,6 +135,20 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) { if (playerUnitEsp[playerIndex]) { + if (!allyEsp && Engine::Get()->GetLocalPlayer()->IsAllied(player)) + { + return; + } + + if (!neutralEsp && Engine::Get()->GetLocalPlayer()->IsNeutral(player)) + { + return; + } + + if (!enemyEsp && Engine::Get()->GetLocalPlayer()->IsEnemy(player)) + { + return; + } if (strcmp(unit->GetUnitData()->GetName(), "FLARE") == 0) { return; //Dont display annoying flares that Bots use @@ -289,6 +303,13 @@ void ESP::OnNeutralUnit(Unit* unit) void ESP::OnMenuMainWindow() { ImGui::Separator(); + ImGui::Text("Diplomacy ESP"); + ImGui::Checkbox("Ally", &allyEsp); + ImGui::SameLine(); + ImGui::Checkbox("Neutral", &neutralEsp); + ImGui::SameLine(); + ImGui::Checkbox("Enemy", &enemyEsp); + ImGui::Text("Siege ESP"); //ImGui::Checkbox("Siege Impact", &siegeImpactLocation); ImGui::Checkbox("Trebuchet range", &trebuchetESP); diff --git a/ESP.h b/ESP.h index a6d9b1e..ab58148 100644 --- a/ESP.h +++ b/ESP.h @@ -12,6 +12,9 @@ class ESP : public Feature bool stoneESP = true; bool trebuchetESP = true; bool siegeImpactLocation = true; + bool allyEsp = false; + bool neutralEsp = true; + bool enemyEsp = true; bool playerUnitEsp[9] = { true,true,true,true,true,true,true,true, true }; bool playerUnitDestinationEsp[9] = { false,false,false,false,false,false,false,false, false }; diff --git a/Engine.cpp b/Engine.cpp index f59e68e..e3adeaa 100644 --- a/Engine.cpp +++ b/Engine.cpp @@ -162,6 +162,31 @@ Player* Engine::GetPlayer(int index) const return playerArray->playerData[index].player; } +//TODO is this stable? +int Engine::GetPlayerNumber(Player* player) +{ + const int64_t totalPlayers = GetTotalPlayers(); + + + MainScreen* mainScreen = GetMainScreen(); + + World* main = GetWorld(); + + PlayerArray* playerArray = main->pPlayerArray; + + + for (int i = 0; i <= totalPlayers; i++) + { + if (playerArray->playerData[i].player == player) + { + return i; + } + } + + printf("Failed to GetPlayerNumber()\n"); + return -1; +} + Player* Engine::GetPlayerByName(char* playerName) const { MainScreen* mainScreen = GetMainScreen(); diff --git a/Engine.h b/Engine.h index 4344e25..87cc120 100644 --- a/Engine.h +++ b/Engine.h @@ -38,6 +38,7 @@ public: uint32_t GetPlayerColor(int colorIndex) const; ImVec4 GetPlayerColorImGUI(int colorIndex) const; Player* GetPlayer(int index) const; + int GetPlayerNumber(Player* player); Player* GetPlayerByName(char* playername) const; Player* GetLocalPlayer() const; -- cgit v1.2.3