SHARE
TWEET

Untitled

a guest Jan 25th, 2020 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #define TICK_INTERVAL           (interfaces::globals->interval_per_tick)
  3. #define TIME_TO_TICKS( dt )     ( (int)( 0.5f + (float)(dt) / TICK_INTERVAL ) )
  4.  
  5. void c_animfix::fix_local_player_animations(CUserCmd * pcmd)
  6. {
  7.     auto local_player = hackManager.pLocal();
  8.     if (!local_player || !local_player->IsAlive())
  9.         return;
  10.  
  11.     static float sim_time;
  12.     if (sim_time != local_player->get_simulation_time())
  13.     {
  14.         auto state = local_player->get_animation_state();
  15.         if (!state)
  16.             return;
  17.  
  18.         const float curtime = interfaces::globals->curtime;
  19.         const float frametime = interfaces::globals->frametime;
  20.         const float realtime = interfaces::globals->realtime;
  21.         const float absoluteframetime = interfaces::globals->absoluteframetime;
  22.         const float absoluteframestarttimestddev = interfaces::globals->absoluteframestarttimestddev;
  23.         const float interpolation_amount = interfaces::globals->interpolation_amount;
  24.         const float framecount = interfaces::globals->framecount;
  25.         const float tickcount = interfaces::globals->tickcount;
  26.  
  27.         static auto host_timescale = interfaces::cvar->FindVar(("host_timescale"));
  28.  
  29.         interfaces::globals->curtime = local_player->get_simulation_time();
  30.         interfaces::globals->realtime = local_player->get_simulation_time(); // i'm not so sure about this
  31.         interfaces::globals->frametime = interfaces::globals->interval_per_tick * host_timescale->GetFloat();
  32.         interfaces::globals->absoluteframetime = interfaces::globals->interval_per_tick * host_timescale->GetFloat();
  33.         interfaces::globals->absoluteframestarttimestddev = local_player->get_simulation_time() - interfaces::globals->interval_per_tick * host_timescale->GetFloat();
  34.         interfaces::globals->interpolation_amount = 0;
  35.         interfaces::globals->framecount = TIME_TO_TICKS(local_player->get_simulation_time());
  36.         interfaces::globals->tickcount = TIME_TO_TICKS(local_player->get_simulation_time()); // is this right?
  37.  
  38.         int backup_flags = local_player->GetFlags();
  39.  
  40.         animationlayer backup_layers[15];
  41.         std::memcpy(backup_layers, local_player->get_anim_overlays(), (sizeof(animationlayer) * 15));
  42.  
  43.         if (state->m_iLastClientSideAnimationUpdateFramecount == interfaces::globals->framecount)
  44.             state->m_iLastClientSideAnimationUpdateFramecount = interfaces::globals->framecount - 1;
  45.  
  46.         local_player->client_side_animation() = true;
  47.         local_player->UpdateClientSideAnimation(); // without this it won't work right
  48.         local_player->client_side_animation() = false;
  49.  
  50.         std::memcpy(local_player->get_anim_overlays(), backup_layers, (sizeof(animationlayer) * 15));
  51.  
  52.         animstate[local_player->GetIndex()] = state;
  53.         local_player->getFlags() = backup_flags; // one of the flags is wrong which causes hp to go to 257
  54.  
  55.         if (GetAsyncKeyState(options::menu.misc.fake_crouch_key.GetKey()) && !(pcmd->buttons & IN_ATTACK))
  56.         {      
  57.             state->m_fDuckAmount = 9.f;    
  58.         }
  59.  
  60.         interfaces::globals->curtime = curtime;
  61.         interfaces::globals->realtime = realtime;
  62.         interfaces::globals->frametime = frametime;
  63.         interfaces::globals->absoluteframetime = absoluteframetime;
  64.         interfaces::globals->absoluteframestarttimestddev = absoluteframestarttimestddev;
  65.         interfaces::globals->interpolation_amount = interpolation_amount;
  66.         interfaces::globals->framecount = framecount;
  67.         interfaces::globals->tickcount = tickcount;
  68.         sim_time = local_player->get_simulation_time();
  69.     }
  70.     local_player->invalidate_bone_cache();
  71.  
  72. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top