Skip to content

Commit b410e06

Browse files
committed
add fov aimbot
1 parent 1d0e1ff commit b410e06

21 files changed

+163
-56
lines changed

CHANGELOG.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Changes📣
22

3-
最新更新于2024年4月28日 14:16,现有功能如下:
3+
最新更新于2024年4月28日 16:46,现有功能如下:
44

55
- 方框透视
66
- 骨骼透视

CS2CheatCpp/CS2_Cheat_Log.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[Tip]: After running this program, please make sure to read the software usage instructions. If it doesn't work, please copy this log file record to the GitHub repository and submit an issue, or directly contact the author via WeChat at yl1099129793. The author has limited capacity and cannot synchronously update CS2 game patch. If urgently needed, you can fork this repository and modify offsets to build with the latest value.
22

3-
[2024/04/28 00:48:04] cs2.exe's process id located at12172
4-
[2024/04/28 00:48:04] client.dll -> 0x7ffe31b00000
3+
[2024/04/28 16:34:06] cs2.exe's process id located at18804
4+
[2024/04/28 16:34:06] client.dll -> 0x7ff987440000

CS2CheatCpp/imgui.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Pos=60,60
33
Size=400,400
44

55
[Window][CS2 ESP Cheat]
6-
Pos=879,152
7-
Size=579,418
6+
Pos=0,8
7+
Size=670,488
88

99
[Window][CS2]
1010
Pos=60,61

CS2CheatCpp/src/entity.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ class Entity
1010
uintptr_t pawnAddress;
1111
uintptr_t controllerAddress;
1212
uintptr_t cameraServices;
13+
unsigned int fFlag;
1314
int health;
1415
int team;
1516
float flashDuration;
1617
float distance;
17-
unsigned int fFlag;
18+
float pixelDistance;
1819
unsigned int lifeState;
1920
int entIndex;
2021
short currentWeaponIndex;
2122
const char* currentWeaponName;
2223
bool spotted;
2324
Vector3 head;
25+
Vector2 head2d;
2426
uintptr_t boneMatrix = 0;
2527
Vector3 origin;
2628
Vector3 viewOffset;

CS2CheatCpp/src/gui.cpp

+26-15
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ void gui::DestroyImGui() noexcept
189189
void gui::BeginRender() noexcept
190190
{
191191
if (GetAsyncKeyState(VK_INSERT) & 1) {
192-
menutoggle = !menutoggle;
192+
menuToggle = !menuToggle;
193193
}
194194

195195
MSG msg;
@@ -224,13 +224,13 @@ void gui::EndRender() noexcept
224224

225225
void gui::Render() noexcept
226226
{
227-
if (menutoggle) {
227+
if (menuToggle) {
228228
// 更新当前玩家最大速度
229229
if (speed > maxSpeed) {
230230
maxSpeed = speed;
231231
}
232-
static bool show_demo_window = true;
233-
ImGui::ShowDemoWindow(&show_demo_window);
232+
/*static bool show_demo_window = true;
233+
ImGui::ShowDemoWindow(&show_demo_window);*/
234234
ImGuiWindowFlags window_flags = 0;
235235
window_flags |= ImGuiWindowFlags_MenuBar;
236236
ImGui::SetNextWindowSize({ 600.f,500.f }, ImGuiCond_FirstUseEver);
@@ -242,13 +242,20 @@ void gui::Render() noexcept
242242
ImGui::MenuItem(("Quit"), NULL, &exit);
243243
ImGui::EndMenu();
244244
}
245+
if (ImGui::BeginMenu("Insert key: Show/Hide"))
246+
{
247+
ImGui::MenuItem(("Show"), NULL, &menuToggle);
248+
ImGui::EndMenu();
249+
}
245250
ImGui::EndMenuBar();
246251
}
247252

248253
ImGui::Text("Runtime Environment: ImGui %s %d", IMGUI_VERSION, IMGUI_VERSION_NUM);
249254
ImGui::Spacing();
255+
ImGui::Text("Screen Configuration(default fullscreen): width %d px, height %d px", screenWidth, screenHeight);
256+
ImGui::Spacing();
250257

251-
if (ImGui::BeginTabBar("CS2 Cheat Functions"))
258+
if (ImGui::BeginTabBar("CS2 ESP Cheat"))
252259
{
253260
if (ImGui::BeginTabItem("Usage"))
254261
{
@@ -259,7 +266,7 @@ void gui::Render() noexcept
259266
ImGui::TextWrapped("5.After each game, it's advisable to exit the cheat program first. Then, repeat the above steps when entering the game room again. This is because handle hijacking sometimes isn't very effective, at least in my experience, I've never been banned.");
260267
ImGui::EndTabItem();
261268
}
262-
if (ImGui::BeginTabItem("Functions"))
269+
if (ImGui::BeginTabItem("ESP Cheat"))
263270
{
264271
ImGui::Columns(2);
265272
ImGui::Checkbox("Team mode", &enableTeamMode);
@@ -269,34 +276,38 @@ void gui::Render() noexcept
269276
}
270277
ImGui::Checkbox("Box perspective", &enableBoxEsp);
271278
ImGui::Checkbox("Bone perspective", &enableBoneEsp);
272-
ImGui::Checkbox("Auto-aim (aimbot)", &enableAimbot);
279+
ImGui::Checkbox("Radar", &enableRadar);
273280
if (ImGui::IsItemHovered())
274281
{
275-
ImGui::SetTooltip("This option will lock onto the nearest enemy's head.");
282+
ImGui::SetTooltip("This option will display a radar on the map showing all enemies.");
283+
}
284+
ImGui::Checkbox("RCS (Recoil Control System) ", &enableRcs);
285+
if (ImGui::IsItemHovered())
286+
{
287+
ImGui::SetTooltip("This option will compensate for recoil in the first few shots. The algorithm needs improvement.");
276288
}
277289
ImGui::Checkbox("Automatic firing", &enableAutoAttack);
278290
if (ImGui::IsItemHovered())
279291
{
280292
ImGui::SetTooltip("This option will automatically fire within the field of view.");
281293
}
282-
ImGui::Checkbox("RCS (Recoil Control System) ", &enableRcs);
294+
ImGui::Checkbox("Auto-aim (aimbot)", &enableAimbot);
283295
if (ImGui::IsItemHovered())
284296
{
285-
ImGui::SetTooltip("This option will compensate for recoil in the first few shots. The algorithm needs improvement.");
297+
ImGui::SetTooltip("This option will lock onto the nearest enemy's head.");
286298
}
287-
ImGui::Checkbox("Radar", &enableRadar);
288-
if (ImGui::IsItemHovered())
299+
ImGui::SliderFloat("Fov Aimbot Pixel", &fovAimbot, 10.0f, 300.0f, "value = %.2f");
300+
if (ImGui::CollapsingHeader("Fov aimbot pixel color"))
289301
{
290-
ImGui::SetTooltip("This option will display a radar on the map showing all enemies.");
302+
ImGui::ColorEdit4("fov circle color", fovAimbotColor);
291303
}
304+
292305
ImGui::NextColumn();
293306
ImGui::Checkbox("Remaining health", &enableHealth);
294307
ImGui::Checkbox("Weapon", &enableWeapon);
295308
ImGui::Checkbox("Anti-flash", &enableFlash);
296309
ImGui::Checkbox("Bunny hop", &enableBhop);
297310
ImGui::SliderInt("fov (Field of view)", &fov, 0, 180);
298-
static float color[] = { 1.f, 0.f, 0.f, 1.f };
299-
ImGui::ColorEdit4("edit", color);
300311
ImGui::Text("Current movement speed: %d", speed);
301312
ImGui::Text("Maximum movement speed: %d", maxSpeed);
302313
ImGui::EndTabItem();

CS2CheatCpp/src/gui.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@ namespace gui
88
{
99
// imgui控件状态
1010
inline bool exit = true;
11-
inline bool menutoggle = true;
11+
inline bool menuToggle = true;
1212
inline bool enableBoxEsp = false;// 方框透视
1313
inline bool enableBoneEsp = true;// 骨骼透视
1414
inline bool enableHealth = true;// 玩家血量
1515
inline bool enableAimbot = true;// 自瞄锁头
1616
inline bool enableAutoAttack = true;// 自瞄锁头并开枪
1717
inline bool enableRcs = true; // 后座力补偿
18-
inline bool enableRadar = false;// 雷达
18+
inline bool enableRadar = true;// 雷达
1919
inline bool enableFlash = true; // 防闪光
2020
inline bool enableBhop = true;// 连跳
2121
inline bool enableWeapon = true; // 显示玩家当前的武器
2222
inline bool enableTeamMode = true; // 团队模式
2323
inline int fov = 0;// 视野角度
24+
inline float fovAimbot = 50.f; // fov自瞄圆圈
25+
inline float fovAimbotColor[] = { 1.f, 1.f, 1.f, 1.f };
2426
inline int speed = 0;// 当前速度
2527
inline int maxSpeed = 0;// 最大速度
2628

CS2CheatCpp/src/main.cpp

+29-22
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)
8686

8787
gui::BeginRender();
8888
gui::Render();
89-
89+
if (mem.GetProcessHandle() == nullptr)
90+
{
91+
gui::EndRender();
92+
continue;
93+
}
9094
// 处理外挂业务逻辑: 获取相关数据的地址
9195
localPlayer.pawnAddress = mem.Read<uintptr_t>(client + offsets::client_dll::dwLocalPlayerPawn);
9296
localPlayer.origin = mem.Read<Vector3>(localPlayer.pawnAddress + schemas::client_dll::C_BasePlayerPawn::m_vOldOrigin);
@@ -100,7 +104,7 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)
100104
const auto enity_list = mem.Read<uintptr_t>(client + offsets::client_dll::dwEntityList);
101105
viewMatrix view_matrix = mem.Read<viewMatrix>(client + offsets::client_dll::dwViewMatrix);
102106

103-
// 处理外挂业务逻辑: 根据entityList找到currentPawn、currentController获取相关玩家信息,currentController下有pawnHandle,通过pawnHandle得到currentPawn
107+
//处理外挂业务逻辑: 根据entityList找到currentPawn、currentController获取相关玩家信息,currentController下有pawnHandle,通过pawnHandle得到currentPawn
104108
for (int playerIndex = 1; playerIndex < 64; ++playerIndex)
105109
{
106110
if (!mem.InForeground()) continue;
@@ -167,6 +171,10 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)
167171
// 获取骨骼信息绘制玩家骨骼
168172
entity.boneMatrix = mem.Read<uintptr_t>(sceneNode + schemas::client_dll::CSkeletonInstance::m_modelState + 0x80);
169173
entity.head = mem.Read<Vector3>(entity.boneMatrix + bones::head * 32);
174+
Vector3 screenHead;
175+
Vector3::world_to_screen(view_matrix, entity.head, screenHead);
176+
entity.head2d = { screenHead.x, screenHead.y };
177+
entity.pixelDistance = Vector2::distance(entity.head2d, Vector2{ static_cast<float>(screenWidth / 2), static_cast<float>(screenHeight / 2) });
170178

171179
entities.push_back(entity);
172180
}
@@ -296,33 +304,32 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)
296304
}
297305
}
298306
}
307+
308+
render::Circle(screenWidth / 2, screenHeight / 2, gui::fovAimbot, gui::fovAimbotColor, 1.0);
299309
}
300310
}
301311

302312
// 自瞄锁头并开枪
303-
if (gui::enableAimbot && entities.size() > 0 && !gui::enableRadar && entities[0].spotted)
313+
if (gui::enableAimbot && entities.size() > 0) // && !gui::enableRadar && entities[0].spotted
304314
{
305-
std::vector<Entity> filteredEntities;
306-
std::copy_if(entities.begin(), entities.end(), std::back_inserter(filteredEntities), [&localPlayer](const Entity& entity) {
307-
if (gui::enableTeamMode)
308-
{
309-
return entity.team != localPlayer.team;
310-
}
311-
else
312-
{
313-
return true;
314-
}
315-
});
316-
std::stable_sort(filteredEntities.begin(), filteredEntities.end(), [](const Entity& entity1, const Entity& entity2) {
317-
return entity1.distance < entity2.distance;
315+
if (gui::enableTeamMode)
316+
{
317+
entities.erase(std::remove_if(entities.begin(), entities.end(), [&](const Entity& entity) {
318+
return entity.team == localPlayer.team;
319+
}), entities.end());
320+
}
321+
std::stable_sort(entities.begin(), entities.end(), [](const Entity& entity1, const Entity& entity2) {
322+
return entity1.pixelDistance < entity2.pixelDistance;
318323
});
319-
320324
// 计算自瞄需要偏移的角度
321-
Vector3 playerView = localPlayer.origin + localPlayer.viewOffset;
322-
//Vector3 entityView = entities[0].origin + entities[0].viewOffset;
323-
Vector3 newAngles = Vector3::angles(playerView, filteredEntities[0].head);
324-
Vector3 newAnglesVec3{newAngles.y, newAngles.x, 0.0f};
325-
mem.Write<Vector3>(client + offsets::client_dll::dwViewAngles, newAnglesVec3);
325+
if (entities[0].pixelDistance < gui::fovAimbot)
326+
{
327+
Vector3 playerView = localPlayer.origin + localPlayer.viewOffset;
328+
Vector3 entityView = entities[0].origin + entities[0].viewOffset;
329+
Vector3 newAngles = Vector3::angles(playerView, entities[0].head);
330+
Vector3 newAnglesVec3{ newAngles.y, newAngles.x, 0.0f };
331+
mem.Write<Vector3>(client + offsets::client_dll::dwViewAngles, newAnglesVec3);
332+
}
326333

327334
// 开枪
328335
if (gui::enableAutoAttack && localPlayer.entIndex > 0)

CS2CheatCpp/src/render.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace render
2828

2929
void DrawTextContent(int x, int y, RGB color, const char* text_content)
3030
{
31-
ImGui::GetBackgroundDrawList()->AddText(ImVec2(x, y), ColorAlpha(color, 255), text_content);
31+
ImGui::GetBackgroundDrawList()->AddText(ImVec2(x, y), ColorAlpha(color, 255), text_content);
3232
}
3333

3434
void DrawRect(int x, int y, int w, int h, RGB color, int thickness, bool IsFilled, float alpha)
@@ -55,4 +55,9 @@ namespace render
5555
ImGui::GetBackgroundDrawList()->AddCircleFilled(ImVec2(x, y), radius, ColorAlpha(color, alpha), 0);
5656
}
5757
}
58+
59+
void Circle(float x, float y, float radius, float* color,float thickness)
60+
{
61+
ImGui::GetBackgroundDrawList()->AddCircle(ImVec2(x, y), radius, ImGui::ColorConvertFloat4ToU32(ImVec4(color[0], color[1], color[2], color[3])), 0, thickness);
62+
}
5863
}

CS2CheatCpp/src/vector.h

+14-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,19 @@ struct Vector2
2020
float x, y;
2121

2222
Vector2(
23-
const float x = 0.f,
24-
const float y = 0.f) noexcept : x(x), y(y) {}
23+
float x = 0.f,
24+
float y = 0.f) noexcept : x(x), y(y) {}
25+
26+
const Vector2& operator-(const Vector2& other) const noexcept
27+
{
28+
return Vector2{ x - other.x, y - other.y };
29+
}
30+
31+
static float distance(const Vector2& from, const Vector2& to)
32+
{
33+
Vector2 res = from - to;
34+
return std::sqrt(res.x * res.x + res.y * res.y);
35+
}
2536
};
2637

2738
struct Vector3
@@ -66,7 +77,7 @@ struct Vector3
6677
static float distance(const Vector3& from, const Vector3& to)
6778
{
6879
Vector3 res = from - to;
69-
return std::sqrt(res.x * res.x + res.y * res.y+res.z * res.z);
80+
return std::sqrt(res.x * res.x + res.y * res.y + res.z * res.z);
7081
}
7182

7283
static Vector3 angles(const Vector3& from, const Vector3& to)

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# CS2 Cheat - C++
22

3-
> Latest Update:2024.04.28 14:16
3+
> Latest Update:2024.04.28 16:46
44
5-
![external](./external.png)
5+
![esp](./esp.png)
66

77
## Features
88

@@ -54,11 +54,11 @@ See [Releases page](https://github.com/yinleiCoder/cs2-cheat-cpp/releases) for
5454

5555
## Star History
5656

57-
<a href="https://star-history.com/#cs2-cheat-cpp/cs2-cheat-cpp&yinleiCoder/cs2-cheat-cpp&Date">
57+
<a href="https://star-history.com/#cs2-cheat-cpp/cs2-cheat-cpp&yinleiCoder/cs2-cheat-cpp">
5858
<picture>
5959
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=cs2-cheat-cpp/cs2-cheat-cpp,yinleiCoder/cs2-cheat-cpp&theme=dark" />
6060
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=cs2-cheat-cpp/cs2-cheat-cpp,yinleiCoder/cs2-cheat-cpp" />
61-
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=cs2-cheat-cpp/cs2-cheat-cpp,yinleiCoder/cs2-cheat-cpp&type=Date" />
61+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=cs2-cheat-cpp/cs2-cheat-cpp,yinleiCoder/cs2-cheat-cpp" />
6262
</picture>
6363
</a>
6464

build/CS2CheatCpp.pdb

5.54 MB
Binary file not shown.

build/intermediates/CS2CheatCpp.ilk

5.88 MB
Binary file not shown.

build/intermediates/CS2CheatCpp.iobj

-1.74 MB
Binary file not shown.

build/intermediates/CS2CheatCpp.ipdb

-182 KB
Binary file not shown.

0 commit comments

Comments
 (0)