Skip to content

Commit

Permalink
More crosshair settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Fr0go1 committed Oct 14, 2023
1 parent 3675746 commit 984ff34
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 19 deletions.
12 changes: 12 additions & 0 deletions CS2_External/AimBot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,17 @@ namespace AimControl
{
gGame.SetViewAngle(Yaw, Pitch);
}

// Referenced N4te2k's fork; https://github.com/N4te2k/CS2_External
/*
Vec2 ScreenPos;
if (gGame.View.WorldToScreen(Vec3(Yaw, Pitch, 0.0f), ScreenPos))
{
mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
(int)(ScreenPos.x * 65535.0f / GetSystemMetrics(SM_CXSCREEN)),
(int)(ScreenPos.y * 65535.0f / GetSystemMetrics(SM_CYSCREEN)),
0, 0);
}*/

}
}
36 changes: 29 additions & 7 deletions CS2_External/Cheats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,22 @@ void Cheats::Menu()

ImGui::Checkbox("CrossHair", &MenuConfig::ShowCrossHair);
ImGui::SameLine();
ImGui::ColorEdit4("##CrossHairColor", reinterpret_cast<float*>(&MenuConfig::CrossHairColor), ImGuiColorEditFlags_NoInputs);
float CrossHairSizeMin = 1, CrossHairSizeMax = 200;
Gui.SliderScalarEx1("CrossHairSize", ImGuiDataType_Float, &MenuConfig::CrossHairSize, &CrossHairSizeMin, &CrossHairSizeMax, "%.1f", ImGuiSliderFlags_None);
ImGui::ColorEdit4("##CrossHairColor", reinterpret_cast<float*>(&CrosshairConfig::CrossHairColor), ImGuiColorEditFlags_NoInputs);
ImGui::SameLine();
if (ImGui::Button("Settings"))
ImGui::OpenPopup("##Settings");
if (ImGui::BeginPopup("##Settings"))
{
ImGui::TextUnformatted("Settings");
ImGui::Checkbox("Center Dot", &CrosshairConfig::drawDot);
ImGui::SliderInt("Horizontal Length", &CrosshairConfig::HorizontalLength, 0, 75, "%d");
ImGui::SliderInt("Vertical Length", &CrosshairConfig::VerticalLength, 0, 75, "%d");
ImGui::SliderInt("Gap", &CrosshairConfig::Gap, 0, 35, "%d");
ImGui::Checkbox("Outline", &CrosshairConfig::drawOutLine);
ImGui::Checkbox("T Style", &CrosshairConfig::tStyle);
ImGui::EndPopup();
}

ImGui::Checkbox("Distance Esp", &MenuConfig::ShowDistance);

}
Expand Down Expand Up @@ -274,6 +287,14 @@ void Cheats::RadarSetting(Base_Radar& Radar)
Radar.Opened = true;
}

void Cheats::RenderCrossHair(ImDrawList* drawList) noexcept
{
if (!MenuConfig::ShowCrossHair)
return;

Render::DrawCrossHair(drawList, ImVec2(ImGui::GetIO().DisplaySize.x / 2, ImGui::GetIO().DisplaySize.y / 2), ImGui::ColorConvertFloat4ToU32(CrosshairConfig::CrossHairColor));
}

void Cheats::Run()
{
// Show menu
Expand Down Expand Up @@ -439,7 +460,7 @@ void Cheats::Run()
char buffer[0x48];
sprintf_s(buffer, "%im", distance);
std::string dis_str = buffer;
Gui.StrokeText(dis_str, { Rect.x + Rect.z + 4, Rect.y }, ImColor(255, 255, 255, 255), 14, false);
Gui.StrokeText(dis_str, { Rect.x + Rect.z + 4, Rect.y }, ImColor(255, 255, 255, 255), 12, false);
}

// Draw weaponName
Expand Down Expand Up @@ -484,9 +505,10 @@ void Cheats::Run()
if (MenuConfig::ShowHeadShootLine)
Render::HeadShootLine(LocalEntity, MenuConfig::HeadShootLineColor);

// CrossHair
if (MenuConfig::ShowCrossHair)
Render::DrawCrossHair();
if (MenuConfig::ShowCrossHair) {
RenderCrossHair(ImGui::GetBackgroundDrawList());
}

// Fov circle
if (MenuConfig::ShowAimFovRange)
Render::DrawFovCircle(LocalEntity);
Expand Down
1 change: 1 addition & 0 deletions CS2_External/Cheats.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ namespace Cheats
{
void Menu();
void RadarSetting(Base_Radar& Radar);
void RenderCrossHair(ImDrawList* drawList) noexcept;
void Run();
}
16 changes: 14 additions & 2 deletions CS2_External/MenuConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,22 @@ namespace MenuConfig
inline ImColor LineToEnemyColor = ImColor(255, 255, 255, 220);

inline bool ShowCrossHair = true;
inline ImColor CrossHairColor = ImColor(45, 45, 45, 255);
inline float CrossHairSize = 150;

inline float RadarBgAlpha = 0.3f;;

inline bool ShowDistance = true;

}

namespace CrosshairConfig
{
inline float CrossHairSize = 75;

inline ImColor CrossHairColor = ImColor(0, 255, 0, 255);
inline bool drawDot = true;
inline bool tStyle = false;
inline int HorizontalLength = 6;
inline int VerticalLength = 6;
inline bool drawOutLine = true;
inline int Gap = 8;
}
49 changes: 45 additions & 4 deletions CS2_External/Render.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include <chrono>
#include <map>
#include "Entity.h"
#include "MenuConfig.hpp"
#define IMGUI_DEFINE_MATH_OPERATORS
#include "OS-ImGui/imgui/imgui_internal.h"

namespace Render
{
Expand All @@ -14,11 +17,49 @@ namespace Render
Gui.Circle(CenterPoint, Radius, MenuConfig::AimFovRangeColor, 1);
}

void DrawCrossHair()
void DrawCrossHair(ImDrawList* drawList, const ImVec2& pos, ImU32 color) noexcept
{
Vec2 SightPos = Gui.Window.Size / 2;
Gui.Line({ SightPos.x - MenuConfig::CrossHairSize,SightPos.y }, { SightPos.x + MenuConfig::CrossHairSize,SightPos.y }, MenuConfig::CrossHairColor, 1);
Gui.Line({ SightPos.x,SightPos.y - MenuConfig::CrossHairSize }, { SightPos.x ,SightPos.y + MenuConfig::CrossHairSize }, MenuConfig::CrossHairColor, 1);
int BorderWidth = 2;
int DotSize = 1;
int gap = CrosshairConfig::Gap / 2;

int oulineGap = gap - 1;

ImVec2 offset1{ 1,1 };
ImVec2 offset2{ 2,2 };

//===== Outline =====
if (CrosshairConfig::drawOutLine)
{
//dot
if (CrosshairConfig::drawDot)
drawList->AddRectFilled(ImVec2(pos.x - offset1.x, pos.y - offset1.y), ImVec2(pos.x + offset2.x, pos.y + offset2.y), color & IM_COL32_A_MASK);
//left
drawList->AddRectFilled(ImVec2(pos.x - (oulineGap + BorderWidth + CrosshairConfig::HorizontalLength), pos.y - 1), ImVec2(pos.x - oulineGap, pos.y + 2), color & IM_COL32_A_MASK);
//right
drawList->AddRectFilled(ImVec2(pos.x + (oulineGap + DotSize), pos.y - 1), ImVec2(pos.x + (oulineGap + DotSize + BorderWidth + CrosshairConfig::HorizontalLength), pos.y + 2), color & IM_COL32_A_MASK);
//top
if (!CrosshairConfig::tStyle)
drawList->AddRectFilled(ImVec2(pos.x - 1, pos.y - (oulineGap + BorderWidth + CrosshairConfig::VerticalLength)), ImVec2(pos.x + 2, pos.y - oulineGap), color & IM_COL32_A_MASK);
//bottom
drawList->AddRectFilled(ImVec2(pos.x - 1, pos.y + oulineGap + DotSize), ImVec2(pos.x + 2, pos.y + (oulineGap + DotSize + BorderWidth + CrosshairConfig::VerticalLength)), color & IM_COL32_A_MASK);
}

//===== Crosshair =====
// dot
if (CrosshairConfig::drawDot)
drawList->AddRectFilled(ImVec2(pos.x, pos.y), ImVec2(pos.x + offset1.x, pos.y + offset1.y), color);
// left
drawList->AddRectFilled(ImVec2(pos.x - (gap + CrosshairConfig::HorizontalLength), pos.y), ImVec2(pos.x - gap, pos.y + 1), color);
// right
drawList->AddRectFilled(ImVec2(pos.x + gap + DotSize, pos.y), ImVec2(pos.x + (gap + DotSize + CrosshairConfig::HorizontalLength), pos.y + 1), color);
// top
if (!CrosshairConfig::tStyle)
drawList->AddRectFilled(ImVec2(pos.x, pos.y - (gap + CrosshairConfig::VerticalLength)), ImVec2(pos.x + 1, pos.y - gap), color);
// bottom
drawList->AddRectFilled(ImVec2(pos.x, pos.y + gap + DotSize), ImVec2(pos.x + 1, pos.y + (gap + DotSize + CrosshairConfig::VerticalLength)), color);


}

void LineToEnemy(ImVec4 Rect, ImColor Color, float Thickness)
Expand Down
10 changes: 8 additions & 2 deletions CS2_External/Utils/ConfigMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,20 @@ namespace ConfigMenu {
MenuConfig::FovLineColor = ImVec4(55, 55, 55, 220);
MenuConfig::LineToEnemyColor = ImVec4(255, 255, 255, 220);
MenuConfig::ShowCrossHair = true;
MenuConfig::CrossHairColor = ImColor(45, 45, 45, 255);
MenuConfig::CrossHairSize = 150;
MenuConfig::RadarBgAlpha = 0.3f;
MenuConfig::ShowAimFovRange = true;
MenuConfig::AimFovRangeColor = ImColor(230, 230, 230, 255);
MenuConfig::OBSBypass = true;
MenuConfig::BunnyHop = false;
MenuConfig::BunnyHop2 = false;
MenuConfig::ShowDistance = true;
CrosshairConfig::CrossHairColor = ImColor(0, 255, 0, 255);
CrosshairConfig::CrossHairSize = 75;
CrosshairConfig::drawDot = true;
CrosshairConfig::tStyle = false;
CrosshairConfig::HorizontalLength = 6;
CrosshairConfig::VerticalLength = 6;
CrosshairConfig::drawOutLine = true;
CrosshairConfig::Gap = 8;
}
}
20 changes: 16 additions & 4 deletions CS2_External/Utils/ConfigSaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,14 @@ namespace MyConfigSaver {
configFile << "VisibleCheck " << MenuConfig::VisibleCheck << std::endl;
configFile << "ShowHeadShootLine " << MenuConfig::ShowHeadShootLine << std::endl;
configFile << "ShowCrossHair " << MenuConfig::ShowCrossHair << std::endl;
configFile << "CrossHairColor " << MenuConfig::CrossHairColor.Value.x << " " << MenuConfig::CrossHairColor.Value.y << " " << MenuConfig::CrossHairColor.Value.z << " " << MenuConfig::CrossHairColor.Value.w << std::endl;
configFile << "CrossHairSize " << MenuConfig::CrossHairSize << std::endl;
configFile << "CrossHairColor " << CrosshairConfig::CrossHairColor.Value.x << " " << CrosshairConfig::CrossHairColor.Value.y << " " << CrosshairConfig::CrossHairColor.Value.z << " " << CrosshairConfig::CrossHairColor.Value.w << std::endl;
configFile << "CrossHairSize " << CrosshairConfig::CrossHairSize << std::endl;
configFile << "drawDot " << CrosshairConfig::drawDot << std::endl;
configFile << "tStyle " << CrosshairConfig::tStyle << std::endl;
configFile << "HorizontalLength " << CrosshairConfig::HorizontalLength << std::endl;
configFile << "VerticalLength " << CrosshairConfig::VerticalLength << std::endl;
configFile << "drawOutLine " << CrosshairConfig::drawOutLine << std::endl;
configFile << "Gap " << CrosshairConfig::Gap << std::endl;
configFile << "ShowAimFovRange " << MenuConfig::ShowAimFovRange << std::endl;
configFile << "AimFovRangeColor " << MenuConfig::AimFovRangeColor.Value.x << " " << MenuConfig::AimFovRangeColor.Value.y << " " << MenuConfig::AimFovRangeColor.Value.z << " " << MenuConfig::AimFovRangeColor.Value.w << std::endl;
configFile << "BoneColorESP " << MenuConfig::BoneColorESP.Value.x << " " << MenuConfig::BoneColorESP.Value.y << " " << MenuConfig::BoneColorESP.Value.z << " " << MenuConfig::BoneColorESP.Value.w << std::endl;
Expand Down Expand Up @@ -163,8 +169,14 @@ namespace MyConfigSaver {
else if (key == "VisibleCheck") iss >> MenuConfig::VisibleCheck;
else if (key == "ShowHeadShootLine") iss >> MenuConfig::ShowHeadShootLine;
else if (key == "ShowCrossHair") iss >> MenuConfig::ShowCrossHair;
else if (key == "CrossHairColor") iss >> MenuConfig::CrossHairColor.Value.x >> MenuConfig::CrossHairColor.Value.y >> MenuConfig::CrossHairColor.Value.z >> MenuConfig::CrossHairColor.Value.w;
else if (key == "CrossHairSize") iss >> MenuConfig::CrossHairSize;
else if (key == "CrossHairColor") iss >> CrosshairConfig::CrossHairColor.Value.x >> CrosshairConfig::CrossHairColor.Value.y >> CrosshairConfig::CrossHairColor.Value.z >> CrosshairConfig::CrossHairColor.Value.w;
else if (key == "CrossHairSize") iss >> CrosshairConfig::CrossHairSize;
else if (key == "drawDot") iss >> CrosshairConfig::drawDot;
else if (key == "tStyle") iss >> CrosshairConfig::tStyle;
else if (key == "HorizontalLength") iss >> CrosshairConfig::HorizontalLength;
else if (key == "VerticalLength") iss >> CrosshairConfig::VerticalLength;
else if (key == "drawOutLine") iss >> CrosshairConfig::drawOutLine;
else if (key == "Gap") iss >> CrosshairConfig::Gap;
else if (key == "ShowAimFovRange") iss >> MenuConfig::ShowAimFovRange;
else if (key == "AimFovRangeColor") iss >> MenuConfig::AimFovRangeColor.Value.x >> MenuConfig::AimFovRangeColor.Value.y >> MenuConfig::AimFovRangeColor.Value.z >> MenuConfig::AimFovRangeColor.Value.w;
else if (key == "BoneColorESP") iss >> MenuConfig::BoneColorESP.Value.x >> MenuConfig::BoneColorESP.Value.y >> MenuConfig::BoneColorESP.Value.z >> MenuConfig::BoneColorESP.Value.w;
Expand Down

0 comments on commit 984ff34

Please sign in to comment.