From d4740fda3b9a1f26ad38b307ba13ec8a7da2e747 Mon Sep 17 00:00:00 2001 From: Fr0go1 <112802612+Fr0go1@users.noreply.github.com> Date: Wed, 11 Oct 2023 21:48:19 +1000 Subject: [PATCH] minor updates to help with future features --- CS2_External/AimBot.hpp | 92 +++++++++++---------------------------- CS2_External/Bunnyhop.hpp | 6 ++- 2 files changed, 29 insertions(+), 69 deletions(-) diff --git a/CS2_External/AimBot.hpp b/CS2_External/AimBot.hpp index 6ba5f59..ebb10d5 100644 --- a/CS2_External/AimBot.hpp +++ b/CS2_External/AimBot.hpp @@ -3,78 +3,18 @@ #include #include "Game.h" #include "Entity.h" -#include #include - -struct Vector { - Vector() noexcept - : x(), y(), z() {} - - Vector(float x, float y, float z) noexcept - : x(x), y(y), z(z) {} - - Vector& operator+(const Vector& v) noexcept { - x += v.x; - y += v.y; - z += v.z; - return *this; - } - - Vector& operator-(const Vector& v) noexcept { - x -= v.x; - y -= v.y; - z -= v.z; - return *this; - } - - float x, y, z; -}; - -struct ViewMatrix { - ViewMatrix() noexcept - : data() {} - - float* operator[](int index) noexcept { - return data[index]; - } - - const float* operator[](int index) const noexcept { - return data[index]; - } - - float data[4][4]; -}; - -static bool world_to_screen(const Vector& world, Vector& screen, const ViewMatrix& vm) noexcept { - float w = vm[3][0] * world.x + vm[3][1] * world.y + vm[3][2] * world.z + vm[3][3]; - - if (w < 0.001f) { - return false; - } - - const float x = world.x * vm[0][0] + world.y * vm[0][1] + world.z * vm[0][2] + vm[0][3]; - const float y = world.x * vm[1][0] + world.y * vm[1][1] + world.z * vm[1][2] + vm[1][3]; - - w = 1.f / w; - float nx = x * w; - float ny = y * w; - - const ImVec2 size = ImGui::GetIO().DisplaySize; - - screen.x = (size.x * 0.5f * nx) + (nx + size.x * 0.5f); - screen.y = -(size.y * 0.5f * ny) + (ny + size.y * 0.5f); - - return true; -} +#include "View.hpp" +#include namespace AimControl { inline int HotKey = VK_LMENU; inline float AimFov = 5; inline float Smooth = 0.7; - inline Vec2 RCSScale = { 1.f,1.f }; + inline Vec2 RCSScale = { 1.f, 1.f }; inline int RCSBullet = 1; - inline std::vector HotKeyList{VK_LMENU, VK_RBUTTON, VK_XBUTTON1, VK_XBUTTON2, VK_CAPITAL, VK_LSHIFT, VK_LCONTROL}; + inline std::vector HotKeyList{ VK_LMENU, VK_RBUTTON, VK_XBUTTON1, VK_XBUTTON2, VK_CAPITAL, VK_LSHIFT, VK_LCONTROL }; inline void SetHotKey(int Index) { @@ -86,11 +26,11 @@ namespace AimControl float Yaw, Pitch; float Distance, Norm; Vec3 OppPos; - + OppPos = AimPos - LocalPos; Distance = sqrt(pow(OppPos.x, 2) + pow(OppPos.y, 2)); - + Yaw = atan2f(OppPos.y, OppPos.x) * 57.295779513 - Local.Pawn.ViewAngle.y; Pitch = -atan(OppPos.z / Distance) * 57.295779513 - Local.Pawn.ViewAngle.x; Norm = sqrt(pow(Yaw, 2) + pow(Pitch, 2)); @@ -113,6 +53,24 @@ namespace AimControl Pitch = Pitch - PunchAngle.x * RCSScale.y; } - gGame.SetViewAngle(Yaw, Pitch); + bool testing = false; + + if (testing) { + Vec2 ScreenPos; + if (gGame.View.WorldToScreen(AimPos, ScreenPos)) { + int targetX = static_cast(AimPos.x); + int targetY = static_cast(AimPos.y); + + int deltaX = targetX - 1920 / 2; + int deltaY = targetY - 1080 / 2; + + mouse_event(MOUSEEVENTF_MOVE, deltaX, deltaY, 0, 0); + Sleep(1); + } + } + else + { + gGame.SetViewAngle(Yaw, Pitch); + } } } \ No newline at end of file diff --git a/CS2_External/Bunnyhop.hpp b/CS2_External/Bunnyhop.hpp index 255344c..ad148b0 100644 --- a/CS2_External/Bunnyhop.hpp +++ b/CS2_External/Bunnyhop.hpp @@ -30,7 +30,7 @@ namespace Bunnyhop2 inline void Run(const CEntity& Local) { const bool hasFlagInAir = Local.Pawn.HasFlag(PlayerPawn::Flags::IN_AIR); - if (GetAsyncKeyState(VK_SPACE)) + if (GetAsyncKeyState(VK_SPACE) && !hasFlagInAir) { // scrolling up INPUT inputScrollUp; @@ -42,7 +42,9 @@ namespace Bunnyhop2 inputScrollUp.mi.time = 0; inputScrollUp.mi.dwExtraInfo = 0; - SendInput(1, &inputScrollUp, sizeof(INPUT)); + while (GetAsyncKeyState(VK_SPACE) && !hasFlagInAir) { + SendInput(1, &inputScrollUp, sizeof(INPUT)); + } } } } \ No newline at end of file