Начинающий
Начинающий
- Статус
- Оффлайн
- Регистрация
- 11 Сен 2024
- Сообщения
- 25
- Реакции
- 1
hi something is wrong with my autowall code like when i shoot it sometimes misses like i guess its something wrong with the trace manager it shoots where the bullet cant go trough or something i dont know
can anyone tell me whats wrong and what i need change
can anyone tell me whats wrong and what i need change
rage:
bool F::RAGEBOT::FireBullet(C_CSPlayerPawn* pPawn, Vector_t eye_pos, Vector_t enemy_pos)
{
if (!m_data.m_wpn_data || !m_data.m_local || !pPawn || pPawn->GetHealth() <= 0 || m_data.m_local->GetHealth() <= 0)
return false;
const float weaponRange = m_data.m_wpn_data->GetRange();
const float weaponRangeModifier = m_data.m_wpn_data->GetRangeModifier();
const int weaponDamage = m_data.m_wpn_data->GetDamage();
const float weaponPenetration = m_data.m_wpn_data->GetPenetration();
Vector_t direction = (enemy_pos - eye_pos).Normalized();
Vector_t end_pos = direction * weaponRange;
TraceData_t trace_data = {};
trace_data.m_arr_pointer = &trace_data.m_arr;
TraceFilter_t filter;
I::GameTraceManager->Init(filter, m_data.m_local, PENMASK, 0x3, 0x7);
I::GameTraceManager->CreateTrace(&trace_data, eye_pos, end_pos, filter, m_data.penetrationCount);
handle_bullet_data_t bullet_data(
static_cast<float>(weaponDamage),
weaponPenetration,
weaponRangeModifier,
weaponRange,
m_data.penetrationCount,
false
);
m_data.m_dmg = static_cast<float>(weaponDamage);
float flTraceLength = 0.f;
float flMaxRange = weaponRange;
const int pPawnEntryIndex = pPawn->GetRefEHandle().GetEntryIndex();
if (trace_data.m_num_update > 0)
{
for (int i = 0; i < trace_data.m_num_update; i++)
{
if (!trace_data.m_pointer_update_value || !trace_data.m_arr.data())
break;
UpdateValue_t* value = reinterpret_cast<UpdateValue_t*>(
reinterpret_cast<std::uintptr_t>(trace_data.m_pointer_update_value) + i * sizeof(UpdateValue_t));
if (!value)
break;
GameTrace_t game_trace = {};
I::GameTraceManager->InitializeTraceInfo(&game_trace);
I::GameTraceManager->GetTraceInfo(&trace_data, &game_trace, 0.f,
reinterpret_cast<void*>(
reinterpret_cast<std::uintptr_t>(trace_data.m_arr.data()) +
sizeof(TraceArrElement_t) * (value->handleIdx & ENT_ENTRY_MASK)));
if (game_trace.m_pHitEntity == m_data.m_local || !game_trace.m_pHitEntity)
continue;
flMaxRange -= flTraceLength;
flTraceLength += game_trace.m_flFraction * flMaxRange;
float distance_factor = flTraceLength / 500.f;
m_data.m_dmg *= std::powf(weaponRangeModifier, distance_factor);
if (game_trace.m_pHitEntity->IsPlayer() && game_trace.m_pHitEntity != pPawn)
{
m_data.m_dmg *= 0.75f;
}
if (game_trace.m_pHitEntity->GetRefEHandle().GetEntryIndex() == pPawnEntryIndex)
{
if (m_data.m_dmg < 1.0f)
continue;
if (game_trace.m_flFraction < 0.97f && !game_trace.m_pHitEntity->IsPlayer())
continue;
ScaleDamage(game_trace.m_pHitboxData, pPawn);
return true;
}
if (game_trace.m_flFraction < 1.0f)
{
if (I::GameTraceManager->handle_bullet_penetration(&trace_data, &bullet_data, value, false))
{
return false;
}
m_data.m_dmg = bullet_data.m_dmg * 0.85f;
if (m_data.m_dmg < 1.0f)
return false;
}
}
}
return false;
}
gametracer:
// Updated cgametracemanager.h
#pragma once
#include "../../utilities/memory.h"
#include "../../sdk/datatypes/vector.h"
#include <array>
class C_BaseEntity;
class C_CSPlayerPawn;
struct Ray_t
{
Vector_t m_vecStart;
Vector_t m_vecEnd;
Vector_t m_vecMins;
Vector_t m_vecMaxs;
MEM_PAD(0x4);
std::uint8_t UnkType;
};
static_assert(sizeof(Ray_t) == 0x38);
struct SurfaceData_t
{
MEM_PAD(0x8)
float m_flPenetrationModifier;
float m_flDamageModifier;
MEM_PAD(0x4)
int m_iMaterial;
};
static_assert(sizeof(SurfaceData_t) == 0x18);
struct TraceHitboxData_t
{
MEM_PAD(0x38);
int m_nHitGroup;
MEM_PAD(0x4);
int m_nHitboxId;
};
static_assert(sizeof(TraceHitboxData_t) == 0x44);
struct GameTrace_t
{
GameTrace_t() = default;
SurfaceData_t* GetSurfaceData();
int GetHitboxId();
int GetHitgroup();
bool IsVisible() const;
void* m_pSurface;
C_BaseEntity* m_pHitEntity;
TraceHitboxData_t* m_pHitboxData;
MEM_PAD(0x38);
std::uint32_t m_uContents;
MEM_PAD(0x24);
Vector_t m_vecStartPos;
Vector_t m_vecEndPos;
Vector_t m_vecNormal;
Vector_t m_vecPosition;
MEM_PAD(0x4);
float m_flFraction;
MEM_PAD(0x6);
bool m_bAllSolid;
MEM_PAD(0x4D)
};
static_assert(sizeof(GameTrace_t) == 0x108);
struct TraceFilter_t
{
MEM_PAD(0x8);
std::int64_t m_uTraceMask;
std::array<std::int64_t, 2> m_v1;
std::array<std::int32_t, 4> m_arrSkipHandles;
std::array<std::int16_t, 2> m_arrCollisions;
std::int16_t m_v2;
std::uint8_t m_v3;
std::uint8_t m_v4;
std::uint8_t m_v5;
TraceFilter_t() = default;
TraceFilter_t(std::uint64_t uMask, C_CSPlayerPawn* pSkip1, C_CSPlayerPawn* pSkip2, int nLayer);
};
static_assert(sizeof(TraceFilter_t) == 0x40);
struct TraceArrElement_t { MEM_PAD(0x30); };
struct TraceData_t
{
std::int32_t m_uk1{};
float m_uk2{ 52.0f };
void* m_arr_pointer{};
std::int32_t m_uk3{ 128 };
std::int32_t m_uk4{ static_cast<std::int32_t>(0x80000000) };
std::array<TraceArrElement_t, 0x80> m_arr = {};
MEM_PAD(0x8);
std::int64_t m_num_update{};
void* m_pointer_update_value{};
MEM_PAD(0xC8);
Vector_t m_start{}, m_end{};
MEM_PAD(0x50);
};
struct UpdateValue_t
{
float previousLenght{};
float currentLenght{};
MEM_PAD(0x8);
std::int16_t handleIdx{};
MEM_PAD(0x6);
};
struct handle_bullet_data_t
{
handle_bullet_data_t(const float dmg_mod, const float pen, const float range_mod, const float range, const int pen_count, const bool failed) :
m_dmg(dmg_mod), m_pen(pen), m_range_mod(range_mod), m_range(range), m_pen_count(pen_count), m_failed(failed) {
}
float m_dmg{}, m_pen{}, m_range_mod{}, m_range{};
int m_pen_count{};
bool m_failed{};
};
class CGameTraceManager
{
public:
void InitializeTraceInfo(GameTrace_t* const hit)
{
using function_t = void(__fastcall*)(GameTrace_t*);
static function_t fn = reinterpret_cast<function_t>(MEM::FindPattern(CLIENT_DLL, "48 89 5C 24 ? 57 48 83 EC ? 48 8B D9 33 FF 48 8B 0D ? ? ? ? 48 85 C9"));
fn(hit);
}
void Init(TraceFilter_t& filter, C_CSPlayerPawn* skip, uint64_t mask, uint8_t layer, uint16_t idk)
{
using function_t = TraceFilter_t * (__fastcall*)(TraceFilter_t&, void*, uint64_t, uint8_t, uint16_t);
static function_t fn = reinterpret_cast<function_t>(MEM::FindPattern(CLIENT_DLL, "48 89 5C 24 08 48 89 74 24 10 57 48 83 EC 20 0F B6 41 37 33"));
fn(filter, skip, mask, layer, idk);
}
void GetTraceInfo(TraceData_t* const trace, GameTrace_t* const hit, const float unknown_float, void* unknown)
{
using function_t = void(__fastcall*)(TraceData_t*, GameTrace_t*, float, void*);
static function_t fn = reinterpret_cast<function_t>(MEM::FindPattern(CLIENT_DLL, "48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 60 48 8B E9 0F"));
fn(trace, hit, unknown_float, unknown);
}
bool handle_bullet_penetration(TraceData_t* const trace, handle_bullet_data_t* stats, UpdateValue_t* const mod_value, const bool draw_showimpacts = false)
{
using function_t = bool(__fastcall*)(TraceData_t*, handle_bullet_data_t*, UpdateValue_t*, void*, void*, void*, void*, void*, bool);
static function_t fn = reinterpret_cast<function_t>(MEM::FindPattern(CLIENT_DLL, "48 8B C4 44 89 48 ? 48 89 50 ? 48 89 48"));
return fn(trace, stats, mod_value, nullptr, nullptr, nullptr, nullptr, nullptr, draw_showimpacts);
}
bool TraceShape(Ray_t* pRay, Vector_t vecStart, Vector_t vecEnd, TraceFilter_t* pFilter, GameTrace_t* pGameTrace)
{
using fnTraceShape = bool(__fastcall*)(CGameTraceManager*, Ray_t*, Vector_t*, Vector_t*, TraceFilter_t*, GameTrace_t*);
static fnTraceShape oTraceShape = reinterpret_cast<fnTraceShape>(MEM::GetAbsoluteAddress(MEM::FindPattern(CLIENT_DLL, "E8 ? ? ? ? 80 7D ? ? 75 ? F3 0F 10 05"), 0x1, 0x0));
return oTraceShape(this, pRay, &vecStart, &vecEnd, pFilter, pGameTrace);
}
bool ClipRayToEntity(Ray_t* pRay, Vector_t vecStart, Vector_t vecEnd, C_CSPlayerPawn* pPawn, TraceFilter_t* pFilter, GameTrace_t* pGameTrace)
{
using fnClipRayToEntity = bool(__fastcall*)(CGameTraceManager*, Ray_t*, Vector_t*, Vector_t*, C_CSPlayerPawn*, TraceFilter_t*, GameTrace_t*);
static fnClipRayToEntity oClipRayToEntity = reinterpret_cast<fnClipRayToEntity>(MEM::FindPattern(CLIENT_DLL, "48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 48 89 7C 24 20 41 54 41 56 41 57 48 81 EC C0 00 00 00 48 8B 9C"));
return oClipRayToEntity(this, pRay, &vecStart, &vecEnd, pPawn, pFilter, pGameTrace);
}
void ClipTraceToPlayers(Vector_t& start, Vector_t& end, TraceFilter_t* filter, GameTrace_t* trace, float min, float max, float length)
{
using function_t = void(__fastcall*)(Vector_t&, Vector_t&, TraceFilter_t*, GameTrace_t*, float, float, float);
static function_t fn = reinterpret_cast<function_t>(MEM::FindPattern(CLIENT_DLL, "48 8B C4 55 56 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 48 89 58 ? 49 8B F0"));
fn(start, end, filter, trace, min, max, length);
}
void CreateTrace(TraceData_t* const trace, Vector_t start, Vector_t end, const TraceFilter_t& filler, int penetration_count)
{
using function_t = void(__fastcall*)(TraceData_t*, Vector_t, Vector_t, TraceFilter_t, int);
static function_t fn = reinterpret_cast<function_t>(MEM::FindPattern(CLIENT_DLL, "48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 41 56 41 57 48 83 EC 40 F2"));
fn(trace, start, end, filler, penetration_count);
}
};
enum Contents_t
{
CONTENTS_EMPTY = 0,
CONTENTS_SOLID = 0x1,
CONTENTS_WINDOW = 0x2,
CONTENTS_AUX = 0x4,
CONTENTS_GRATE = 0x8,
CONTENTS_SLIME = 0x10,
CONTENTS_WATER = 0x20,
CONTENTS_BLOCKLOS = 0x40,
CONTENTS_OPAQUE = 0x80,
CONTENTS_TESTFOGVOLUME = 0x100,
CONTENTS_UNUSED = 0x200,
CONTENTS_BLOCKLIGHT = 0x400,
CONTENTS_TEAM1 = 0x800,
CONTENTS_TEAM2 = 0x1000,
CONTENTS_IGNORE_NODRAW_OPAQUE = 0x2000,
CONTENTS_MOVEABLE = 0x4000,
CONTENTS_AREAPORTAL = 0x8000,
CONTENTS_PLAYERCLIP = 0x10000,
CONTENTS_MONSTERCLIP = 0x20000,
CONTENTS_CURRENT_0 = 0x40000,
CONTENTS_CURRENT_90 = 0x80000,
CONTENTS_CURRENT_180 = 0x100000,
CONTENTS_CURRENT_270 = 0x200000,
CONTENTS_CURRENT_UP = 0x400000,
CONTENTS_CURRENT_DOWN = 0x800000,
CONTENTS_ORIGIN = 0x1000000,
CONTENTS_MONSTER = 0x2000000,
CONTENTS_DEBRIS = 0x4000000,
CONTENTS_DETAIL = 0x8000000,
CONTENTS_TRANSLUCENT = 0x10000000,
CONTENTS_LADDER = 0x20000000,
CONTENTS_HITBOX = 0x40000000,
};
enum Masks_t
{
MASK_ALL = 0xFFFFFFFF,
MASK_SOLID = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE,
MASK_PLAYERSOLID = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE,
MASK_NPCSOLID = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE,
MASK_NPCFLUID = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE,
MASK_WATER = CONTENTS_WATER | CONTENTS_MOVEABLE | CONTENTS_SLIME,
MASK_OPAQUE = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_OPAQUE,
MASK_OPAQUE_AND_NPCS = MASK_OPAQUE | CONTENTS_MONSTER,
MASK_BLOCKLOS = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_BLOCKLOS,
MASK_BLOCKLOS_AND_NPCS = MASK_BLOCKLOS | CONTENTS_MONSTER,
MASK_VISIBLE = MASK_OPAQUE | CONTENTS_IGNORE_NODRAW_OPAQUE,
MASK_VISIBLE_AND_NPCS = MASK_OPAQUE_AND_NPCS | CONTENTS_IGNORE_NODRAW_OPAQUE,
MASK_SHOT = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_WINDOW | CONTENTS_DEBRIS | CONTENTS_GRATE | CONTENTS_HITBOX,
MASK_SHOT_BRUSHONLY = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_DEBRIS,
MASK_SHOT_HULL = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_WINDOW | CONTENTS_DEBRIS | CONTENTS_GRATE,
MASK_SHOT_PORTAL = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_MONSTER,
MASK_SOLID_BRUSHONLY = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_GRATE,
MASK_PLAYERSOLID_BRUSHONLY = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_PLAYERCLIP | CONTENTS_GRATE,
MASK_NPCSOLID_BRUSHONLY = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_MONSTERCLIP | CONTENTS_GRATE,
MASK_NPCWORLDSTATIC = CONTENTS_SOLID | CONTENTS_WINDOW | CONTENTS_MONSTERCLIP | CONTENTS_GRATE,
MASK_NPCWORLDSTATIC_FLUID = CONTENTS_SOLID | CONTENTS_WINDOW | CONTENTS_MONSTERCLIP,
MASK_SPLITAREPORTAL = CONTENTS_WATER | CONTENTS_SLIME,
MASK_CURRENT = CONTENTS_CURRENT_0 | CONTENTS_CURRENT_90 | CONTENTS_CURRENT_180 | CONTENTS_CURRENT_270 | CONTENTS_CURRENT_UP | CONTENTS_CURRENT_DOWN,
MASK_DEADSOLID = CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_GRATE,
};
.cpp:
// cgametracemanager.cpp
#include "cgametracemanager.h"
#include "../../sdk/entity.h"
SurfaceData_t* GameTrace_t::GetSurfaceData()
{
using fnGetSurfaceData = std::uint64_t(__fastcall*)(void*);
static fnGetSurfaceData oGetSurfaceData = reinterpret_cast<fnGetSurfaceData>(MEM::GetAbsoluteAddress(MEM::FindPattern(CLIENT_DLL, "E8 ? ? ? ? 48 85 C0 74 ? 44 38 60"), 0x1, 0x0));
return reinterpret_cast<SurfaceData_t*>(oGetSurfaceData(m_pSurface));
}
int GameTrace_t::GetHitboxId()
{
return m_pHitboxData ? m_pHitboxData->m_nHitboxId : 0;
}
int GameTrace_t::GetHitgroup()
{
return m_pHitboxData ? m_pHitboxData->m_nHitGroup : 0;
}
bool GameTrace_t::IsVisible() const
{
return (m_flFraction > 0.92f);
}
TraceFilter_t::TraceFilter_t(std::uint64_t uMask, C_CSPlayerPawn* pSkip1, C_CSPlayerPawn* pSkip2, int nLayer)
{
m_uTraceMask = uMask;
m_v1[0] = m_v1[1] = 0;
m_v2 = 7;
m_v3 = nLayer;
m_v4 = 0x49;
m_v5 = 0;
if (pSkip1)
{
m_arrSkipHandles[0] = pSkip1->GetRefEHandle().GetEntryIndex();
m_arrCollisions[0] = pSkip1->GetCollisionMask();
}
if (pSkip2)
{
m_arrSkipHandles[1] = pSkip2->GetRefEHandle().GetEntryIndex();
m_arrCollisions[1] = pSkip2->GetCollisionMask();
}
}