Jump to content

source Real Animation Fix


KATE
 Share

Recommended Posts

C++

void c_animations::local::correct_client_anims() {
    if (!cheat::local || !cheat::local->alive())
        return;
 
    sdk::c_animstate* animstate = cheat::local->animstate();
 
    if (!animstate)
        return;
 
    // Backing up current values for restoring later.
    float old_curtime = cheat::globals->curtime, old_frametime = cheat::globals->frametime;
 
    // Resimulate recent commands to refresh the data for animstate.
    cheat::prediction->run_command(cheat::vars::local_cmd);
 
    // Syncing our predicted current time with the server.
    cheat::globals->curtime = cheat::globals->realtime * cheat::local->anim_layer(0).m_flWeight;
 
    // Fixes local player legs on moving
    if (cheat::local->OnGround()) {
        cheat::local->anim_layer(6).m_flWeight = 0.f;
        cheat::local->poseparam(ePoses::MOVE_YAW ) = 1.f / cheat::local->simulationtime();
    }
    // Fixes the client fucking up frametime under certain conditions.
    cheat::globals->frametime = ((cheat::globals->curtime % 2.f) == 0.f) ?
        (cheat::local->poseparam(ePoses::BODY_YAW ) * cheat::globals->tick_interval) :
        (cheat::local->tickbase() * cheat::globals->tick_interval);
 
    float corrected_abs_yaw = animstate->old_absyaw;
 
    // Always negate the old position.
    if (corrected_abs_yaw > 0.f)
        corrected_abs_yaw *= -1.f;
 
    // The clients abs yaw is desynced when the yaw is at a certain position at a certain time.
    // We correct it by negating the old value which is negated when required, to mimic server functionality.
    if ((cheat::local->eye_angles().yaw >= -45.f && cheat::local->eye_angles().yaw <= 45.f) && ((cheat::globals->curtime % 2.f) == 0.f))
        cheat::local->set_abs_angles(sdk::angle_t(0.f, animstate->abs_yaw - corrected_abs_yaw, 0.f));
 
    // Rebuilding bones with corrected values, we'll need to do this twice.
    // Once here, and once after updating bones. This is to maintain correct shootpos.
    sdk::c_matrix3x4 temp_matrix[126];
    local->setup_bones(cheat::globals->curtime, 0x00000100, temp_matrix, sizeof(ccsgo_player_animstate));
 
    // Forcing the client to update anims under all circumstances.
    animstate->last_update_framecount = 0.f;
 
    // Update clientside anims.
    cheat::local->client_anims = true;
    cheat::local->update_client_anims();
    cheat::local->client_anims = false;
 
    // Explained above.
    local->setup_bones(cheat::globals->curtime, 0x00000100, temp_matrix, 126);
 
    // Restore values to not mess with the game.
    cheat::globals->curtime = old_curtime;
    cheat::globals->frametime = old_frametime;
}

RAW Paste Data:

void c_animations::local::correct_client_anims() {
	if (!cheat::local || !cheat::local->alive())
		return;
 
	sdk::c_animstate* animstate = cheat::local->animstate();
 
	if (!animstate)
		return;
 
	// Backing up current values for restoring later.
	float old_curtime = cheat::globals->curtime, old_frametime = cheat::globals->frametime;
 
	// Resimulate recent commands to refresh the data for animstate.
	cheat::prediction->run_command(cheat::vars::local_cmd);
 
	// Syncing our predicted current time with the server.
	cheat::globals->curtime = cheat::globals->realtime * cheat::local->anim_layer(0).m_flWeight;
 
	// Fixes local player legs on moving
	if (cheat::local->OnGround()) {
		cheat::local->anim_layer(6).m_flWeight = 0.f;
		cheat::local->poseparam(ePoses::MOVE_YAW ) = 1.f / cheat::local->simulationtime();
	}
	// Fixes the client fucking up frametime under certain conditions.
	cheat::globals->frametime = ((cheat::globals->curtime % 2.f) == 0.f) ?
		(cheat::local->poseparam(ePoses::BODY_YAW ) * cheat::globals->tick_interval) :
		(cheat::local->tickbase() * cheat::globals->tick_interval);
 
	float corrected_abs_yaw = animstate->old_absyaw;
 
	// Always negate the old position.
	if (corrected_abs_yaw > 0.f)
		corrected_abs_yaw *= -1.f;
 
	// The clients abs yaw is desynced when the yaw is at a certain position at a certain time.
	// We correct it by negating the old value which is negated when required, to mimic server functionality.
	if ((cheat::local->eye_angles().yaw >= -45.f && cheat::local->eye_angles().yaw <= 45.f) && ((cheat::globals->curtime % 2.f) == 0.f))
		cheat::local->set_abs_angles(sdk::angle_t(0.f, animstate->abs_yaw - corrected_abs_yaw, 0.f));
 
	// Rebuilding bones with corrected values, we'll need to do this twice.
	// Once here, and once after updating bones. This is to maintain correct shootpos.
	sdk::c_matrix3x4 temp_matrix[126];
	local->setup_bones(cheat::globals->curtime, 0x00000100, temp_matrix, sizeof(ccsgo_player_animstate));
 
	// Forcing the client to update anims under all circumstances.
	animstate->last_update_framecount = 0.f;
 
	// Update clientside anims.
	cheat::local->client_anims = true;
	cheat::local->update_client_anims();
	cheat::local->client_anims = false;
 
	// Explained above.
	local->setup_bones(cheat::globals->curtime, 0x00000100, temp_matrix, 126);
 
	// Restore values to not mess with the game.
	cheat::globals->curtime = old_curtime;
	cheat::globals->frametime = old_frametime;
}

pastebin:

 

  • Like 11
Link to comment
Share on other sites

  • 3 months later...
  • 1 year later...
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...