Advertisement
Guest User

fakelag

a guest
Dec 15th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. int CFakeLag::Fakelag_AdaptiveFactor()
  2. {
  3. auto local_player = g_pEntityList->GetClientEntity(g_pEngine->GetLocalPlayer());
  4.  
  5. if (!local_player)
  6. return 0;
  7.  
  8. auto velocity = local_player->GetVelocity();;
  9. auto speed = velocity.Length();
  10. auto distance_per_tick = speed *
  11. g_pGlobalVars->intervalPerTick;
  12. //choked_ticks = std::ceilf(TELEPORT_DISTANCE / distance_per_tick);
  13. //return std::min<int>(choked_ticks, MAX_CHOKE);
  14. return 0;
  15. }
  16. int iChoke = 1;
  17.  
  18. void CFakeLag::do_fakelag(CUserCmd * cmd, C_BaseEntity* local)
  19. {
  20. if (g_pEngine->IsVoiceRecording())
  21. return;
  22.  
  23. if (!g_Settings.bFakeLagShooting && cmd->buttons & IN_ATTACK && aimbot->can_shoot(cmd) && !Globals::isfakeducking)
  24. return;
  25.  
  26. auto NetChannel = g_pEngine->GetNetChannel();
  27.  
  28. if (!NetChannel)
  29. return;
  30.  
  31. bool standing = local->GetVelocity().Length2D() <= 0.1f;
  32. bool accelerating = local->GetVelocity().Length2D() >= 0.1f && local->GetVelocity().Length2D() <= 150.f;
  33. bool onhighspeed = local->GetVelocity().Length2D() >= 265.f;
  34. bool onground = local->GetFlags() & FL_ONGROUND;
  35. bool running = onground && accelerating || local->GetVelocity().Length2D() >= 175.f;
  36.  
  37. bool flag1 = false;
  38. bool flag2 = false;
  39. bool flag3 = false;
  40. bool flag4 = false;
  41.  
  42. if (g_Settings.bFakeLagFlags[0] && (onground && standing))
  43. flag1 = true;
  44.  
  45. if (g_Settings.bFakeLagFlags[1] && accelerating)
  46. flag2 = true;
  47.  
  48. if (g_Settings.bFakeLagFlags[2] && onhighspeed)
  49. flag3 = true;
  50.  
  51. if (g_Settings.bFakeLagFlags[3] && running)
  52. flag4 = true;
  53.  
  54. if (Globals::isfakeducking)
  55. iChoke = 14;
  56. else if (flag1 || flag2 || flag3 || flag4)
  57. iChoke = g_Settings.iFakeLagChoke;
  58. else
  59. return;
  60.  
  61. if (g_Settings.iFakeLagType == 1)
  62. {
  63. if (NetChannel->m_nChokedPackets < iChoke)
  64. {
  65. Globals::bsendpacket = false;
  66. }
  67. else
  68. {
  69. Globals::bsendpacket = true;
  70. }
  71. }
  72. else if (g_Settings.iFakeLagType == 2)
  73. {
  74. auto velocity = g::pLocalEntity->GetVelocity();;
  75.  
  76. auto speed = velocity.Length();
  77.  
  78. auto distance_per_tick = speed * g_pGlobalVars->intervalPerTick;
  79.  
  80. if (Globals::isfakeducking)
  81. iChoke = 14;
  82. else if (velocity.Length2D() > 0)
  83. iChoke = std::min<int>(std::ceilf(TELEPORT_DISTANCE / distance_per_tick), g_Settings.iFakeLagChoke);
  84. else
  85. iChoke = g_Settings.iFakeLagChoke;
  86.  
  87. if (NetChannel->m_nChokedPackets < iChoke)
  88. {
  89. Globals::bsendpacket = false;
  90. }
  91. else
  92. {
  93. Globals::bsendpacket = true;
  94. }
  95. }
  96. else if (g_Settings.iFakeLagType == 3)
  97. {
  98. static float next_update_time = 0;
  99. bool yo = false;
  100. if (next_update_time < g_pGlobalVars->curtime)
  101. {
  102. next_update_time = g_pGlobalVars->curtime + 1.1f;
  103. yo = true;
  104. }
  105.  
  106. if (NetChannel->m_nChokedPackets < iChoke && yo)
  107. {
  108. Globals::bsendpacket = false;
  109. }
  110. else
  111. {
  112. Globals::bsendpacket = true;
  113. }
  114. }
  115. }
  116.  
  117. void CFakeLag::fakeduck2(CUserCmd * cmd, C_BaseEntity* local)
  118. {
  119. if (!GetAsyncKeyState(0x05))
  120. {
  121. Globals::isfakeducking = false;
  122. return;
  123. }
  124.  
  125. if (!local->GetFlags() & FL_ONGROUND)
  126. return;
  127.  
  128. auto NetChannel = g_pEngine->GetNetChannel();
  129.  
  130. if (!NetChannel)
  131. return;
  132.  
  133. int fakelag_limit = 14;
  134. int choked_goal = fakelag_limit / 2;
  135. bool should_crouch = NetChannel->m_nChokedPackets >= choked_goal;
  136.  
  137. Globals::isfakeducking = true;
  138.  
  139. if (should_crouch)
  140. cmd->buttons |= IN_DUCK;
  141. else
  142. cmd->buttons &= ~IN_DUCK;
  143. }
  144.  
  145. CFakeLag* fakelag = new CFakeLag();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement