Skip to content

Commit

Permalink
add fov aimbot
Browse files Browse the repository at this point in the history
  • Loading branch information
yinleiCoder committed Apr 28, 2024
1 parent 1d0e1ff commit b410e06
Show file tree
Hide file tree
Showing 21 changed files with 163 additions and 56 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Changes📣

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

- 方框透视
- 骨骼透视
Expand Down
4 changes: 2 additions & 2 deletions CS2CheatCpp/CS2_Cheat_Log.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[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.

[2024/04/28 00:48:04] cs2.exe's process id located at12172
[2024/04/28 00:48:04] client.dll -> 0x7ffe31b00000
[2024/04/28 16:34:06] cs2.exe's process id located at18804
[2024/04/28 16:34:06] client.dll -> 0x7ff987440000
4 changes: 2 additions & 2 deletions CS2CheatCpp/imgui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Pos=60,60
Size=400,400

[Window][CS2 ESP Cheat]
Pos=879,152
Size=579,418
Pos=0,8
Size=670,488

[Window][CS2]
Pos=60,61
Expand Down
4 changes: 3 additions & 1 deletion CS2CheatCpp/src/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ class Entity
uintptr_t pawnAddress;
uintptr_t controllerAddress;
uintptr_t cameraServices;
unsigned int fFlag;
int health;
int team;
float flashDuration;
float distance;
unsigned int fFlag;
float pixelDistance;
unsigned int lifeState;
int entIndex;
short currentWeaponIndex;
const char* currentWeaponName;
bool spotted;
Vector3 head;
Vector2 head2d;
uintptr_t boneMatrix = 0;
Vector3 origin;
Vector3 viewOffset;
Expand Down
41 changes: 26 additions & 15 deletions CS2CheatCpp/src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void gui::DestroyImGui() noexcept
void gui::BeginRender() noexcept
{
if (GetAsyncKeyState(VK_INSERT) & 1) {
menutoggle = !menutoggle;
menuToggle = !menuToggle;
}

MSG msg;
Expand Down Expand Up @@ -224,13 +224,13 @@ void gui::EndRender() noexcept

void gui::Render() noexcept
{
if (menutoggle) {
if (menuToggle) {
// 更新当前玩家最大速度
if (speed > maxSpeed) {
maxSpeed = speed;
}
static bool show_demo_window = true;
ImGui::ShowDemoWindow(&show_demo_window);
/*static bool show_demo_window = true;
ImGui::ShowDemoWindow(&show_demo_window);*/
ImGuiWindowFlags window_flags = 0;
window_flags |= ImGuiWindowFlags_MenuBar;
ImGui::SetNextWindowSize({ 600.f,500.f }, ImGuiCond_FirstUseEver);
Expand All @@ -242,13 +242,20 @@ void gui::Render() noexcept
ImGui::MenuItem(("Quit"), NULL, &exit);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Insert key: Show/Hide"))
{
ImGui::MenuItem(("Show"), NULL, &menuToggle);
ImGui::EndMenu();
}
ImGui::EndMenuBar();
}

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

if (ImGui::BeginTabBar("CS2 Cheat Functions"))
if (ImGui::BeginTabBar("CS2 ESP Cheat"))
{
if (ImGui::BeginTabItem("Usage"))
{
Expand All @@ -259,7 +266,7 @@ void gui::Render() noexcept
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.");
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Functions"))
if (ImGui::BeginTabItem("ESP Cheat"))
{
ImGui::Columns(2);
ImGui::Checkbox("Team mode", &enableTeamMode);
Expand All @@ -269,34 +276,38 @@ void gui::Render() noexcept
}
ImGui::Checkbox("Box perspective", &enableBoxEsp);
ImGui::Checkbox("Bone perspective", &enableBoneEsp);
ImGui::Checkbox("Auto-aim (aimbot)", &enableAimbot);
ImGui::Checkbox("Radar", &enableRadar);
if (ImGui::IsItemHovered())
{
ImGui::SetTooltip("This option will lock onto the nearest enemy's head.");
ImGui::SetTooltip("This option will display a radar on the map showing all enemies.");
}
ImGui::Checkbox("RCS (Recoil Control System) ", &enableRcs);
if (ImGui::IsItemHovered())
{
ImGui::SetTooltip("This option will compensate for recoil in the first few shots. The algorithm needs improvement.");
}
ImGui::Checkbox("Automatic firing", &enableAutoAttack);
if (ImGui::IsItemHovered())
{
ImGui::SetTooltip("This option will automatically fire within the field of view.");
}
ImGui::Checkbox("RCS (Recoil Control System) ", &enableRcs);
ImGui::Checkbox("Auto-aim (aimbot)", &enableAimbot);
if (ImGui::IsItemHovered())
{
ImGui::SetTooltip("This option will compensate for recoil in the first few shots. The algorithm needs improvement.");
ImGui::SetTooltip("This option will lock onto the nearest enemy's head.");
}
ImGui::Checkbox("Radar", &enableRadar);
if (ImGui::IsItemHovered())
ImGui::SliderFloat("Fov Aimbot Pixel", &fovAimbot, 10.0f, 300.0f, "value = %.2f");
if (ImGui::CollapsingHeader("Fov aimbot pixel color"))
{
ImGui::SetTooltip("This option will display a radar on the map showing all enemies.");
ImGui::ColorEdit4("fov circle color", fovAimbotColor);
}

ImGui::NextColumn();
ImGui::Checkbox("Remaining health", &enableHealth);
ImGui::Checkbox("Weapon", &enableWeapon);
ImGui::Checkbox("Anti-flash", &enableFlash);
ImGui::Checkbox("Bunny hop", &enableBhop);
ImGui::SliderInt("fov (Field of view)", &fov, 0, 180);
static float color[] = { 1.f, 0.f, 0.f, 1.f };
ImGui::ColorEdit4("edit", color);
ImGui::Text("Current movement speed: %d", speed);
ImGui::Text("Maximum movement speed: %d", maxSpeed);
ImGui::EndTabItem();
Expand Down
6 changes: 4 additions & 2 deletions CS2CheatCpp/src/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ namespace gui
{
// imgui控件状态
inline bool exit = true;
inline bool menutoggle = true;
inline bool menuToggle = true;
inline bool enableBoxEsp = false;// 方框透视
inline bool enableBoneEsp = true;// 骨骼透视
inline bool enableHealth = true;// 玩家血量
inline bool enableAimbot = true;// 自瞄锁头
inline bool enableAutoAttack = true;// 自瞄锁头并开枪
inline bool enableRcs = true; // 后座力补偿
inline bool enableRadar = false;// 雷达
inline bool enableRadar = true;// 雷达
inline bool enableFlash = true; // 防闪光
inline bool enableBhop = true;// 连跳
inline bool enableWeapon = true; // 显示玩家当前的武器
inline bool enableTeamMode = true; // 团队模式
inline int fov = 0;// 视野角度
inline float fovAimbot = 50.f; // fov自瞄圆圈
inline float fovAimbotColor[] = { 1.f, 1.f, 1.f, 1.f };
inline int speed = 0;// 当前速度
inline int maxSpeed = 0;// 最大速度

Expand Down
51 changes: 29 additions & 22 deletions CS2CheatCpp/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)

gui::BeginRender();
gui::Render();

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

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

entities.push_back(entity);
}
Expand Down Expand Up @@ -296,33 +304,32 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)
}
}
}

render::Circle(screenWidth / 2, screenHeight / 2, gui::fovAimbot, gui::fovAimbotColor, 1.0);
}
}

// 自瞄锁头并开枪
if (gui::enableAimbot && entities.size() > 0 && !gui::enableRadar && entities[0].spotted)
if (gui::enableAimbot && entities.size() > 0) // && !gui::enableRadar && entities[0].spotted
{
std::vector<Entity> filteredEntities;
std::copy_if(entities.begin(), entities.end(), std::back_inserter(filteredEntities), [&localPlayer](const Entity& entity) {
if (gui::enableTeamMode)
{
return entity.team != localPlayer.team;
}
else
{
return true;
}
});
std::stable_sort(filteredEntities.begin(), filteredEntities.end(), [](const Entity& entity1, const Entity& entity2) {
return entity1.distance < entity2.distance;
if (gui::enableTeamMode)
{
entities.erase(std::remove_if(entities.begin(), entities.end(), [&](const Entity& entity) {
return entity.team == localPlayer.team;
}), entities.end());
}
std::stable_sort(entities.begin(), entities.end(), [](const Entity& entity1, const Entity& entity2) {
return entity1.pixelDistance < entity2.pixelDistance;
});

// 计算自瞄需要偏移的角度
Vector3 playerView = localPlayer.origin + localPlayer.viewOffset;
//Vector3 entityView = entities[0].origin + entities[0].viewOffset;
Vector3 newAngles = Vector3::angles(playerView, filteredEntities[0].head);
Vector3 newAnglesVec3{newAngles.y, newAngles.x, 0.0f};
mem.Write<Vector3>(client + offsets::client_dll::dwViewAngles, newAnglesVec3);
if (entities[0].pixelDistance < gui::fovAimbot)
{
Vector3 playerView = localPlayer.origin + localPlayer.viewOffset;
Vector3 entityView = entities[0].origin + entities[0].viewOffset;
Vector3 newAngles = Vector3::angles(playerView, entities[0].head);
Vector3 newAnglesVec3{ newAngles.y, newAngles.x, 0.0f };
mem.Write<Vector3>(client + offsets::client_dll::dwViewAngles, newAnglesVec3);
}

// 开枪
if (gui::enableAutoAttack && localPlayer.entIndex > 0)
Expand Down
7 changes: 6 additions & 1 deletion CS2CheatCpp/src/render.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace render

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

void DrawRect(int x, int y, int w, int h, RGB color, int thickness, bool IsFilled, float alpha)
Expand All @@ -55,4 +55,9 @@ namespace render
ImGui::GetBackgroundDrawList()->AddCircleFilled(ImVec2(x, y), radius, ColorAlpha(color, alpha), 0);
}
}

void Circle(float x, float y, float radius, float* color,float thickness)
{
ImGui::GetBackgroundDrawList()->AddCircle(ImVec2(x, y), radius, ImGui::ColorConvertFloat4ToU32(ImVec4(color[0], color[1], color[2], color[3])), 0, thickness);
}
}
17 changes: 14 additions & 3 deletions CS2CheatCpp/src/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,19 @@ struct Vector2
float x, y;

Vector2(
const float x = 0.f,
const float y = 0.f) noexcept : x(x), y(y) {}
float x = 0.f,
float y = 0.f) noexcept : x(x), y(y) {}

const Vector2& operator-(const Vector2& other) const noexcept
{
return Vector2{ x - other.x, y - other.y };
}

static float distance(const Vector2& from, const Vector2& to)
{
Vector2 res = from - to;
return std::sqrt(res.x * res.x + res.y * res.y);
}
};

struct Vector3
Expand Down Expand Up @@ -66,7 +77,7 @@ struct Vector3
static float distance(const Vector3& from, const Vector3& to)
{
Vector3 res = from - to;
return std::sqrt(res.x * res.x + res.y * res.y+res.z * res.z);
return std::sqrt(res.x * res.x + res.y * res.y + res.z * res.z);
}

static Vector3 angles(const Vector3& from, const Vector3& to)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# CS2 Cheat - C++

> Latest Update:2024.04.28 14:16
> Latest Update:2024.04.28 16:46
![external](./external.png)
![esp](./esp.png)

## Features

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

## Star History

<a href="https://star-history.com/#cs2-cheat-cpp/cs2-cheat-cpp&yinleiCoder/cs2-cheat-cpp&Date">
<a href="https://star-history.com/#cs2-cheat-cpp/cs2-cheat-cpp&yinleiCoder/cs2-cheat-cpp">
<picture>
<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" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=cs2-cheat-cpp/cs2-cheat-cpp,yinleiCoder/cs2-cheat-cpp" />
<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" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=cs2-cheat-cpp/cs2-cheat-cpp,yinleiCoder/cs2-cheat-cpp" />
</picture>
</a>

Expand Down
Binary file modified build/CS2CheatCpp.pdb
Binary file not shown.
Binary file added build/intermediates/CS2CheatCpp.ilk
Binary file not shown.
Binary file modified build/intermediates/CS2CheatCpp.iobj
Binary file not shown.
Binary file modified build/intermediates/CS2CheatCpp.ipdb
Binary file not shown.
Loading

0 comments on commit b410e06

Please sign in to comment.