|
10 | 10 | class Aimbot
|
11 | 11 | {
|
12 | 12 | private:
|
13 |
| - const int m_smoothing = 10; |
14 |
| - const int m_activationFOV = 7; |
| 13 | + ConfigLoader *m_configLoader; |
| 14 | + Level *m_level; |
| 15 | + LocalPlayer *m_localPlayer; |
| 16 | + std::vector<Player *> *m_players; |
| 17 | + X11Utils *m_x11Utils; |
| 18 | + |
15 | 19 | Player *m_lockedOnPlayer = nullptr;
|
16 | 20 |
|
17 | 21 | public:
|
18 |
| - void update(Level *level, LocalPlayer *localPlayer, std::vector<Player *> *players, X11Utils *x11Utils) |
| 22 | + Aimbot(ConfigLoader *configLoader, |
| 23 | + Level *level, |
| 24 | + LocalPlayer *localPlayer, |
| 25 | + std::vector<Player *> *players, |
| 26 | + X11Utils *x11Utils) |
19 | 27 | {
|
20 |
| - // if (!x11Utils->triggerKeyDown()) |
21 |
| - // { |
22 |
| - // m_lockedOnPlayer = nullptr; |
23 |
| - // return; |
24 |
| - // } |
25 |
| - if (!level->isPlayable()) |
26 |
| - { |
27 |
| - m_lockedOnPlayer = nullptr; |
28 |
| - return; |
| 28 | + m_configLoader = configLoader; |
| 29 | + m_level = level; |
| 30 | + m_localPlayer = localPlayer; |
| 31 | + m_players = players; |
| 32 | + m_x11Utils = x11Utils; |
| 33 | + } |
| 34 | + void update() |
| 35 | + { |
| 36 | + if (m_configLoader->getAimbotTrigger() != 0x0000){ // our trigger is a button |
| 37 | + if (!m_x11Utils->keyDown(m_configLoader->getAimbotTrigger())) |
| 38 | + { |
| 39 | + m_lockedOnPlayer = nullptr; |
| 40 | + return; |
| 41 | + } |
29 | 42 | }
|
30 |
| - if (localPlayer->isDead()) |
| 43 | + if (!m_level->isPlayable()) |
31 | 44 | {
|
32 | 45 | m_lockedOnPlayer = nullptr;
|
33 | 46 | return;
|
34 | 47 | }
|
35 |
| - if (localPlayer->isKnocked()) |
| 48 | + if (m_localPlayer->isDead()) |
36 | 49 | {
|
37 | 50 | m_lockedOnPlayer = nullptr;
|
38 | 51 | return;
|
39 | 52 | }
|
40 |
| - if (!localPlayer->isInAttack()) |
| 53 | + if (m_localPlayer->isKnocked()) |
41 | 54 | {
|
42 | 55 | m_lockedOnPlayer = nullptr;
|
43 | 56 | return;
|
44 | 57 | }
|
| 58 | + if (m_configLoader->getAimbotTrigger() == 0x0000) // our trigger is localplayer attacking |
| 59 | + if (!m_localPlayer->isInAttack()) |
| 60 | + { |
| 61 | + m_lockedOnPlayer = nullptr; |
| 62 | + return; |
| 63 | + } |
| 64 | + |
45 | 65 | double desiredViewAngleYaw = 0;
|
46 | 66 | double desiredViewAnglePitch = 0;
|
47 |
| - if (level->isTrainingArea()) |
| 67 | + if (m_level->isTrainingArea()) |
48 | 68 | {
|
49 |
| - desiredViewAngleYaw = calculateDesiredYaw(localPlayer->getLocationX(), |
50 |
| - localPlayer->getLocationY(), |
| 69 | + desiredViewAngleYaw = calculateDesiredYaw(m_localPlayer->getLocationX(), |
| 70 | + m_localPlayer->getLocationY(), |
51 | 71 | 31518,
|
52 | 72 | -6712);
|
53 |
| - desiredViewAnglePitch = calculateDesiredPitch(localPlayer->getLocationX(), |
54 |
| - localPlayer->getLocationY(), |
55 |
| - localPlayer->getLocationZ(), |
| 73 | + desiredViewAnglePitch = calculateDesiredPitch(m_localPlayer->getLocationX(), |
| 74 | + m_localPlayer->getLocationY(), |
| 75 | + m_localPlayer->getLocationZ(), |
56 | 76 | 31518,
|
57 | 77 | -6712,
|
58 | 78 | -29235);
|
59 | 79 | }
|
60 | 80 | else
|
61 | 81 | {
|
62 | 82 | if (m_lockedOnPlayer == nullptr)
|
63 |
| - m_lockedOnPlayer = findClosestEnemy(localPlayer, players); |
| 83 | + m_lockedOnPlayer = findClosestEnemy(); |
64 | 84 | if (m_lockedOnPlayer == nullptr)
|
65 | 85 | return;
|
66 |
| - desiredViewAngleYaw = calculateDesiredYaw(localPlayer->getLocationX(), |
67 |
| - localPlayer->getLocationY(), |
| 86 | + desiredViewAngleYaw = calculateDesiredYaw(m_localPlayer->getLocationX(), |
| 87 | + m_localPlayer->getLocationY(), |
68 | 88 | m_lockedOnPlayer->getLocationX(),
|
69 | 89 | m_lockedOnPlayer->getLocationY());
|
70 |
| - desiredViewAnglePitch = calculateDesiredPitch(localPlayer->getLocationX(), |
71 |
| - localPlayer->getLocationY(), |
72 |
| - localPlayer->getLocationZ(), |
| 90 | + desiredViewAnglePitch = calculateDesiredPitch(m_localPlayer->getLocationX(), |
| 91 | + m_localPlayer->getLocationY(), |
| 92 | + m_localPlayer->getLocationZ(), |
73 | 93 | m_lockedOnPlayer->getLocationX(),
|
74 | 94 | m_lockedOnPlayer->getLocationY(),
|
75 | 95 | m_lockedOnPlayer->getLocationZ());
|
76 | 96 | }
|
77 | 97 |
|
78 | 98 | // Setup Pitch
|
79 |
| - const double pitch = localPlayer->getPitch(); |
| 99 | + const double pitch = m_localPlayer->getPitch(); |
80 | 100 | const double pitchAngleDelta = calculatePitchAngleDelta(pitch, desiredViewAnglePitch);
|
81 | 101 | const double pitchAngleDeltaAbs = abs(pitchAngleDelta);
|
82 |
| - if (pitchAngleDeltaAbs > m_activationFOV / 2) |
| 102 | + if (pitchAngleDeltaAbs > m_configLoader->getAimbotActivationFOV() / 2) |
83 | 103 | return;
|
84 | 104 |
|
85 | 105 | // Setup Yaw
|
86 |
| - const double yaw = localPlayer->getYaw(); |
| 106 | + const double yaw = m_localPlayer->getYaw(); |
87 | 107 | const double angleDelta = calculateAngleDelta(yaw, desiredViewAngleYaw);
|
88 | 108 | const double angleDeltaAbs = abs(angleDelta);
|
89 |
| - if (angleDeltaAbs > m_activationFOV) |
| 109 | + if (angleDeltaAbs > m_configLoader->getAimbotActivationFOV()) |
90 | 110 | return;
|
91 |
| - double newYaw = flipYawIfNeeded(yaw + (angleDelta / m_smoothing)); |
92 |
| - localPlayer->setYaw(newYaw); |
| 111 | + double newYaw = flipYawIfNeeded(yaw + (angleDelta / m_configLoader->getAimbotSmoothing())); |
| 112 | + m_localPlayer->setYaw(newYaw); |
93 | 113 | }
|
94 | 114 | double flipYawIfNeeded(double angle)
|
95 | 115 | {
|
@@ -141,26 +161,26 @@ class Aimbot
|
141 | 161 | const double pitchInDegrees = pitchInRadians * (180 / M_PI);
|
142 | 162 | return pitchInDegrees;
|
143 | 163 | }
|
144 |
| - Player *findClosestEnemy(LocalPlayer *localPlayer, std::vector<Player *> *players) |
| 164 | + Player *findClosestEnemy() |
145 | 165 | {
|
146 | 166 | Player *closestPlayerSoFar = nullptr;
|
147 | 167 | double closestPlayerAngleSoFar;
|
148 |
| - for (int i = 0; i < players->size(); i++) |
| 168 | + for (int i = 0; i < m_players->size(); i++) |
149 | 169 | {
|
150 |
| - Player *player = players->at(i); |
| 170 | + Player *player = m_players->at(i); |
151 | 171 | if (!player->isValid())
|
152 | 172 | continue;
|
153 | 173 | if (player->isKnocked())
|
154 | 174 | continue;
|
155 |
| - if (player->getTeamNumber() == localPlayer->getTeamNumber()) |
| 175 | + if (player->getTeamNumber() == m_localPlayer->getTeamNumber()) |
156 | 176 | continue;
|
157 | 177 | if (!player->isVisible())
|
158 | 178 | continue;
|
159 |
| - double desiredViewAngleYaw = calculateDesiredYaw(localPlayer->getLocationX(), |
160 |
| - localPlayer->getLocationY(), |
| 179 | + double desiredViewAngleYaw = calculateDesiredYaw(m_localPlayer->getLocationX(), |
| 180 | + m_localPlayer->getLocationY(), |
161 | 181 | player->getLocationX(),
|
162 | 182 | player->getLocationY());
|
163 |
| - double angleDelta = calculateAngleDelta(localPlayer->getYaw(), desiredViewAngleYaw); |
| 183 | + double angleDelta = calculateAngleDelta(m_localPlayer->getYaw(), desiredViewAngleYaw); |
164 | 184 | if (closestPlayerSoFar == nullptr)
|
165 | 185 | {
|
166 | 186 | closestPlayerSoFar = player;
|
|
0 commit comments