Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.78 KB | None | 0 0
  1. #include "Resolver.h"
  2. #include "Hooks.h"
  3.  
  4. bool bLowerBodyUpdated;
  5. bool IsUsingFakeAngles;
  6. float Differences[65];
  7. inline float RandomFloat(float min, float max)
  8. {
  9. static auto fn = (decltype(&RandomFloat))(GetProcAddress(GetModuleHandle("vstdlib.dll"), "RandomFloat"));
  10. return fn(min, max);
  11. }
  12. bool HasFakeHead(IClientEntity* pEntity) {
  13. //lby should update if distance from lby to eye angles exceeds 35 degrees
  14. return abs(pEntity->GetEyeAngles()->y - pEntity->GetLowerBodyYaw()) > 35;
  15. }
  16. bool Lbywithin35(IClientEntity* pEntity) {
  17. //lby should update if distance from lby to eye angles less than 35 degrees
  18. return abs(pEntity->GetEyeAngles()->y - pEntity->GetLowerBodyYaw()) < 35;
  19. }
  20. bool IsMovingOnGround(IClientEntity* pEntity) {
  21. //Check if player has a velocity greater than 0 (moving) and if they are onground.
  22. return pEntity->GetVelocity().Length2D() > 45.f && pEntity->GetFlags() & FL_ONGROUND;
  23. }
  24. bool IsMovingOnInAir(IClientEntity* pEntity) {
  25. //Check if player has a velocity greater than 0 (moving) and if they are onground.
  26. return !(pEntity->GetFlags() & FL_ONGROUND);
  27. }
  28. bool OnGround(IClientEntity* pEntity) {
  29. //Check if player has a velocity greater than 0 (moving) and if they are onground.
  30. return pEntity->GetFlags() & FL_ONGROUND;
  31. }
  32. bool IsFakeWalking(IClientEntity* pEntity) {
  33. //Check if a player is moving, but at below a velocity of 36
  34. return IsMovingOnGround(pEntity) && pEntity->GetVelocity().Length2D() < 36.0f;
  35. }
  36. bool IsEntityMoving(IClientEntity *player)
  37. {
  38. return (player->GetVelocity().Length2D() > 0.1f && player->GetFlags() & FL_ONGROUND);
  39. }
  40. bool CResolver::YawResolve2(IClientEntity *player)
  41. {
  42. float PlayerIsMoving = abs(player->GetVelocity().Length2D());
  43. bool bLowerBodyUpdated = false;
  44. bool IsUsingFakeAngles = false;
  45. float oldlowerbodyyaw;
  46. int result; // al@1
  47. float viewangles = player->GetEyeAngles()->y;
  48.  
  49. int v3; // [sp+0h] [bp-4h]@1
  50.  
  51. v3 = rand() % 40 + 160;
  52. result = PlayerIsMoving;
  53. if (bLowerBodyUpdated)
  54. {
  55. result = IsUsingFakeAngles;
  56. if (bLowerBodyUpdated = -1)
  57. {
  58. oldlowerbodyyaw = (viewangles + 16);
  59. result = IsUsingFakeAngles;
  60. }
  61. }
  62. *(float *)&bLowerBodyUpdated = (float)v3 + *(float *)&oldlowerbodyyaw;
  63. bLowerBodyUpdated = oldlowerbodyyaw;
  64. return result;
  65. }
  66. bool CResolver::YawResolve3(IClientEntity *player)
  67. {
  68. float PlayerIsMoving = abs(player->GetVelocity().Length2D());
  69. bool bLowerBodyUpdated = false;
  70. bool IsUsingFakeAngles = false;
  71. float oldlowerbodyyaw;
  72. int result; // al@1
  73. float viewangles = player->GetEyeAngles()->y;
  74.  
  75.  
  76. result = (unsigned __int8)PlayerIsMoving;
  77. if (bLowerBodyUpdated)
  78. {
  79. result = (unsigned __int8)oldlowerbodyyaw;
  80. if (bLowerBodyUpdated)
  81. {
  82. result = player->GetEyeAngles()->y;
  83.  
  84. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) + 90.0);
  85. }
  86. else
  87. {
  88. if ((player->GetEyeAngles()->y + 16) > player->GetEyeAngles()->y + 16) - 90.0;
  89. }
  90. }
  91. else if (++IsUsingFakeAngles == 1)
  92. {
  93. oldlowerbodyyaw = 0;
  94. result = player->GetEyeAngles()->y;
  95. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 90.0);
  96. }
  97. else
  98. {
  99. oldlowerbodyyaw = 1;
  100. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) + 90.0);
  101. bLowerBodyUpdated = 0;
  102. }
  103. return result;
  104. }
  105. bool CResolver::YawResolve4(IClientEntity *player)
  106. {
  107. float PlayerIsMoving = abs(player->GetVelocity().Length2D());
  108. bool bLowerBodyUpdated = false;
  109. bool IsUsingFakeAngles = false;
  110. float oldlowerbodyyaw;
  111. int result; // al@1
  112.  
  113.  
  114.  
  115. result = PlayerIsMoving;
  116. if (bLowerBodyUpdated)
  117. {
  118. result = IsUsingFakeAngles;
  119. if (oldlowerbodyyaw)
  120. {
  121. result = player->GetEyeAngles()->y;
  122. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 90.0);
  123. }
  124. else
  125. {
  126. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 180.0);
  127. }
  128. }
  129. else if (++oldlowerbodyyaw == 1)
  130. {
  131. bLowerBodyUpdated = 0;
  132. result = player->GetEyeAngles()->y;
  133. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 180.0);
  134. }
  135. else
  136. {
  137. IsUsingFakeAngles = 1;
  138. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 90.0);
  139. bLowerBodyUpdated = 0;
  140. }
  141. return result;
  142. }
  143. bool CResolver::YawResolve5(IClientEntity *player)
  144. {
  145. int v1; // eax@1
  146. int result; // eax@1
  147. signed __int64 v3; // rtt@1
  148. float v4; // xmm0_4@4
  149. float v5; // xmm0_4@6
  150. signed int v6; // [sp+8h] [bp-4h]@1
  151.  
  152. v1 = rand();
  153. v3 = v1;
  154. result = v1 / 100;
  155. v6 = v3 % 100;
  156. if (v6 < 98)
  157. {
  158. result = player->GetEyeAngles()->y;
  159. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 180.0);
  160. }
  161. if (v6 < 15)
  162. {
  163. v4 = (player->GetEyeAngles()->y + 16) + (float)(rand() % 141 - 70);
  164. result = player->GetEyeAngles()->y;
  165. if (player->GetEyeAngles()->y + 16 == v4);
  166. }
  167. if (v6 == 69)
  168. {
  169. v5 = (player->GetEyeAngles()->y + 16) + (float)(rand() % 181 - 90);
  170. result = player->GetEyeAngles()->y;
  171. if (player->GetEyeAngles()->y + 16 == v5);
  172. }
  173. return result;
  174. }
  175. bool CResolver::YawResolve6(IClientEntity *player)
  176. {
  177. bool bLowerBodyUpdated = false;
  178. bool IsUsingFakeAngles = false;
  179. float oldlowerbodyyaw;
  180. char result; // al@1
  181.  
  182.  
  183. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 91.0);
  184. result = bLowerBodyUpdated == 0;
  185. oldlowerbodyyaw = result;
  186. if (result)
  187. {
  188. result = player->GetEyeAngles()->y;
  189. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 180.0);
  190. }
  191. return result;
  192. }
  193. bool CResolver::YawResolve7(IClientEntity *player)
  194. {
  195. int result; // eax@1
  196. float PlayerIsMoving = abs(player->GetVelocity().Length2D());
  197. bool bLowerBodyUpdated = false;
  198. bool IsUsingFakeAngles = false;
  199. float oldlowerbodyyaw;
  200.  
  201.  
  202. result = oldlowerbodyyaw;
  203. if (PlayerIsMoving)
  204. {
  205. result = IsUsingFakeAngles;
  206. if (bLowerBodyUpdated)
  207. {
  208. result = oldlowerbodyyaw;
  209. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) + 0.0);
  210. }
  211. else
  212. {
  213. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) + 180.0);
  214. }
  215. }
  216. else if (++PlayerIsMoving == 1)
  217. {
  218. bLowerBodyUpdated = 0;
  219. result = player->GetEyeAngles()->y;
  220. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) + 180.0);
  221. }
  222. else
  223. {
  224. oldlowerbodyyaw = 1;
  225. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) + 0.0);
  226. bLowerBodyUpdated = 0;
  227. }
  228. return result;
  229. }
  230. bool CResolver::YawResolve8(IClientEntity *player)
  231. {
  232. float PlayerIsMoving = abs(player->GetVelocity().Length2D());
  233. bool bLowerBodyUpdated = false;
  234. bool IsUsingFakeAngles = false;
  235. float oldlowerbodyyaw;
  236.  
  237. double v2; // [sp+0h] [bp-Ch]@4
  238.  
  239. if (PlayerIsMoving)
  240. {
  241. bLowerBodyUpdated;
  242. if (oldlowerbodyyaw == -1)
  243. {
  244. bLowerBodyUpdated = 0;
  245. (&PlayerIsMoving);
  246. }
  247. }
  248. v2 = (double)bLowerBodyUpdated;
  249. if (oldlowerbodyyaw)
  250. {
  251. if (IsUsingFakeAngles)
  252. {
  253. if (oldlowerbodyyaw)
  254. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 90.0);
  255. else
  256. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) + 90.0);
  257. }
  258. else
  259. {
  260. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 180.0);
  261. }
  262. }
  263. else if (++PlayerIsMoving == 1)
  264. {
  265. bLowerBodyUpdated = 0;
  266. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 180.0);
  267. }
  268. else
  269. {
  270. oldlowerbodyyaw = 1;
  271. if (bLowerBodyUpdated)
  272. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 90.0);
  273. else
  274. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) + 90.0);
  275. oldlowerbodyyaw = 0;
  276. }
  277. if (v2 >= 0.35)
  278. {
  279. IsUsingFakeAngles = bLowerBodyUpdated == 0;
  280. oldlowerbodyyaw = IsUsingFakeAngles;
  281. }
  282. return bLowerBodyUpdated;
  283. }
  284. bool CResolver::YawResolve9(IClientEntity *player)
  285. {
  286. int idx = player->GetIndex();
  287. float new_yaw = player->GetLowerBodyYaw();
  288.  
  289.  
  290.  
  291. //AnimationLayer curBalanceLayer, prevBalanceLayer;
  292.  
  293. //SResolveInfo &player_recs = arr_infos[idx];
  294.  
  295. float PlayerIsMoving = abs(player->GetVelocity().Length2D());
  296. bool bLowerBodyUpdated = false;
  297. bool IsUsingFakeAngles = false;
  298. float oldlowerbodyyaw;
  299. bool result; // al@4
  300.  
  301.  
  302. if (IsEntityMoving(player))
  303. {
  304. if (oldlowerbodyyaw)
  305. {
  306. if (bLowerBodyUpdated)
  307. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 226.0);
  308. else
  309. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 134.0);
  310. result = oldlowerbodyyaw == 0;
  311. PlayerIsMoving = oldlowerbodyyaw == 0;
  312. }
  313. else
  314. {
  315. if (oldlowerbodyyaw)
  316. {
  317. result = player->GetEyeAngles()->y;
  318. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 134.0);
  319. }
  320. else
  321. {
  322. result = player->GetEyeAngles()->y;
  323. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 226.0);
  324. }
  325. bLowerBodyUpdated = PlayerIsMoving == 0;
  326. }
  327. }
  328. else if (++bLowerBodyUpdated == 1)
  329. {
  330. oldlowerbodyyaw = 0;
  331. if (bLowerBodyUpdated == true)
  332. {
  333. result = player->GetEyeAngles()->y;
  334. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 134.0);
  335. }
  336. else
  337. {
  338. result = player->GetEyeAngles()->y;
  339. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 226.0);
  340. }
  341. PlayerIsMoving = oldlowerbodyyaw == 0;
  342. }
  343. else
  344. {
  345. PlayerIsMoving = 1;
  346. if (IsUsingFakeAngles)
  347. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 226.0);
  348. else
  349. if ((player->GetEyeAngles()->y + 16 > player->GetEyeAngles()->y + 16) - 134.0);
  350. result = oldlowerbodyyaw == 0;
  351. bLowerBodyUpdated = PlayerIsMoving == 0;
  352. IsUsingFakeAngles = 0;
  353. }
  354. return result;
  355. }
  356.  
  357.  
  358. CResolver resolver;
  359.  
  360. void CResolver::draw_developer_data() {
  361. if (resolverconfig.bResolverDebug) {
  362. int pos_y = 30;
  363. char buffer_shots[128];
  364. float shots = game::globals.Shots % 4;
  365. sprintf_s(buffer_shots, "Shots: %1.0f", shots);
  366. draw.text(4, pos_y, buffer_shots, draw.fonts.menu_bold, Color(255, 255, 255));
  367. pos_y += 10;
  368.  
  369. char buffer_chokedticks[128];
  370. float choked_ticks = game::globals.choked_ticks;
  371. sprintf_s(buffer_chokedticks, "Choked ticks: %1.0f", choked_ticks);
  372. draw.text(4, pos_y, buffer_chokedticks, draw.fonts.menu_bold, Color(255, 255, 255));
  373. pos_y += 10;
  374.  
  375. if (game::globals.UserCmd) {
  376. char buffer_realyaw[128];
  377. static float real_yaw = 0;
  378. if (!game::globals.SendPacket) real_yaw = game::globals.UserCmd->viewangles.y;
  379. sprintf_s(buffer_realyaw, "Real yaw: %1.0f", real_yaw);
  380. draw.text(4, pos_y, buffer_realyaw, draw.fonts.menu_bold, Color(255, 255, 255));
  381. pos_y += 10;
  382.  
  383. char buffer_fakeyaw[128];
  384. static float fake_yaw = 0;
  385. if (game::globals.SendPacket) fake_yaw = game::globals.UserCmd->viewangles.y;
  386. sprintf_s(buffer_fakeyaw, "Fake yaw: %1.0f", fake_yaw);
  387. draw.text(4, pos_y, buffer_fakeyaw, draw.fonts.menu_bold, Color(255, 255, 255));
  388. pos_y += 20;
  389. }
  390. }
  391. }
  392.  
  393. void CResolver::add_corrections()
  394. {
  395. {
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402. if (OnGround)
  403. {
  404.  
  405. YawResolve9(pEntity) + YawResolve7(pEntity) + YawResolve8(pEntity) + YawResolve6(pEntity) + YawResolve3(pEntity);
  406. }
  407. else
  408. {
  409.  
  410. YawResolve2(pEntity) + YawResolve3(pEntity) + YawResolve4(pEntity) + YawResolve5(pEntity) + YawResolve6(pEntity) + YawResolve7(pEntity) + YawResolve8(pEntity) + YawResolve9(pEntity);
  411. }
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418. if (IsUsingFakeAngles)
  419. {
  420.  
  421. YawResolve2(pEntity) + YawResolve3(pEntity);
  422. }
  423. else
  424. {
  425.  
  426. YawResolve2(pEntity) + YawResolve3(pEntity) + YawResolve4(pEntity) + YawResolve5(pEntity) + YawResolve6(pEntity) + YawResolve7(pEntity) + YawResolve8(pEntity) + YawResolve9(pEntity);
  427. }
  428.  
  429.  
  430.  
  431.  
  432.  
  433. if (IsFakeWalking)
  434. {
  435.  
  436. YawResolve3(pEntity) + YawResolve4(pEntity);
  437. }
  438. else
  439. {
  440.  
  441. YawResolve4(pEntity) + YawResolve5(pEntity) + YawResolve9(pEntity);
  442. }
  443.  
  444.  
  445.  
  446.  
  447.  
  448. if (IsMovingOnGround)
  449. {
  450.  
  451. YawResolve4(pEntity) + YawResolve5(pEntity) + YawResolve7(pEntity) + YawResolve8(pEntity) + YawResolve9(pEntity);
  452. }
  453. else
  454. {
  455.  
  456. YawResolve2(pEntity) + YawResolve4(pEntity) + YawResolve6(pEntity) + YawResolve7(pEntity) + YawResolve8(pEntity) + YawResolve9(pEntity);
  457. }
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464. if (IsMovingOnInAir)
  465. {
  466.  
  467. YawResolve2(pEntity) + YawResolve3(pEntity) + YawResolve4(pEntity) + YawResolve5(pEntity) + YawResolve6(pEntity) + YawResolve7(pEntity) + YawResolve8(pEntity) + YawResolve9(pEntity);
  468. }
  469. else
  470. {
  471.  
  472. YawResolve2(pEntity) + YawResolve4(pEntity) + YawResolve6(pEntity) + YawResolve8(pEntity);
  473. }
  474.  
  475.  
  476.  
  477.  
  478.  
  479. if (Lbywithin35)
  480. {
  481.  
  482. YawResolve3(pEntity) + YawResolve6(pEntity) + YawResolve7(pEntity) + YawResolve9(pEntity);
  483. }
  484. else
  485. {
  486.  
  487. YawResolve8(pEntity) + YawResolve9(pEntity) + YawResolve6(pEntity) + YawResolve7(pEntity) + YawResolve5(pEntity) + YawResolve3(pEntity) + YawResolve4(pEntity);
  488. }
  489.  
  490.  
  491.  
  492.  
  493.  
  494. if (HasFakeHead)
  495. {
  496.  
  497. pEntity->GetEyeAngles()->y = pEntity->GetLowerBodyYaw() + YawResolve8(pEntity) + YawResolve9(pEntity) + YawResolve6(pEntity) + YawResolve7(pEntity) + YawResolve5(pEntity);
  498. }
  499. else
  500. {
  501.  
  502. pEntity->GetLowerBodyYaw() + YawResolve8(pEntity) + YawResolve9(pEntity) + YawResolve6(pEntity) + YawResolve7(pEntity) + YawResolve5(pEntity) + YawResolve3(pEntity) + YawResolve4(pEntity);
  503. }
  504.  
  505.  
  506.  
  507.  
  508.  
  509. }
  510.  
  511.  
  512. }
  513.  
  514. void CResolver::apply_corrections(CUserCmd* m_pcmd) {
  515. if (m_pEngine->IsInGame() && m_pEngine->IsConnected() && game::localdata.localplayer()) {
  516. for each (CResolverData current in resolver.corrections) {
  517. IClientEntity* ent = (IClientEntity*)m_pEntityList->GetClientEntity(current.index);
  518. if (!ent || ent == game::localdata.localplayer() || ent->GetClientClass()->m_ClassID != (int)CSGOClassID::CCSPlayer || !ent->IsAlive()) continue;
  519. ent->GetEyeAngles()->y = current.realAngles.y;
  520. ent->GetEyeAngles()->x = current.realAngles.x;
  521. }
  522. }
  523. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement