Skip to content

Commit

Permalink
minor updates to help with future features
Browse files Browse the repository at this point in the history
  • Loading branch information
Fr0go1 committed Oct 11, 2023
1 parent 0aa2f0f commit d4740fd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 69 deletions.
92 changes: 25 additions & 67 deletions CS2_External/AimBot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,78 +3,18 @@
#include <math.h>
#include "Game.h"
#include "Entity.h"
#include <iostream>
#include <Windows.h>

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 <iostream>

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<int> HotKeyList{VK_LMENU, VK_RBUTTON, VK_XBUTTON1, VK_XBUTTON2, VK_CAPITAL, VK_LSHIFT, VK_LCONTROL};
inline std::vector<int> HotKeyList{ VK_LMENU, VK_RBUTTON, VK_XBUTTON1, VK_XBUTTON2, VK_CAPITAL, VK_LSHIFT, VK_LCONTROL };

inline void SetHotKey(int Index)
{
Expand All @@ -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));
Expand All @@ -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<int>(AimPos.x);
int targetY = static_cast<int>(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);
}
}
}
6 changes: 4 additions & 2 deletions CS2_External/Bunnyhop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}
}
}
}

0 comments on commit d4740fd

Please sign in to comment.