Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define TICK_INTERVAL (interfaces::globals->interval_per_tick)
- #define TIME_TO_TICKS( dt ) ( (int)( 0.5f + (float)(dt) / TICK_INTERVAL ) )
- void c_animfix::fix_local_player_animations(CUserCmd * pcmd)
- {
- auto local_player = hackManager.pLocal();
- if (!local_player || !local_player->IsAlive())
- return;
- static float sim_time;
- if (sim_time != local_player->get_simulation_time())
- {
- auto state = local_player->get_animation_state();
- if (!state)
- return;
- const float curtime = interfaces::globals->curtime;
- const float frametime = interfaces::globals->frametime;
- const float realtime = interfaces::globals->realtime;
- const float absoluteframetime = interfaces::globals->absoluteframetime;
- const float absoluteframestarttimestddev = interfaces::globals->absoluteframestarttimestddev;
- const float interpolation_amount = interfaces::globals->interpolation_amount;
- const float framecount = interfaces::globals->framecount;
- const float tickcount = interfaces::globals->tickcount;
- static auto host_timescale = interfaces::cvar->FindVar(("host_timescale"));
- interfaces::globals->curtime = local_player->get_simulation_time();
- interfaces::globals->realtime = local_player->get_simulation_time(); // i'm not so sure about this
- interfaces::globals->frametime = interfaces::globals->interval_per_tick * host_timescale->GetFloat();
- interfaces::globals->absoluteframetime = interfaces::globals->interval_per_tick * host_timescale->GetFloat();
- interfaces::globals->absoluteframestarttimestddev = local_player->get_simulation_time() - interfaces::globals->interval_per_tick * host_timescale->GetFloat();
- interfaces::globals->interpolation_amount = 0;
- interfaces::globals->framecount = TIME_TO_TICKS(local_player->get_simulation_time());
- interfaces::globals->tickcount = TIME_TO_TICKS(local_player->get_simulation_time()); // is this right?
- int backup_flags = local_player->GetFlags();
- animationlayer backup_layers[15];
- std::memcpy(backup_layers, local_player->get_anim_overlays(), (sizeof(animationlayer) * 15));
- if (state->m_iLastClientSideAnimationUpdateFramecount == interfaces::globals->framecount)
- state->m_iLastClientSideAnimationUpdateFramecount = interfaces::globals->framecount - 1;
- local_player->client_side_animation() = true;
- local_player->UpdateClientSideAnimation(); // without this it won't work right
- local_player->client_side_animation() = false;
- std::memcpy(local_player->get_anim_overlays(), backup_layers, (sizeof(animationlayer) * 15));
- animstate[local_player->GetIndex()] = state;
- local_player->getFlags() = backup_flags; // one of the flags is wrong which causes hp to go to 257
- if (GetAsyncKeyState(options::menu.misc.fake_crouch_key.GetKey()) && !(pcmd->buttons & IN_ATTACK))
- {
- state->m_fDuckAmount = 9.f;
- }
- interfaces::globals->curtime = curtime;
- interfaces::globals->realtime = realtime;
- interfaces::globals->frametime = frametime;
- interfaces::globals->absoluteframetime = absoluteframetime;
- interfaces::globals->absoluteframestarttimestddev = absoluteframestarttimestddev;
- interfaces::globals->interpolation_amount = interpolation_amount;
- interfaces::globals->framecount = framecount;
- interfaces::globals->tickcount = tickcount;
- sim_time = local_player->get_simulation_time();
- }
- local_player->invalidate_bone_cache();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement