animside on move via layers:
int resolver::detect_side_moving( lag_record_t* current, lag_record_t* previous )
{
if ( current->m_velocity.Length2D() <= 1.f )
{
if ( current->m_lagamt <= 1 )
return 0;
const auto strafe_weight = current->m_layers[ 7 ].m_flWeight;
const auto lean_weight = current->m_layers[ 12 ].m_flWeight;
if ( fabsf( strafe_weight ) < 0.001f )
{
if ( lean_weight < -0.001f )
return -1;
if ( lean_weight > 0.001f )
return 1;
return 0;
}
}
if ( !previous )
return 0;
const auto strafe_weight = current->m_layers[ 7 ].m_flWeight;
if ( fabsf( strafe_weight ) < 0.001f )
{
const auto lean_weight = current->m_layers[ 12 ].m_flWeight;
if ( lean_weight < -0.001f )
return -1;
if ( lean_weight > 0.001f )
return 1;
return 0;
}
const auto layer6_weight_cur = current->m_layers[ 6 ].m_flWeight;
const auto layer6_weight_prev = previous->m_layers[ 6 ].m_flWeight;
const auto accelerating = static_cast< int >( layer6_weight_cur * 1000.f ) == static_cast< int >( layer6_weight_prev * 1000.f );
if ( !accelerating || static_cast< int >( current->m_layers[ 12 ].m_flWeight * 1000.f ) != 0 )
return 0;
const auto current_playback = current->m_layers[ 6 ].m_flPlaybackRate;
auto best_dir = 0;
auto best_diff = std::numeric_limits< float >::max();
const auto diff_max = fabsf( current->m_state[ resolver_direction::resolver_max ].m_own_layers[ 6 ].m_flPlaybackRate - current_playback );
const auto diff_min = fabsf( current->m_state[ resolver_direction::resolver_min ].m_own_layers[ 6 ].m_flPlaybackRate - current_playback );
if ( diff_max < diff_min )
{
best_dir = 1;
best_diff = diff_max;
}
else
{
best_dir = -1;
best_diff = diff_min;
}
if ( diff_max < 0.000001f )
return 1;
if ( diff_min < 0.000001f )
return -1;
if ( best_diff < std::numeric_limits< float >::max() )
return best_dir;
return 0;
}
get desync amount via layer 6:
float resolver::detect_desync_amount( lag_record_t* record, lag_record_t* previous )
{
if ( record->m_shot || ( previous && previous->m_shot ) )
return 0.f;
const auto player = globals::get_player( record->m_index );
if ( !player )
return 0.f;
const auto state = player->get_anim_state();
if ( !state )
return 0.f;
const auto weight = record->m_layers[ 6 ].m_flWeight;
const auto standing = weight == 0.f;
auto max_desync = 58.f;
if ( state->aim_yaw_max > 0.f )
max_desync = state->aim_yaw_max;
if ( max_desync > 60.f )
max_desync = 60.f;
const auto speed = record->m_velocity.Length2D();
const auto max_run_speed = 260.f;
if ( speed > 1.f )
{
const auto speed_ratio = clamp( speed / max_run_speed, 0.f, 1.f );
const auto dynamic_max = max_desync - ( max_desync - 29.f ) * speed_ratio;
return standing ? 0.f : clamp( ( 1.f - weight ) * 10000.f, 0.f, dynamic_max );
}
return standing ? 0.f : clamp( ( 1.f - weight ) * 10000.f, 0.f, max_desync );
}
max out desync at stand:
float resolver::detect_desync_amount_standing( lag_record_t* record )
{
const auto player = globals::get_player( record->m_index );
if ( !player )
return 58.f;
const auto state = player->get_anim_state();
if ( !state )
return 58.f;
auto max_desync = 58.f;
if ( state->aim_yaw_max > 0.f )
max_desync = state->aim_yaw_max;
if ( max_desync > 60.f )
max_desync = 60.f;
return max_desync;
}
resolve stand via lagrecords:
void resolver::use_lagrecords_for_standing( lag_record_t* record, lag_record_t* previous )
{
auto& log = player_log::get_log( record->m_index );
const auto weight = record->m_layers[ 6 ].m_flWeight;
const auto standing = weight == 0.f;
if ( !standing )
return;
if ( previous && !previous->m_extrapolated )
{
const auto side = detect_side_moving( record, previous );
if ( side != 0 )
{
record->m_resolver_side = side == -1 ? resolver_side::resolver_left : resolver_side::resolver_right;
record->m_resolved_desync = detect_desync_amount_standing( record );
return;
}
if ( previous->m_velocity.Length2D() > 1.f )
{
const auto prev_weight = previous->m_layers[ 6 ].m_flWeight;
if ( prev_weight > 0.f )
{
const auto prev_max = detect_desync_amount_standing( record );
record->m_resolved_desync = clamp( ( 1.f - prev_weight ) * 10000.f, 0.f, prev_max );
return;
}
}
}
record->m_resolved_desync = detect_desync_amount_standing( record );
}
resolve lby breaker via 3rd layer weight cycle sequence:
void resolver::resolve_opposite_lby( lag_record_t* record )
{
const auto& adjust_layer = record->m_layers[ 3 ];
if ( adjust_layer.m_flWeight != 0.f || adjust_layer.m_flCycle != 0.f )
return;
if ( adjust_layer.m_nSequence != 979 )
return;
record->m_resolved_desync = -record->m_resolved_desync;
record->m_resolver_side = record->m_resolver_side == resolver_side::resolver_left
? resolver_side::resolver_right
: resolver_side::resolver_left;
}
rebuild setupvelocity for accurate resolving via MOVEMENT_MOVE layer:
void animations::setup_velocity( CCSGOPlayerAnimState* state, C_CSPlayer* player )
{
if ( !state || !player )
return;
const auto weapon = globals::get_weapon( player->get_active_weapon() );
state->weapon = weapon;
state->last_weapon = weapon;
Vector velocity = player->get_velocity();
if ( fabsf( velocity.x ) < 0.001f )
velocity.x = 0.f;
if ( fabsf( velocity.y ) < 0.001f )
velocity.y = 0.f;
if ( fabsf( velocity.z ) < 0.001f )
velocity.z = 0.f;
state->speed_z = velocity.z;
velocity.z = 0.f;
state->is_accelerating = velocity.Length2DSqr() > state->velocity.Length2DSqr();
const auto delta_time = state->last_increment * 2000.f;
const auto smooth_factor = clamp( delta_time, 0.f, 1.f );
state->velocity = state->velocity * ( 1.f - smooth_factor ) + velocity * smooth_factor;
state->movement_direction = state->velocity;
const auto length = state->movement_direction.Length();
if ( length > 0.f )
state->movement_direction /= length;
state->speed = std::fmin( state->velocity.Length(), 260.f );
if ( state->speed > 0.f )
state->last_accel_speed = state->movement_direction;
float max_movement_speed = 260.f;
if ( weapon )
max_movement_speed = std::fmax( weapon->get_max_speed(), 0.001f );
const auto speed_normalized = clamp( state->speed / max_movement_speed, 0.f, 1.f );
state->running_speed = state->speed / ( max_movement_speed * 0.520f );
state->ducking_speed = state->speed / ( max_movement_speed * 0.340f );
if ( state->running_speed < 1.f )
{
if ( state->running_speed < 0.5f )
state->static_approach_speed = math::approach( 80.f, state->static_approach_speed, state->last_increment * 60.f );
}
else
{
state->static_approach_speed = state->speed;
}
bool just_stopped_moving = false;
bool just_started_moving = false;
if ( state->speed <= 0.f )
{
state->moving_time = 0.f;
just_stopped_moving = state->standing_time <= 0.f;
state->standing_time += state->last_increment;
}
else
{
state->standing_time = 0.f;
just_started_moving = state->moving_time <= 0.f;
state->moving_time += state->last_increment;
}
if ( !state->adjust_started
&& just_stopped_moving
&& state->on_ground
&& !state->on_ladder
&& !state->in_hit_ground
&& state->stutter_step < 50.f )
{
state->adjust_started = true;
}
const auto layer3_activity = player->get_anim_layers()[ 3 ].m_nSequence >= 2
? player->get_anim_layers()[ 3 ].m_nSequence : 0;
if ( state->adjust_started )
{
if ( state->ducking_speed <= 0.25f )
{
auto layer3_weight = state->feet_weight;
player->get_anim_layers()[ 3 ].m_flCycle += state->last_increment * player->get_layer_sequence_cycle_rate( &player->get_anim_layers()[ 3 ], player->get_anim_layers()[ 3 ].m_nSequence );
player->get_anim_layers()[ 3 ].m_flWeight = state->get_layer_ideal_weight_from_sequence_cycle( 3 );
player->get_anim_layers()[ 3 ].m_flWeightDeltaRate = ( player->get_anim_layers()[ 3 ].m_flWeight - layer3_weight ) / state->last_increment;
state->adjust_started = player->get_anim_layers()[ 3 ].m_flCycle < 1.f;
}
else
{
state->adjust_started = false;
player->get_anim_layers()[ 3 ].m_flWeight = math::approach( 0.f, player->get_anim_layers()[ 3 ].m_flWeight, state->last_increment * 5.f );
}
}
state->foot_yaw_last = state->foot_yaw;
state->foot_yaw = clamp( state->foot_yaw, -360.f, 360.f );
const auto eye_foot_delta = math::angle_diff( state->eye_yaw, state->foot_yaw );
const auto clamped_running_speed = clamp( state->running_speed, 0.f, 1.f );
auto yaw_modifier = ( ( state->ground_fraction * -0.3f ) - 0.2f ) * clamped_running_speed + 1.f;
if ( state->duck_amount > 0.f )
{
const auto clamped_ducking_speed = clamp( state->ducking_speed, 0.f, 1.f );
yaw_modifier += ( state->duck_amount * clamped_ducking_speed ) * ( 0.5f - yaw_modifier );
}
const auto max_yaw_modifier = yaw_modifier * state->aim_yaw_max;
const auto min_yaw_modifier = yaw_modifier * state->aim_yaw_min;
if ( eye_foot_delta <= max_yaw_modifier )
{
if ( min_yaw_modifier > eye_foot_delta )
state->foot_yaw = fabsf( min_yaw_modifier ) + state->eye_yaw;
}
else
{
state->foot_yaw = state->eye_yaw - fabsf( max_yaw_modifier );
}
math::normalize_float( state->foot_yaw );
if ( state->speed > 0.1f || fabsf( state->speed_z ) > 100.f )
{
state->foot_yaw = math::approach_angle(
state->eye_yaw,
state->foot_yaw,
( state->ground_fraction * 20.f + 30.f ) * state->last_increment );
}
else
{
state->foot_yaw = math::approach_angle(
player->get_lby(),
state->foot_yaw,
state->last_increment * 100.f );
}
if ( state->speed <= 1.f
&& state->on_ground
&& !state->on_ladder
&& !state->in_hit_ground
&& state->last_increment > 0.f
&& ( fabsf( math::angle_diff( state->foot_yaw_last, state->foot_yaw ) ) / state->last_increment ) > 120.f )
{
state->adjust_started = true;
}
if ( state->speed > 0.f )
{
const auto vel_angle = RAD2DEG( atan2f( -state->velocity.y, -state->velocity.x ) );
state->move_yaw_ideal = math::normalize_float( math::angle_diff( vel_angle, state->foot_yaw ) );
}
const auto feet_vel_dir_delta = math::normalize_float( math::angle_diff( state->move_yaw_ideal, state->move_yaw_current_to_ideal ) );
if ( just_started_moving && state->feet_weight <= 0.f )
{
state->move_yaw_current_to_ideal = state->move_yaw_ideal;
}
else
{
const auto ducking_speed_clamped = clamp( state->ducking_speed, 0.f, 1.f );
const auto running_speed_clamped = clamp( state->running_speed, 0.f, 1.f );
const auto lerped = ( ( ducking_speed_clamped - running_speed_clamped ) * state->duck_amount ) + running_speed_clamped;
const auto bias_move = clamp( lerped, 0.f, 1.f );
state->move_yaw_current_to_ideal = math::normalize_float( ( bias_move + 0.1f ) * feet_vel_dir_delta + state->move_yaw_current_to_ideal );
}
player->get_pose_params()[ 4 ] = state->move_yaw_current_to_ideal;
const auto eye_goalfeet_delta = math::angle_diff( state->eye_yaw, state->foot_yaw );
float new_body_yaw_pose = 0.f;
if ( eye_goalfeet_delta < 0.f || state->aim_yaw_max == 0.f )
{
if ( state->aim_yaw_min != 0.f )
new_body_yaw_pose = ( eye_goalfeet_delta / state->aim_yaw_min ) * -58.f;
}
else
{
new_body_yaw_pose = ( eye_goalfeet_delta / state->aim_yaw_max ) * 58.f;
}
player->get_pose_params()[ 6 ] = new_body_yaw_pose;
const auto eye_pitch_normalized = math::normalize_float( state->eye_pitch );
float new_body_pitch_pose;
if ( eye_pitch_normalized <= 0.f )
new_body_pitch_pose = ( eye_pitch_normalized / state->aim_pitch_min ) * -90.f;
else
new_body_pitch_pose = ( eye_pitch_normalized / state->aim_pitch_max ) * 90.f;
player->get_pose_params()[ 7 ] = new_body_pitch_pose;
player->get_pose_params()[ 1 ] = state->running_speed;
}
P.S. layers = best sovving teq w/o endless goshing with footyaw, dont listen to drip etc they wont help u w anything unless u pay them alot (sup immigrantFSN)
Last edited:

