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

Commit cde44a8

Browse files
committed
added config file
1 parent bf3348e commit cde44a8

File tree

6 files changed

+212
-30
lines changed

6 files changed

+212
-30
lines changed

ConfigLoader.cpp

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#pragma once
2+
#include <string>
3+
#include <vector>
4+
#include <iostream>
5+
#include <fstream>
6+
#include "Utils.cpp"
7+
8+
class ConfigLoader
9+
{
10+
private:
11+
const std::string m_fileName = "settings.ini";
12+
std::vector<std::string> *lines = new std::vector<std::string>;
13+
long m_lastTimeFileEdited = 0;
14+
15+
// features
16+
bool m_featureAimbotOn = false;
17+
bool m_featureNoRecoilOn = false;
18+
bool m_featureSenseOn = false;
19+
20+
// aimbot
21+
int m_aimbotSmoothing = 999999;
22+
int m_aimbotActivationFOV = 0;
23+
std::string m_aimbotTrigger = "IN_ATTACK";
24+
25+
// norecoil
26+
double m_strengthPitch = 0;
27+
double m_strengthYaw = 0;
28+
29+
void loadFileIntoVector()
30+
{
31+
lines->clear();
32+
std::string str;
33+
std::ifstream myFile(m_fileName);
34+
while (getline(myFile, str))
35+
{
36+
utils::trim(str);
37+
if (str.empty())
38+
continue;
39+
if (str.rfind("#", 0) == 0)
40+
continue;
41+
lines->push_back(str);
42+
}
43+
myFile.close();
44+
}
45+
46+
void parseLines()
47+
{
48+
for (int i = 0; i < lines->size(); i++)
49+
{
50+
std::vector<std::string> lineParts = utils::split(lines->at(i));
51+
52+
// line key
53+
std::string lineKey(lineParts.at(0));
54+
utils::trim(lineKey);
55+
if (lineKey.empty())
56+
throw "Cannot parse the config";
57+
58+
// line value
59+
std::string lineValue(lineParts.at(1));
60+
utils::trim(lineValue);
61+
if (lineValue.empty())
62+
throw "Cannot parse the config";
63+
64+
// features
65+
m_featureAimbotOn = (lineKey.compare("FEATURE_AIMBOT_ON") != 0) ? m_featureAimbotOn : utils::toBool(lineValue);
66+
m_featureNoRecoilOn = (lineKey.compare("FEATURE_NORECOIL_ON") != 0) ? m_featureNoRecoilOn : utils::toBool(lineValue);
67+
m_featureSenseOn = (lineKey.compare("FEATURE_SENSE_ON") != 0) ? m_featureSenseOn : utils::toBool(lineValue);
68+
// aimbot
69+
m_aimbotTrigger = (lineKey.compare("AIMBOT_TRIGGER") != 0) ? m_aimbotTrigger : lineValue;
70+
m_aimbotSmoothing = (lineKey.compare("AIMBOT_SMOOTHING") != 0) ? m_aimbotSmoothing : stoi(lineValue);
71+
m_aimbotActivationFOV = (lineKey.compare("AIMBOT_ACTIVATION_FOV") != 0) ? m_aimbotActivationFOV : stoi(lineValue);
72+
// 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);
75+
}
76+
}
77+
78+
void print()
79+
{
80+
printf("=== SETTINGS LOADED ===\n");
81+
82+
printf("FEATURE_AIMBOT_ON \t\t%s\n", m_featureAimbotOn ? "true" : "false");
83+
printf("FEATURE_NORECOIL_ON \t\t%s\n", m_featureNoRecoilOn ? "true" : "false");
84+
printf("FEATURE_SENSE_ON \t\t%s\n", m_featureSenseOn ? "true" : "false");
85+
86+
printf("AIMBOT_TRIGGER \t\t\t%s\n", m_aimbotTrigger.c_str());
87+
printf("AIMBOT_SMOOTHING \t\t%d\n", m_aimbotSmoothing);
88+
printf("AIMBOT_ACTIVATION_FOV \t\t%d\n", m_aimbotActivationFOV);
89+
90+
printf("NORECOIL_PITCH_STRENGTH \t%.6f\n", m_strengthPitch);
91+
printf("NORECOIL_YAW_STRENGTH \t\t%.6f\n", m_strengthYaw);
92+
}
93+
94+
public:
95+
ConfigLoader()
96+
{
97+
loadFileIntoVector();
98+
parseLines();
99+
print();
100+
}
101+
102+
bool isAimbotOn()
103+
{
104+
return m_featureAimbotOn;
105+
}
106+
bool isNorecoilOn()
107+
{
108+
return m_featureNoRecoilOn;
109+
}
110+
bool isSenseOn()
111+
{
112+
return m_featureSenseOn;
113+
}
114+
};

Main.cpp

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@
1313
#include "NoRecoil.cpp"
1414
#include "Aimbot.cpp"
1515
#include "X11Utils.cpp"
16-
17-
bool senseOn = true;
18-
bool norecoilOn = false;
19-
bool aimbotOn = true;
16+
#include "ConfigLoader.cpp"
2017

2118
int main(int argc, char *argv[])
2219
{
20+
ConfigLoader *configLoader = new ConfigLoader();
2321
if (getuid())
2422
{
2523
printf("MUST RUN AS ROOT!\n");
@@ -30,7 +28,6 @@ int main(int argc, char *argv[])
3028
printf("GAME NOT FOUND. EXITING!\n");
3129
return -1;
3230
}
33-
printf("MYAPEX RUNNING\n");
3431
Level *level = new Level();
3532
LocalPlayer *localPlayer = new LocalPlayer();
3633
X11Utils *x11Utils = new X11Utils();
@@ -42,41 +39,39 @@ int main(int argc, char *argv[])
4239
Sense *sense = new Sense();
4340
NoRecoil *noRecoil = new NoRecoil();
4441
Aimbot *aimbot = new Aimbot();
42+
43+
// Main loop
44+
printf("MYAPEX STARTING MAIN LOOP\n");
4545
int counter = 0;
4646
while (1)
4747
{
4848
try
4949
{
50-
if (norecoilOn)
50+
// resolve pointers only once per loop for all players
51+
localPlayer->markForPointerResolution();
52+
for (int i = 0; i < players->size(); i++)
5153
{
52-
noRecoil->update(level, localPlayer, x11Utils);
54+
Player *player = players->at(i);
55+
player->markForPointerResolution();
5356
}
54-
if (aimbotOn)
55-
{
57+
58+
// run features
59+
if (configLoader->isNorecoilOn())
60+
noRecoil->update(level, localPlayer, x11Utils);
61+
if (configLoader->isAimbotOn())
5662
aimbot->update(level, localPlayer, players, x11Utils);
57-
}
58-
if (senseOn)
59-
{
63+
if (configLoader->isSenseOn())
6064
sense->update(level, localPlayer, players, x11Utils);
61-
}
62-
// printf("UPDATE %d OK. \n", counter);
65+
printf("UPDATE[%d]\tOK. \n", counter);
6366
std::this_thread::sleep_for(std::chrono::milliseconds(5));
6467
}
6568
catch (...)
6669
{
67-
printf("LOOP ERROR (LOADING SCREEN?). SLEEPING FOR 10 SECONDS, RAND: %d\n", counter); // this happens on loading screen
70+
printf("UPDATE[%d] ERROR (LOADING SCREEN?). SLEEPING FOR 10 SECONDS\n", counter); // this happens on loading screen
6871
std::this_thread::sleep_for(std::chrono::seconds(10));
6972
}
7073
counter++;
7174
if (counter > 1000)
72-
{
7375
counter = 0;
74-
localPlayer->markForPointerResolution();
75-
for (int i = 0; i < players->size(); i++)
76-
{
77-
Player *player = players->at(i);
78-
player->markForPointerResolution();
79-
}
80-
}
8176
}
8277
}

NoRecoil.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
class NoRecoil
1010
{
1111
private:
12-
const double m_streangthPitch = 0.99;
13-
const double m_streangthYaw = 0.99;
12+
const double m_strengthPitch = 0.99;
13+
const double m_strengthYaw = 0.99;
1414
double m_previousPunchPitch = 0;
1515
double m_previousPunchYaw = 0;
1616

@@ -27,15 +27,15 @@ class NoRecoil
2727
if (punchPitch != 0)
2828
{
2929
const double pitch = localPlayer->getPitch();
30-
const double punchPitchDelta = (punchPitch - m_previousPunchPitch) * m_streangthPitch;
30+
const double punchPitchDelta = (punchPitch - m_previousPunchPitch) * m_strengthPitch;
3131
localPlayer->setPitch(pitch - punchPitchDelta);
3232
m_previousPunchPitch = punchPitch;
3333
}
3434
const double punchYaw = localPlayer->getPunchYaw();
3535
if (punchYaw != 0)
3636
{
3737
const double yaw = localPlayer->getYaw();
38-
const double punchYawDelta = (punchYaw - m_previousPunchYaw) * m_streangthYaw;
38+
const double punchYawDelta = (punchYaw - m_previousPunchYaw) * m_strengthYaw;
3939
localPlayer->setYaw(yaw - punchYawDelta);
4040
m_previousPunchYaw = punchYaw;
4141
}

Offsets.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ namespace offsets
33
{
44
// buttons
55
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6-
const long IN_ATTACK = 0x075cc2e0; // [Buttons] -> in_attack
6+
const long IN_ATTACK = 0x075cc260; // [Buttons] -> in_attack
77
// core
88
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
99
const long REGION = 0x140000000; // [Mine] -> Region
1010
const long LEVEL = 0x13c3e38; // [Miscellaneous] -> LevelName
11-
const long LOCAL_PLAYER = 0x1e4f288; // [Miscellaneous] -> LocalPlayer
12-
const long ENTITY_LIST = 0x1a9e778; // [Miscellaneous] -> cl_entitylist
11+
const long LOCAL_PLAYER = 0x1e4f268; // [Miscellaneous] -> LocalPlayer
12+
const long ENTITY_LIST = 0x1a9e758; // [Miscellaneous] -> cl_entitylist
1313
// entity
1414
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1515
const long LOCAL_ORIGIN = 0x0158; // [DataMap.CBaseViewModel] -> m_localOrigin

Utils.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
#include <sstream>
44
#include <sys/uio.h>
55
#include <math.h>
6+
#include <algorithm>
7+
#include <cctype>
8+
#include <locale>
9+
#include <iterator>
610

711
namespace utils
812
{
@@ -14,4 +18,45 @@ namespace utils
1418
out << std::fixed << a_value;
1519
return out.str();
1620
}
21+
22+
// trim from start (in place)
23+
static inline void ltrim(std::string &s)
24+
{
25+
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch)
26+
{ return !std::isspace(ch); }));
27+
}
28+
29+
// trim from end (in place)
30+
static inline void rtrim(std::string &s)
31+
{
32+
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch)
33+
{ return !std::isspace(ch); })
34+
.base(),
35+
s.end());
36+
}
37+
38+
// trim from both ends (in place)
39+
static inline void trim(std::string &s)
40+
{
41+
ltrim(s);
42+
rtrim(s);
43+
}
44+
45+
std::vector<std::string> static inline split(std::string s)
46+
{
47+
std::stringstream ss(s);
48+
std::istream_iterator<std::string> begin(ss);
49+
std::istream_iterator<std::string> end;
50+
std::vector<std::string> tokens(begin, end);
51+
return tokens;
52+
}
53+
54+
bool toBool(std::string str)
55+
{
56+
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
57+
std::istringstream is(str);
58+
bool b;
59+
is >> std::boolalpha >> b;
60+
return b;
61+
}
1762
}

settings.ini

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
##############################################################################################################################################
2+
#### FEATURES ENABLE/DISABLE
3+
##############################################################################################################################################
4+
FEATURE_AIMBOT_ON true #true or false
5+
FEATURE_NORECOIL_ON false #true or false
6+
FEATURE_SENSE_ON true #true or false
7+
8+
##############################################################################################################################################
9+
### AIMBOT SETTINGS
10+
##############################################################################################################################################
11+
AIMBOT_TRIGGER IN_ATTACK #IN_ATTACK - engage aimbot when shooting. XK_Alt_L - engage aimbot when holding the button
12+
AIMBOT_SMOOTHING 10 #The higher the smoother. Range is 1 to 999999
13+
AIMBOT_ACTIVATION_FOV 8 #How far away from the cross-hairs the aimbost will activate. Range is 0.01 to 180.00
14+
15+
##############################################################################################################################################
16+
### NORECOIL SETTINGS
17+
##############################################################################################################################################
18+
NORECOIL_PITCH_STRENGTH 0.5 #Vertical Norecoil strength. Range is 0 to 1
19+
NORECOIL_YAW_STRENGTH 0.5 #Horizontal Norecoil strength. Range is 0 to 1
20+
21+
22+
23+
24+
25+
26+
27+
28+

0 commit comments

Comments
 (0)