aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBDKPlayer <fabian.stotz@yahoo.de>2020-06-04 18:07:55 +0200
committerBDKPlayer <fabian.stotz@yahoo.de>2020-06-04 18:07:55 +0200
commitc0d10fa5c6aec95bc858cd52c5a0f89d786cc49e (patch)
tree3fd04ce15948dc67260813f914914cf61d1ffdfb
parent3a8e1f17e6a2a032271157da906c6f44c196f77e (diff)
ReRefactored the ESP code
Fixed last player ESP not showing
-rw-r--r--ESP.cpp98
-rw-r--r--ESP.h21
2 files changed, 47 insertions, 72 deletions
diff --git a/ESP.cpp b/ESP.cpp
index 3cf5c35..a4092f7 100644
--- a/ESP.cpp
+++ b/ESP.cpp
@@ -3,7 +3,7 @@
#include "Sdk.h"
#include "Renderer.h"
#include "Engine.h"
-#include <map>
+
#include <math.h>
#include "Config.h"
@@ -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;
+ static const float PI = 3.14159265358979323846;
int32_t tileSize = Engine::Get()->GetWorld()->pMap->GetTileSize();
Vector3 center = unit->position;
@@ -97,7 +97,7 @@ void ESP::DrawCircle(Unit* unit, int radius, int32_t color, int smoothness = 16,
Vector2 screenPos = Engine::Get()->worldToScreen(Vector3(x, y, center.z));
screeenPoints.push_back(ImVec2(screenPos.x, screenPos.y));
}
- for (size_t i = 1; i < screeenPoints.size(); i++)
+ for (int i = 1; i < screeenPoints.size(); i++)
{
Renderer::Get()->RenderLine(screeenPoints[i], screeenPoints[i - 1], color, thickness);
}
@@ -243,74 +243,50 @@ void ESP::OnNeutralUnit(Unit* unit)
return;
}
- typedef void (ESP::* fPtr)(Vector2&, std::string&);
- typedef std::map<std::vector<std::string>, fPtr> Actions;
- Actions link;
- std::vector<std::string> valuesFish = { "FISHS", "FISHX","FISH1","FISH2","FISH3","FISH4","turtles" };
- std::vector<std::string> valuesHeavyFood = { "BOARX", "RHINO","BOAR","BOARJ","WELEF" };
- std::vector<std::string> valuesLighthuntable = { "DEERX", "IBEX","ZEBRA","OSTRICH" };
- std::vector<std::string> valuesLightFood = { "SHEEPG", "GOOSE","PIG", "LLAMAG", "Cow Black", "Cow Brown", "Cow Black and White", "BUFFALO", "TURKYG", "GOAT" };
- std::vector<std::string> valuesDangerousAnimal = { "WOLFX", "KOMODO","GJAGR", "SLEOPA", "BEAR", "CROCO", "LION", "TIGER" };
- std::vector<std::string> valuesRelic = { "RELIC" };
+ if (std::find(namesFish.begin(), namesFish.end(), unitName) != namesFish.end())
+ {
+ Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x400000ff);
+ Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
+ return;
+ }
- void (ESP:: * RenderStyleAction)(Vector2&, std::string&);
+ if (std::find(namesHeavyFood.begin(), namesHeavyFood.end(), unitName) != namesHeavyFood.end())
+ {
+ Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x4000ff00);
+ Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
+ return;
+ }
- link.emplace(valuesFish, &ESP::RenderStyleFish);
- link.emplace(valuesHeavyFood, &ESP::RenderStyleHeavyFood);
- link.emplace(valuesLighthuntable, &ESP::RenderStyleLighHuntable);
- link.emplace(valuesLightFood, &ESP::RenderStyleLightFood);
- link.emplace(valuesDangerousAnimal, &ESP::RenderStyleDangerousAnimal);
- link.emplace(valuesRelic, &ESP::RenderStyleRelic);
+ if (std::find(namesLighthuntable.begin(), namesLighthuntable.end(), unitName) != namesLighthuntable.end())
+ {
+ Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x4000ffff);
+ Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
+ return;
+ }
- for (std::pair<std::vector<std::string>, fPtr> element : link)
+ if (std::find(namesLightFood.begin(), namesLightFood.end(), unitName) != namesLightFood.end())
{
- if (std::find(element.first.begin(), element.first.end(), unitName) != element.first.end())
- {
- RenderStyleAction = element.second;
- }
+ Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x400000ff);
+ Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
+ return;
}
- (this->*RenderStyleAction)(screenPos, unitName);
+ if (std::find(namesDangerousAnimal.begin(), namesDangerousAnimal.end(), unitName) != namesDangerousAnimal.end())
+ {
+ Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x40ff0000);
+ 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);
+ Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
+ }
}
}
-void ESP::RenderStyleRelic(Vector2& screenPos, std::string& unitName)
-{
- Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 50, 0x40ffffff);
- Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
-}
-
-void ESP::RenderStyleDangerousAnimal(Vector2& screenPos, std::string& unitName)
-{
- Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x40ff0000);
- Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
-}
-
-void ESP::RenderStyleLighHuntable(Vector2& screenPos, std::string& unitName)
-{
- Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x4000ffff);
- Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
-}
-
-void ESP::RenderStyleHeavyFood(Vector2& screenPos, std::string& unitName)
-{
- Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x4000ff00);
- Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
-}
-
-void ESP::RenderStyleLightFood(Vector2& screenPos, std::string& unitName)
-{
- Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x400000ff);
- Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
-}
-
-void ESP::RenderStyleFish(Vector2& screenPos, std::string& unitName)
-{
- Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 20, 0x400000ff);
- Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff);
-}
-
void ESP::OnMenuMainWindow()
{
ImGui::Separator();
diff --git a/ESP.h b/ESP.h
index 1595556..a6d9b1e 100644
--- a/ESP.h
+++ b/ESP.h
@@ -1,5 +1,6 @@
#pragma once
#include "Feature.h"
+
#include <string>
struct Vector2;
@@ -12,15 +13,21 @@ class ESP : public Feature
bool trebuchetESP = true;
bool siegeImpactLocation = true;
- bool playerUnitEsp[8] = { true,true,true,true,true,true,true,true };
- bool playerUnitDestinationEsp[8] = { false,false,false,false,false,false,false,false };
+ bool playerUnitEsp[9] = { true,true,true,true,true,true,true,true, true };
+ bool playerUnitDestinationEsp[9] = { false,false,false,false,false,false,false,false, false };
- bool playerUnitNameEsp[8] = { false,false,false,false,false,false,false,false };
+ bool playerUnitNameEsp[9] = { false,false,false,false,false,false,false,false, false };
//bool playerBuildingEsp[8] = { false,true,true,true,true,true,true,true };
//bool playerBuildingNameEsp[8] = { false,true,true,true,true,true,true,true };
float colors[8][3] = { 0 };
static uint32_t colors_hex[8];
+ std::vector<std::string> namesFish = { "FISHS", "FISHX","FISH1","FISH2","FISH3","FISH4","turtles" };
+ std::vector<std::string> namesHeavyFood = { "BOARX", "RHINO","BOAR","BOARJ","WELEF" };
+ std::vector<std::string> namesLighthuntable = { "DEERX", "IBEX","ZEBRA","OSTRICH" };
+ std::vector<std::string> namesLightFood = { "SHEEPG", "GOOSE","PIG", "LLAMAG", "Cow Black", "Cow Brown", "Cow Black and White", "BUFFALO", "TURKYG", "GOAT" };
+ std::vector<std::string> namesDangerousAnimal = { "WOLFX", "KOMODO","GJAGR", "SLEOPA", "BEAR", "CROCO", "LION", "TIGER" };
+
//Callbacks
void LoadConfig() override;
void SaveConfig() override;
@@ -32,13 +39,5 @@ class ESP : public Feature
void DrawBox(Unit* unit, int32_t color, bool drawName);
void DrawBox(Vector3 position, Vector2 edgeSize, int32_t color);
-
- void RenderStyleRelic(Vector2& screenPos, std::string& unitName);
- void RenderStyleDangerousAnimal(Vector2& screenPos, std::string& unitName);
- void RenderStyleLighHuntable(Vector2& screenPos, std::string& unitName);
- void RenderStyleHeavyFood(Vector2& screenPos, std::string& unitName);
- void RenderStyleLightFood(Vector2& screenPos, std::string& unitName);
- void RenderStyleFish(Vector2& screenPos, std::string& unitName);
-
void DrawCircle(Unit* unit, int radius, int32_t color, int smoothness , float thickness, bool drawName);
}; \ No newline at end of file