-
Автор темы
- #1
При включении AutoDirection aka Freestanding мой реальный аа становится 180.0f aka backward и не разворачивает под нужный угол. Помогите пожалуйста :)
Код:
float fov_player(Vector ViewOffSet, Vector View, sdk::CBaseEntity* entity, int hitbox)
{
// Anything past 180 degrees is just going to wrap around
CONST FLOAT MaxDegrees = 180.0f;
// Get local angles
Vector Angles = View;
// Get local view / eye position
Vector Origin = ViewOffSet;
// Create and intiialize vectors for calculations below
Vector Delta(0, 0, 0);
//Vector Origin(0, 0, 0);
Vector Forward(0, 0, 0);
// Convert angles to normalized directional forward vector
MATH::AngleVectors(Angles, &Forward);
Vector AimPos = aimbot->get_hitbox_pos(entity, hitbox); //pvs fix disabled
MATH::VectorSubtract(AimPos, Origin, Delta);
//Delta = AimPos - Origin;
// Normalize our delta vector
MATH::NormalizeNum(Delta, Delta);
// Get dot product between delta position and directional forward vectors
FLOAT DotProduct = Forward.Dot(Delta);
// Time to calculate the field of view
return (acos(DotProduct) * (MaxDegrees / M_PI));
}
int closest_to_crosshair()
{
int index = -1;
float lowest_fov = INT_MAX;
sdk::CBaseEntity* local_player = ctx::client_ent_list->GetClientEntity(ctx::engine->GetLocalPlayer());
if (!local_player)
return -1;
Vector local_position = local_player->GetVecOrigin() + local_player->GetViewOffset();
Vector angles;
ctx::engine->GetViewAngles(angles);
for (int i = 1; i <= ctx::globals->maxclients; i++)
{
sdk::CBaseEntity *entity = ctx::client_ent_list->GetClientEntity(i);
if (!entity || !entity->IsAlive() || entity->GetTeam() == local_player->GetTeam() || entity->GetIsDormant() || entity == local_player)
continue;
float fov = fov_player(local_position, angles, entity, 0);
if (fov < lowest_fov)
{
lowest_fov = fov;
index = i;
}
}
return index;
}
void CAntiAim::freestand(sdk::CUserCmd* cmd)
{
auto local_player = ctx::client_ent_list->GetClientEntity(ctx::engine->GetLocalPlayer());
if (!local_player)
return;
static float last_real;
bool no_active = false;
float bestrotation = 0.f;
float highestthickness = 0.f;
Vector besthead;
auto leyepos = local_player->GetVecOrigin() + local_player->GetViewOffset();
auto headpos = aimbot->get_hitbox_pos(local_player, 0);
auto origin = local_player->GetAbsOrigin();
auto checkWallThickness = [&](sdk::CBaseEntity* pPlayer, Vector newhead) -> float
{
Vector endpos1, endpos2;
Vector eyepos = pPlayer->GetVecOrigin() + pPlayer->GetViewOffset();
sdk::Ray_t ray;
ray.Init(newhead, eyepos);
sdk::CTraceFilterSkipTwoEntities filter(pPlayer, local_player);
sdk::trace_t trace1, trace2;
ctx::trace->TraceRay(ray, MASK_SHOT_BRUSHONLY, &filter, &trace1);
if (trace1.DidHit())
endpos1 = trace1.end;
else
return 0.f;
ray.Init(eyepos, newhead);
ctx::trace->TraceRay(ray, MASK_SHOT_BRUSHONLY, &filter, &trace2);
if (trace2.DidHit())
endpos2 = trace2.end;
float add = newhead.DistTo(eyepos) - leyepos.DistTo(eyepos) + 3.f;
return endpos1.DistTo(endpos2) + add / 3;
};
int index = closest_to_crosshair();
sdk::CBaseEntity* entity = nullptr;
if (index != -1)
entity = ctx::client_ent_list->GetClientEntity(index);
float step = (2 * M_PI) / 18.f; // One PI = half a circle ( for stacker cause low iq :sunglasses: ), 28
float radius = fabs(Vector(headpos - origin).Length2D());
if (index == -1)
{
no_active = true;
}
else
{
for (float rotation = 0; rotation < (M_PI * 2.0); rotation += step)
{
Vector newhead(radius * cos(rotation) + leyepos.x, radius * sin(rotation) + leyepos.y, leyepos.z);
float totalthickness = 0.f;
no_active = false;
totalthickness += checkWallThickness(entity, newhead);
if (totalthickness > highestthickness)
{
highestthickness = totalthickness;
bestrotation = rotation;
besthead = newhead;
}
}
}
if (GLOBAL::should_send_packet)
cmd->viewangles.y += randnumb(-180, 180);
else
{
if (next_lby_update(cmd->viewangles.y + Vars::options.delta_val, cmd))
{
cmd->viewangles.y = last_real + Vars::options.delta_val;
}
else
{
if (no_active)
cmd->viewangles.y += 180.f;
else
cmd->viewangles.y = RAD2DEG(bestrotation);
last_real = cmd->viewangles.y;
}
}
}