From cdc71b248d67fa5d1ac10a4a35ac3a58f757255e Mon Sep 17 00:00:00 2001 From: BDKPlayer Date: Fri, 31 Jul 2020 16:14:55 +0200 Subject: Working minimal version --- Engine.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'Engine.cpp') diff --git a/Engine.cpp b/Engine.cpp index 3619af9..7f797dc 100644 --- a/Engine.cpp +++ b/Engine.cpp @@ -92,7 +92,7 @@ Vector2 Engine::worldToScreen(Vector3 position) const Vector2 Engine::worldToScreen(Unit* unit) const { - return worldToScreen(unit->position); + return worldToScreen(unit->GetPosition()); } uint32_t Engine::GetPlayerColor(int colorIndex) const @@ -249,12 +249,3 @@ void Engine::PrintBottomNotification(const char* message, unsigned int hexcolor) static tPrintBottomText fPrintBottomText = (tPrintBottomText)(base + Offsets::printBottomText); fPrintBottomText(GetMainScreen()->pGameScreen, message, hexcolor, 0xffffffffffffffff); //Color format: RBGA } - -int64_t Engine::Flare(float xPos, float yPos) const -{ - typedef __int64(__fastcall* tCreateFlare) (Player* player, __int64 hundert12, __int64 zero1, __int64 zero2, float xPos, float yPos, int64_t zero3, int64_t zero4); - static tCreateFlare fCreateFlare = (tCreateFlare)(base + 0xc31270); - - return fCreateFlare(GetLocalPlayer(), 0x112, 0, 0, 220.f, 220.f, 0, 0); - //__usercall fhsCreateFlare_MAYBE_7FF718CF1270@( __int64 a3_zero@, __int64 a4_zero@, float xPos@, float yPos@, __int64 a5_zero, int a6_Zero) -} -- cgit v1.2.3 From be9a9b51f2258cceb7cf911c3e6981134c06a552 Mon Sep 17 00:00:00 2001 From: BDKPlayer Date: Sat, 1 Aug 2020 14:27:24 +0200 Subject: Updates more features to current game version: - CastleManager - RelicManager - CustomLoadingScreen --- CastleManager.cpp | 12 ++++++++++-- Core.cpp | 12 +++++------- Engine.cpp | 11 +---------- Engine.h | 1 - InitialiseOffsets.cpp | 6 +----- Offsets.cpp | 13 ++++++------- Offsets.h | 1 - 7 files changed, 23 insertions(+), 33 deletions(-) (limited to 'Engine.cpp') diff --git a/CastleManager.cpp b/CastleManager.cpp index 2b7ab6f..6b85e36 100644 --- a/CastleManager.cpp +++ b/CastleManager.cpp @@ -11,6 +11,7 @@ bool warningEnabled = true; int notification = 0; +ThreadSafeQueue localMessages; ThreadSafeQueue teamMessages; ThreadSafeQueue allMessages; @@ -40,7 +41,7 @@ void CastleManager::OnUnitCreated(Unit* unit) return; } Player* owningPlayer = unit->GetOwner(); - if (!owningPlayer || owningPlayer == Engine::Get()->GetLocalPlayer()) + if (!owningPlayer /*|| owningPlayer == Engine::Get()->GetLocalPlayer()*/) { return; } @@ -53,7 +54,7 @@ void CastleManager::OnUnitCreated(Unit* unit) switch (notification) { case 0: - Engine::Get()->PrintNotification(charMessage); + localMessages.push(message); break; case 1: teamMessages.push(message); @@ -69,6 +70,13 @@ void CastleManager::OnUnitCreated(Unit* unit) void CastleManager::OnMenuMainWindow() { + if (!localMessages.isEmpty()) + { + std::string message; + localMessages.pop(message); + Engine::Get()->PrintNotification(message.c_str()); + } + if (!teamMessages.isEmpty()) { std::string message; diff --git a/Core.cpp b/Core.cpp index 318fba2..17f0f03 100644 --- a/Core.cpp +++ b/Core.cpp @@ -82,20 +82,18 @@ void __fastcall OnCreateUnitHook(Registers* registers) Core::Core() { - //printf("Core::Core()\n"); - //onCreateUnitHook.Hook((BYTE*)GetModuleHandle(NULL) + Offsets::createUnitHook, (BYTE*)OnCreateUnitHook, 15); + onCreateUnitHook.Hook((BYTE*)GetModuleHandle(NULL) + Offsets::createUnitHook, (BYTE*)OnCreateUnitHook, 15); FeatureManager* featureManager = FeatureManager::Get(); //featureManager->RegisterFeature(new InitialiseOffsets()); //Register Features here - //featureManager->RegisterFeature(new ResourceInformation()); + featureManager->RegisterFeature(new ResourceInformation()); featureManager->RegisterFeature(new ESP()); featureManager->RegisterFeature(new MinimapText()); - //featureManager->RegisterFeature(new RelicManager()); - //featureManager->RegisterFeature(new CustomLoadingScreen("C:\\wallpaper.jpg")); - //featureManager->RegisterFeature(new PauseManager()); - //featureManager->RegisterFeature(new CastleManager()); + featureManager->RegisterFeature(new RelicManager()); + featureManager->RegisterFeature(new CustomLoadingScreen("C:\\wallpaper.jpg")); + featureManager->RegisterFeature(new CastleManager()); #ifdef _DEBUG featureManager->RegisterFeature(new Debug()); diff --git a/Engine.cpp b/Engine.cpp index 7f797dc..bb3db2a 100644 --- a/Engine.cpp +++ b/Engine.cpp @@ -208,15 +208,6 @@ Player* Engine::GetLocalPlayer() const return *reinterpret_cast(tribePanelInven + Offsets::tribePanelInven_localPlayer); } -// -//Pauses the game -void Engine::PauseGame() const -{ - typedef int64_t(__fastcall* tPauseGame)(CommHandler* CommHandler); - static tPauseGame fPauseGame = (tPauseGame)(base + Offsets::pauseGame); - fPauseGame(Get()->GetGame()->pCommHandler); -} - // //Sends a chat message. Only to be called from rendering thread void Engine::SendChat(const char* message, bool teamchat) const @@ -240,7 +231,7 @@ 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); - fPrintNotification(GetMainScreen()->pGameScreen, message, 1); + fPrintNotification(GetMainScreen()->pGameScreen, message, 0); } void Engine::PrintBottomNotification(const char* message, unsigned int hexcolor) const diff --git a/Engine.h b/Engine.h index 692418c..4344e25 100644 --- a/Engine.h +++ b/Engine.h @@ -41,7 +41,6 @@ public: Player* GetPlayerByName(char* playername) const; Player* GetLocalPlayer() const; - void PauseGame() const; void SendChat(const char* message, bool teamchat = false) const; void PrintNotification(const char* message) const; void PrintBottomNotification(const char* message, unsigned int hexcolor) const; diff --git a/InitialiseOffsets.cpp b/InitialiseOffsets.cpp index 4611db8..d626897 100644 --- a/InitialiseOffsets.cpp +++ b/InitialiseOffsets.cpp @@ -57,11 +57,7 @@ void InitialiseOffsets::OnInitialise() printBottomText = Pattern::FindSignature("AoE2DE_s.exe", "48 8B C4 48 83 EC 78 F3 0F 10 05 ? ? ? ? 41"); printBottomText -= base; printf("printBottomText: %x\n", printBottomText); - - pauseGame = Pattern::FindSignature("AoE2DE_s.exe", "48 89 5C 24 ? 55 48 8D 6C 24 ? 48 81 EC ? ? ? ? 80"); - pauseGame -= base; - printf("pauseGame: %x\n", pauseGame); - + sendChat = Pattern::FindSignature("AoE2DE_s.exe", "E8 ? ? ? ? 90 48 8B 05 ? ? ? ? F2") - 0x94; sendChat -= base; printf("sendChat: %x\n", sendChat); diff --git a/Offsets.cpp b/Offsets.cpp index 56695f7..129d0bf 100644 --- a/Offsets.cpp +++ b/Offsets.cpp @@ -22,19 +22,18 @@ namespace Offsets int64_t minimapHookOffset = 0xCB2616; //Functions - int64_t printNotification = 0xca7b10; //48 83 EC 48 48 8B 05 ? ? ? ? 4C 8D //4 - int64_t printBottomText = 0xc914d0; //48 8B C4 48 83 EC 78 F3 0F 10 05 ? ? ? ? 41 //4 - int64_t pauseGame = 0x874620; //48 89 5C 24 ? 55 48 8D 6C 24 ? 48 81 EC ? ? ? ? 80 //3 + int64_t printNotification = 0xCA8AC0; //48 83 EC 48 48 8B 05 ? ? ? ? 4C 8D //4 + int64_t printBottomText = 0xc92480; //48 8B C4 48 83 EC 78 F3 0F 10 05 ? ? ? ? 41 //4 //E8 ? ? ? ? 90 48 8B 05 ? ? ? ? F2 - 0x94 //1 - int64_t sendChat = 0xa158c0; + int64_t sendChat = 0xa16090; - int64_t createUnitHook = 0xeacf60; //48 89 5C 24 ? 48 89 6C 24 ? 57 48 83 EC 20 8B 41 //3 + int64_t createUnitHook = 0xeadf40; //48 89 5C 24 ? 48 89 6C 24 ? 57 48 83 EC 20 8B 41 //4 int64_t playerArrayStart = 0x2a8; //Manual Update //CustomLoadingScreen - int64_t pathToLoadScreen = 0x2012278; // /resources/loading_slash.png - int64_t loadPathToLoadScreen = 0xfe0eae; // x-ref /resources/loading_slash.png + int64_t pathToLoadScreen = 0x2013488; // /resources/loading_slash.png + int64_t loadPathToLoadScreen = 0xfe1ece; // x-ref /resources/loading_slash.png } \ No newline at end of file diff --git a/Offsets.h b/Offsets.h index 74edc51..4530bc0 100644 --- a/Offsets.h +++ b/Offsets.h @@ -18,7 +18,6 @@ namespace Offsets //Functions extern int64_t printNotification; extern int64_t printBottomText; - extern int64_t pauseGame; extern int64_t sendChat; extern int64_t createUnitHook; -- 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 'Engine.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 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 'Engine.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