Skip to content

Commit 88a9773

Browse files
committed
Added prediction
1 parent d08922f commit 88a9773

File tree

15 files changed

+173
-9
lines changed

15 files changed

+173
-9
lines changed
1.19 KB
Binary file not shown.
24 Bytes
Binary file not shown.
Binary file not shown.
1.18 KB
Binary file not shown.
604 Bytes
Binary file not shown.
20 Bytes
Binary file not shown.

build/xepa.exe

34.9 KB
Binary file not shown.

src/console.cc

+16
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "console.h"
99

1010
std::vector<Console::TextData*> g_VecTextData;
11+
bool g_ShowConsole;
1112

1213
std::string Console::GetTime()
1314
{
@@ -31,6 +32,8 @@ void Console::Clean()
3132

3233
void Console::WriteLog(const char* text, ...)
3334
{
35+
g_ShowConsole = true;
36+
3437
char buffer[256];
3538

3639
va_list argptr;
@@ -44,4 +47,17 @@ void Console::WriteLog(const char* text, ...)
4447
memcpy(tx->text, output.c_str(), 255);
4548

4649
g_VecTextData.push_back(tx);
50+
}
51+
52+
void Console::DisplayLoop(void* blank)
53+
{
54+
while (!g_Vars->shouldExit)
55+
{
56+
Sleep(3000);
57+
if (g_ShowConsole)
58+
{
59+
Sleep(3000);
60+
g_ShowConsole = false;
61+
}
62+
}
4763
}

src/console.h

+2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ namespace Console
1616
std::string GetTime();
1717
void WriteLog(const char* text, ...);
1818
void Clean();
19+
void DisplayLoop(void* blank);
1920
};
2021

2122
extern std::vector<Console::TextData*> g_VecTextData;
23+
extern bool g_ShowConsole;
2224

2325
#endif
2426

src/features/base.cc

+63-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void FeatureBase::Loop()
2323

2424
uintptr_t aimtarget = 0;
2525
float maxfov = 999.9f;
26-
for (int i = 0; i < 80; i++)
26+
for (int i = 0; i < 100; i++)
2727
{
2828
uintptr_t current = g_Drv->Read<uintptr_t>(g_Vars->apexBase + g_Vars->offsets.entityList + (i << 5));
2929
EntityPlayer* player = new EntityPlayer(current);
@@ -34,7 +34,7 @@ void FeatureBase::Loop()
3434
// TODO: local-player check and entity type check
3535

3636
if (plocalplayer == current)
37-
return;
37+
continue;
3838

3939
if (g_Vars->settings.visuals.enabled)
4040
{
@@ -79,6 +79,66 @@ void FeatureBase::Loop()
7979

8080
if (g_Vars->settings.aim.enabled)
8181
{
82-
82+
if (aimtarget)
83+
{
84+
if(GetKeyState(g_Vars->settings.aim.aimkey) & 0x8000)
85+
{
86+
EntityPlayer* player = new EntityPlayer(aimtarget);
87+
Vector target = player->HitBoxPos(0);
88+
89+
if (g_Vars->settings.aim.gravity || g_Vars->settings.aim.velocity)
90+
{
91+
EntityWeapon* active = localplayer->ActiveWeapon();
92+
if (active)
93+
{
94+
float BulletSpeed = active->BulletSpeed();
95+
float BulletGrav = active->BulletGravity();
96+
printf("%f %f\n", BulletSpeed, BulletGrav);
97+
98+
if (BulletSpeed > 1.f)
99+
{
100+
Vector muzzle = localplayer->HitBoxPos(0); // TODO: use actual muzzle pos
101+
if (g_Vars->settings.aim.gravity)
102+
{
103+
float VerticalTime = SDK::Dist3D(target, muzzle) / BulletSpeed;
104+
target.z += (750.f * BulletGrav * 0.5f) * (VerticalTime * VerticalTime);
105+
}
106+
if (g_Vars->settings.aim.velocity)
107+
{
108+
float HorizontalTime = SDK::Dist3D(target, muzzle) / BulletSpeed;
109+
target += (player->Velocity() * HorizontalTime);
110+
}
111+
}
112+
}
113+
}
114+
115+
Vector calcangle = SDK::CalculateAngle(camera, target);
116+
Vector Delta = calcangle - viewangles;
117+
118+
if (g_Vars->settings.aim.smooth && abs(Delta.x) > 0.009 && abs(Delta.y) > 0.009)
119+
{
120+
Delta = Delta / ((float)g_Vars->settings.aim.divider / 100);
121+
}
122+
123+
Vector SmoothedAngles = viewangles + Delta;
124+
125+
if (g_Vars->settings.aim.nopunch)
126+
{
127+
Vector RecoilVec = g_Drv->Read<Vector>(plocalplayer + g_Vars->offsets.punchAngle);
128+
129+
if (RecoilVec.x != 0 || RecoilVec.y != 0)
130+
{
131+
if (g_Vars->settings.aim.smooth)
132+
{
133+
RecoilVec = RecoilVec / ((float)g_Vars->settings.aim.divider / 100);
134+
}
135+
SmoothedAngles -= RecoilVec;
136+
}
137+
}
138+
139+
SmoothedAngles = SDK::NormalizeAngles(SmoothedAngles);
140+
localplayer->WriteViewangles(SmoothedAngles);
141+
}
142+
}
83143
}
84144
}

src/globals.h

+11
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ typedef struct _Offsets
2727
uintptr_t health;
2828
uintptr_t shield;
2929
uintptr_t flags;
30+
31+
uintptr_t bulletSpeed;
32+
uintptr_t bulletGravity;
3033
} Offsets;
3134

3235
typedef struct _Visuals
@@ -41,6 +44,14 @@ typedef struct _Aim
4144
{
4245
bool enabled;
4346
float maxfov;
47+
bool nopunch;
48+
int aimkey;
49+
50+
bool smooth;
51+
int divider;
52+
53+
bool velocity;
54+
bool gravity;
4455
} Aim;
4556

4657
typedef struct _Settings

src/main.cc

+14-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ void OfflineOffsets()
3333
g_Vars->offsets.teamNum = 0x3f0;
3434
g_Vars->offsets.health = 0x3e0;
3535
g_Vars->offsets.shield = 0x170;
36-
g_Vars->offsets.flags = 0x98;
36+
g_Vars->offsets.flags = 0x98;
37+
38+
g_Vars->offsets.bulletSpeed = 0x1d2c;
39+
g_Vars->offsets.bulletGravity = 0x1d34;
3740
}
3841

3942
void OfflineSettings()
@@ -44,7 +47,15 @@ void OfflineSettings()
4447
g_Vars->settings.visuals.box = true;
4548

4649
g_Vars->settings.aim.enabled = true;
50+
g_Vars->settings.aim.aimkey = VK_XBUTTON1;
4751
g_Vars->settings.aim.maxfov = 10.0f;
52+
g_Vars->settings.aim.nopunch = true;
53+
54+
g_Vars->settings.aim.smooth = true;
55+
g_Vars->settings.aim.divider = 200;
56+
57+
g_Vars->settings.aim.gravity = true;
58+
g_Vars->settings.aim.velocity = true;
4859
}
4960

5061
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
@@ -58,6 +69,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
5869
{
5970
Console::WriteLog("Starting in debug mode...");
6071
OfflineOffsets();
72+
OfflineSettings();
6173

6274
Console::WriteLog("Allocating and connecting to system console...");
6375
AllocConsole();
@@ -74,6 +86,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
7486

7587
Console::WriteLog("Creating threads...");
7688
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Overlay::Loop, nullptr, 0, nullptr);
89+
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Console::DisplayLoop, nullptr, 0, nullptr);
7790

7891
Console::WriteLog("Getting program info...");
7992
int pid = Utils::FindProcess(L"r5apex.exe");

src/overlay.cc

+8-5
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,15 @@ void Helper::RenderStatic()
333333
const char* text = toptext.c_str();
334334
Render::EasyText(ImVec2(10, 10), ImColor(ImVec4(1.0f, 1.0f, 1.0f, 1.0f)), text);
335335

336-
for (int i = 0; i < g_VecTextData.size(); i++)
336+
if (g_ShowConsole)
337337
{
338-
Console::TextData* tx = g_VecTextData.at(i);
339-
if (tx == nullptr) break;
340-
Render::EasyText(ImVec2(10, 75 + (i * 20)), ImColor(ImVec4(1.0f, 1.0f, 1.0f, 1.0f)), tx->text);
341-
}
338+
for (int i = 0; i < g_VecTextData.size(); i++)
339+
{
340+
Console::TextData* tx = g_VecTextData.at(i);
341+
if (tx == nullptr) break;
342+
Render::EasyText(ImVec2(10, 75 + (i * 20)), ImColor(ImVec4(1.0f, 1.0f, 1.0f, 1.0f)), tx->text);
343+
}
344+
}
342345
}
343346

344347
void Helper::RenderNotifications()

src/sdk/entity.h

+47
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@
44
#include "../globals.h"
55
#include "../sdk/structs.h"
66

7+
class EntityWeapon
8+
{
9+
private:
10+
uintptr_t _base;
11+
12+
public:
13+
EntityWeapon(uintptr_t base)
14+
{
15+
_base = base;
16+
}
17+
18+
float BulletSpeed()
19+
{
20+
return g_Drv->Read<float>(_base + g_Vars->offsets.bulletSpeed);
21+
}
22+
23+
float BulletGravity()
24+
{
25+
return g_Drv->Read<float>(_base + g_Vars->offsets.bulletGravity);
26+
}
27+
};
28+
729
class EntityPlayer
830
{
931
private:
@@ -80,6 +102,31 @@ class EntityPlayer
80102
{
81103
return g_Drv->Read<Vector>(_base + g_Vars->offsets.viewAngles);
82104
}
105+
106+
void WriteViewangles(Vector angle)
107+
{
108+
g_Drv->Write<Vector>(_base + g_Vars->offsets.viewAngles, angle);
109+
}
110+
111+
EntityWeapon* ActiveWeapon()
112+
{
113+
DWORD64 ActWeaponId = g_Drv->Read<DWORD64>(_base + g_Vars->offsets.activeWeapon) & 0xFFFF;
114+
if (ActWeaponId)
115+
{
116+
uintptr_t pweapon = g_Drv->Read<uintptr_t>(g_Vars->apexBase + g_Vars->offsets.entityList + (ActWeaponId << 5));
117+
EntityWeapon* ewpn = new EntityWeapon(pweapon);
118+
return ewpn;
119+
}
120+
else
121+
{
122+
return nullptr;
123+
}
124+
}
125+
126+
Vector Velocity()
127+
{
128+
return g_Drv->Read<Vector>(_base + g_Vars->offsets.absVelocity);
129+
}
83130
};
84131

85132
#endif

src/sdk/sdk.h

+12
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ namespace SDK
4444

4545
return (float)(sqrt(pow(delta.x, 2.0f) + pow(delta.y, 2.0f)));
4646
}
47+
48+
float FastSQRT(float x)
49+
{
50+
union { int i; float x; } u;
51+
u.x = x; u.i = (u.i >> 1) + 0x1FC00000;
52+
u.x = u.x + x / u.x; return .25f * u.x + x / u.x;
53+
}
54+
55+
float Dist3D(const Vector& Src, const Vector& Dst)
56+
{
57+
return FastSQRT(powf(Src.x - Dst.x, 2.f) + powf(Src.y - Dst.y, 2.f) + powf(Src.z - Dst.z, 2.f));
58+
}
4759
}
4860

4961
#endif

0 commit comments

Comments
 (0)