Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 3492e3d

Browse files
committed
config will now accept keycodes for trigger keys
1 parent cde44a8 commit 3492e3d

File tree

8 files changed

+2551
-86
lines changed

8 files changed

+2551
-86
lines changed

Aimbot.cpp

Lines changed: 60 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,86 +10,106 @@
1010
class Aimbot
1111
{
1212
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+
1519
Player *m_lockedOnPlayer = nullptr;
1620

1721
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)
1927
{
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+
}
2942
}
30-
if (localPlayer->isDead())
43+
if (!m_level->isPlayable())
3144
{
3245
m_lockedOnPlayer = nullptr;
3346
return;
3447
}
35-
if (localPlayer->isKnocked())
48+
if (m_localPlayer->isDead())
3649
{
3750
m_lockedOnPlayer = nullptr;
3851
return;
3952
}
40-
if (!localPlayer->isInAttack())
53+
if (m_localPlayer->isKnocked())
4154
{
4255
m_lockedOnPlayer = nullptr;
4356
return;
4457
}
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+
4565
double desiredViewAngleYaw = 0;
4666
double desiredViewAnglePitch = 0;
47-
if (level->isTrainingArea())
67+
if (m_level->isTrainingArea())
4868
{
49-
desiredViewAngleYaw = calculateDesiredYaw(localPlayer->getLocationX(),
50-
localPlayer->getLocationY(),
69+
desiredViewAngleYaw = calculateDesiredYaw(m_localPlayer->getLocationX(),
70+
m_localPlayer->getLocationY(),
5171
31518,
5272
-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(),
5676
31518,
5777
-6712,
5878
-29235);
5979
}
6080
else
6181
{
6282
if (m_lockedOnPlayer == nullptr)
63-
m_lockedOnPlayer = findClosestEnemy(localPlayer, players);
83+
m_lockedOnPlayer = findClosestEnemy();
6484
if (m_lockedOnPlayer == nullptr)
6585
return;
66-
desiredViewAngleYaw = calculateDesiredYaw(localPlayer->getLocationX(),
67-
localPlayer->getLocationY(),
86+
desiredViewAngleYaw = calculateDesiredYaw(m_localPlayer->getLocationX(),
87+
m_localPlayer->getLocationY(),
6888
m_lockedOnPlayer->getLocationX(),
6989
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(),
7393
m_lockedOnPlayer->getLocationX(),
7494
m_lockedOnPlayer->getLocationY(),
7595
m_lockedOnPlayer->getLocationZ());
7696
}
7797

7898
// Setup Pitch
79-
const double pitch = localPlayer->getPitch();
99+
const double pitch = m_localPlayer->getPitch();
80100
const double pitchAngleDelta = calculatePitchAngleDelta(pitch, desiredViewAnglePitch);
81101
const double pitchAngleDeltaAbs = abs(pitchAngleDelta);
82-
if (pitchAngleDeltaAbs > m_activationFOV / 2)
102+
if (pitchAngleDeltaAbs > m_configLoader->getAimbotActivationFOV() / 2)
83103
return;
84104

85105
// Setup Yaw
86-
const double yaw = localPlayer->getYaw();
106+
const double yaw = m_localPlayer->getYaw();
87107
const double angleDelta = calculateAngleDelta(yaw, desiredViewAngleYaw);
88108
const double angleDeltaAbs = abs(angleDelta);
89-
if (angleDeltaAbs > m_activationFOV)
109+
if (angleDeltaAbs > m_configLoader->getAimbotActivationFOV())
90110
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);
93113
}
94114
double flipYawIfNeeded(double angle)
95115
{
@@ -141,26 +161,26 @@ class Aimbot
141161
const double pitchInDegrees = pitchInRadians * (180 / M_PI);
142162
return pitchInDegrees;
143163
}
144-
Player *findClosestEnemy(LocalPlayer *localPlayer, std::vector<Player *> *players)
164+
Player *findClosestEnemy()
145165
{
146166
Player *closestPlayerSoFar = nullptr;
147167
double closestPlayerAngleSoFar;
148-
for (int i = 0; i < players->size(); i++)
168+
for (int i = 0; i < m_players->size(); i++)
149169
{
150-
Player *player = players->at(i);
170+
Player *player = m_players->at(i);
151171
if (!player->isValid())
152172
continue;
153173
if (player->isKnocked())
154174
continue;
155-
if (player->getTeamNumber() == localPlayer->getTeamNumber())
175+
if (player->getTeamNumber() == m_localPlayer->getTeamNumber())
156176
continue;
157177
if (!player->isVisible())
158178
continue;
159-
double desiredViewAngleYaw = calculateDesiredYaw(localPlayer->getLocationX(),
160-
localPlayer->getLocationY(),
179+
double desiredViewAngleYaw = calculateDesiredYaw(m_localPlayer->getLocationX(),
180+
m_localPlayer->getLocationY(),
161181
player->getLocationX(),
162182
player->getLocationY());
163-
double angleDelta = calculateAngleDelta(localPlayer->getYaw(), desiredViewAngleYaw);
183+
double angleDelta = calculateAngleDelta(m_localPlayer->getYaw(), desiredViewAngleYaw);
164184
if (closestPlayerSoFar == nullptr)
165185
{
166186
closestPlayerSoFar = player;

ConfigLoader.cpp

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ class ConfigLoader
2020
// aimbot
2121
int m_aimbotSmoothing = 999999;
2222
int m_aimbotActivationFOV = 0;
23-
std::string m_aimbotTrigger = "IN_ATTACK";
23+
int m_aimbotTrigger = 0x0000;
2424

2525
// norecoil
26-
double m_strengthPitch = 0;
27-
double m_strengthYaw = 0;
26+
double m_norecoilPitchStrength = 0;
27+
double m_norecoilYawStrength = 0;
2828

2929
void loadFileIntoVector()
3030
{
@@ -66,12 +66,12 @@ class ConfigLoader
6666
m_featureNoRecoilOn = (lineKey.compare("FEATURE_NORECOIL_ON") != 0) ? m_featureNoRecoilOn : utils::toBool(lineValue);
6767
m_featureSenseOn = (lineKey.compare("FEATURE_SENSE_ON") != 0) ? m_featureSenseOn : utils::toBool(lineValue);
6868
// aimbot
69-
m_aimbotTrigger = (lineKey.compare("AIMBOT_TRIGGER") != 0) ? m_aimbotTrigger : lineValue;
69+
m_aimbotTrigger = (lineKey.compare("AIMBOT_TRIGGER") != 0) ? m_aimbotTrigger : stoi(lineValue, 0, 16);
7070
m_aimbotSmoothing = (lineKey.compare("AIMBOT_SMOOTHING") != 0) ? m_aimbotSmoothing : stoi(lineValue);
7171
m_aimbotActivationFOV = (lineKey.compare("AIMBOT_ACTIVATION_FOV") != 0) ? m_aimbotActivationFOV : stoi(lineValue);
7272
// norecoil
73-
m_strengthPitch = (lineKey.compare("NORECOIL_PITCH_STRENGTH") != 0) ? m_strengthPitch : stod(lineValue);
74-
m_strengthYaw = (lineKey.compare("NORECOIL_YAW_STRENGTH") != 0) ? m_strengthYaw : stod(lineValue);
73+
m_norecoilPitchStrength = (lineKey.compare("NORECOIL_PITCH_STRENGTH") != 0) ? m_norecoilPitchStrength : stod(lineValue);
74+
m_norecoilYawStrength = (lineKey.compare("NORECOIL_YAW_STRENGTH") != 0) ? m_norecoilYawStrength : stod(lineValue);
7575
}
7676
}
7777

@@ -83,12 +83,12 @@ class ConfigLoader
8383
printf("FEATURE_NORECOIL_ON \t\t%s\n", m_featureNoRecoilOn ? "true" : "false");
8484
printf("FEATURE_SENSE_ON \t\t%s\n", m_featureSenseOn ? "true" : "false");
8585

86-
printf("AIMBOT_TRIGGER \t\t\t%s\n", m_aimbotTrigger.c_str());
86+
printf("AIMBOT_TRIGGER \t\t\t%d\n", m_aimbotTrigger);
8787
printf("AIMBOT_SMOOTHING \t\t%d\n", m_aimbotSmoothing);
8888
printf("AIMBOT_ACTIVATION_FOV \t\t%d\n", m_aimbotActivationFOV);
8989

90-
printf("NORECOIL_PITCH_STRENGTH \t%.6f\n", m_strengthPitch);
91-
printf("NORECOIL_YAW_STRENGTH \t\t%.6f\n", m_strengthYaw);
90+
printf("NORECOIL_PITCH_STRENGTH \t%.6f\n", m_norecoilPitchStrength);
91+
printf("NORECOIL_YAW_STRENGTH \t\t%.6f\n", m_norecoilYawStrength);
9292
}
9393

9494
public:
@@ -99,6 +99,7 @@ class ConfigLoader
9999
print();
100100
}
101101

102+
// features
102103
bool isAimbotOn()
103104
{
104105
return m_featureAimbotOn;
@@ -111,4 +112,28 @@ class ConfigLoader
111112
{
112113
return m_featureSenseOn;
113114
}
115+
116+
// aimbot
117+
int getAimbotTrigger()
118+
{
119+
return m_aimbotTrigger;
120+
}
121+
int getAimbotSmoothing()
122+
{
123+
return m_aimbotSmoothing;
124+
}
125+
int getAimbotActivationFOV()
126+
{
127+
return m_aimbotActivationFOV;
128+
}
129+
130+
// norecoil
131+
double getNorecoilPitchStrength()
132+
{
133+
return m_norecoilPitchStrength;
134+
}
135+
double getNorecoilYawStrength()
136+
{
137+
return m_norecoilYawStrength;
138+
}
114139
};

Main.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ int main(int argc, char *argv[])
3636
{
3737
players->push_back(new Player(i));
3838
}
39-
Sense *sense = new Sense();
40-
NoRecoil *noRecoil = new NoRecoil();
41-
Aimbot *aimbot = new Aimbot();
39+
Sense *sense = new Sense(configLoader, level, localPlayer, players, x11Utils);
40+
NoRecoil *noRecoil = new NoRecoil(configLoader, level, localPlayer, players, x11Utils);
41+
Aimbot *aimbot = new Aimbot(configLoader, level, localPlayer, players, x11Utils);
4242

4343
// Main loop
4444
printf("MYAPEX STARTING MAIN LOOP\n");
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
4747
{
4848
try
4949
{
50-
// resolve pointers only once per loop for all players
50+
// resolve pointers
5151
localPlayer->markForPointerResolution();
5252
for (int i = 0; i < players->size(); i++)
5353
{
@@ -57,17 +57,20 @@ int main(int argc, char *argv[])
5757

5858
// run features
5959
if (configLoader->isNorecoilOn())
60-
noRecoil->update(level, localPlayer, x11Utils);
60+
noRecoil->update();
6161
if (configLoader->isAimbotOn())
62-
aimbot->update(level, localPlayer, players, x11Utils);
62+
aimbot->update();
6363
if (configLoader->isSenseOn())
64-
sense->update(level, localPlayer, players, x11Utils);
65-
printf("UPDATE[%d]\tOK. \n", counter);
64+
sense->update();
65+
66+
// all ran fine
67+
if (counter % 250 == 0)
68+
printf("UPDATE[%d] OK. \n", counter);
6669
std::this_thread::sleep_for(std::chrono::milliseconds(5));
6770
}
6871
catch (...)
6972
{
70-
printf("UPDATE[%d] ERROR (LOADING SCREEN?). SLEEPING FOR 10 SECONDS\n", counter); // this happens on loading screen
73+
printf("UPDATE[%d] ERROR (LOADING SCREEN?). SLEEPING FOR 10 SECONDS\n", counter);
7174
std::this_thread::sleep_for(std::chrono::seconds(10));
7275
}
7376
counter++;

NoRecoil.cpp

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,50 @@
99
class NoRecoil
1010
{
1111
private:
12-
const double m_strengthPitch = 0.99;
13-
const double m_strengthYaw = 0.99;
12+
ConfigLoader *m_configLoader;
13+
Level *m_level;
14+
LocalPlayer *m_localPlayer;
15+
std::vector<Player *> *m_players;
16+
X11Utils *m_x11Utils;
17+
1418
double m_previousPunchPitch = 0;
1519
double m_previousPunchYaw = 0;
1620

1721
public:
18-
void update(Level *level, LocalPlayer *localPlayer, X11Utils *x11Utils)
22+
NoRecoil(ConfigLoader *configLoader,
23+
Level *level,
24+
LocalPlayer *localPlayer,
25+
std::vector<Player *> *players,
26+
X11Utils *x11Utils)
27+
{
28+
m_configLoader = configLoader;
29+
m_level = level;
30+
m_localPlayer = localPlayer;
31+
m_players = players;
32+
m_x11Utils = x11Utils;
33+
}
34+
void update()
1935
{
20-
if (!level->isPlayable())
36+
if (!m_level->isPlayable())
2137
return;
22-
if (localPlayer->isDead())
38+
if (m_localPlayer->isDead())
2339
return;
24-
if (localPlayer->isKnocked())
40+
if (m_localPlayer->isKnocked())
2541
return;
26-
const double punchPitch = localPlayer->getPunchPitch();
42+
const double punchPitch = m_localPlayer->getPunchPitch();
2743
if (punchPitch != 0)
2844
{
29-
const double pitch = localPlayer->getPitch();
30-
const double punchPitchDelta = (punchPitch - m_previousPunchPitch) * m_strengthPitch;
31-
localPlayer->setPitch(pitch - punchPitchDelta);
45+
const double pitch = m_localPlayer->getPitch();
46+
const double punchPitchDelta = (punchPitch - m_previousPunchPitch) * m_configLoader->getNorecoilPitchStrength();
47+
m_localPlayer->setPitch(pitch - punchPitchDelta);
3248
m_previousPunchPitch = punchPitch;
3349
}
34-
const double punchYaw = localPlayer->getPunchYaw();
50+
const double punchYaw = m_localPlayer->getPunchYaw();
3551
if (punchYaw != 0)
3652
{
37-
const double yaw = localPlayer->getYaw();
38-
const double punchYawDelta = (punchYaw - m_previousPunchYaw) * m_strengthYaw;
39-
localPlayer->setYaw(yaw - punchYawDelta);
53+
const double yaw = m_localPlayer->getYaw();
54+
const double punchYawDelta = (punchYaw - m_previousPunchYaw) * m_configLoader->getNorecoilYawStrength();
55+
m_localPlayer->setYaw(yaw - punchYawDelta);
4056
m_previousPunchYaw = punchYaw;
4157
}
4258
}

0 commit comments

Comments
 (0)