inline vec3_t get_hitbox_pos( c_cs_player* player, matrix3x4_t* mat, int hitbox_id )
{
if ( !player )
return vec3_t( );
auto hdr = HACKS->model_info->get_studio_model( player->get_model( ) );
if ( !hdr )
return vec3_t( );
auto hitbox_set = hdr->hitbox_set( player->hitbox_set( ) );
if ( !hitbox_set )
return vec3_t( );
auto hitbox = hitbox_set->hitbox( hitbox_id );
if ( !hitbox )
return vec3_t( );
vec3_t min, max;
math::vector_transform( hitbox->min, mat[ hitbox->bone ], min );
math::vector_transform( hitbox->max, mat[ hitbox->bone ], max );
return ( min + max ) * 0.5f;
}
inline float_t max_yaw_modifier( c_cs_player* enemy )
{
auto animstate = enemy->animstate( );
if ( !animstate )
return 0.0f;
auto speedfactor = std::clamp( animstate->speed_as_portion_of_run_top_speed, 0.0f, 1.0f );
auto avg_speedfactor = ( animstate->speed_as_portion_of_walk_top_speed * -0.3f - 0.2f ) * speedfactor + 1.0f;
auto duck_amount = animstate->anim_duck_amount;
if ( duck_amount )
{
auto max_velocity = std::clamp( animstate->speed_as_portion_of_run_top_speed, 0.0f, 1.0f );
auto duck_speed = duck_amount * max_velocity;
avg_speedfactor += duck_speed * ( 0.5f - avg_speedfactor );
}
return animstate->get_max_rotation( ) * avg_speedfactor;
}
inline void prepare_side(c_cs_player* player, anim_record_t* current, anim_record_t* last)
{
auto& info = resolver_info[player->index()];
if (!HACKS->weapon_info || !HACKS->local || !HACKS->local->is_alive() || player->is_bot() || !g_cfg.rage.resolver)
{
if (info.resolved)
info.reset();
return;
}
auto state = player->animstate();
if (!state)
{
if (info.resolved)
info.reset();
return;
}
auto hdr = player->get_studio_hdr();
if (!hdr)
return;
if (current->choke < 2)
info.add_legit_ticks();
else
info.add_fake_ticks();
if (info.is_legit())
{
info.resolved = false;
info.mode = XOR("no fake");
return;
}
prepare_jitter(player, info, current);
auto choked = abs( TIME_TO_TICKS( player->sim_time( ) - player->old_sim_time( ) ) - 1 );
int playerint = player->index( );
float new_body_yaw_pose = 0.0f;
auto m_flCurrentFeetYaw = state->abs_yaw;
auto m_flGoalFeetYaw = state->foot_lerp;
auto m_flEyeYaw = state->eye_yaw;
float flMaxYawModifier = max_yaw_modifier( player );
float flMinYawModifier = state->get_min_rotation( );
auto anglesy = math::normalize_yaw( player->eye_angles( ).y - state->abs_yaw );
auto valid_lby = true;
auto speed = player->velocity( ).length_2d( );
float m_lby = player->lower_body_yaw( ) * 0.574f;
auto player_stand = player->velocity( ).length_2d( );
player_stand = 0.f;
float m_flLastClientSideAnimationUpdateTimeDelta = 0.0f;
auto trace = false;
auto v54 = state->anim_duck_amount;
auto v55 = ( ( ( ( *( float* )( ( uintptr_t )state + 0x11C ) ) * -0.30000001 ) - 0.19999999 ) * state->static_approach_speed ) + 1.0f;
bool bWasMovingLastUpdate = false;
bool bJustStartedMovingLastUpdate = false;
auto unknown_velocity = *( float* )( uintptr_t( state ) + 0x2A4 );
auto first_matrix = current->matrix_left.matrix;
auto second_matrix = current->matrix_right.matrix;
auto central_matrix = current->matrix_zero.matrix;
auto leftPose = get_hitbox_pos( player, first_matrix, HITBOX_HEAD );
auto rightPose = get_hitbox_pos( player, second_matrix, HITBOX_HEAD );
auto centralPose = get_hitbox_pos( player, central_matrix, HITBOX_HEAD );
auto fire_first = penetration::simulate( HACKS->local, player, HACKS->local->get_eye_position( ), player->get_hitbox_position( HITBOX_HEAD, first_matrix ) );
auto fire_second = penetration::simulate( HACKS->local, player, HACKS->local->get_eye_position( ), player->get_hitbox_position( HITBOX_HEAD, second_matrix ) );
auto fire_third = penetration::simulate( HACKS->local, player, HACKS->local->get_eye_position( ), player->get_hitbox_position( HITBOX_HEAD, central_matrix ) );
static const float resolve_list[ 3 ] = { 0.f, player->eye_angles( ).y + state->get_max_rotation( ), player->eye_angles( ).y - state->get_max_rotation( ) };
int missed_player = player->index( );
auto delta = math::angle_diff( state->abs_yaw, state->eye_yaw );
int i = player->index( );
c_animation_layers layers[ 13 ];
c_animation_layers movelayers[ 3 ][ 13 ];
memcpy( layers, player->animlayers( ), sizeof( c_animation_layers ) );
if ( RAGEBOT->missed_shots[ i ] > 2 )
{
state->abs_yaw = math::normalize_yaw( player->eye_angles( ).y + resolve_list[ RAGEBOT->missed_shots[ i ] % 3 ] );
}
if ( player->flags( ).has( FL_ONGROUND ) )
{
if ( speed <= 1.f || current->layers[ 3 ].weight == layers[ 3 ].weight )
{
int m_side = 2 * ( m_lby > 0.f ) ? -1 : 1;
state->abs_yaw = ( player->eye_angles( ).y + 58.f ) * m_side;
if ( RAGEBOT->missed_shots[ i ] > 2 )
{
state->abs_yaw = math::normalize_yaw( player->eye_angles( ).y + resolve_list[ RAGEBOT->missed_shots[ i ] % 3 ] );
}
}
else if ( speed > 1.f && ( !( current->layers[ 12 ].weight ) && ( current->layers[ 6 ].weight == layers[ 6 ].weight ) ) )
{
float delta_rotate_first = abs( layers[ 6 ].weight - movelayers[ 0 ][ 6 ].weight );
float delta_rotate_second = abs( layers[ 6 ].weight - movelayers[ 2 ][ 6 ].weight );
float delta_rotate_third = abs( layers[ 6 ].weight - movelayers[ 1 ][ 6 ].weight );
if ( delta_rotate_first < delta_rotate_second || delta_rotate_second <= delta_rotate_third || delta_rotate_second )
{
if ( delta_rotate_first >= delta_rotate_third && delta_rotate_second > delta_rotate_third && !( delta_rotate_third ) )
{
state->abs_yaw = math::normalize_yaw( player->eye_angles( ).y + state->get_max_rotation( ) );
switch ( RAGEBOT->missed_shots[ i ] % 2 )
{
case 0:
state->abs_yaw_last = math::normalize_yaw( player->eye_angles( ).y - state->get_max_rotation( ) );
break;
case 1:
state->abs_yaw = math::normalize_yaw( player->eye_angles( ).y + resolve_list[ RAGEBOT->missed_shots[ i ] % 3 ] );
break;
default:
break;
}
}
}
else
{
state->abs_yaw = math::normalize_yaw( player->eye_angles( ).y - state->get_max_rotation( ) );
switch ( RAGEBOT->missed_shots[ i ] % 2 )
{
case 0:
state->abs_yaw = math::normalize_yaw( player->eye_angles( ).y + state->get_max_rotation( ) );
break;
case 1:
state->abs_yaw = math::normalize_yaw( player->eye_angles( ).y + resolve_list[ RAGEBOT->missed_shots[ i ] % 3 ] );
break;
default:
break;
}
}
}
}
}
inline void apply_side(c_cs_player* player, anim_record_t* current, int choke)
{
auto& info = resolver_info[player->index()];
if (!HACKS->weapon_info || !HACKS->local || !HACKS->local->is_alive() || !info.resolved || info.side == 1337 || player->is_teammate(false))
return;
auto state = player->animstate();
if (!state)
return;
switch ( info.side )
{
case -1:
{
state->abs_yaw = math::normalize_yaw( player->eye_angles( ).y - state->get_max_rotation( ) );
}
case 1:
{
state->abs_yaw = math::normalize_yaw( player->eye_angles( ).y + state->get_max_rotation( ) );
}
case 0:
{
state->abs_yaw = math::normalize_yaw( player->eye_angles( ).y );
}
}
}