Skip to content

Commit

Permalink
骨骼透视完成
Browse files Browse the repository at this point in the history
  • Loading branch information
yinleiCoder committed Mar 9, 2024
1 parent fc77aea commit 267bfb6
Show file tree
Hide file tree
Showing 22 changed files with 262 additions and 117 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
## Changes📣

最新更新于2024年2月29日 21:54:22,功能如下
最新更新于2024年3月9日 16:39:00,现有功能如下

- 方框透视
- 骨骼透视
- 人物身体发光
- 实时显示剩余血条
- 玩家身体发光
- 地图扫描敌人雷达
- 实时显示剩余血条、玩家名字、玩家持有的武器
- 自瞄锁头并开枪射击
- 枪后坐力补偿
- 地图扫描敌人雷达
- 防闪光弹
- 连跳
- 玩家当前移动速度监控
Expand Down
1 change: 1 addition & 0 deletions CS2CheatCpp/CS2CheatCpp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
<ClInclude Include="src\memory\memory.h" />
<ClInclude Include="src\render.h" />
<ClInclude Include="src\vector.h" />
<ClInclude Include="src\weapon.hpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="CS2CheatCpp1.rc" />
Expand Down
3 changes: 3 additions & 0 deletions CS2CheatCpp/CS2CheatCpp.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
<ClInclude Include="resource1.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="src\weapon.hpp">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="CS2CheatCpp1.rc">
Expand Down
4 changes: 2 additions & 2 deletions CS2CheatCpp/imgui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ IsChild=1
Size=150,380

[Window][CS2 Cheat]
Pos=776,199
Size=600,500
Pos=1065,56
Size=443,487

[Table][0xD181190E,2]
Column 0 Weight=1.0000
Expand Down
6 changes: 5 additions & 1 deletion CS2CheatCpp/src/entity.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include "vector.h"
#include <string>
#include <vector>

class Entity
{
Expand All @@ -12,14 +13,17 @@ class Entity
int health;
int team;
float flashDuration;
float distance;
unsigned int fFlag;
unsigned int lifeState;
int entIndex;
short currentWeaponIndex;
const char* currentWeaponName;
bool spotted;
Vector3 head;
Vector3 origin;
Vector3 viewOffset;
Vector3 aimPunch;
Vector3 velocity;
float distance;
std::vector<Vector3> bones;
};
26 changes: 14 additions & 12 deletions CS2CheatCpp/src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,24 +304,26 @@ void gui::Render() noexcept
}
}

ImGui::Text("Player current movement speed: %d", speed);
ImGui::Text("Player maximum movement speed: %d", maxSpeed);
ImGui::Checkbox("Box perspective", &boxEsp);
ImGui::Checkbox("Player body glow", &playerBodyGlow);
ImGui::Checkbox("Player remaining health", &playerHealth);
ImGui::Text("Current movement speed: %d", speed);
ImGui::Text("Maximum movement speed: %d", maxSpeed);
ImGui::Checkbox("Box perspective", &enableBoxEsp);
ImGui::Checkbox("Bone perspective", &enableBoneEsp);
ImGui::Checkbox("Body glow", &enableBodyGlow);
ImGui::Checkbox("Remaining health", &enableHealth);
ImGui::SetItemTooltip("Health is displayed in real-time as a green rectangle next to the enemy");
ImGui::Checkbox("Auto-aim (aimbot)", &aimbot);
ImGui::Checkbox("Weapon", &enableWeapon);
ImGui::Checkbox("Auto-aim (aimbot)", &enableAimbot);
ImGui::SetItemTooltip("This option requires the player to manually fire, or in conjunction with the automatic firing option. When combined with turning off the radar option, it enables visibility detection for enemies behind walls");
ImGui::Checkbox("Radar", &radar);
ImGui::Checkbox("Radar", &enableRadar);
ImGui::SetItemTooltip("This option will continuously display the radar for enemies on the map, but it will block visibility detection and auto-aim (aimbot)");
ImGui::Checkbox("Automatic firing", &autoAttack);
ImGui::Checkbox("Automatic firing", &enableAutoAttack);
ImGui::SetItemTooltip("This option needs to be enabled in conjunction with auto-aim (aimbot)");
ImGui::Checkbox("RCS (Recoil Control System) ", &rcs);
ImGui::Checkbox("Anti-flash", &flash);
ImGui::Checkbox("Bunny hop", &bhop);
ImGui::Checkbox("RCS (Recoil Control System) ", &enableRcs);
ImGui::Checkbox("Anti-flash", &enableFlash);
ImGui::Checkbox("Bunny hop", &enableBhop);
ImGui::SetItemTooltip("Hold down the space bar on the keyboard continuously");
ImGui::SliderInt("fov (Field of view)", &fov, 0, 180);
if (bombPlanted) {
if (enableBombPlanted) {
ImGui::Text("The terrorist has planted the bomb. Time until explosion: %d seconds", bombTimeLeft);
}
else
Expand Down
22 changes: 12 additions & 10 deletions CS2CheatCpp/src/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ namespace gui
// imgui控件状态
inline bool exit = true;
inline bool menutoggle = true;
inline bool boxEsp = true;// 方框透视
inline bool playerBodyGlow = true;// 玩家身体发光
inline bool playerHealth = true;// 玩家血量
inline bool aimbot = false;// 自瞄锁头
inline bool autoAttack = false;// 自瞄锁头并开枪
inline bool rcs = false; // 后座力补偿
inline bool radar = false;// 雷达
inline bool flash = true; // 防闪光
inline bool bhop = false;// 连跳
inline bool enableBoxEsp = true;// 方框透视
inline bool enableBoneEsp = true;// 骨骼透视
inline bool enableBodyGlow = false;// 玩家身体发光
inline bool enableHealth = true;// 玩家血量
inline bool enableAimbot = false;// 自瞄锁头
inline bool enableAutoAttack = false;// 自瞄锁头并开枪
inline bool enableRcs = false; // 后座力补偿
inline bool enableRadar = false;// 雷达
inline bool enableFlash = true; // 防闪光
inline bool enableBhop = false;// 连跳
inline int fov = 0;// 视野角度
inline int speed = 0;// 当前速度
inline int maxSpeed = 0;// 最大速度
inline bool bombPlanted = false; // 炸弹是否已安放
inline bool enableBombPlanted = false; // 炸弹是否已安放
inline int bombTimeLeft = -1; // 炸弹爆炸倒计时
inline bool enableWeapon = true; // 显示玩家当前的武器

// win32api window相关变量
inline HWND overlay = nullptr;
Expand Down
103 changes: 63 additions & 40 deletions CS2CheatCpp/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "vector.h"
#include "render.h"
#include "bone.hpp"
#include "weapon.hpp"
#include "entity.h"

namespace offsets {
Expand Down Expand Up @@ -48,6 +49,10 @@ namespace offsets {
constexpr std::ptrdiff_t m_bIsScoped = 0x1400; // bool
constexpr std::ptrdiff_t m_vecAbsVelocity = 0x3D8; // Vector
constexpr std::ptrdiff_t m_bBombPlanted = 0x9DD; // bool C_CSGameRules
constexpr std::ptrdiff_t m_pClippingWeapon = 0x1308; // C_CSWeaponBase*
constexpr std::ptrdiff_t m_iItemDefinitionIndex = 0x1BA; // uint16_t
constexpr std::ptrdiff_t m_AttributeManager = 0x1098; // C_AttributeContainer C_EconEntity
constexpr std::ptrdiff_t m_Item = 0x50; // C_EconItemView
}

struct C_UTL_VECTOR
Expand Down Expand Up @@ -109,7 +114,7 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)
bombPlanted = mem.Read<bool>(gameRules + offsets::m_bBombPlanted);
if (bombPlanted)
{
gui::bombPlanted = true;
gui::enableBombPlanted = true;
/*for (int i = 0;i < 40;i++)
{
bombPlanted = mem.Read<bool>(gameRules + offsets::m_bBombPlanted);
Expand All @@ -126,7 +131,7 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)
else
{
gui::bombTimeLeft = -1;
gui::bombPlanted = false;
gui::enableBombPlanted = false;
}
}

Expand Down Expand Up @@ -158,7 +163,9 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)
if (!list_entry2) {
continue;
}

const auto currentPawn = mem.Read<uintptr_t>(list_entry2 + 120 * (playerPawnHandle & 0x1FF));// 120==0x78

// 扫描到"我"就排除我的信息
if (!currentPawn || currentPawn == localPlayer.pawnAddress) {
continue;
Expand All @@ -170,24 +177,25 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)
if (team == localPlayer.team) {
continue;
}
// 玩家的真实姓名
const auto playerName = mem.ReadString<128>(currentController + offsets::m_iszPlayerName);

// currentPawn有生命值等信息,而玩家姓名在currentController下
// currentPawn有生命值、武器等信息,而玩家姓名在currentController下
int health = mem.Read<int>(currentPawn + offsets::m_iHealth);
const auto lifeState = mem.Read<unsigned int>(currentPawn + offsets::m_lifeState);
if (health <= 0 || health > 100 || lifeState != 256) {
continue;
}
auto currentWeapon = mem.Read<uintptr_t>(currentPawn + offsets::m_pClippingWeapon);
short weaponDefinitionIndex = mem.Read<short>(currentWeapon + offsets::m_AttributeManager + offsets::m_Item + offsets::m_iItemDefinitionIndex);

// 获取雷达状态并设置敌人显示在雷达上
if (gui::radar) {
if (gui::enableRadar) {
bool spotted = mem.Read<bool>(currentPawn + offsets::m_entitySpottedState + offsets::m_bSpotted);
mem.Write<bool>(currentPawn + offsets::m_entitySpottedState + offsets::m_bSpotted, true);
}

// 玩家身体发光
if (gui::playerBodyGlow) {
if (gui::enableBodyGlow) {
mem.Write<float>(currentPawn + offsets::m_flDetectedByEnemySensorTime, 86400);
}

Expand All @@ -202,12 +210,13 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)
entity.origin = mem.Read<Vector3>(currentPawn+offsets::m_vOldOrigin);
entity.viewOffset = mem.Read<Vector3>(currentPawn+offsets::m_vecViewOffset);
entity.distance = Vector3::distance(entity.origin, localPlayer.origin);
entity.currentWeaponIndex = weaponDefinitionIndex;
entity.currentWeaponName = getWeaponName(weaponDefinitionIndex);

// 获取玩家的头坐标实现锁头
const auto sceneNode = mem.Read<uintptr_t>(currentPawn + offsets::m_pGameSceneNode);
// 获取骨骼信息绘制玩家骨骼
const auto boneMatrix = mem.Read<uintptr_t>(sceneNode + offsets::m_modelState + 0x80);
//Vector3 head = { entity.origin.x, entity.origin.y, entity.origin.z + 75.f };
entity.head = mem.Read<Vector3>(boneMatrix + bones::head * 32);

// 将收集好的所有玩家信息存储起来
Expand All @@ -217,66 +226,80 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)
Vector3 screenPos;
Vector3 screenHead;

RGB enemy = { 255, 0, 0 };
RGB hp = { 0, 255, 0 };
//RGB bone = { 255, 255, 255 };

if (Vector3::word_to_screen(view_matrix, entity.origin, screenPos) &&
Vector3::word_to_screen(view_matrix, entity.head, screenHead) &&
entity.origin.x != 0) {
float height = screenPos.y - screenHead.y;
//float headHeight = height / 8;
float headHeight = height / 8;
float width = height / 2.4f;

if (gui::boxEsp) {
Render::DrawRect(
if (gui::enableBoxEsp) {
render::DrawRect(
screenHead.x - width / 2,
screenHead.y,
width,
height,
enemy,
render::enemy,
1.5,
false,
255
);
render::DrawTextContent(
screenHead.x + width / 2,
screenHead.y,
render::name,
entity.name.c_str()
);
}

if (gui::enableWeapon) {
render::DrawTextContent(
screenHead.x,
screenHead.y + height / 4,
render::weapon,
entity.currentWeaponName
);
}

if (gui::playerHealth) {
Render::DrawRect(
if (gui::enableHealth) {
render::DrawRect(
screenHead.x - (width / 2 + 10),
screenHead.y + (height * (100 - health) / 100),
3,
height - (height * (100 - health) / 100),
hp,
render::hp,
1.5,
true,
255
);
}
}
/*Render::Circle(
screenHead.x,
screenHead.y,
headHeight - 3,
bone
);
for (int i = 0; i < sizeof(boneConnections) / sizeof(boneConnections[0]); i++) {
int bone1 = boneConnections[i].bone1;
int bone2 = boneConnections[i].bone2;

Vector3 vectorBone1 = mem.Read<Vector3>(boneArray + bone1*32);
Vector3 vectorBone2 = mem.Read<Vector3>(boneArray + bone2*32);
for (int i = 0; i < sizeof(boneConnections) / sizeof(boneConnections[0]); i++) {
int bone1 = boneConnections[i].bone1;
int bone2 = boneConnections[i].bone2;

Vector3 b1 = vectorBone1.WorldConvertToScreen(view_matrix);
Vector3 b2 = vectorBone1.WorldConvertToScreen(view_matrix);
Vector3 vectorBone1 = mem.Read<Vector3>(boneMatrix + bone1 * 32);
Vector3 vectorBone2 = mem.Read<Vector3>(boneMatrix + bone2 * 32);

Render::Line(b1.x, b1.y, b2.x, b2.y, bone, 2.0);
}*/
Vector3 b1;
Vector3 b2;
Vector3::word_to_screen(view_matrix, vectorBone1, b1);
Vector3::word_to_screen(view_matrix, vectorBone2, b2);
render::Circle(
screenHead.x,
screenHead.y,
headHeight - 3,
render::bone,
false,
255
);
render::Line(b1.x, b1.y, b2.x, b2.y, render::bone, 255, 1.5);
}
}
}

// 自瞄锁头并开枪
if (gui::aimbot && entities.size() > 0 && !gui::radar && entities[0].spotted)
if (gui::enableAimbot && entities.size() > 0 && !gui::enableRadar && entities[0].spotted)
{
// 扫描距离我最近的敌人
std::stable_sort(entities.begin(), entities.end(), [](const Entity& entity1, const Entity& entity2) {
Expand All @@ -291,7 +314,7 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)
mem.Write<Vector3>(client + offsets::dwViewAngles, newAnglesVec3);

// 开枪
if (gui::autoAttack && localPlayer.entIndex > 0)
if (gui::enableAutoAttack && localPlayer.entIndex > 0)
{
mem.Write<int>(client + offsets::dwForceAttack, PLUS_ATTACK);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
Expand All @@ -301,13 +324,13 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)
}

// 防闪光弹
if (gui::flash && localPlayer.flashDuration > 0)
if (gui::enableFlash && localPlayer.flashDuration > 0)
{
mem.Write<float>(localPlayer.pawnAddress + offsets::m_flFlashBangTime, 0);
}

// 连跳
if (gui::bhop && GetAsyncKeyState(VK_SPACE) & 0x01)
if (gui::enableBhop && GetAsyncKeyState(VK_SPACE) & 0x01)
{
if (localPlayer.fFlag == STANDING || localPlayer.fFlag == CROUCHING)
{
Expand All @@ -334,7 +357,7 @@ INT APIENTRY WinMain(HINSTANCE instance, HINSTANCE, PSTR, INT cmd_show)
gui::speed = std::sqrt(localPlayer.velocity.x * localPlayer.velocity.x + localPlayer.velocity.y * localPlayer.velocity.y + localPlayer.velocity.z * localPlayer.velocity.z);

// 后坐力补偿
if (gui::rcs) {
if (gui::enableRcs) {
const auto shotsFired = mem.Read<int32_t>(localPlayer.pawnAddress + offsets::m_iShotsFired);// 开枪次数
auto sensPointer = mem.Read<uintptr_t>(client + offsets::dwSensitivity);
auto sensitivity = mem.Read<float>(sensPointer + offsets::dwSensitivity_sensitivity);
Expand Down
Loading

0 comments on commit 267bfb6

Please sign in to comment.