Files
2026-11-07 20:24:47 +00:00

219 lines
4.5 KiB
C++

#pragma once
#include <stdint.h>
#include <stdio.h>
#include <intrin.h>
#ifndef __FLTUSED__
#define __FLTUSED__
extern "C" __declspec(selectany) int _fltused = 1;
#endif
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;
typedef unsigned long long u64;
typedef u64 uptr;
#define BASE_OF(X) ((u64)X)
#define memset(dst, val, len) __stosb( (unsigned char*)dst, val, len )
#define memcpy(dst, src, len) __movsb( (unsigned char*)dst, (unsigned char*)src, len )
#include "offsets.h"
__forceinline float dword2float(u32 val)
{
return *(float*)(&val);
}
#define _FP( X ) (float)((u32)X)
#define xf(X) dword2float(X)
#include "xmm_reg.h"
#include "in_state.h"
#pragma pack(push, 1)
struct EntityRecord
{
u64 ptr;
u64 v0;
u64 v1;
u64 v2;
};
struct Vector3D
{
float x;
float y;
float z;
float *base()
{
return reinterpret_cast<float *>(reinterpret_cast<uintptr_t>(this));
}
Vector3D()
{
this->x = xf(0);
this->y = xf(0);
this->z = xf(0);
}
Vector3D(float _x, float _y, float _z)
{
this->x = _x;
this->y = _y;
this->z = _z;
}
Vector3D operator-(const Vector3D& other)
{
this->x -= other.x;
this->y -= other.y;
this->z -= other.z;
return *this;
}
Vector3D operator+=(const Vector3D& other)
{
this->x += other.x;
this->y += other.y;
this->z += other.z;
return *this;
}
float length() { return this->x + this->y + this->z; }
float length_sqr()
{
return (this->x * this->x) +
(this->y * this->y) +
(this->z * this->z);
}
};
namespace /* ANONYMOUS */
{
#define SUPERGLIDE_STATE_IDLE 0
#define SUPERGLIDE_STATE_STARTED 1
struct SuperGlideContext
{
u8 state;
u8 force_duck;
u8 force_reset;
float last;
};
}
enum class GameModes
{
INVALID = 0,
SURVIVAL,
TEAM_DEATHMATCH,
CONTROL,
GUN_RUN
};
struct Context;
#include "math.h"
struct CachedEntity
{
bool is_valid;
bool is_ally;
int health;
math::render_points_t rpts;
bool rpts_avail;
Vector3D vec_origin;
u64 signifier;
const char* name;
int color[3];
float draw_pos_top[2];
int level;
float dist_to_local;
};
struct CheatState
{
rs::In_state in_forward;
rs::In_state in_duck;
rs::In_state in_jump;
SuperGlideContext sgctx;
GameModes game_mode;
u64 game_mode_raw;
CachedEntity entity_cache[0x10000];
size_t highest_eidx;
float fp_cache[16];
bool is_controller;
};
using fn_draw_colored_text = void(__fastcall*)(u64, u16, int, int, int, signed int, signed int, signed int, signed int, int, const char*, ...);
using fn_get_player_name = const char*(__fastcall*)(u64);
using fn_draw_set_color = void(__fastcall*)(u64, int, int, int, int);
using fn_draw_filled_rect = void(__fastcall*)(u64, int, int, int, int);
using fn_draw_outlined_rect = void(__fastcall*)(u64, int, int, int, int);
using fn_transform_pos = bool(__fastcall*)(Vector3D&, Vector3D*);
struct Context
{
u32 magic;
u8 inited;
u64 game_base;
u64 crt_base;
u64 me;
Vector3D last_punch;
u64* mss_ptr;
fn_draw_colored_text pfn_draw_colored_text;
fn_get_player_name pfn_get_player_name;
fn_draw_set_color pfn_draw_set_color;
fn_draw_filled_rect pfn_draw_filled_rect;
fn_draw_outlined_rect pfn_draw_outlined_rect;
fn_transform_pos pfn_transform_position;
CheatState state;
};
#pragma pack(pop)
inline float fabsf( Context* pctx, float v )
{
using fn = double(__fastcall*)(double);
auto fun = (fn)(pctx->crt_base + 0x6DF00);
return (float)fun( (float)v );
}
#define PLAYER__IS_ALIVE(P) ( *(uint8_t*)(P + OFF_PLAYER_LIFE_STATE) == 0u )
#include "entity.h"
#include "features.h"
#include "render.h"
namespace r5
{
inline Entity local_player( Context* pctx )
{
return Entity( *(u64*)(pctx->game_base + OFF_LOCAL_PLAYER) );
}
inline float cur_time( Context* pctx )
{
return *(float*)( *(u64*)(pctx->game_base + OFF_GLOBAL_VARS) + 0x28);
}
inline bool is_valid_context( Context* pctx )
{
if(pctx->magic != 0x1327)
return false;
auto me = local_player( pctx );
if(me.is_valid() == 0 || !me.is_alive())
return false;
auto map_hash = *(u64*)(pctx->game_base + OFF_MAP_NAME);
return map_hash != 0x7962626f6c5f7000 && map_hash != 0x7962626f6c5f706d;
}
}