Skip to content

Commit 5c6538a

Browse files
Add files via upload
1 parent d524c75 commit 5c6538a

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#include "Utils.h"
2+
#include "Config.h"
3+
#include "Arduino.h"
4+
#include "Weapons.h"
5+
#include "AsciiArt.h"
6+
#include "ColorBot.h"
7+
8+
Weapon weapon = OFF;
9+
10+
static void HandleWeaponFire(const Arduino& arduino, Weapon& weapon, const Config& config)
11+
{
12+
if (weapon == OFF) return;
13+
14+
double obs = 0.75 / config.GetZoomSensitivity();
15+
double modifier = 2.52 / config.GetSensitivity();
16+
modifier = IsKeyHolded(VK_RBUTTON) ? modifier * obs : modifier;
17+
18+
WeaponData data = GetWeaponData(weapon, modifier);
19+
20+
if (!(data.x.size() == data.y.size() && data.x.size() == data.delay.size()))
21+
{
22+
//cerr << "Warning: Mismatch in the number of elements across x, y, and delay vectors. All three vectors must have the same number of elements." << endl;
23+
weapon = OFF;
24+
return;
25+
}
26+
27+
for (size_t i = 0; i < data.x.size(); i++)
28+
{
29+
if (!IsKeyHolded(VK_LBUTTON) || (config.GetConfirmationKey() != 0 && !IsKeyHolded(config.GetConfirmationKey())))
30+
{
31+
break;
32+
}
33+
34+
arduino.WriteMessage("MOUSE_LEFT_HOLDED:" + to_string(data.x[i]) + "," + to_string(data.y[i]) + "," + to_string(data.delay[i]));
35+
sleep_for(milliseconds(data.delay[i]));
36+
}
37+
}
38+
39+
static void ProcessKeyEvents(const Arduino& arduino, const Config& config, const ColorBot& colorBot)
40+
{
41+
if (IsKeyHolded(VK_SPACE) && config.GetBhop() != 0)
42+
{
43+
arduino.WriteMessage("SPACE_BUTTON_HOLDED");
44+
}
45+
46+
if (IsKeyHolded(VK_MBUTTON) && config.GetRapidFire() != 0)
47+
{
48+
arduino.WriteMessage("MOUSE_MIDDLE_HOLDED");
49+
}
50+
51+
if (IsKeyHolded(config.GetColorBotKey()) && config.GetColorBotKey() != 0)
52+
{
53+
colorBot.Process(arduino);
54+
}
55+
}
56+
57+
int main()
58+
{
59+
Utils utils;
60+
Config config;
61+
62+
utils.PrintAscii(ASCII_INTRO);
63+
Arduino arduino("Arduino Leonardo");
64+
utils.PrintAscii(ASCII_OUTRO), utils.PrintHotkeys(ASCII_HOTKEYS);
65+
66+
ColorBot colorBot(config.GetColorBotThreshold(), config.GetColorBotKey());
67+
68+
while (true)
69+
{
70+
weapon = GetWeaponState(weapon);
71+
string message = arduino.ReceiveMessage('\n');
72+
73+
if (message.rfind("ARDUINO_INITIATED", 0) != 0)
74+
{
75+
HandleWeaponFire(arduino, weapon, config);
76+
ProcessKeyEvents(arduino, config, colorBot);
77+
}
78+
}
79+
}

0 commit comments

Comments
 (0)