1
Пользователь
-
Автор темы
- #1
Резольвер не мой,дал друг
Резик для лв
Резик для лв
C++:
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
#include "animation_system.h"
#include "..\ragebot\aim.h"
void resolver::initialize(player_t* e, adjust_data* record, const float& goal_feet_yaw, const float& pitch)
{
player = e;
player_record = record;
original_goal_feet_yaw = math::normalize_yaw(goal_feet_yaw);
original_pitch = math::normalize_pitch(pitch);
}
void resolver::reset()
{
player = nullptr;
player_record = nullptr;
side = false;
fake = false;
was_first_bruteforce = false;
was_second_bruteforce = false;
original_goal_feet_yaw = 0.0f;
original_pitch = 0.0f;
}
float flAngleMod(float flAngle)
{
return((360.0f / 65536.0f) * ((int32_t)(flAngle * (65536.0f / 360.0f)) & 65535));
}
float ApproachAngle(float flTarget, float flValue, float flSpeed)
{
flTarget = flAngleMod(flTarget);
flValue = flAngleMod(flValue);
float delta = flTarget - flValue;
if (flSpeed < 0)
flSpeed = -flSpeed;
if (delta < -180)
delta += 360;
else if (delta > 180)
delta -= 360;
if (delta > flSpeed)
flValue += flSpeed;
else if (delta < -flSpeed)
flValue -= flSpeed;
else
flValue = flTarget;
return flValue;
}
static auto GetSmoothedVelocity = [](float min_delta, Vector a, Vector b) {
Vector delta = a - b;
float delta_length = delta.Length();
if (delta_length <= min_delta) {
Vector result;
if (-min_delta <= delta_length) {
return a;
}
else {
float iradius = 1.0f / (delta_length + FLT_EPSILON);
return b - ((delta * iradius) * min_delta);
}
}
else {
float iradius = 1.0f / (delta_length + FLT_EPSILON);
return b + ((delta * iradius) * min_delta);
}
};
bool is_near_equal(float v1, float v2, float tolerance) {
return std::abs(v1 - v2) <= std::abs(tolerance);
}
bool resolver::ent_use_jiter(player_t* player, int* new_side) {
if (!player->is_alive())
return false;
if (!player->valid(false, false))
return false;
if (player->IsDormant())
return false;
static float LastAngle[64];
static int LastBrute[64];
static bool Switch[64];
static float LastUpdateTime[64];
int i = player->EntIndex();
float CurrentAngle = player->m_angEyeAngles().y;
if (is_near_equal(CurrentAngle, LastAngle[i], 50.f)) {
Switch[i] = !Switch[i];
LastAngle[i] = CurrentAngle;
*new_side = Switch[i] ? 1 : -1;
LastBrute[i] = *new_side;
LastUpdateTime[i] = m_globals()->m_curtime;
return true;
}
else {
if (fabsf(LastUpdateTime[i] - m_globals()->m_curtime >= TICKS_TO_TIME(17))
|| player->m_flSimulationTime() != player->m_flOldSimulationTime()) {
LastAngle[i] = CurrentAngle;
}
*new_side = LastBrute[i];
}
return false;
}
void resolver::update_animations(bool update)
{
if (m_engine()->IsConnected() == false || g_ctx.local()->is_alive() == false || g_ctx.local()->m_iTeamNum() == player->m_iTeamNum())
return;
if (update)
{
g_ctx.globals.updating_animation = true;
player->update_clientside_animation();
g_ctx.globals.updating_animation = false;
}
}
float resolver::GetForwardYaw(player_t* ent) {
return math::normalize_yaw(GetBackwardYaw(ent) - 180.f);
}
float resolver::GetBackwardYaw(player_t* ent) {
return math::normalize_yaw(player->m_angEyeAngles().y);
}
float build_server_abs_yaw(player_t* m_player, float angle)
{
Vector velocity = m_player->m_vecVelocity();
auto anim_state = m_player->get_animation_state();
float m_flEyeYaw = angle;
float m_flGoalFeetYaw = 0.f;
float eye_feet_delta = math::AngleDiff(m_flEyeYaw, m_flGoalFeetYaw);
static auto GetSmoothedVelocity = [](float min_delta, Vector a, Vector b) {
Vector delta = a - b;
float delta_length = delta.Length();
if (delta_length <= min_delta)
{
Vector result;
if (-min_delta <= delta_length)
return a;
else
{
float iradius = 1.0f / (delta_length + FLT_EPSILON);
return b - ((delta * iradius) * min_delta);
}
}
else
{
float iradius = 1.0f / (delta_length + FLT_EPSILON);
return b + ((delta * iradius) * min_delta);
}
};
float spd = velocity.LengthSqr();
if (spd > std::powf(1.2f * 260.0f, 2.f))
{
Vector velocity_normalized = velocity.Normalized();
velocity = velocity_normalized * (1.2f * 260.0f);
}
float m_flChokedTime = anim_state->m_flLastClientSideAnimationUpdateTime;
float v25 = std::clamp(m_player->m_flDuckAmount() + anim_state->m_fLandingDuckAdditiveSomething, 0.0f, 1.0f);
float v26 = anim_state->m_fDuckAmount;
float v27 = m_flChokedTime * 6.0f;
float v28;
if ((v25 - v26) <= v27) {
if (-v27 <= (v25 - v26))
v28 = v25;
else
v28 = v26 - v27;
}
else {
v28 = v26 + v27;
}
float flDuckAmount = std::clamp(v28, 0.0f, 1.0f);
Vector animationVelocity = GetSmoothedVelocity(m_flChokedTime * 2000.0f, velocity, m_player->m_vecVelocity());
float speed = std::fminf(animationVelocity.Length(), 260.0f);
float flMaxMovementSpeed = 260.0f;
weapon_t* pWeapon = m_player->m_hActiveWeapon();
if (pWeapon && pWeapon->get_csweapon_info())
flMaxMovementSpeed = std::fmaxf(pWeapon->get_csweapon_info()->flMaxPlayerSpeedAlt, 0.001f);
float flRunningSpeed = speed / (flMaxMovementSpeed * 0.520f);
float flDuckingSpeed = speed / (flMaxMovementSpeed * 0.340f);
flRunningSpeed = std::clamp(flRunningSpeed, 0.0f, 1.0f);
float flYawModifier = (((anim_state->m_flStopToFullRunningFraction * -0.30000001) - 0.19999999) * flRunningSpeed) + 1.0f;
if (flDuckAmount > 0.0f)
{
float flDuckingSpeed = std::clamp(flDuckingSpeed, 0.0f, 1.0f);
flYawModifier += (flDuckAmount * flDuckingSpeed) * (0.5f - flYawModifier);
}
const float v60 = -58.f;
const float v61 = 58.f;
float flMinYawModifier = v60 * flYawModifier;
float flMaxYawModifier = v61 * flYawModifier;
if (eye_feet_delta <= flMaxYawModifier)
{
if (flMinYawModifier > eye_feet_delta)
m_flGoalFeetYaw = fabs(flMinYawModifier) + m_flEyeYaw;
}
else
{
m_flGoalFeetYaw = m_flEyeYaw - fabs(flMaxYawModifier);
}
math::normalize_yaw(m_flGoalFeetYaw);
if (speed > 0.1f || fabs(velocity.z) > 100.0f)
{
m_flGoalFeetYaw = math::ApproachAngle(
m_flEyeYaw,
m_flGoalFeetYaw,
((anim_state->m_flStopToFullRunningFraction * 20.0f) + 30.0f)
* m_flChokedTime);
}
else
{
m_flGoalFeetYaw = math::ApproachAngle(
m_player->m_flLowerBodyYawTarget(),
m_flGoalFeetYaw,
m_flChokedTime * 100.0f);
}
return m_flGoalFeetYaw;
}
bool resolver::low_delta()
{
if (m_engine()->IsConnected() == false || g_ctx.local()->is_alive() == false || g_ctx.local()->m_iTeamNum() == player->m_iTeamNum())
return false;
Vector firsttwo = ZERO, secondtwo = ZERO, thirdtwo = ZERO;
auto animstate = player->get_animation_state();
float delta = math::normalize_yaw(player->m_angEyeAngles().y - animstate->m_flGoalFeetYaw);
firsttwo = Vector(player->m_angEyeAngles().x, player->m_angEyeAngles().y + delta, player->m_angEyeAngles().z);
secondtwo = Vector(player->m_angEyeAngles().x, 180, player->m_angEyeAngles().z);
thirdtwo = Vector(player->m_angEyeAngles().x, player->m_angEyeAngles().y - delta, player->m_angEyeAngles().z);
if ((aim::get().hitbox_intersection(player, player_record->matrixes_data.first, 0, g_ctx.local()->get_eye_pos(), firsttwo)
&& aim::get().hitbox_intersection(player, player_record->matrixes_data.zero, 0, g_ctx.local()->get_eye_pos(), secondtwo))
|| (aim::get().hitbox_intersection(player, player_record->matrixes_data.zero, 0, g_ctx.local()->get_eye_pos(), secondtwo)
&& aim::get().hitbox_intersection(player, player_record->matrixes_data.second, 0, g_ctx.local()->get_eye_pos(), thirdtwo)))
return true;
else
return false;
}
void resolver::resolve_yaw()
{
if (m_engine()->IsConnected() == false || g_ctx.local()->is_alive() == false || g_ctx.local()->m_iTeamNum() == player->m_iTeamNum())
return;
auto weapon = player->m_hActiveWeapon();
if (!weapon)
return;
float delta = 0.f, angle = 0.f, speed = 0.f;
speed = player->m_vecVelocity().Length();
bool safe = false, low = false;
static int gside = 0, safeside = 0;
AnimationLayer* Layers[15], MoveLayers[3][15], ServerLayers[12][15];
auto animstate = player->get_animation_state();
if (!animstate)
return;
float flMaxMovementSpeed = 260.0f;
if (weapon) {
flMaxMovementSpeed = std::fmaxf(weapon->get_csweapon_info()->flMaxPlayerSpeed, 0.001f);
}
float flRunningSpeed = speed / (flMaxMovementSpeed * 0.520f);
float flDuckingSpeed = speed / (flMaxMovementSpeed * 0.340f);
flRunningSpeed = std::clamp(flRunningSpeed, 0.0f, 1.0f);
float flYawModifier = (((animstate->m_flMovingFraction * -0.3f) - 0.2f) * flRunningSpeed) + 1.0f;
if (player->m_flDuckAmount() > 0.0f) {
float flDuckingSpeed = std::clamp(flDuckingSpeed, 0.0f, 1.0f);
flYawModifier += (player->m_flDuckAmount() * flDuckingSpeed) * (0.5f - flYawModifier);
}
float flMinBodyYaw = std::fabsf(animstate->m_flMinBodyYaw() * flYawModifier);
float flMaxBodyYaw = std::fabsf(animstate->m_flMaxBodyYaw() * flYawModifier);
bool update = true;
update_animations(update);
Vector current;
float back_two, right_two, left_two;
trace_t tr;
Ray_t ray, ray2, ray3;
CTraceFilter filter;
Vector right(player->m_angEyeAngles().x, player->m_angEyeAngles().y + delta, player->m_angEyeAngles().z);
Vector left(player->m_angEyeAngles().x, player->m_angEyeAngles().y - delta, player->m_angEyeAngles().z);
Vector back(player->m_angEyeAngles().x, 180.f, player->m_angEyeAngles().z);
current = player->m_angEyeAngles();
filter.pSkip = player;
float distance = g_ctx.local()->GetAbsOrigin().DistTo(player->GetAbsOrigin()) * 6;
ray.Init(current, right);
ray2.Init(current, left);
ray3.Init(current, back);
float back_one, right_one, left_one;
right_one = current.y - right.y;
left_one = current.y - left.y;
back_one = current.y - back.y;
m_trace()->TraceRay(ray, MASK_SHOT, &filter, &tr);
right_two = tr.endpos.Length2D() - tr.startpos.Length2D();
m_trace()->TraceRay(ray2, MASK_SHOT, &filter, &tr);
left_two = tr.endpos.Length2D() - tr.startpos.Length2D();
m_trace()->TraceRay(ray3, MASK_SHOT, &filter, &tr);
back_two = tr.endpos.Length2D() - tr.startpos.Length2D();
gside = 0;
if (player->get_animlayers()[3].m_flCycle == 0.f && player->get_animlayers()[3].m_flWeight == 0.f)
{
if (fabs(right_one) >= delta)
gside = 1;
else if (fabs(left_one) >= delta)
gside = -1;
else if (fabs(back_one) >= delta)
gside = 0;
update = false;
}
else
{
if (fabs(right_two) >= distance)
gside = 1;
else if (fabs(left_two) >= distance)
gside = -1;
else if (fabs(back_two) >= distance)
gside = 0;
update = false;
}
update = true;
//if (GetAngle(player) == GetForwardYaw(player))
gside *= -1;
update = false;
int new_side = 0;
auto lby_yaw = std::clamp(player->m_flLowerBodyYawTarget(), 0.f, 180.f);
if (g_ctx.globals.missed_shots[player->EntIndex()] == 0)
{
if (ent_use_jiter(player, &new_side))
{
player_record->resolver_yaw = math::normalize_yaw(player->m_angEyeAngles().y - delta * new_side);
animstate->m_flAbsRotation() = math::normalize_yaw(player->m_angEyeAngles().y - delta * new_side);
}
else {
if (gside <= -1)
player_record->resolver_yaw = math::normalize_yaw(player->m_angEyeAngles().y - flMinBodyYaw);
else if (gside >= 1)
player_record->resolver_yaw = math::normalize_yaw(player->m_angEyeAngles().y + flMaxBodyYaw);
else
player_record->resolver_yaw = math::normalize_yaw(player->m_angEyeAngles().y + math::random_float(flMinBodyYaw, flMaxBodyYaw));
}
}
else if (g_ctx.globals.missed_shots[player->EntIndex()] > 0)
{
switch (g_ctx.globals.missed_shots[player->EntIndex()])
{
case 0:
{
player_record->resolver_yaw = math::normalize_yaw(player->m_angEyeAngles().y - (player->m_vecVelocity().Length() > 3.0f && lby_yaw < 29) || low_delta() ? 21.7 : delta);
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y - (player->m_vecVelocity().Length() > 3.0f && lby_yaw < 29) || low_delta() ? 21.7 : delta);
}break;
case 1: {
player_record->resolver_yaw = math::normalize_yaw(player->m_angEyeAngles().y + (player->m_vecVelocity().Length() > 3.0f && lby_yaw < 29) || low_delta() ? 21.7 : delta);
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y + (player->m_vecVelocity().Length() > 3.0f && lby_yaw < 29) || low_delta() ? 21.7 : delta);
}break;
case 2: {
player_record->resolver_yaw = math::normalize_yaw(player->m_angEyeAngles().y - delta / 2);
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y - max(delta / 2, 21));
}break;
case 3: {
player_record->resolver_yaw = math::normalize_yaw(player->m_angEyeAngles().y + max(delta / 2, 21));
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y + max(delta / 2, 21));
}break;
case 4: {
player_record->resolver_yaw = math::normalize_yaw(player->m_angEyeAngles().y - g_ctx.send_packet == false ? delta : -delta);
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y - g_ctx.send_packet == false ? delta : -delta);
}break;
}
}
}
float resolver::resolve_pitch()
{
float liohsdafg = 0.f;
if (g_cfg.ragebot.pitch_antiaim_correction)
{
if (liohsdafg < -179.f) liohsdafg += 360.f;
else if (liohsdafg > 90.0 || liohsdafg < -90.0) liohsdafg = 89.f;
else if (liohsdafg > 89.0 && liohsdafg < 91.0) liohsdafg -= 90.f;
else if (liohsdafg > 179.0 && liohsdafg < 181.0) liohsdafg -= 180;
else if (liohsdafg > -179.0 && liohsdafg < -181.0) liohsdafg += 180;
else if (fabs(liohsdafg) == 0) liohsdafg = copysign(89.0f, liohsdafg);
else liohsdafg = original_pitch;
return liohsdafg;
}
else
return original_pitch;
}