44#include < thread>
55#include < Windows.h>
66
7- namespace features
8- {
7+ namespace features {
98 void TriggerBot::Run (const Memory& memory) noexcept {
10- while (globals::isRunning)
11- {
12- if (!globals::TriggerBot)
13- {
9+ while (globals::isRunning) {
10+ if (!globals::TriggerBot) {
1411 std::this_thread::sleep_for (std::chrono::milliseconds (20 ));
1512 continue ;
1613 }
1714
18- bool keyDown = (GetAsyncKeyState (globals::TriggerBotKey) & 0x8000 ) != 0 ;
19- if (globals::TriggerBotMode == 0 )
20- {
21- if (!keyDown)
22- {
15+ bool keyState = GetAsyncKeyState (globals::TriggerBotKey) & 0x8000 ;
16+
17+ if (globals::TriggerBotMode == 0 ) {
18+ if (!keyState) {
2319 std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
2420 continue ;
2521 }
2622 }
27- else if (globals::TriggerBotMode == 1 )
28- {
29- if (keyDown)
30- {
23+ else if (globals::TriggerBotMode == 1 ) {
24+ if (keyState) {
3125 globals::TriggerBotToggled = !globals::TriggerBotToggled;
3226 std::this_thread::sleep_for (std::chrono::milliseconds (200 ));
3327 }
3428
35- if (!globals::TriggerBotToggled)
36- {
29+ if (!globals::TriggerBotToggled) {
3730 std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
3831 continue ;
3932 }
@@ -42,8 +35,7 @@ namespace features
4235 std::uintptr_t localPlayer = memory.Read <std::uintptr_t >(globals::client + offsets::dwLocalPlayerPawn);
4336 BYTE team = memory.Read <BYTE>(localPlayer + offsets::m_iTeamNum);
4437
45- if (!globals::TriggerBotIgnoreFlash)
46- {
38+ if (!globals::TriggerBotIgnoreFlash) {
4739 float flashDuration = memory.Read <float >(localPlayer + offsets::flFlashDuration);
4840 if (flashDuration > 0 .0f ) {
4941 std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
@@ -52,25 +44,32 @@ namespace features
5244 }
5345
5446 int crosshairEntityIndex = memory.Read <int >(localPlayer + offsets::m_iIDEntIndex);
55- if (crosshairEntityIndex == 0 )
47+ if (crosshairEntityIndex == 0 ) {
5648 continue ;
49+ }
5750
5851 std::uintptr_t entityList = memory.Read <std::uintptr_t >(globals::client + offsets::dwEntityList);
59- std::uintptr_t entity = memory.Read <std::uintptr_t >(memory.Read <std::uintptr_t >(entityList + 0x8 * (crosshairEntityIndex >> 9 ) + 0x10 ) + 120 * (crosshairEntityIndex & 0x1ff ));
60- if (!entity)
52+ std::uintptr_t listEntry = memory.Read <std::uintptr_t >(entityList + 0x8 * (crosshairEntityIndex >> 9 ) + 0x10 );
53+ std::uintptr_t entity = memory.Read <std::uintptr_t >(listEntry + 120 * (crosshairEntityIndex & 0x1ff ));
54+
55+ if (!entity) {
6156 continue ;
57+ }
6258
63- // Skip teammate or dead target (optional)
64- if (globals::TriggerBotTeamCheck && team == memory.Read <BYTE>(entity + offsets::m_iTeamNum))
59+ if (globals::TriggerBotTeamCheck && team == memory.Read <BYTE>(entity + offsets::m_iTeamNum)) {
6560 continue ;
61+ }
6662
67- if (memory.Read <int >(entity + offsets::m_iHealth) <= 0 )
63+ if (memory.Read <int >(entity + offsets::m_iHealth) <= 0 ) {
6864 continue ;
65+ }
66+
67+ memory.Write <int >(globals::client + offsets::attack, 65537 );
6968
70- // Simulate shooting
71- memory.Write <int >(globals::client + offsets::attack, 65537 ); // Set attack command
7269 std::this_thread::sleep_for (std::chrono::milliseconds (globals::TriggerBotDelay));
73- memory.Write <int >(globals::client + offsets::attack, 256 ); // Clear attack command
70+
71+ memory.Write <int >(globals::client + offsets::attack, 256 );
72+
7473 std::this_thread::sleep_for (std::chrono::milliseconds (globals::TriggerBotDelay));
7574 }
7675 }
0 commit comments