forked from planee/FORTNITE-HACK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aimbot.h
125 lines (104 loc) · 3.9 KB
/
aimbot.h
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
#ifndef __AIMBOT_H
#define __AIMBOT_H
#include <chrono>
#include <windows.h>
#include "SDK.hpp"
#include "config.h"
#include "util.h"
#include <time.h>
class Aimbot
{
public:
float m_LastAimDistance = 0.0f;
void Run(Config& cfg, SDK::APlayerController* playerController)
{
if (!cfg.m_EnableAimbot)
{
return;
}
auto now = m_Timer.now();
auto deltaTime = std::chrono::duration_cast<std::chrono::milliseconds>(now - m_LastTime);
m_LastTime = now;
if (playerController == nullptr || playerController->AcknowledgedPawn == nullptr)
{
return;
}
if (GetAsyncKeyState(cfg.m_AimbotHotkey) & 0x8000 && !(GetAsyncKeyState(cfg.m_IgnoreHotkey) & 0x8000)) // Ignore Aimbot when Mouse5 pressed
{
if (m_TargetPlayer == nullptr)
{
m_TargetPlayer = Util::GetClosestVisiblePlayer(cfg, playerController);
}
}
else
{
m_TargetPlayer = nullptr;
}
if (m_TargetPlayer != nullptr)
{
auto pawn = static_cast<SDK::AFortPawn*>(m_TargetPlayer);
if (pawn->bIsDBNO)
{
m_TargetPlayer = nullptr;
return;
}
SDK::FVector playerLoc;
Util::Engine::GetBoneLocation(static_cast<SDK::ACharacter*>(m_TargetPlayer)->Mesh, &playerLoc, eBone::BONE_CHEST);
auto dist = Util::GetDistance(playerController->AcknowledgedPawn->RootComponent->Location, playerLoc);
m_LastAimDistance = dist;
if (dist < cfg.m_MinAimbotHeadshotDistance)
{
Util::Engine::GetBoneLocation(static_cast<SDK::ACharacter*>(m_TargetPlayer)->Mesh, &playerLoc, eBone::BONE_HEAD);
// Uncomment lower part if you want aimspot randomization
// Untested, probably switches like mad
// Also the randomization seed should be changed after enemy change or sth else
/*
switch (rand() % 4 + 1)
{
case 1:
Util::Engine::GetBoneLocation(static_cast<SDK::ACharacter*>(m_TargetPlayer)->Mesh, &playerLoc, eBone::BONE_HEAD);
case 2:
Util::Engine::GetBoneLocation(static_cast<SDK::ACharacter*>(m_TargetPlayer)->Mesh, &playerLoc, eBone::BONE_CHEST_TOP_1);
case 3:
Util::Engine::GetBoneLocation(static_cast<SDK::ACharacter*>(m_TargetPlayer)->Mesh, &playerLoc, eBone::BONE_CHEST);
case 4:
Util::Engine::GetBoneLocation(static_cast<SDK::ACharacter*>(m_TargetPlayer)->Mesh, &playerLoc, eBone::BONE_CHEST_TOP_2);
}*/
}
LookAt(cfg, playerController, playerLoc, deltaTime.count() / 1000.0f);
}
}
void LookAt(Config& cfg, SDK::APlayerController* m_Player, SDK::FVector position, float deltaTime)
{
using namespace Util;
int screenSizeX, screenSizeY;
m_Player->GetViewportSize(&screenSizeX, &screenSizeY);
SDK::FVector2D centerScreen{ (float)screenSizeX / 2, (float)screenSizeY / 2 };
SDK::FVector2D screenPos;
if (Engine::WorldToScreen(m_Player, position, &screenPos))
{
auto enemyDir = screenPos - centerScreen;
//m_Agressiveness += (Len(enemyDir) / cfg.m_AimbotFieldOfViewPixels) * deltaTime;
//m_AimVelocity = m_AimVelocity + enemyDir * cfg.m_AimbotSmoothing * m_Agressiveness * deltaTime;
//Util::MoveMouse(m_AimVelocity.X, m_AimVelocity.Y);
mouse_event(MOUSEEVENTF_MOVE, floor(enemyDir.X / 2.7f), floor(enemyDir.Y / 2.7f), NULL, NULL);
}
m_AimVelocity = m_AimVelocity * cfg.m_AimVelocityDamping * deltaTime;
m_Agressiveness *= 0.95f;
if (m_Agressiveness < 1.0f)
{
m_Agressiveness = 1.0f;
}
}
SDK::AActor* GetTargetPlayer() const
{
return m_TargetPlayer;
}
private:
SDK::FVector2D m_AimVelocity{ 0.0f, 0.0f };
float m_Agressiveness = 1.0f;
SDK::AActor* m_TargetPlayer = nullptr;
std::chrono::high_resolution_clock m_Timer;
std::chrono::high_resolution_clock::time_point m_LastTime;
};
#endif