Skip to content

Commit ebbe4c3

Browse files
authored
Merge pull request #13 from ByteCorum/main
code cleanup / organization / optimization
2 parents b868efd + 055aad5 commit ebbe4c3

19 files changed

Lines changed: 195 additions & 191 deletions

File tree

.github/workflows/build-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ jobs:
1818

1919
- name: Building project
2020
run: |
21-
msbuild CS2-External-Base.sln -t:Rebuild -p:Configuration=Release -p:Platform=x64
21+
msbuild TempleWare-External.sln -t:Rebuild -p:Configuration=Release -p:Platform=x64
2222
2323
- name: Archive artifacts
2424
uses: actions/upload-artifact@v4
2525
with:
2626
name: Compiled-Binaries
2727
path: |
28-
D:\a\CS2-External-Base\x64\Release\CS2-External-Base.exe
28+
D:\a\TempleWare-External\x64\Release\TempleWare-External.exe

TempleWare-External/source/features/bhop.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ namespace features
1414
return;
1515

1616
HWND hwnd_cs2 = FindWindowA(NULL, "Counter-Strike 2");
17-
if (hwnd_cs2 == NULL) {
17+
if (hwnd_cs2 == NULL)
1818
hwnd_cs2 = FindWindowA(NULL, "Counter-Strike 2");
19-
}
2019

2120
bool spacePressed = GetAsyncKeyState(VK_SPACE);
2221
int flags = memory.Read<std::uintptr_t>(localPlayer + offsets::m_fFlags);
@@ -27,14 +26,9 @@ namespace features
2726
SendMessage(hwnd_cs2, WM_KEYUP, VK_SPACE, 0);
2827
SendMessage(hwnd_cs2, WM_KEYDOWN, VK_SPACE, 0);
2928
}
30-
3129
else if (spacePressed && !isInAir)
32-
{
3330
SendMessage(hwnd_cs2, WM_KEYUP, VK_SPACE, 0);
34-
}
3531
else if (!spacePressed)
36-
{
3732
SendMessage(hwnd_cs2, WM_KEYUP, VK_SPACE, 0);
38-
}
3933
}
4034
}

TempleWare-External/source/features/bhop.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ namespace features
1010
{
1111
public:
1212
static void Run(const Memory& memory) noexcept;
13+
1314
};
1415
}

TempleWare-External/source/features/fov.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
#include "../globals/globals.h"
33
#include "../offsets/offsets.h"
44

5-
namespace features {
6-
void FOVManager::AdjustFOV(const Memory& memory) noexcept {
5+
namespace features
6+
{
7+
void FOVManager::AdjustFOV(const Memory& memory) noexcept
8+
{
79
std::uintptr_t localPlayer = memory.Read<std::uintptr_t>(globals::client + offsets::dwLocalPlayerPawn);
8-
if (!localPlayer) return;
10+
if (!localPlayer)
11+
return;
912

1013
std::uintptr_t cameraServices = memory.Read<std::uintptr_t>(localPlayer + offsets::m_pCameraServices);
11-
if (!cameraServices) return;
14+
if (!cameraServices)
15+
return;
1216

1317
std::uint16_t currentFov = memory.Read<std::uint16_t>(cameraServices + offsets::m_iFOV);
1418
bool isScoped = memory.Read<bool>(localPlayer + offsets::m_bIsScoped);
15-
1619
std::uint16_t desiredFov = static_cast<uint16_t>(globals::FOV);
1720

18-
if (!isScoped && currentFov != desiredFov) {
21+
if (!isScoped && currentFov != desiredFov)
1922
memory.Write<uint16_t>(cameraServices + offsets::m_iFOV, desiredFov);
20-
}
2123
}
2224
}

TempleWare-External/source/features/fov.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
#include "../memory/Memory.h"
44

5-
namespace features {
6-
class FOVManager {
5+
namespace features
6+
{
7+
class FOVManager
8+
{
79
public:
810
static void AdjustFOV(const Memory& memory) noexcept;
11+
912
};
1013
}

TempleWare-External/source/features/glow.cpp

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,24 @@
33
#include "../offsets/offsets.h"
44
#include <thread>
55

6-
namespace features {
7-
void Glow::Run(const Memory& memory) noexcept {
6+
namespace features
7+
{
8+
9+
uintptr_t GetEntityInListOffset(int index)
10+
{
11+
return 0x8 * (index & 0x7FFF) >> 9 + 16;
12+
}
13+
14+
DWORD PackColor(const ImVec4& color)
15+
{
16+
return ((DWORD)(color.w * 255) << 24) |
17+
((DWORD)(color.z * 255) << 16) |
18+
((DWORD)(color.y * 255) << 8) |
19+
(DWORD)(color.x * 255);
20+
}
21+
22+
void Glow::Run(const Memory& memory) noexcept
23+
{
824
if (!globals::Glow)
925
return;
1026

@@ -14,47 +30,37 @@ namespace features {
1430

1531
int localTeam = memory.Read<int>(localPlayerController + offsets::m_iTeamNum);
1632

17-
for (int i = 1; i < 64; i++) {
33+
34+
for (int i = 1; i < 64; ++i)
35+
{
1836
uintptr_t entityList = memory.Read<uintptr_t>(globals::client + offsets::dwEntityList);
1937
if (!entityList)
2038
continue;
2139

22-
uintptr_t listEntry = memory.Read<uintptr_t>(entityList + (8 * (i & 0x7FFF) >> 9) + 16);
23-
if (!listEntry)
40+
uintptr_t entity = memory.Read<uintptr_t>(entityList + GetEntityInListOffset(i));
41+
if (!entity)
2442
continue;
2543

26-
uintptr_t player = memory.Read<uintptr_t>(listEntry + 120 * (i & 0x1FF));
27-
if (!player)
44+
int entityTeam = memory.Read<int>(entity + offsets::m_iTeamNum);
45+
if (entityTeam == localTeam)
2846
continue;
2947

30-
int playerTeam = memory.Read<int>(player + offsets::m_iTeamNum);
31-
if (playerTeam == localTeam)
32-
continue;
33-
34-
uint32_t playerPawn = memory.Read<uint32_t>(player + offsets::m_hPlayerPawn);
48+
uint32_t playerPawn = memory.Read<uint32_t>(entity + offsets::m_hPlayerPawn);
3549
if (!playerPawn)
3650
continue;
3751

38-
uintptr_t listEntry2 = memory.Read<uintptr_t>(entityList + 0x8 * ((playerPawn & 0x7FFF) >> 9) + 16);
39-
if (!listEntry2)
40-
continue;
41-
42-
uintptr_t playerCsPawn = memory.Read<uintptr_t>(listEntry2 + 120 * (playerPawn & 0x1FF));
52+
uintptr_t playerCsPawn = memory.Read<uintptr_t>(entityList + GetEntityInListOffset(playerPawn));
4353
if (!playerCsPawn)
4454
continue;
4555

4656
int health = memory.Read<int>(playerCsPawn + offsets::m_iHealth);
4757
if (health < 1)
4858
continue;
4959

50-
ImVec4 color = globals::GlowColor;
51-
DWORD colorArgb = (
52-
((DWORD)(color.w * 255) << 24) |
53-
((DWORD)(color.z * 255) << 16) |
54-
((DWORD)(color.y * 255) << 8) |
55-
(DWORD)(color.x * 255)
56-
);
5760

61+
62+
ImVec4 color = globals::GlowColor;
63+
DWORD colorArgb = PackColor(color);
5864
memory.Write<DWORD64>(playerCsPawn + offsets::m_Glow + offsets::m_glowColorOverride, colorArgb);
5965
memory.Write<DWORD64>(playerCsPawn + offsets::m_Glow + offsets::m_bGlowing, 1);
6066
}

TempleWare-External/source/features/glow.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
#include "../memory/memory.h"
44

5-
namespace features {
6-
class Glow {
5+
namespace features
6+
{
7+
class Glow
8+
{
79
public:
810
static void Run(const Memory& memory) noexcept;
11+
912
};
1013
}

TempleWare-External/source/features/noflash.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@
22
#include "../globals/globals.h"
33
#include "../offsets/offsets.h"
44

5-
namespace features {
6-
void NoFlash::Run(const Memory& memory) noexcept {
7-
if (globals::NoFlashEnabled) {
5+
namespace features
6+
{
7+
8+
void NoFlash::Run(const Memory& memory) noexcept
9+
{
10+
if (globals::NoFlashEnabled)
11+
{
812
std::uintptr_t localPlayer = memory.Read<std::uintptr_t>(globals::client + offsets::dwLocalPlayerPawn);
9-
if (localPlayer) {
13+
14+
if (localPlayer)
15+
{
1016
float flashDuration = memory.Read<float>(localPlayer + offsets::flFlashDuration);
11-
if (flashDuration > 0.0f) {
17+
if (flashDuration > 0.0f)
1218
memory.Write<float>(localPlayer + offsets::flFlashDuration, 0.0f);
13-
}
1419
}
1520
}
1621
}
22+
1723
}

TempleWare-External/source/features/noflash.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
#include "../memory/Memory.h"
44

5-
namespace features {
6-
class NoFlash {
5+
namespace features
6+
{
7+
class NoFlash
8+
{
79
public:
810
static void Run(const Memory& memory) noexcept;
11+
912
};
1013
}

TempleWare-External/source/features/triggerbot.cpp

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,36 @@
44
#include <thread>
55
#include <Windows.h>
66

7-
namespace features {
7+
namespace features
8+
{
89
void TriggerBot::Run(const Memory& memory) noexcept {
9-
while (globals::isRunning) {
10-
if (!globals::TriggerBot) {
10+
while (globals::isRunning)
11+
{
12+
if (!globals::TriggerBot)
13+
{
1114
std::this_thread::sleep_for(std::chrono::milliseconds(20));
1215
continue;
1316
}
1417

15-
bool keyState = GetAsyncKeyState(globals::TriggerBotKey) & 0x8000;
16-
17-
if (globals::TriggerBotMode == 0) {
18-
if (!keyState) {
18+
bool keyDown = (GetAsyncKeyState(globals::TriggerBotKey) & 0x8000) != 0;
19+
if (globals::TriggerBotMode == 0)
20+
{
21+
if (!keyDown)
22+
{
1923
std::this_thread::sleep_for(std::chrono::milliseconds(10));
2024
continue;
2125
}
2226
}
23-
else if (globals::TriggerBotMode == 1) {
24-
if (keyState) {
27+
else if (globals::TriggerBotMode == 1)
28+
{
29+
if (keyDown)
30+
{
2531
globals::TriggerBotToggled = !globals::TriggerBotToggled;
2632
std::this_thread::sleep_for(std::chrono::milliseconds(200));
2733
}
2834

29-
if (!globals::TriggerBotToggled) {
35+
if (!globals::TriggerBotToggled)
36+
{
3037
std::this_thread::sleep_for(std::chrono::milliseconds(10));
3138
continue;
3239
}
@@ -35,7 +42,8 @@ namespace features {
3542
std::uintptr_t localPlayer = memory.Read<std::uintptr_t>(globals::client + offsets::dwLocalPlayerPawn);
3643
BYTE team = memory.Read<BYTE>(localPlayer + offsets::m_iTeamNum);
3744

38-
if (!globals::TriggerBotIgnoreFlash) {
45+
if (!globals::TriggerBotIgnoreFlash)
46+
{
3947
float flashDuration = memory.Read<float>(localPlayer + offsets::flFlashDuration);
4048
if (flashDuration > 0.0f) {
4149
std::this_thread::sleep_for(std::chrono::milliseconds(10));
@@ -44,32 +52,25 @@ namespace features {
4452
}
4553

4654
int crosshairEntityIndex = memory.Read<int>(localPlayer + offsets::m_iIDEntIndex);
47-
if (crosshairEntityIndex == 0) {
55+
if (crosshairEntityIndex == 0)
4856
continue;
49-
}
5057

5158
std::uintptr_t entityList = memory.Read<std::uintptr_t>(globals::client + offsets::dwEntityList);
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) {
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)
5661
continue;
57-
}
5862

59-
if (globals::TriggerBotTeamCheck && team == memory.Read<BYTE>(entity + offsets::m_iTeamNum)) {
63+
// Skip teammate or dead target (optional)
64+
if (globals::TriggerBotTeamCheck && team == memory.Read<BYTE>(entity + offsets::m_iTeamNum))
6065
continue;
61-
}
6266

63-
if (memory.Read<int>(entity + offsets::m_iHealth) <= 0) {
67+
if (memory.Read<int>(entity + offsets::m_iHealth) <= 0)
6468
continue;
65-
}
66-
67-
memory.Write<int>(globals::client + offsets::attack, 65537);
6869

70+
// Simulate shooting
71+
memory.Write<int>(globals::client + offsets::attack, 65537); // Set attack command
6972
std::this_thread::sleep_for(std::chrono::milliseconds(globals::TriggerBotDelay));
70-
71-
memory.Write<int>(globals::client + offsets::attack, 256);
72-
73+
memory.Write<int>(globals::client + offsets::attack, 256); // Clear attack command
7374
std::this_thread::sleep_for(std::chrono::milliseconds(globals::TriggerBotDelay));
7475
}
7576
}

0 commit comments

Comments
 (0)