-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrainer.cpp
More file actions
341 lines (299 loc) · 9.36 KB
/
Copy pathtrainer.cpp
File metadata and controls
341 lines (299 loc) · 9.36 KB
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
/**
* trainer.cpp - Trainer Class Implementation
*
* Implements all trainer features, hotkey handling,
* and memory manipulation logic.
*
* @version 1.0
* @date 2026-08-21
*/
#include "trainer.h"
#include <iostream>
#include <thread>
#include <chrono>
Trainer::Trainer()
: m_isAttached(false), m_damageMultiplier(1.0f) {
// Initialize saved position to zero
m_savedPosition[0] = 0.0f;
m_savedPosition[1] = 0.0f;
m_savedPosition[2] = 0.0f;
// Initialize all features as disabled
m_features["godmode"] = false;
m_features["infinite_resources"] = false;
m_features["onehitkill"] = false;
m_features["freeze_enemies"] = false;
m_features["noclip"] = false;
}
Trainer::~Trainer() {}
bool Trainer::AttachToGame() {
// The process name of the game (Pax Autocratica)
if (m_memory.AttachToProcess(L"Pax Autocratica.exe")) {
m_isAttached = true;
FindAddresses();
return true;
}
return false;
}
bool Trainer::FindAddresses() {
/**
* Note: These are placeholder addresses.
* In a real trainer, these are found using signature scanning.
*
* The offsets need to be updated for each game version.
*/
uintptr_t base = m_memory.GetBaseAddress();
// Player stats addresses (placeholders)
m_stats.healthAddr = base + 0x1234;
m_stats.maxHealthAddr = base + 0x1238;
m_stats.staminaAddr = base + 0x1240;
m_stats.positionAddr = base + 0x1300;
m_stats.ammoAddr = base + 0x1250;
m_stats.currencyAddr = base + 0x1260;
// Resource addresses (placeholders)
m_resources.foodAddr = base + 0x2000;
m_resources.metalAddr = base + 0x2004;
m_resources.energyAddr = base + 0x2008;
m_resources.rareAddr = base + 0x200C;
return true;
}
void Trainer::Update() {
if (!m_isAttached) return;
// Apply active features
if (m_features["godmode"]) GodMode();
if (m_features["infinite_resources"]) InfiniteResources();
if (m_features["onehitkill"]) OneHitKill();
if (m_features["freeze_enemies"]) FreezeEnemies();
// Handle hotkey input
HandleHotkeys();
}
void Trainer::GodMode() {
/**
* God Mode: Keeps health at maximum.
*
* Continuously sets the player's health value
* to the maximum health value.
*/
if (m_stats.healthAddr) {
float maxHealth = m_memory.Read<float>(m_stats.maxHealthAddr);
m_memory.Write<float>(m_stats.healthAddr, maxHealth);
}
}
void Trainer::InfiniteResources() {
/**
* Infinite Resources: Sets all resources to a very high value.
*
* Writes a large value (99999) to each resource address,
* effectively making them unlimited.
*/
if (m_resources.foodAddr) {
m_memory.Write<int>(m_resources.foodAddr, 99999);
m_memory.Write<int>(m_resources.metalAddr, 99999);
m_memory.Write<int>(m_resources.energyAddr, 99999);
m_memory.Write<int>(m_resources.rareAddr, 99999);
}
}
void Trainer::OneHitKill() {
/**
* One-Hit Kill: Instantly eliminates enemies.
*
* Note: Full implementation requires:
* 1. Finding the enemy list in memory
* 2. Iterating through all enemies
* 3. Setting their health to 0
*
* This is a placeholder that prints a message.
*/
// Placeholder: requires scanning for enemy health addresses
}
void Trainer::TeleportToSaved() {
/**
* Teleport to saved position.
*
* Checks if a position has been saved,
* then writes that position to the player's coordinates.
*/
if (m_savedPosition[0] != 0.0f || m_savedPosition[1] != 0.0f || m_savedPosition[2] != 0.0f) {
WritePosition(m_savedPosition);
std::cout << "[+] Teleported to saved position!" << std::endl;
}
}
void Trainer::SavePosition() {
/**
* Save current position.
*
* Reads the player's current coordinates
* and stores them for later teleportation.
*/
ReadPosition(m_savedPosition);
std::cout << "[+] Position saved!" << std::endl;
}
void Trainer::ReadPosition(float* pos) {
/**
* Read player position from memory.
*
* Reads three consecutive floats for X, Y, Z coordinates.
*/
if (m_stats.positionAddr) {
pos[0] = m_memory.Read<float>(m_stats.positionAddr);
pos[1] = m_memory.Read<float>(m_stats.positionAddr + 4);
pos[2] = m_memory.Read<float>(m_stats.positionAddr + 8);
}
}
void Trainer::WritePosition(const float* pos) {
/**
* Write player position to memory.
*
* Writes three consecutive floats for X, Y, Z coordinates.
*/
if (m_stats.positionAddr) {
m_memory.Write<float>(m_stats.positionAddr, pos[0]);
m_memory.Write<float>(m_stats.positionAddr + 4, pos[1]);
m_memory.Write<float>(m_stats.positionAddr + 8, pos[2]);
}
}
void Trainer::FreezeEnemies() {
/**
* Freeze Enemies: Stop enemy AI and movement.
*
* Note: Full implementation requires:
* 1. Finding the enemy list in memory
* 2. Pausing enemy AI state machines
*
* This is a placeholder.
*/
// Placeholder: requires scanning for enemy AI addresses
}
void Trainer::Noclip() {
/**
* Noclip: Disable collision.
*
* Note: Full implementation requires:
* 1. Finding the collision flag
* 2. Setting it to false
*
* This is a placeholder.
*/
// Placeholder: requires finding collision flag address
}
void Trainer::AdjustDamage(float multiplier) {
/**
* Adjust damage multiplier.
*
* Updates the damage multiplier and logs the change.
*/
m_damageMultiplier = multiplier;
std::cout << "[+] Damage multiplier: " << multiplier << "x" << std::endl;
}
void Trainer::ToggleHUD() {
/**
* Toggle HUD: Hide or show the interface.
*
* Note: Full implementation requires:
* 1. Finding HUD render flag
* 2. Toggling visibility
*
* This is a placeholder.
*/
std::cout << "[+] HUD toggled" << std::endl;
}
void Trainer::HandleHotkeys() {
/**
* Handle keyboard input for all hotkeys.
*
* Uses GetAsyncKeyState to detect key presses.
* Prevents key repeat by tracking previous state.
*/
// F1: Open menu
if (IsKeyPressed(VK_F1)) {
std::cout << "[Menu] Press F1 to open/close menu" << std::endl;
}
// F2: Toggle God Mode
if (IsKeyPressed(VK_F2)) {
m_features["godmode"] = !m_features["godmode"];
std::cout << "[+] God Mode: " << (m_features["godmode"] ? "ON" : "OFF") << std::endl;
}
// F3: Toggle Infinite Resources
if (IsKeyPressed(VK_F3)) {
m_features["infinite_resources"] = !m_features["infinite_resources"];
std::cout << "[+] Infinite Resources: " << (m_features["infinite_resources"] ? "ON" : "OFF") << std::endl;
}
// F4: Toggle One-Hit Kill
if (IsKeyPressed(VK_F4)) {
m_features["onehitkill"] = !m_features["onehitkill"];
std::cout << "[+] One-Hit Kill: " << (m_features["onehitkill"] ? "ON" : "OFF") << std::endl;
}
// F5: Teleport to saved position
if (IsKeyPressed(VK_F5)) {
TeleportToSaved();
}
// F6: Save current position
if (IsKeyPressed(VK_F6)) {
SavePosition();
}
// F7: Toggle Freeze Enemies
if (IsKeyPressed(VK_F7)) {
m_features["freeze_enemies"] = !m_features["freeze_enemies"];
std::cout << "[+] Freeze Enemies: " << (m_features["freeze_enemies"] ? "ON" : "OFF") << std::endl;
}
// F8: Open item spawner
if (IsKeyPressed(VK_F8)) {
std::cout << "[+] Item spawner opened" << std::endl;
}
// F9: Toggle Noclip
if (IsKeyPressed(VK_F9)) {
m_features["noclip"] = !m_features["noclip"];
std::cout << "[+] Noclip: " << (m_features["noclip"] ? "ON" : "OFF") << std::endl;
}
// F10: Reload config
if (IsKeyPressed(VK_F10)) {
std::cout << "[+] Config reloaded" << std::endl;
}
// Insert: Toggle HUD
if (IsKeyPressed(VK_INSERT)) {
ToggleHUD();
}
// PageUp: Increase damage multiplier
if (IsKeyPressed(VK_PRIOR)) {
AdjustDamage(m_damageMultiplier + 0.5f);
}
// PageDown: Decrease damage multiplier
if (IsKeyPressed(VK_NEXT)) {
AdjustDamage(std::max(0.1f, m_damageMultiplier - 0.5f));
}
}
bool Trainer::IsKeyPressed(int key) {
/**
* Check if a key was pressed (not just held).
*
* Tracks the previous state of each key to detect
* transition from not-pressed to pressed.
*/
static std::map<int, bool> prevState;
bool currentState = (GetAsyncKeyState(key) & 0x8000) != 0;
// Key was pressed this frame (wasn't pressed last frame)
if (currentState && !prevState[key]) {
prevState[key] = true;
return true;
}
// Key is not pressed this frame
if (!currentState) {
prevState[key] = false;
}
return false;
}
void Trainer::ToggleFeature(const std::string& feature) {
/**
* Toggle a feature by name.
*/
if (m_features.find(feature) != m_features.end()) {
m_features[feature] = !m_features[feature];
std::cout << "[+] " << feature << ": " << (m_features[feature] ? "ON" : "OFF") << std::endl;
}
}
bool Trainer::IsFeatureEnabled(const std::string& feature) const {
/**
* Check if a feature is enabled.
*/
auto it = m_features.find(feature);
return it != m_features.end() && it->second;
}