-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFunctions.h
More file actions
406 lines (326 loc) · 9.44 KB
/
Functions.h
File metadata and controls
406 lines (326 loc) · 9.44 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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
#pragma once
#include <thread>
#include <conio.h>
#include <vector>
#include <locale>
#include <codecvt>
#include "ProcMem.h"
#include "Vector.h"
#include "hDirectX.h"
#include "Offsets.h"
#include "FindPattern/FindPattern.h"
#pragma comment(lib,"winmm.lib")
class CFG;
struct Color
{
int r, g, b;
};
/*#define WORLD_OFFSET 0x51b5578
#define OBJECTS_OFFSET 0x50f3680
#define NAME_OFFSET 0x50f7e40*/
ULONG_PTR GNames;
ProcMem mem;
DWORD pid;
uintptr_t BASE;
bool FirstRun = true;
uintptr_t WorldAddress;
uintptr_t ObjectsAddress;
uintptr_t NamesAddress;
Vector3 myLocation, myAngles, Cameralocation;
float CameraFov;
void ReadData()
{
if (FirstRun)
{
mem.Process("SoTGame.exe");
/* Set Module and store it in Client */
BASE = mem.Module("SoTGame.exe");
FirstRun = false;
auto address = EOWidgets::FindPatternExternal(mem.hProcess, reinterpret_cast<HMODULE>(BASE),
reinterpret_cast<const unsigned char*>("\x48\x8B\x0D\x00\x00\x00\x00\x48\x8B\x01\xFF\x90\x00\x00\x00\x00\x48\x8B\xF8\x33\xD2\x48\x8D\x4E"),
"xxx????xxxxx????xxxxxxxx");
if (address > 0)
{
WorldAddress = EOWidgets::ReadRIPAddress(mem.hProcess, address, 3, 7);
}
address = EOWidgets::FindPatternExternal(mem.hProcess, reinterpret_cast<HMODULE>(BASE),
reinterpret_cast<const unsigned char*>("\x48\x8B\x3D\x00\x00\x00\x00\x48\x85\xFF\x75\x00\xB9\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x48\x8B\xF8\x48\x89\x44"),
"xxx????xxxx?x????x????xxxxxx");
if (address > 0)
{
NamesAddress = EOWidgets::ReadRIPAddress(mem.hProcess, address, 3, 7);
}
//WaitForMultipleObjects(sizeof(rghThreads) / sizeof(HANDLE), rghThreads, TRU E, INFINITE);
}
}
class text
{
public:
char word[64];
};
class textx
{
public:
wchar_t word[64];
};
enum rareity
{
Common,
Rare,
Legendary,
Mythical,
Fort,
Weeping,
Drunken
};
enum type
{
chest,
skull,
artifact,
merchantcrate,
animalcrate,
gunpowder,
player,
skeleton,
ship,
chicken,
pig,
snake,
fort
};
struct AActors
{
int id;
std::string name, item;
Vector3 Location;
Vector3 TopLocation;
int type, rareity, namesize;
float health, maxhealth;
float yaw;
int distance;
};
std::vector<AActors> ActorArray;
//std::vector<AActors> myActorArray;
std::vector<AActors> WeildingArray;
#define Assert( _exp ) ((void)0)
struct vMatrix
{
vMatrix() {}
vMatrix(
float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23)
{
m_flMatVal[0][0] = m00; m_flMatVal[0][1] = m01; m_flMatVal[0][2] = m02; m_flMatVal[0][3] = m03;
m_flMatVal[1][0] = m10; m_flMatVal[1][1] = m11; m_flMatVal[1][2] = m12; m_flMatVal[1][3] = m13;
m_flMatVal[2][0] = m20; m_flMatVal[2][1] = m21; m_flMatVal[2][2] = m22; m_flMatVal[2][3] = m23;
}
float *operator[](int i) { Assert((i >= 0) && (i < 3)); return m_flMatVal[i]; }
const float *operator[](int i) const { Assert((i >= 0) && (i < 3)); return m_flMatVal[i]; }
float *Base() { return &m_flMatVal[0][0]; }
const float *Base() const { return &m_flMatVal[0][0]; }
float m_flMatVal[3][4];
};
vMatrix Matrix(Vector3 rot, Vector3 origin)
{
origin = Vector3(0, 0, 0);
float radPitch = (rot.x * float(PI) / 180.f);
float radYaw = (rot.y * float(PI) / 180.f);
float radRoll = (rot.z * float(PI) / 180.f);
float SP = sinf(radPitch);
float CP = cosf(radPitch);
float SY = sinf(radYaw);
float CY = cosf(radYaw);
float SR = sinf(radRoll);
float CR = cosf(radRoll);
vMatrix matrix;
matrix[0][0] = CP * CY;
matrix[0][1] = CP * SY;
matrix[0][2] = SP;
matrix[0][3] = 0.f;
matrix[1][0] = SR * SP * CY - CR * SY;
matrix[1][1] = SR * SP * SY + CR * CY;
matrix[1][2] = -SR * CP;
matrix[1][3] = 0.f;
matrix[2][0] = -(CR * SP * CY + SR * SY);
matrix[2][1] = CY * SR - CR * SP * SY;
matrix[2][2] = CR * CP;
matrix[2][3] = 0.f;
matrix[3][0] = origin.x;
matrix[3][1] = origin.y;
matrix[3][2] = origin.z;
matrix[3][3] = 1.f;
return matrix;
}
bool WorldToScreen(Vector3 origin, Vector2 * out) {
Vector3 Screenlocation = Vector3(0, 0, 0);
Vector3 Rotation = myAngles; // FRotator
vMatrix tempMatrix = Matrix(Rotation, Vector3(0, 0, 0)); // Matrix
Vector3 vAxisX, vAxisY, vAxisZ;
vAxisX = Vector3(tempMatrix[0][0], tempMatrix[0][1], tempMatrix[0][2]);
vAxisY = Vector3(tempMatrix[1][0], tempMatrix[1][1], tempMatrix[1][2]);
vAxisZ = Vector3(tempMatrix[2][0], tempMatrix[2][1], tempMatrix[2][2]);
Vector3 vDelta = origin - Cameralocation;
Vector3 vTransformed = Vector3(vDelta.Dot(vAxisY), vDelta.Dot(vAxisZ), vDelta.Dot(vAxisX));
if (vTransformed.z < 1.f)
vTransformed.z = 1.f;
float FovAngle = CameraFov; // + 22; for widescreen?
float ScreenCenterX = Width / 2.0f;
float ScreenCenterY = Height / 2.0f;
out->x = ScreenCenterX + vTransformed.x * (ScreenCenterX / tanf(FovAngle * static_cast<float>(PI) / 360.f)) / vTransformed.z;
out->y = ScreenCenterY - vTransformed.y * (ScreenCenterX / tanf(FovAngle * static_cast<float>(PI) / 360.f)) / vTransformed.z;
return true;
}
Vector3 CalcAngle(Vector3 src, Vector3 dst)
{
Vector3 angles;
Vector3 delta = src - dst;
angles.x = (asinf(delta.z / delta.Length()) * RADPI);
angles.y = (atanf(delta.y / delta.x) * RADPI);
angles.z = 0.0f;
if (delta.x >= 0.0) { angles.y += 180.0f; }
return angles;
}
Vector2 RotatePoint(Vector2 pointToRotate, Vector2 centerPoint, float angle, bool angleInRadians = false)
{
if (!angleInRadians)
angle = static_cast<float>(angle * (PI / 180.f));
float cosTheta = static_cast<float>(cos(angle));
float sinTheta = static_cast<float>(sin(angle));
Vector2 returnVec = Vector2(cosTheta * (pointToRotate.x - centerPoint.x) - sinTheta * (pointToRotate.y - centerPoint.y), sinTheta * (pointToRotate.x - centerPoint.x) + cosTheta * (pointToRotate.y - centerPoint.y)
);
returnVec += centerPoint;
return returnVec;
}
float getAngle(Vector2 initial, Vector2 final)
{
return atan2(initial.y - final.y, initial.x - final.x) * 180 / PI;
}
int GetTextWidth(const char *szText, ID3DXFont* pFont)
{
RECT rcRect = { 0,0,0,0 };
if (pFont)
{
// calculate required rect
pFont->DrawText(nullptr, szText, strlen(szText), &rcRect, DT_CALCRECT, D3DCOLOR_XRGB(0, 0, 0));
}
// return width
return rcRect.right - rcRect.left;
}
template< class T > struct TArray
{
public:
T* Data;
int Count;
int Max;
public:
TArray()
{
Data = NULL;
Count = Max = 0;
};
public:
int Num()
{
return this->Count;
};
T& operator() (int i)
{
return this->Data[i];
};
const T& operator() (int i) const
{
return this->Data[i];
};
void Add(T InputData)
{
Data = (T*)realloc(Data, sizeof(T) * (Count + 1));
Data[Count++] = InputData;
Max = Count;
};
void Clear()
{
free(Data);
Count = Max = 0;
};
};
std::string getNameFromID(int ID) {
try {
DWORD_PTR fNamePtr = mem.Read<DWORD_PTR>(GNames + int(ID / 0x4000) * 0x8);
DWORD_PTR fName = mem.Read<DWORD_PTR>(fNamePtr + 0x8 * int(ID % 0x4000));
return mem.Read<text>(fName + 0x10).word;
}
catch (int e) { return std::string(""); }
}
class AActor
{
public:
char pad_0000[2120]; //0x0000
}; //Size: 0x0848
DWORD_PTR IslandDataAsset_PTR;
struct FTreasureLocationData {
Vector3 WorldSpaceLocation;
Vector3 IslandSpaceLocation;
Vector2 MapSpaceLocation;
};
bool get_IslandDataEntries_list(DWORD_PTR IslandDataAsset_PTR, DWORD_PTR * list, __int32 * count) {
try {
*list = mem.Read<DWORD_PTR>(IslandDataAsset_PTR + Offsets::IslandDataEntries);
*count = mem.Read<__int32>(IslandDataAsset_PTR + Offsets::IslandDataEntriesCount);
return true;
}
catch (int e) {
*list = NULL;
*count = 0;
return false;
}
}
bool find_Island_In_IslandDataEntries(std::string MapTexturePath, DWORD_PTR * TreasureLocations_PTR, __int32 * TreasureLocations_Count) {
DWORD_PTR list = NULL;
__int32 count = 0;
if (get_IslandDataEntries_list(IslandDataAsset_PTR, &list, &count)) {
for (auto nIndex = 0; nIndex <= count; nIndex++) {
try {
const auto cIsland = mem.Read<DWORD_PTR>(list + (nIndex * 0x8));
const auto IslandName_ID = mem.Read<__int32>(cIsland + Offsets::IslandName);
const std::string IslandName = getNameFromID(IslandName_ID);
if (MapTexturePath.find(IslandName) != std::string::npos) {
const auto FTreasureMapData_PTR = mem.Read<DWORD_PTR>(cIsland + Offsets::TreasureMaps); // FTreasureMapData
*TreasureLocations_PTR = mem.Read<DWORD_PTR>(FTreasureMapData_PTR + Offsets::TreasureLocations); // FTreasureLocationData
*TreasureLocations_Count = mem.Read<__int32>(FTreasureMapData_PTR + Offsets::TreasureLocationsCount); // FTreasureLocationData_Size
return true;
}
}
catch (int e) { continue; }
}
return false;
}
else {
return false;
}
}
std::vector<Vector3> XMarksTheSpot;
bool get_TreasureMap(DWORD_PTR _PTR, std::string * MapTexturePath, std::vector<Vector2> * Marks) {
try {
DWORD_PTR Name_PTR = mem.Read<DWORD_PTR>(_PTR + Offsets::MapTexturePath);
DWORD_PTR Marks_PTR = mem.Read<DWORD_PTR>(_PTR + Offsets::Marks);
__int32 Marks_Cout = mem.Read<__int32>(_PTR + Offsets::MarksCount);
std::wstring test = mem.Read<textx>(Name_PTR).word;
using convert_type = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_type, wchar_t> converter;
//use converter (.to_bytes: wstr->str, .from_bytes: str->wstr)
std::string converted_str = converter.to_bytes(test);
*MapTexturePath = converted_str;
for (int nIndex = 0; nIndex < Marks_Cout; nIndex++) {
Vector2 Position = mem.Read<Vector2>(Marks_PTR + (nIndex * (sizeof(Vector2) + sizeof(float))));
Marks->push_back(Position);
}
return true;
}
catch (int e) {
*MapTexturePath = "";
Marks->clear();
return false;
}
}