Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.29 KB | None | 0 0
  1. #include "Resolver.h"
  2. #include "..\Aimbot\Aimbot.h"
  3. #include "..\Aimbot\Autowall.h"
  4. #include "..\Aimbot\LagComp.h"
  5. #include "..\..\Utils\Utils.h"
  6. #include "..\..\SDK\IVEngineClient.h"
  7. #include "..\..\SDK\Hitboxes.h"
  8. #include "..\..\SDK\PlayerInfo.h"
  9. #include "..\..\Utils\Math.h"
  10. #include "..\..\Menu\Menu.h"
  11. #include "..\..\Menu\config.h"
  12. Resolver g_Resolver;
  13.  
  14. /*
  15. my attempt at fixing desync and i was pretty successful
  16. it can resolve static desync pretty perfectly
  17. and can resolve some jitter desync but
  18. it still gets rekt by other things
  19. */
  20.  
  21. void Resolver::AnimationFix(C_BaseEntity* pEnt)
  22. {
  23. if (pEnt == Globals::LocalPlayer) {
  24. pEnt->ClientAnimations(true);
  25. auto player_animation_state = pEnt->AnimState();
  26. player_animation_state->m_flLeanAmount = 20;
  27. player_animation_state->m_flCurrentTorsoYaw += 15;
  28. pEnt->UpdateClientAnimation();
  29. pEnt->SetAbsAngles(Vector(0, player_animation_state->m_flGoalFeetYaw, 0));
  30. pEnt->ClientAnimations(false);
  31. }
  32. else {
  33. auto player_index = pEnt->EntIndex() - 1;
  34.  
  35. pEnt->ClientAnimations(true);
  36.  
  37. auto old_curtime = g_pGlobalVars->curtime;
  38. auto old_frametime = g_pGlobalVars->frametime;
  39.  
  40. g_pGlobalVars->curtime = pEnt->GetSimulationTime();
  41. g_pGlobalVars->frametime = g_pGlobalVars->intervalPerTick;
  42.  
  43. auto player_animation_state = pEnt->AnimState();
  44. auto player_model_time = reinterpret_cast<int*>(player_animation_state + 112);
  45. if (player_animation_state != nullptr && player_model_time != nullptr)
  46. if (*player_model_time == g_pGlobalVars->framecount)
  47. *player_model_time = g_pGlobalVars->framecount - 1;
  48.  
  49.  
  50. pEnt->UpdateClientAnimation();
  51.  
  52. g_pGlobalVars->curtime = old_curtime;
  53. g_pGlobalVars->frametime = old_frametime;
  54.  
  55. //pEnt->SetAbsAngles(Vector(0, player_animation_state->m_flGoalFeetYaw, 0));
  56.  
  57. pEnt->ClientAnimations(false);
  58. }
  59.  
  60. }
  61. float flAngleMod(float flAngle)
  62. {
  63. return((360.0f / 65536.0f) * ((int32_t)(flAngle * (65536.0f / 360.0f)) & 65535));
  64. }
  65. float ApproachAngle(float target, float value, float speed)
  66. {
  67. target = flAngleMod(target);
  68. value = flAngleMod(value);
  69.  
  70. float delta = target - value;
  71.  
  72. // Speed is assumed to be positive
  73. if (speed < 0)
  74. speed = -speed;
  75.  
  76. if (delta < -180)
  77. delta += 360;
  78. else if (delta > 180)
  79. delta -= 360;
  80.  
  81. if (delta > speed)
  82. value += speed;
  83. else if (delta < -speed)
  84. value -= speed;
  85. else
  86. value = target;
  87.  
  88. return value;
  89. }
  90. /*
  91.  
  92.  
  93. */
  94.  
  95. void update_state(C_AnimState * state, Vector angles) {
  96. using Fn = void(__vectorcall*)(void *, void *, float, float, float, void *);
  97. static auto fn = reinterpret_cast<Fn>(Utils::FindSignature("client_panorama.dll", "55 8B EC 83 E4 F8 83 EC 18 56 57 8B F9 F3 0F 11 54 24"));
  98. fn(state, nullptr, 0.0f, angles[1], angles[0], nullptr);
  99. }
  100.  
  101. void HandleBackUpResolve(C_BaseEntity* pEnt) {
  102.  
  103. if (!c_config::get().aimbot_resolver)
  104. return;
  105.  
  106. if (pEnt->GetTeam() == Globals::LocalPlayer->GetTeam())
  107. return;
  108.  
  109. const auto player_animation_state = pEnt->AnimState();
  110.  
  111. if (!player_animation_state)
  112. return;
  113.  
  114. float m_flLastClientSideAnimationUpdateTimeDelta = fabs(player_animation_state->m_iLastClientSideAnimationUpdateFramecount - player_animation_state->m_flLastClientSideAnimationUpdateTime);
  115.  
  116. auto v48 = 0.f;
  117.  
  118. if (player_animation_state->m_flFeetSpeedForwardsOrSideWays >= 0.0f)
  119. {
  120. v48 = fminf(player_animation_state->m_flFeetSpeedForwardsOrSideWays, 1.0f);
  121. }
  122. else
  123. {
  124. v48 = 0.0f;
  125. }
  126.  
  127. float v49 = ((player_animation_state->m_flStopToFullRunningFraction * -0.30000001) - 0.19999999) * v48;
  128.  
  129. float flYawModifier = v49 + 1.0;
  130.  
  131. if (player_animation_state->m_fDuckAmount > 0.0)
  132. {
  133. float v53 = 0.0f;
  134.  
  135. if (player_animation_state->m_flFeetSpeedUnknownForwardOrSideways >= 0.0)
  136. {
  137. v53 = fminf(player_animation_state->m_flFeetSpeedUnknownForwardOrSideways, 1.0);
  138. }
  139. else
  140. {
  141. v53 = 0.0f;
  142. }
  143. }
  144.  
  145. float flMaxYawModifier = player_animation_state->pad10[516] * flYawModifier;
  146. float flMinYawModifier = player_animation_state->pad10[512] * flYawModifier;
  147.  
  148. float newFeetYaw = 0.f;
  149.  
  150. auto eyeYaw = player_animation_state->m_flEyeYaw;
  151.  
  152. auto lbyYaw = player_animation_state->m_flGoalFeetYaw;
  153.  
  154. float eye_feet_delta = fabs(eyeYaw - lbyYaw);
  155.  
  156. if (eye_feet_delta <= flMaxYawModifier)
  157. {
  158. if (flMinYawModifier > eye_feet_delta)
  159. {
  160. newFeetYaw = fabs(flMinYawModifier) + eyeYaw;
  161. }
  162. }
  163. else
  164. {
  165. newFeetYaw = eyeYaw - fabs(flMaxYawModifier);
  166. }
  167.  
  168. float v136 = fmod(newFeetYaw, 360.0);
  169.  
  170. if (v136 > 180.0)
  171. {
  172. v136 = v136 - 360.0;
  173. }
  174.  
  175. if (v136 < 180.0)
  176. {
  177. v136 = v136 + 360.0;
  178. }
  179.  
  180. player_animation_state->m_flGoalFeetYaw = v136;
  181.  
  182. /*static int stored_yaw = 0;
  183.  
  184. if (pEnt->GetEyeAnglesPointer()->y != stored_yaw) {
  185. if ((pEnt->GetEyeAnglesPointer()->y - stored_yaw > 120)) { // Arbitrary high angle value.
  186. if (pEnt->GetEyeAnglesPointer()->y - stored_yaw > 120) {
  187. pEnt->GetEyeAnglesPointer()->y = pEnt->GetEyeAnglesPointer()->y - (pEnt->GetEyeAnglesPointer()->y - stored_yaw);
  188. }
  189.  
  190. stored_yaw = pEnt->GetEyeAnglesPointer()->y;
  191. }
  192. }*/
  193. //if (pEnt->GetVelocity().Length2D() > 0.1f)
  194. //{
  195. // player_animation_state->m_flGoalFeetYaw = ApproachAngle(pEnt->GetLowerBodyYaw(), player_animation_state->m_flGoalFeetYaw, (player_animation_state->m_flStopToFullRunningFraction * 20.0f) + 30.0f *player_animation_state->m_flLastClientSideAnimationUpdateTime);
  196. //}
  197. //else
  198. //{
  199. // player_animation_state->m_flGoalFeetYaw = ApproachAngle(pEnt->GetLowerBodyYaw(), player_animation_state->m_flGoalFeetYaw, (m_flLastClientSideAnimationUpdateTimeDelta * 100.0f));
  200. //}
  201. //if (Globals::MissedShots[pEnt->EntIndex()] > 3) {
  202. // switch (Globals::MissedShots[pEnt->EntIndex()] % 4) {
  203. // case 0: pEnt->GetEyeAnglesPointer()->y = pEnt->GetEyeAnglesPointer()->y + 45; break;
  204. // case 1: pEnt->GetEyeAnglesPointer()->y = pEnt->GetEyeAnglesPointer()->y - 45; break;
  205. // case 2: pEnt->GetEyeAnglesPointer()->y = pEnt->GetEyeAnglesPointer()->y - 30; break;
  206. // case 3: pEnt->GetEyeAnglesPointer()->y = pEnt->GetEyeAnglesPointer()->y + 30; break;
  207. // }
  208. //}
  209. }
  210.  
  211. void HandleHits(C_BaseEntity* pEnt)
  212. {
  213. auto NetChannel = g_pEngine->GetNetChannelInfo();
  214.  
  215. if (!NetChannel)
  216. return;
  217.  
  218. static float predTime[65];
  219. static bool init[65];
  220.  
  221. if (Globals::Shot[pEnt->EntIndex()])
  222. {
  223. if (init[pEnt->EntIndex()])
  224. {
  225. g_Resolver.pitchHit[pEnt->EntIndex()] = pEnt->GetEyeAngles().x;
  226. predTime[pEnt->EntIndex()] = g_pGlobalVars->curtime + NetChannel->GetAvgLatency(FLOW_INCOMING) + NetChannel->GetAvgLatency(FLOW_OUTGOING) + TICKS_TO_TIME(1) + TICKS_TO_TIME(g_pEngine->GetNetChannel()->m_nChokedPackets);
  227. init[pEnt->EntIndex()] = false;
  228. }
  229.  
  230. if (g_pGlobalVars->curtime > predTime[pEnt->EntIndex()] && !Globals::Hit[pEnt->EntIndex()])
  231. {
  232. Globals::MissedShots[pEnt->EntIndex()] += 1;
  233. Globals::Shot[pEnt->EntIndex()] = false;
  234. }
  235. else if (g_pGlobalVars->curtime <= predTime[pEnt->EntIndex()] && Globals::Hit[pEnt->EntIndex()])
  236. Globals::Shot[pEnt->EntIndex()] = false;
  237.  
  238. }
  239. else
  240. init[pEnt->EntIndex()] = true;
  241.  
  242. Globals::Hit[pEnt->EntIndex()] = false;
  243. }
  244.  
  245. void Resolver::OnCreateMove() // cancer v2
  246. {
  247. if (!c_config::get().aimbot_resolver)
  248. return;
  249.  
  250. if (!Globals::LocalPlayer->IsAlive())
  251. return;
  252.  
  253. if (!Globals::LocalPlayer->GetActiveWeapon() || Globals::LocalPlayer->IsKnifeorNade())
  254. return;
  255.  
  256.  
  257. for (int i = 1; i < g_pEngine->GetMaxClients(); ++i)
  258. {
  259. C_BaseEntity* pPlayerEntity = g_pEntityList->GetClientEntity(i);
  260.  
  261. if (!pPlayerEntity
  262. || !pPlayerEntity->IsAlive()
  263. || pPlayerEntity->IsDormant()
  264. || pPlayerEntity == Globals::LocalPlayer
  265. || pPlayerEntity->GetTeam() == Globals::LocalPlayer->GetTeam())
  266. {
  267. UseFreestandAngle[i] = false;
  268. continue;
  269. }
  270.  
  271. if (abs(pPlayerEntity->GetVelocity().Length2D()) > 29.f)
  272. UseFreestandAngle[pPlayerEntity->EntIndex()] = false;
  273.  
  274. if (abs(pPlayerEntity->GetVelocity().Length2D()) <= 29.f && !UseFreestandAngle[pPlayerEntity->EntIndex()])
  275. {
  276. bool Autowalled = false, HitSide1 = false, HitSide2 = false;
  277.  
  278. float angToLocal = g_Math.CalcAngle(Globals::LocalPlayer->GetOrigin(), pPlayerEntity->GetOrigin()).y;
  279. Vector ViewPoint = Globals::LocalPlayer->GetOrigin() + Vector(0, 0, 90);
  280.  
  281. Vector2D Side1 = { (45 * sin(g_Math.GRD_TO_BOG(angToLocal))),(45 * cos(g_Math.GRD_TO_BOG(angToLocal))) };
  282. Vector2D Side2 = { (45 * sin(g_Math.GRD_TO_BOG(angToLocal + 180))) ,(45 * cos(g_Math.GRD_TO_BOG(angToLocal + 180))) };
  283.  
  284. Vector2D Side3 = { (50 * sin(g_Math.GRD_TO_BOG(angToLocal))),(50 * cos(g_Math.GRD_TO_BOG(angToLocal))) };
  285. Vector2D Side4 = { (50 * sin(g_Math.GRD_TO_BOG(angToLocal + 180))) ,(50 * cos(g_Math.GRD_TO_BOG(angToLocal + 180))) };
  286.  
  287. Vector Origin = pPlayerEntity->GetOrigin();
  288.  
  289. Vector2D OriginLeftRight[] = { Vector2D(Side1.x, Side1.y), Vector2D(Side2.x, Side2.y) };
  290.  
  291. Vector2D OriginLeftRightLocal[] = { Vector2D(Side3.x, Side3.y), Vector2D(Side4.x, Side4.y) };
  292.  
  293. for (int side = 0; side < 2; side++)
  294. {
  295. Vector OriginAutowall = { Origin.x + OriginLeftRight[side].x, Origin.y - OriginLeftRight[side].y , Origin.z + 90 };
  296. Vector OriginAutowall2 = { ViewPoint.x + OriginLeftRightLocal[side].x, ViewPoint.y - OriginLeftRightLocal[side].y , ViewPoint.z };
  297.  
  298. if (g_Autowall.CanHitFloatingPoint(OriginAutowall, ViewPoint))
  299. {
  300. if (side == 0)
  301. {
  302. HitSide1 = true;
  303. FreestandAngle[pPlayerEntity->EntIndex()] = 90;
  304. }
  305. else if (side == 1)
  306. {
  307. HitSide2 = true;
  308. FreestandAngle[pPlayerEntity->EntIndex()] = -90;
  309. }
  310.  
  311. Autowalled = true;
  312. }
  313. else
  314. {
  315. for (int side222 = 0; side222 < 2; side222++)
  316. {
  317. Vector OriginAutowall222 = { Origin.x + OriginLeftRight[side222].x, Origin.y - OriginLeftRight[side222].y , Origin.z + 90 };
  318.  
  319. if (g_Autowall.CanHitFloatingPoint(OriginAutowall222, OriginAutowall2))
  320. {
  321. if (side222 == 0)
  322. {
  323. HitSide1 = true;
  324. FreestandAngle[pPlayerEntity->EntIndex()] = 90;
  325. }
  326. else if (side222 == 1)
  327. {
  328. HitSide2 = true;
  329. FreestandAngle[pPlayerEntity->EntIndex()] = -90;
  330. }
  331.  
  332. Autowalled = true;
  333. }
  334. }
  335. }
  336. }
  337.  
  338. if (Autowalled)
  339. {
  340. if (HitSide1 && HitSide2)
  341. UseFreestandAngle[pPlayerEntity->EntIndex()] = false;
  342. else
  343. UseFreestandAngle[pPlayerEntity->EntIndex()] = true;
  344. }
  345. }
  346. }
  347. }
  348.  
  349. void Resolver::FrameStage(ClientFrameStage_t stage)
  350. {
  351. if (!Globals::LocalPlayer || !g_pEngine->IsInGame())
  352. return;
  353.  
  354. static bool wasDormant[65];
  355.  
  356. for (int i = 1; i < g_pEngine->GetMaxClients(); ++i)
  357. {
  358. C_BaseEntity* pPlayerEntity = g_pEntityList->GetClientEntity(i);
  359.  
  360. if (!pPlayerEntity
  361. || !pPlayerEntity->IsAlive())
  362. continue;
  363. if (pPlayerEntity->IsDormant())
  364. {
  365. wasDormant[i] = true;
  366. continue;
  367. }
  368.  
  369. if (stage == FRAME_RENDER_START)
  370. {
  371. HandleHits(pPlayerEntity);
  372. AnimationFix(pPlayerEntity);
  373.  
  374.  
  375. }
  376.  
  377. if (stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START) {
  378. HandleBackUpResolve(pPlayerEntity);
  379. }
  380.  
  381. if (stage == FRAME_NET_UPDATE_END && pPlayerEntity != Globals::LocalPlayer)
  382. {
  383. auto VarMap = reinterpret_cast<uintptr_t>(pPlayerEntity) + 36;
  384. auto VarMapSize = *reinterpret_cast<int*>(VarMap + 20);
  385.  
  386. for (auto index = 0; index < VarMapSize; index++)
  387. *reinterpret_cast<uintptr_t*>(*reinterpret_cast<uintptr_t*>(VarMap) + index * 12) = 0;
  388. }
  389.  
  390. wasDormant[i] = false;
  391. }
  392. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement