-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestOverlay.cpp
184 lines (158 loc) · 5.32 KB
/
TestOverlay.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
#include "TestOverlay.h"
#include <imgui.h>
#include "BaseObject.hpp"
#include "GameWorld.hpp"
#include "Offsets.hpp"
#include "Player.hpp"
#include <vector>
#include <iostream>
#include "Global.hpp"
#include "Hacks.hpp"
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <nlohmann/json.hpp>
#include "Utils.h"
#include <locale>
#include <codecvt>
#include "mdissect/mdissect.hpp"
namespace nlohmann {
template <>
struct adl_serializer<std::wstring> {
static void to_json(json& j, const std::wstring& value) {
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
j = conv.to_bytes(value);
}
static void from_json(const json& j, std::wstring& value) {
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
value = conv.from_bytes(j.get<std::string>());
}
};
template <typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>& operator>>(std::basic_istream<_CharT, _Traits>& stream, json& j) {
std::wstringstream ws;
ws << stream.rdbuf();
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
std::string utf8_str = conv.to_bytes(ws.str());
j = json::parse(utf8_str);
return stream;
}
}
TestOverlay::TestOverlay(const char* title, int updateRate) :
Overlay(title, updateRate)
{
bool hasError = false;
Global::pSettings = std::make_unique<Settings>(Settings::FromFile("config.json", &hasError));
if (hasError) {
std::cout << "An error occurred while loading the config" << std::endl;
}
SetExitKey(KeyboardKey::KEY_END);
if (std::filesystem::exists("items.json")) {
std::wifstream fs{"items.json"};
fs.imbue(std::locale(std::locale(), new std::codecvt_utf8<wchar_t>));
nlohmann::json json_data{};
fs >> json_data;
for (auto& element : json_data.items()) {
std::string keyStr = element.key();
std::wstring key{keyStr.begin(), keyStr.end()};
Global::itemTemplates[key] = element.value().get<std::wstring>();
}
}
else {
printf_s("Missing items.json?\n");
}
mdissect::read_memory = [](uintptr_t address, void* buffer, size_t size) -> bool {
return Global::pMemoryInterface->ReadRaw(address, buffer, size);
};
mdissect::write_memory = [](uintptr_t address, const void* buffer, size_t size) -> bool {
return Global::pMemoryInterface->WriteRaw(address, const_cast<void*>(buffer), size);
};
}
void TestOverlay::OnFocusFound() {
Global::pSettings = std::make_unique<Settings>(Settings::FromFile("config.json", nullptr));
}
void TestOverlay::OnFocusLost() {
Global::pSettings->Serialize();
}
void TestOverlay::UpdateImGui() {
Global::totalTime += GetFrameTime();
Global::centerScreen = Vector2{GetRenderWidth() * 0.5f, GetRenderHeight() * 0.5f};
Hacks::DoKeybindActions();
if (Global::pMemoryInterface->UpdateProcessId(L"EscapeFromTarkov.exe")) {
if (Global::gom.address) {
if (Global::totalTime >= Global::lastUpdated + Global::pSettings->updateRate) {
Global::lastUpdated = Global::totalTime;
Global::activeCamera.address = 0;
Global::gameWorld = GameWorld::Get();
if (Global::gameWorld.address) {
Global::activeCamera = EFTCamera{Global::gom.GetCameraList().GetObject(nullptr)};
}
}
if (Global::gameWorld.address && Global::activeCamera.address) {
Hacks::DoNoRecoil();
}
}
else {
Global::gom = GameObjectManager::Get();
}
}
}
bool TestOverlay::ShouldShowMenu() {
return this->isMenuOpen;
}
void TestOverlay::DrawImGui() {
if (Global::pSettings->debug.enabled) {
if (ImGui::Begin("Debug")) {
}
ImGui::End();
}
if (this->isMenuOpen) {
if (ImGui::Selectable(TextFormat("GOM: %p", Global::gom.address))) {
std::ostringstream stream{};
stream << std::uppercase << std::hex << Global::gom.address;
ImGui::SetClipboardText(stream.str().c_str());
}
if (ImGui::Selectable(TextFormat("ActiveCamera: %p", Global::activeCamera.address))) {
std::ostringstream stream{};
stream << std::uppercase << std::hex << Global::activeCamera.address;
ImGui::SetClipboardText(stream.str().c_str());
}
if (ImGui::Selectable(TextFormat("GameWorld: %p", Global::gameWorld.address))) {
std::ostringstream stream{};
stream << std::uppercase << std::hex << Global::gameWorld.address;
ImGui::SetClipboardText(stream.str().c_str());
}
if (Global::gameWorld.GetPlayers().size() > 0) {
if (ImGui::Selectable(TextFormat("LocalPlayer: %p", Global::gameWorld.GetPlayers()[0].address))) {
std::ostringstream stream{};
stream << std::uppercase << std::hex << Global::gameWorld.GetPlayers()[0].address;
ImGui::SetClipboardText(stream.str().c_str());
}
}
ImGui::DragFloat("Polling Rate", &Global::pSettings->updateRate, 0.01f, 0.f, 5.f);
ImGui::Checkbox("Show FPS", &Global::pSettings->showFPS);
if (ImGui::CollapsingHeader("FOV")) {
ImGui::Checkbox("Visualize", &Global::pSettings->visualizeImportantRadius);
ImGui::DragFloat("Value", &Global::pSettings->importantRadius);
}
Hacks::DrawMenuOptions();
}
if (Global::pSettings->visualizeImportantRadius) {
DrawCircleLines(
static_cast<float>(Global::centerScreen.x),
static_cast<float>(Global::centerScreen.y),
Global::pSettings->importantRadius,
MAGENTA
);
}
if (Global::pSettings->showFPS) {
DrawFPS(4, 4);
}
if (Global::gameWorld.address && Global::activeCamera.address) {
Hacks::DrawLootESP();
Hacks::DrawPlayerESP();
Hacks::DrawSkeletonESP();
}
}