Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. void FreeStanding() // should have rewritten
  2. {
  3. static float FinalAngle;
  4. bool bside1 = false;
  5. bool bside2 = false;
  6. bool autowalld = false;
  7.  
  8. float tempdis = 999999999.f;
  9. Vector2D LocalOrg = Vector2D(Globals::LocalPlayer->GetOrigin().x, Globals::LocalPlayer->GetOrigin().y);
  10.  
  11. float closeYaw = 999.f;
  12.  
  13. for (int i = 1; i <= g_pEngine->GetMaxClients(); ++i)
  14. {
  15. C_BaseEntity* pPlayerEntity = g_pEntityList->GetClientEntity(i);
  16.  
  17. if (!pPlayerEntity
  18. || !pPlayerEntity->IsAlive()
  19. || pPlayerEntity->IsDormant()
  20. || pPlayerEntity == Globals::LocalPlayer
  21. || pPlayerEntity->GetTeam() == Globals::LocalPlayer->GetTeam())
  22. continue;
  23.  
  24. Vector2D EnemyOrg = Vector2D(pPlayerEntity->GetOrigin().x, pPlayerEntity->GetOrigin().y);
  25.  
  26.  
  27. if (tempdis > fabs(g_Math.Distance(EnemyOrg, LocalOrg)))
  28. {
  29. closeYaw = g_Math.NormalizeYaw(g_Math.CalcAngle(Globals::LocalPlayer->GetOrigin(), pPlayerEntity->GetOrigin()).y);
  30. tempdis = fabs(g_Math.Distance(EnemyOrg, LocalOrg));
  31. }
  32.  
  33. if (c_config::get().Freestanding)
  34. {
  35. float angToLocal = g_Math.CalcAngle(Globals::LocalPlayer->GetOrigin(), pPlayerEntity->GetOrigin()).y;
  36. Vector ViewPoint = pPlayerEntity->GetOrigin() + Vector(0, 0, 90);
  37.  
  38. Vector2D Side1 = { (45 * sin(g_Math.GRD_TO_BOG(angToLocal))),(45 * cos(g_Math.GRD_TO_BOG(angToLocal))) };
  39. Vector2D Side2 = { (45 * sin(g_Math.GRD_TO_BOG(angToLocal + 180))) ,(45 * cos(g_Math.GRD_TO_BOG(angToLocal + 180))) };
  40.  
  41. Vector2D Side3 = { (50 * sin(g_Math.GRD_TO_BOG(angToLocal))),(50 * cos(g_Math.GRD_TO_BOG(angToLocal))) };
  42. Vector2D Side4 = { (50 * sin(g_Math.GRD_TO_BOG(angToLocal + 180))) ,(50 * cos(g_Math.GRD_TO_BOG(angToLocal + 180))) };
  43.  
  44. Vector Origin = Globals::LocalPlayer->GetOrigin();
  45.  
  46. Vector2D OriginLeftRight[] = { Vector2D(Side1.x, Side1.y), Vector2D(Side2.x, Side2.y) };
  47.  
  48. Vector2D OriginLeftRightLocal[] = { Vector2D(Side3.x, Side3.y), Vector2D(Side4.x, Side4.y) };
  49.  
  50. for (int side = 0; side < 2; side++)
  51. {
  52. Vector OriginAutowall = { Origin.x + OriginLeftRight[side].x, Origin.y - OriginLeftRight[side].y , Origin.z + 80 };
  53. Vector OriginAutowall2 = { ViewPoint.x + OriginLeftRightLocal[side].x, ViewPoint.y - OriginLeftRightLocal[side].y , ViewPoint.z };
  54.  
  55. if (g_Autowall.CanHitFloatingPoint(OriginAutowall, ViewPoint))
  56. {
  57. if (side == 0)
  58. {
  59. FreestandingSide = true;
  60. bside1 = true;
  61. FinalAngle = angToLocal + 90;
  62. }
  63. else if (side == 1)
  64. {
  65. FreestandingSide = false;
  66. bside2 = true;
  67. FinalAngle = angToLocal - 90;
  68. }
  69. autowalld = true;
  70. }
  71. else
  72. {
  73. for (int side222 = 0; side222 < 2; side222++)
  74. {
  75. Vector OriginAutowall222 = { Origin.x + OriginLeftRight[side222].x, Origin.y - OriginLeftRight[side222].y , Origin.z + 80 };
  76.  
  77. if (g_Autowall.CanHitFloatingPoint(OriginAutowall222, OriginAutowall2))
  78. {
  79. if (side222 == 0)
  80. {
  81. FreestandingSide = true;
  82. bside1 = true;
  83. FinalAngle = angToLocal + 90;
  84. }
  85. else if (side222 == 1)
  86. {
  87. FreestandingSide = false;
  88. bside2 = true;
  89. FinalAngle = angToLocal - 90;
  90. }
  91. autowalld = true;
  92. }
  93. }
  94. }
  95. }
  96. }
  97. }
  98.  
  99. if (!autowalld || (bside1 && bside2))
  100. {
  101. if (closeYaw != 999.f && c_config::get().AtTarget)
  102. Globals::pCmd->viewangles.y = g_Math.NormalizeYaw(closeYaw + SentYaw);
  103. else
  104. Globals::pCmd->viewangles.y += SentYaw;
  105. }
  106. else
  107. Globals::pCmd->viewangles.y = FinalAngle;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement