-
Автор темы
- #1
Resolver.cpp:
// 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 AngleDiff(float destAngle, float srcAngle)
{
float delta;
delta = fmodf(destAngle - srcAngle, 360.0f);
if (destAngle > srcAngle)
{
if (delta >= 180)
delta -= 360;
}
else
{
if (delta <= -180)
delta += 360;
}
return delta;
}
void DetectDesyncSide(player_t* player, int m_Side)
{
//auto last_anims_update_time = player->get_animation_state()->m_last_update_time;
AnimationLayer layers[13];
AnimationLayer moveLayers[3][13];
AnimationLayer preserver_anim_layers[13];
auto speed = player->m_vecVelocity().Length2D();
if (speed < 0.1f)
{
auto delta = std::remainder(math::normalize_yaw(player->m_angEyeAngles().y - player->m_flLowerBodyYawTarget()), 360.f) <= 0.f;
if (layers[3].m_flWeight == 0.0f && layers[3].m_flCycle == 0.0f)
{
m_Side = std::clamp((2 * (delta <= 0.f) - 1), -1, 1);
}
}
else if (!int(layers[12].m_flWeight * 1000.f))
{
if (int(layers[6].m_flWeight * 1000.f) == int(layers[6].m_flWeight * 1000.f))
{
float delta1 = abs(layers[6].m_flPlaybackRate - moveLayers[0][6].m_flPlaybackRate);
float delta2 = abs(layers[6].m_flPlaybackRate - moveLayers[1][6].m_flPlaybackRate);
float delta3 = abs(layers[6].m_flPlaybackRate - moveLayers[2][6].m_flPlaybackRate);
if (delta1 < delta3 || delta2 <= delta3 || (int)(float)(delta3 * 1000.0f)) {
if (delta1 >= delta2 && delta3 > delta2 && !(int)(float)(delta2 * 1000.0f))
{
m_Side = 1;
// last_anims_update_time = interfaces.global_vars->realtime;
}
}
else
{
m_Side = -1;
//last_anims_update_time = interfaces.global_vars->realtime;
}
}
}
}
int resolver::MutinyDetectDesyncDelta(c_baseplayeranimationstate* animstate)
{
// auto animstate = player->get_animation_state();
float predictionangles = player->m_angEyeAngles().y;
math::normalize_yaw(predictionangles);
float m_flEyeYaw = player->m_angEyeAngles().y;
Vector absvelocity = player->m_vecAbsVelocity();
float m_flAbsVelocityZ = absvelocity.z;
absvelocity.z = 0.0f;
float m_flSpeed = fminf(player->m_vecVelocity().Length(), 260.0f);
float flMaxMovementSpeed = 260.0f;
if (player && player->m_hActiveWeapon())
flMaxMovementSpeed = fmaxf(player->m_hActiveWeapon()->get_csweapon_info()->flMaxPlayerSpeed, 0.001f);
float m_flRunningSpeed = m_flSpeed / (flMaxMovementSpeed * 0.520f);
float m_flDuckingSpeed = m_flSpeed / (flMaxMovementSpeed * 0.340f);
animstate->m_flCurrentFeetYaw = animstate->m_flGoalFeetYaw;
animstate->m_flGoalFeetYaw = std::clamp(animstate->m_flGoalFeetYaw, -360.0f, 360.0f);
float eye_feet_delta = AngleDiff(m_flEyeYaw, animstate->m_flGoalFeetYaw);
float flRunningSpeed = std::clamp(m_flRunningSpeed, 0.0f, 1.0f);
float flYawModifier = (((*reinterpret_cast<float*> (animstate + 0x11C) * -0.3f) - 0.2f) * m_flRunningSpeed) + 1.0f;
float flMaxYawModifier = flYawModifier * animstate->pad10[516];
float flMinYawModifier = flYawModifier * animstate->pad10[512];
float brute_force_yaw = 0;
if (eye_feet_delta <= flMaxYawModifier) {
if (flMinYawModifier > eye_feet_delta)
brute_force_yaw = fabs(flMinYawModifier) + m_flEyeYaw;
}
else {
brute_force_yaw = m_flEyeYaw - fabsf(flMaxYawModifier);
}
return brute_force_yaw;
}
int last_ticks[65];
int resolver::GetChokedPackets() {
auto ticks = TIME_TO_TICKS(player->m_flSimulationTime() - player->m_flOldSimulationTime());
if (ticks == 0 && last_ticks[player->EntIndex()] > 0) {
return last_ticks[player->EntIndex()] - 1;
}
else {
last_ticks[player->EntIndex()] = ticks;
return ticks;
}
}
bool AnimsTriggered(player_t* e)
{
auto animations = [](player_t* plr) -> bool
{
for (int i = 0; i < 13; i++)
{
const int activity = plr->sequence_activity(plr->get_animlayers()[i].m_nSequence);
if (activity == 979)
{
return true;
}
}
return false;
};
if (animations(e))
return true;
else
return false;
}
bool standing(player_t* pl)
{
const float vel = pl->m_vecVelocity().Length();
float v = vel;
if (v <= 0.1f)
return true;
else
return false;
}
bool slowwalking(player_t* pl)
{
const float vel = pl->m_vecVelocity().Length();
float v = vel;
if (v <= 80.0f && !standing(pl))
return true;
else
return false;
}
bool moving(player_t* pl)
{
const float vel = pl->m_vecVelocity().Length();
float v = vel;
if (v >= 82.0f && !standing(pl) && !slowwalking(pl))
return true;
else
return false;
}
bool isInAir(player_t* pl)
{
if (!(pl->m_fFlags() & FL_ONGROUND))
return true;
else
return false;
}
bool resolver::IsbreakingLby(player_t* pl)
{
if (AnimsTriggered(pl) && standing(pl))
return true;
else
return false;
}
bool resolver::check_jitter(int* new_side)
{
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 (!math::IsNearEqual(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::StoreAntifreestand()
{
CGameTrace trace;
CTraceFilter filter;
filter.pSkip = g_ctx.local();
auto animstate = player->get_animation_state();
float LeftSide = animstate->m_flEyeYaw - 60.0f;
float RightSide = animstate->m_flEyeYaw + 60.0f;
Vector m_vecDirectionLeft, m_vecDirectionRight;
Vector m_vecDesyncLeft(0.0f, LeftSide, 0.0f);
Vector m_vecDesyncRight(0.0f, RightSide, 0.0f);
math::angle_vectors(m_vecDesyncLeft, m_vecDirectionLeft);
math::angle_vectors(m_vecDesyncRight, m_vecDirectionRight);
const auto m_vecSrc = g_ctx.local()->get_shoot_position();
const auto m_vecLeftSrc = m_vecSrc + (m_vecDesyncLeft * 8192.f);
const auto m_vecRightSrc = m_vecSrc + (m_vecDesyncRight * 8192.f);
m_trace()->TraceRay(Ray_t(m_vecSrc, m_vecLeftSrc), MASK_ALL, (ITraceFilter*)&filter, &trace);
float m_flLeftFraction = trace.fraction;
m_trace()->TraceRay(Ray_t(m_vecSrc, m_vecRightSrc), MASK_ALL, (ITraceFilter*)&filter, &trace);
float m_flRightFraction = trace.fraction;
if (m_flLeftFraction > m_flRightFraction)
FreestandSide[player->EntIndex()] = 1;
else if (m_flLeftFraction < m_flRightFraction)
FreestandSide[player->EntIndex()] = -1;
else
FreestandSide[player->EntIndex()] = 0;
}
void resolver::resolve_yaw()
{
player_info_t player_info;
if (!m_engine()->GetPlayerInfo(player->EntIndex(), &player_info))
return;
if (!g_ctx.local()->is_alive() || player->m_iTeamNum() == g_ctx.local()->m_iTeamNum())
{
player_record->side = RESOLVER_ORIGINAL;
return;
}
auto animstate = player->get_animation_state();
if (!animstate)
{
player_record->side = RESOLVER_ORIGINAL;
return;
}
if (fabs(original_pitch) > 85.0f)
fake = true;
else if (!fake)
{
player_record->side = RESOLVER_ORIGINAL;
return;
}
static int side = 0;
int side_stored = 0;
int side_corrected = 0;
DetectDesyncSide(player, side_corrected);
side_stored = side;
side = side_corrected;
const float detect_moving_desync = player->get_max_desync_delta() * 0.5;
float moving_desync_final = detect_moving_desync;
const float detect_moving_desync2 = MutinyDetectDesyncDelta(animstate);
float moving_desync_final2 = detect_moving_desync2;
bool is_brute_forcing = false;
float stored_feet_yaw = 0.0f;
int brute_force_status = 0;
int jitter_side = 0;
bool does_have_jitter = check_jitter(&jitter_side);
int force_side_while_jittering = 1;
StoreAntifreestand();
if (does_have_jitter) {
side = FreestandSide[player->EntIndex()]; // jitter rozpierdala detekcje z animlayerow ಠ_ಠ
}
if (!is_brute_forcing && brute_force_status == 0) {
if (standing(player))
{
if (IsbreakingLby(player))
{
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y + (58 * side));
g_ctx.resomode = animstate->m_flGoalFeetYaw;
}
else {
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y + (28 * side));
g_ctx.resomode = animstate->m_flGoalFeetYaw;
}
}
else if (moving(player)) {
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y + (moving_desync_final * side));
g_ctx.resomode = animstate->m_flGoalFeetYaw;
}
else if (slowwalking(player)) {
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y + (23 * side));
g_ctx.resomode = animstate->m_flGoalFeetYaw;
}
else if (isInAir(player)) {
animstate->m_flGoalFeetYaw = moving_desync_final2;
g_ctx.resomode = animstate->m_flGoalFeetYaw;
}
}
if (brute_force_status == 4) {
animstate->m_flGoalFeetYaw = player->m_angEyeAngles().y + (player->get_max_desync_delta() * FreestandSide[player->EntIndex()]);
g_ctx.resomode = animstate->m_flGoalFeetYaw;
}
else if (brute_force_status == 5) {
animstate->m_flGoalFeetYaw = player->m_angEyeAngles().y + (moving_desync_final * FreestandSide[player->EntIndex()]);
g_ctx.resomode = animstate->m_flGoalFeetYaw;
}
else if (brute_force_status == 6) {
animstate->m_flGoalFeetYaw = player->m_angEyeAngles().y + (math::random_int(60, -60) * FreestandSide[player->EntIndex()]); // bruh
g_ctx.resomode = animstate->m_flGoalFeetYaw;
}
stored_feet_yaw = animstate->m_flGoalFeetYaw;
if (!does_have_jitter) {
switch (g_ctx.globals.missed_shots[player->EntIndex()] % 4)
{
case 1:
side *= -1; //inverse side detect
is_brute_forcing = false;
brute_force_status = 0;
break;
case 2:
brute_force_status += 1;
is_brute_forcing = true;
animstate->m_flGoalFeetYaw = moving_desync_final2;
g_ctx.resomode = animstate->m_flGoalFeetYaw;
break;
case 3:
is_brute_forcing = true;
brute_force_status = 1;
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y);
g_ctx.resomode = animstate->m_flGoalFeetYaw;
break;
}
}
else {
switch (g_ctx.globals.missed_shots[player->EntIndex()] % 2)
{
case 1:
brute_force_status = 4;
break;
case 2:
brute_force_status = 5;
break;
case 3:
brute_force_status = 6;
break;
}
}
if (!g_ctx.local()->is_alive())
brute_force_status = 0;
float goal_feet_yaw = player->m_angEyeAngles().y + stored_feet_yaw;
if (brute_force_status == 1)
side = side_stored;
else if (brute_force_status == 2)
player->set_abs_angles(Vector(0.f, goal_feet_yaw, player->m_angEyeAngles().z + 90.f)); // kys
auto delta = math::normalize_yaw(player->m_angEyeAngles().y - original_goal_feet_yaw);
auto valid_lby = true;
if (animstate->m_velocity > 0.1f || fabs(animstate->flUpVelocity) > 100.f)
valid_lby = animstate->m_flTimeSinceStartedMoving < 0.22f;
if (!player->m_bDucking() && player->m_bIsWalking() && player->is_alive() && player->m_iHealth() < 80)
{
g_ctx.globals.canfreestand = true;
}
else {
g_ctx.globals.canfreestand = false;
}
}
float resolver::resolve_pitch()
{
return original_pitch;
}
Последнее редактирование: