Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. #include "BunnyHop.h"
  2. namespace BunnyHop
  3. {
  4. bool BHop::BunnyHopActive, BHop::inWaterBHop, BHop::StandUpActive;
  5. float BHop::Distance ( float frametime )
  6. {
  7. if ( g_Vars.BHop.ScrollEmulation )
  8. {
  9. return abs ( Info::g_Local.Height / Engine::g_pPlayerMove->flFallVelocity / 0.01f * 2 );
  10. }
  11. else
  12. {
  13. if ( g_Vars.BHop.NoSlowDown )
  14. {
  15. if ( Info::g_Local.GroundAngle > 0 && Info::g_Local.GroundAngle <= 45 )
  16. {
  17. return abs ( Info::g_Local.Height / Engine::g_pPlayerMove->flFallVelocity / frametime * 2 );
  18. }
  19. else
  20. {
  21. return abs ( Info::g_Local.Height / frametime * 0.01f );
  22. }
  23. }
  24. else
  25. {
  26. return abs ( Info::g_Local.Height / Engine::g_pPlayerMove->flFallVelocity / frametime * 2 );
  27. }
  28. }
  29. }
  30. void BHop::BunnyHop ( float frametime, usercmd_s *cmd )
  31. {
  32. static uint8 inAirBHopCount;
  33. static bool State;
  34. if ( inWaterBHop )
  35. {
  36. cmd->buttons |= IN_JUMP;
  37. return;
  38. }
  39. if ( State )
  40. {
  41. State = false;
  42. return;
  43. }
  44. if ( Engine::g_pPlayerMove->waterlevel >= 2 )
  45. {
  46. cmd->buttons |= IN_JUMP;
  47. inWaterBHop = true;
  48. return;
  49. }
  50. if ( g_Vars.BHop.OnLadder && Engine::g_pPlayerMove->movetype == 5 && Engine::g_pPlayerMove->flFallVelocity >= 0 )
  51. {
  52. cmd->buttons |= IN_JUMP;
  53. return;
  54. }
  55. if ( g_Vars.BHop.NoSlowDown )
  56. {
  57. static uint8 GroundFrame;
  58. if ( !State && ( Engine::g_pPlayerMove->flags & FL_ONGROUND ||
  59. ( Distance ( frametime ) >= 5 && Distance ( frametime ) <= 18 ) ) )
  60. {
  61. if ( Engine::g_pPlayerMove->velocity.Length2D ( ) < Engine::g_pPlayerMove->maxspeed * 1.2f )
  62. {
  63. cmd->buttons |= IN_JUMP;
  64. State = true;
  65. return;
  66. }
  67. else
  68. {
  69. if ( Engine::g_pPlayerMove->flags & FL_ONGROUND )
  70. {
  71. if ( GroundFrame < 2 )
  72. {
  73. ++GroundFrame;
  74. return;
  75. }
  76. else
  77. {
  78. cmd->buttons |= IN_JUMP;
  79. State = true;
  80. GroundFrame = 0;
  81. return;
  82. }
  83. }
  84. }
  85. }
  86. }
  87. else
  88. {
  89. if ( !State && ( Engine::g_pPlayerMove->flags & FL_ONGROUND || Distance ( frametime )
  90. <= Engine::g_Engine.pfnRandomFloat ( g_Vars.BHop.Distance[0], g_Vars.BHop.Distance[1] ) ) )
  91. {
  92. g_Vars.BHop.ScrollEmulation ?
  93. mouse_event ( MOUSEEVENTF_WHEEL, 0, 0, g_Vars.BHop.ScrollDirection > 1000 ? 120 : -120, 0 ) : cmd->buttons |= IN_JUMP;
  94. State = true;
  95. inAirBHopCount = 4;
  96. if ( !g_Vars.BHop.ScrollEmulation )
  97. {
  98. return;
  99. }
  100. }
  101. }
  102. if ( g_Vars.BHop.ScrollEmulation && inAirBHopCount > 0 )
  103. {
  104. if ( inAirBHopCount % 2 == 0 )
  105. {
  106. mouse_event ( MOUSEEVENTF_WHEEL, 0, 0, g_Vars.BHop.ScrollDirection > 1000 ? 120 : -120, 0 );
  107. }
  108. --inAirBHopCount;
  109. }
  110. }
  111. void BHop::StandUp ( usercmd_s *cmd )
  112. {
  113. if ( Engine::g_pPlayerMove->flFallVelocity >= g_Vars.BHop.StandUpFallVelocity && !Info::g_Local.FallDamage &&
  114. Info::g_Local.GroundAngle < 28 && Engine::g_pPlayerMove->movetype != 5 )
  115. {
  116. cmd->buttons |= IN_DUCK;
  117. }
  118. }
  119. void _fastcall BHop::CL_CreateMove ( float frametime, usercmd_s *cmd )
  120. {
  121. if ( BunnyHopActive )
  122. {
  123. BunnyHop ( frametime, cmd );
  124. if ( g_Vars.BHop.StandUpAuto || StandUpActive )
  125. {
  126. StandUp ( cmd );
  127. }
  128. }
  129. else
  130. {
  131. inWaterBHop = false;
  132. }
  133. }
  134. BHop g_BHop;
  135. }
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement