-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
#include "animation_system.h"
#include "..\ragebot\aim.h"
std::string ResolverMode[65];
float resolver::get_angle(player_t* player) {
return math::NormalizedAngle(player->m_angEyeAngles().y);
}
float resolver::get_backward_yaw(player_t* player) {
return math::calculate_angle(g_ctx.local()->m_vecOrigin(), player->m_vecOrigin()).y;
}
float resolver::get_forward_yaw(player_t* player) {
return math::NormalizedAngle(get_backward_yaw(player) - 180.f);
}
bool CanSeeHitbox(player_t* entity, int HITBOX) {
return g_ctx.local()->CanSeePlayer(entity, entity->hitbox_position(HITBOX));
}
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;
safe_matrix_shot = false;
freestand_side = false;
was_first_bruteforce = false;
was_second_bruteforce = false;
original_goal_feet_yaw = 0.0f;
original_pitch = 0.0f;
}
bool resolver::desync_detect()
{
if (!player->is_alive())
return false;
if (~player->m_fFlags() & FL_ONGROUND)
return false;
if (~player->m_iTeamNum() == g_ctx.local()->m_iTeamNum())
return false;
if (!player->m_hActiveWeapon().Get()->can_fire(true))
return false;
if (player->get_move_type() == MOVETYPE_NOCLIP
|| player->get_move_type() == MOVETYPE_LADDER)
return false;
return true;
}
bool resolver::DoesHaveJitter(player_t* player, int* new_side)
{
static float LastAngle[64];
static int LastBrute[64];
static bool Switch[64];
static float LastUpdateTime[64];
if (!math::IsNearEqual(player->m_angEyeAngles().y, LastAngle[player->EntIndex()], 60.f))
{
Switch[player->EntIndex()] = !Switch[player->EntIndex()];
LastAngle[player->EntIndex()] = player->m_angEyeAngles().y;
*new_side = Switch[player->EntIndex()] ? 1 : -1;
LastBrute[player->EntIndex()] = *new_side;
LastUpdateTime[player->EntIndex()] = m_globals()->m_curtime;
return true;
}
else
{
if (fabsf(LastUpdateTime[player->EntIndex()] - m_globals()->m_curtime >= TICKS_TO_TIME(17)) || player->m_flSimulationTime() != player->m_flOldSimulationTime())
LastAngle[player->EntIndex()] = player->m_angEyeAngles().y;
*new_side = LastBrute[player->EntIndex()];
}
return false;
}
void resolver::antifreestand()
{
if (!g_ctx.local()->is_alive())
return;
if (!g_ctx.globals.weapon->IsGun())
return;
if (g_cfg.ragebot.desync_correction)
return;
for (int i = 1; i < m_engine()->GetMaxClients(); ++i)
{
auto player = static_cast<player_t*>(m_entitylist()->GetClientEntity(i));
if (!player || !player->is_alive() || player->IsDormant() || !player->is_player() || player->m_iTeamNum() == g_ctx.local()->m_iTeamNum() || player->EntIndex() == m_engine()->GetLocalPlayer())
continue;
float angToLocal = math::calculate_angle(g_ctx.local()->m_vecOrigin(), player->m_vecOrigin()).y;
Vector ViewPoint = g_ctx.local()->m_vecOrigin() + Vector(0, 0, 90);
Vector2D Side1 = { (45 * sin(DEG2RAD(angToLocal))),(45 * cos(DEG2RAD(angToLocal))) };
Vector2D Side2 = { (45 * sin(DEG2RAD(angToLocal + 180))) ,(45 * cos(DEG2RAD(angToLocal + 180))) };
Vector2D Side3 = { (60 * sin(DEG2RAD(angToLocal))),(60 * cos(DEG2RAD(angToLocal))) };
Vector2D Side4 = { (60 * sin(DEG2RAD(angToLocal + 180))) ,(60 * cos(DEG2RAD(angToLocal + 180))) };
Vector Origin = player->m_vecOrigin();
Vector2D OriginLeftRight[] = { Vector2D(Side1.x, Side1.y), Vector2D(Side2.x, Side2.y) };
Vector2D OriginLeftRightLocal[] = { Vector2D(Side3.x, Side3.y), Vector2D(Side4.x, Side4.y) };
for (int side = 0; side < 2; side++)
{
Vector OriginAutowall = { Origin.x + OriginLeftRight[side].x, Origin.y - OriginLeftRight[side].y , Origin.z + 90 };
Vector ViewPointAutowall = { ViewPoint.x + OriginLeftRightLocal[side].x, ViewPoint.y - OriginLeftRightLocal[side].y , ViewPoint.z };
if (autowall::get().can_hit_floating_point(OriginAutowall, ViewPoint))
{
if (side == 0)
{
freestand_side = true;
}
else if (side == 1)
{
freestand_side = false;
}
}
else
{
for (int sidealternative = 0; sidealternative < 2; sidealternative++)
{
Vector ViewPointAutowallalternative = { Origin.x + OriginLeftRight[sidealternative].x, Origin.y - OriginLeftRight[sidealternative].y , Origin.z + 90 };
if (autowall::get().can_hit_floating_point(ViewPointAutowallalternative, ViewPointAutowall))
{
if (sidealternative == 0)
{
freestand_side = true;
}
else if (sidealternative == 1)
{
freestand_side = false;
}
}
}
}
}
}
}
void resolver::resolve_yaw()
{
player_info_t player_info;
auto animstate = player->get_animation_state();
if (!m_engine()->GetPlayerInfo(player->EntIndex(), &player_info))
return;
safe_matrix_shot = animstate->m_velocity > 180.0f;
if (!animstate || !desync_detect() || !g_cfg.ragebot.desync_correction)
{
player_record->side = RESOLVER_ORIGINAL;
return;
}
animstate->m_flGoalFeetYaw = get_angle(player);
if (!g_cfg.ragebot.enable)
{
shot_resolver();
return;
}
if (!g_ctx.local()->is_alive())
return;
if (player_info.fakeplayer || !g_ctx.local()->is_alive() || player->m_iTeamNum() == g_ctx.local()->m_iTeamNum() || player_record->shot || player->get_move_type() == MOVETYPE_LADDER || player->get_move_type() == MOVETYPE_NOCLIP)
{
player_record->side = RESOLVER_ORIGINAL;
return;
}
if (!(player->m_fFlags() & FL_ONGROUND))
return;
float angle = get_angle(player);
int new_side = -1;
auto delta = math::normalize_yaw(player->m_angEyeAngles().y - resolver_goal_feet_yaw[0]);
bool forward = fabsf(math::normalize_yaw(get_angle(player) - get_forward_yaw(player))) < 90.f;
bool low_delta = false;
auto first_side = low_delta ? RESOLVER_LOW_FIRST : RESOLVER_FIRST;
auto second_side = low_delta ? RESOLVER_LOW_SECOND : RESOLVER_SECOND;
auto low_first_side = RESOLVER_LOW_FIRST;
auto low_second_side = RESOLVER_LOW_SECOND;
auto valid_lby = true;;
if (animstate->m_velocity > 0.1f || fabs(animstate->flUpVelocity) > 100.f)
valid_lby = animstate->m_flTimeSinceStartedMoving < 0.22f;
bool ducking = animstate->m_fDuckAmount && player->m_fFlags() & FL_ONGROUND && !animstate->m_bInHitGroundAnimation;
if (fabs(delta) > 35.0f && valid_lby || player->m_vecVelocity().Length() >= player->GetMaxPlayerSpeed() && ducking || player->m_vecVelocity().Length() >= player->GetMaxPlayerSpeed() && !ducking)
{
if (player->m_fFlags() & FL_ONGROUND || player->m_vecVelocity().Length2D() <= 2.0f)
{
if (player->sequence_activity(player_record->layers[3].m_nSequence) == 979)
if (g_ctx.globals.missed_shots[player->EntIndex()])
delta = -delta;
else
player_record->side = delta > 0 ? first_side : second_side;
}
}
else
{
if (valid_lby && !((int)player_record->layers[ANIMATION_LAYER_LEAN].m_flWeight * 1000.f) && ((int)player_record->layers[ANIMATION_LAYER_MOVEMENT_MOVE].m_flWeight * 1000.f) == ((int)previous_layers[ANIMATION_LAYER_MOVEMENT_MOVE].m_flWeight * 1000.f))
{
float processedAnimationSpeed = abs(player_record->layers[ANIMATION_LAYER_MOVEMENT_MOVE].m_flPlaybackRate - resolver_layers[0][ANIMATION_LAYER_MOVEMENT_MOVE].m_flPlaybackRate);
float positiveAnimationSpeed = abs(player_record->layers[ANIMATION_LAYER_MOVEMENT_MOVE].m_flPlaybackRate - resolver_layers[1][ANIMATION_LAYER_MOVEMENT_MOVE].m_flPlaybackRate);
float negativeAnimationSpeed = abs(player_record->layers[ANIMATION_LAYER_MOVEMENT_MOVE].m_flPlaybackRate - resolver_layers[2][ANIMATION_LAYER_MOVEMENT_MOVE].m_flPlaybackRate);
if (processedAnimationSpeed < positiveAnimationSpeed || negativeAnimationSpeed <= positiveAnimationSpeed || (signed int)(float)(positiveAnimationSpeed * 1000.0))
{
if (processedAnimationSpeed >= negativeAnimationSpeed && positiveAnimationSpeed > negativeAnimationSpeed && !(signed int)(float)(negativeAnimationSpeed * 1000.0))
{
player_record->type = ANIMATION;
player_record->side = first_side;
}
else
{
if (forward)
{
player_record->type = DIRECTIONAL;
player_record->side = freestand_side ? second_side : first_side;
}
else
{
player_record->type = DIRECTIONAL;
player_record->side = freestand_side ? first_side : second_side;
}
}
}
else
{
player_record->type = ANIMATION;
player_record->side = second_side;
}
}
else
{
if (m_globals()->m_curtime - lock_side > 2.0f)
{
auto first_visible = util::visible(g_ctx.globals.eye_pos, player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.first), player, g_ctx.local());
auto second_visible = util::visible(g_ctx.globals.eye_pos, player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.second), player, g_ctx.local());
if (first_visible != second_visible)
{
freestand_side = true;
side = second_visible;
lock_side = m_globals()->m_curtime;
}
else
{
auto first_position = g_ctx.globals.eye_pos.DistTo(player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.first));
auto second_position = g_ctx.globals.eye_pos.DistTo(player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.second));
if (fabs(first_position - second_position) > 1.0f)
side = first_position > second_position;
}
}
else
freestand_side = true;
if (forward)
{
player_record->type = DIRECTIONAL;
player_record->side = freestand_side ? second_side : first_side;
}
else
{
player_record->type = DIRECTIONAL;
player_record->side = freestand_side ? first_side : second_side;
}
}
}
static auto get_rotated_pos = [](Vector start, float rotation, float distance)
{
float rad = DEG2RAD(rotation);
start.x += cos(rad) * distance;
start.y += sin(rad) * distance;
return start;
};
bool CurrentSideIsSafe = !util::visible(g_ctx.globals.eye_pos, player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.first), player, g_ctx.local());
c_baseplayeranimationstate* AnimState = player->get_animation_state();
float Vector2d = player->m_vecVelocity().Length2D();
bool AdjustmentBalance = player->m_nSequence() == 979 ? true : false;
Vector Angle = math::calculate_angle(g_ctx.globals.eye_pos, player->hitbox_position(HITBOX_HEAD));
Vector PosRight = get_rotated_pos(player->hitbox_position(HITBOX_HEAD), Angle.y, 60.f);
Vector PosLeft = get_rotated_pos(player->hitbox_position(HITBOX_HEAD), Angle.y, -60.f);
const auto WallRight = autowall::get().wall_penetration(g_ctx.globals.eye_pos, PosRight, g_ctx.local());
const auto WallLeft = autowall::get().wall_penetration(g_ctx.globals.eye_pos, PosLeft, g_ctx.local());
if (WallRight.valid && WallLeft.valid)
{
side = WallRight.damage > WallLeft.damage ? 1 : -1;
if (CurrentSideIsSafe)
{
side = WallRight.damage > WallLeft.damage ? -1 : 1;
}
}
float Delta = AdjustmentBalance ? 127 : player->get_max_desync_delta();
AnimState->m_flGoalFeetYaw += Delta * side;
player_record->side == side;
if (player->m_vecVelocity().Length2D() > player->GetMaxPlayerSpeed() || ~player->m_fFlags() & FL_ONGROUND)
player_record->side = RESOLVER_ORIGINAL;
//else if (g_ctx.globals.missed_shots[player->EntIndex()] == 0)
// player_record->side = RESOLVER_SECOND;
else if (g_ctx.globals.missed_shots[player->EntIndex()] >= 0)
{
if (DoesHaveJitter(player, &new_side) && player->m_angEyeAngles().x < 45)
{
switch (g_ctx.globals.missed_shots[player->EntIndex()] % 2)
{
case 0:
ResolverMode[player->EntIndex()] = "DETECT JITTER";
animstate->m_flGoalFeetYaw = math::normalize_yaw(angle - 90.f * freestand_side);
break;
case 1:
ResolverMode[player->EntIndex()] = "DETECT JITTER";
animstate->m_flGoalFeetYaw = math::normalize_yaw(angle + 90.f * freestand_side);
break;
}
}
}
if (g_ctx.globals.missed_shots[player->EntIndex()] >= 0)
{
ResolverMode[player->EntIndex()] = "C";
if (forward)
{
freestand_side *= -1;
ResolverMode[player->EntIndex()] += "B";
}
else
ResolverMode[player->EntIndex()] += "A";
animstate->m_flGoalFeetYaw = math::normalize_yaw(angle - second_side * freestand_side);
}
else if (g_ctx.globals.missed_shots[player->EntIndex()] >= 0 || g_ctx.globals.missed_shots[player->EntIndex()] && aim::get().last_target[player->EntIndex()].record.type != LBY && aim::get().last_target[player->EntIndex()].record.type != JITTER)
{
if (forward)
{
switch (g_ctx.globals.missed_shots[player->EntIndex()] % 2)
{
case 0:
ResolverMode[player->EntIndex()] = "SECOND";
if (freestand_side == 1)
animstate->m_flGoalFeetYaw = math::normalize_yaw(angle - second_side);
else
animstate->m_flGoalFeetYaw = math::normalize_yaw(angle + first_side);
break;
case 1:
ResolverMode[player->EntIndex()] = "LOW";
if (freestand_side == 1)
animstate->m_flGoalFeetYaw = math::normalize_yaw(angle - low_second_side);
else
animstate->m_flGoalFeetYaw = math::normalize_yaw(angle + low_first_side);
break;
}
}
else
{
switch (g_ctx.globals.missed_shots[player->EntIndex()] % 2)
{
case 0:
ResolverMode[player->EntIndex()] = "FIRST";
if (freestand_side == 1)
animstate->m_flGoalFeetYaw = math::normalize_yaw(angle + first_side);
else
animstate->m_flGoalFeetYaw = math::normalize_yaw(angle - second_side);
break;
case 1:
ResolverMode[player->EntIndex()] = "LOW";
if (freestand_side == 1)
animstate->m_flGoalFeetYaw = math::normalize_yaw(angle + low_first_side);
else
animstate->m_flGoalFeetYaw = math::normalize_yaw(angle - low_second_side);
break;
}
}
}
// ghetto way
auto choked = TIME_TO_TICKS(player->m_flSimulationTime() - player->m_flOldSimulationTime());
// if his pitch down, or he is choking or we already hitted in desync, we can say that he might use desync
if (fabs(original_pitch) > 85.f || choked >= 1)
fake = true;
else if (!fake && !g_ctx.globals.missed_shots[player->EntIndex()])
{
player_record->type = ORIGINAL;
return;
}
if (g_ctx.globals.missed_shots[player->EntIndex()] == 0)
player_record->side = RESOLVER_ORIGINAL;
animstate->m_flGoalFeetYaw = math::normalize_yaw(animstate->m_flGoalFeetYaw);
}
void resolver::shot_resolver()
{
bool m_shot;
float m_flLastShotTime;
m_flLastShotTime = player->m_hActiveWeapon() ? player->m_hActiveWeapon()->m_fLastShotTime() : 0.f;
m_shot = m_flLastShotTime > player->m_flOldSimulationTime() && m_flLastShotTime <= player->m_flSimulationTime();
if (m_flLastShotTime <= player->m_flSimulationTime() && m_shot)
{
player_record->side = RESOLVER_ORIGINAL;
return;
};
}
float resolver::resolve_pitch()
{
return original_pitch;
}