Advertisement
Guest User

Untitled

a guest
May 21st, 2018
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.43 KB | None | 0 0
  1. void DrawEsp()
  2. {
  3.     if (Global::m_PersistentLevel != nullptr && Global::m_LocalPlayer != nullptr && Global::m_LocalPlayer->PlayerController->AcknowledgedPawn != nullptr)
  4.     {
  5.         Classes::TArray<Classes::AActor*> actors = Global::m_PersistentLevel->AActors;
  6.         for (int i = 0; i < actors.Num(); i++)
  7.         {
  8.             Classes::AActor* actor = Global::m_PersistentLevel->AActors[i];
  9.             if (actor == nullptr || actor->RootComponent == nullptr)
  10.                 continue;
  11.  
  12.             if (actor->IsA(Classes::ATASC_Enforcer_C::StaticClass()))
  13.             {
  14.                 Classes::ATASC_Enforcer_C* pawn = static_cast<Classes::ATASC_Enforcer_C*>(actor);
  15.                 if (pawn == nullptr || pawn->PlayerState == nullptr)
  16.                     continue;
  17.  
  18.                 if (Util::IsLocalPlayer(actor))
  19.                     continue;
  20.  
  21.                 Classes::APlayerState* state = static_cast<Classes::APlayerState*>(pawn->PlayerState);
  22.                 if (!state->PlayerName.IsValid() || pawn->RootComponent == nullptr)
  23.                     continue;
  24.  
  25.                 // text size
  26.                 Vec2 size;
  27.  
  28.                 // Get Name
  29.                 std::wstring playerName = state->PlayerName.c_str();
  30.  
  31.                 // Draw Box
  32.                 Classes::FVector HeadPos, LeftFootPos, RightFootPos, BottomPos, SpinePos;
  33.                 Util::Engine::GetBoneLocation(pawn->Mesh, &HeadPos, Neck_01);
  34.                 Util::Engine::GetBoneLocation(pawn->Mesh, &SpinePos, Spine_03);
  35.                 Util::Engine::GetBoneLocation(pawn->Mesh, &LeftFootPos, Foot_l);
  36.                 Util::Engine::GetBoneLocation(pawn->Mesh, &RightFootPos, Foot_r);
  37.  
  38.                 BottomPos = Util::Vector::Divide(Util::Vector::Add(LeftFootPos, RightFootPos), 2);
  39.  
  40.                 HeadPos.Z += 20.f;
  41.                 BottomPos.Z -= 20.f;
  42.  
  43.                 Classes::FVector2D ScreenHead, ScreenBottom;
  44.                 Global::m_LocalPlayer->PlayerController->ProjectWorldLocationToScreen(HeadPos, &ScreenHead);
  45.                 Global::m_LocalPlayer->PlayerController->ProjectWorldLocationToScreen(BottomPos, &ScreenBottom);
  46.                 //Util::Engine::WorldToScreen(Global::m_LocalPlayer->PlayerController, HeadPos, &ScreenHead);
  47.                 //Util::Engine::WorldToScreen(Global::m_LocalPlayer->PlayerController, BottomPos, &ScreenBottom);
  48.  
  49.                 if (ScreenHead.X == 0 && ScreenHead.Y == 0)
  50.                     continue;
  51.  
  52.                 float height = ScreenBottom.Y - ScreenHead.Y;
  53.                 float width = height * 0.6f;
  54.  
  55.                 //renderer->drawOutlinedRect(Vec4(ScreenHead.X - width / 2, ScreenHead.Y, width, height), 2.f, RED_COLOR, TRANSPARENT_COLOR);
  56.  
  57.                 // Get Distance
  58.                 float distance = Util::GetDistance(Global::m_LocalPlayer->PlayerController->AcknowledgedPawn->RootComponent->RelativeLocation, HeadPos);
  59.                 std::wstring distanceText = Util::DistanceToString(distance);
  60.  
  61.  
  62.                 Classes::FVector vCamera = Global::m_LocalPlayer->PlayerController->PlayerCameraManager->TransformComponent->RelativeLocation;
  63.                
  64.                
  65.                 //HeadPos.X += OffSetAim;
  66.  
  67.                 Classes::FVector vRelative = Util::Vector::Subtract(HeadPos, vCamera);
  68.  
  69.                 auto Distance = Util::GetDistance(vCamera, HeadPos);
  70.  
  71.                 //if (distance > 300.f)
  72.                 //  continue;
  73.  
  74.                 Classes::FVector2D center(960, 540);
  75.                
  76.                 auto DistanceScreen = Util::GetDistance2D(center, ScreenHead);
  77.  
  78.                 if (GetAsyncKeyState(0x70))
  79.                     OffSetAim += 0.003f;
  80.                 if (GetAsyncKeyState(0x71))
  81.                     OffSetAim -= 0.003f;
  82.                 if (GetAsyncKeyState(0x72))
  83.                     OffSetAim = 0;
  84.  
  85.  
  86.                 std::wstring offset_text = std::to_wstring(OffSetAim);
  87.                 renderer->drawText(Vec2(14.0f, 10.0f), offset_text, RED_COLOR, 0, 12.0f, FONT_TYPE);
  88.  
  89.                 //auto CurrentWeapon = Global::m_LocalPlayer->PlayerController->
  90.  
  91.                 if ((GetAsyncKeyState(0x02) && DistanceScreen < 70.f) && isAiming == false)
  92.                 {
  93.                     isAiming = true;
  94.                     if (!Global::m_LocalPlayer->PlayerController->LineOfSightTo(actor, Global::m_LocalPlayer->PlayerController->SpawnLocation, false))
  95.                     {
  96.                         renderer->drawText(Vec2(14.0f, 30.0f), L"NOT IN LOS", RED_COLOR, 0, 12.0f, FONT_TYPE);
  97.                     }
  98.                     Global::m_LocalPlayer->PlayerController->ControlRotation.Pitch = -((acos(vRelative.Z / Distance) * 180.0f / M_PI) - 90.0f) + OffSetAim;
  99.                     Global::m_LocalPlayer->PlayerController->ControlRotation.Yaw = atan2(vRelative.Y, vRelative.X) * 180.0f / M_PI;
  100.                 }
  101.                 else
  102.                     isAiming = false;
  103.                 //Draw Name
  104.                 //size = renderer->getTextExtent(playerName, FONT_SIZE, FONT_TYPE);
  105.                 //renderer->drawText(Vec2(ScreenHead.X - size.x / 2, ScreenHead.Y - 13.f), playerName, RED_COLOR, 0, FONT_SIZE, FONT_TYPE);
  106.  
  107.                 // Draw Distance
  108.                 size = renderer->getTextExtent(distanceText, FONT_SIZE, FONT_TYPE);
  109.                 renderer->drawText(Vec2(ScreenHead.X - size.x / 2, ScreenHead.Y + height + 1.f), distanceText, RED_COLOR, 0, FONT_SIZE, FONT_TYPE);
  110.             }
  111.             else if (actor->IsA(Classes::ABMXTest_C::StaticClass()))
  112.             {
  113.                 Classes::ABMXTest_C* pawn = static_cast<Classes::ABMXTest_C*>(actor);
  114.                 if (pawn == nullptr)
  115.                     continue;
  116.  
  117.                 if (pawn->RootComponent == nullptr)
  118.                     continue;
  119.  
  120.                 Classes::FVector pos = pawn->RootComponent->RelativeLocation;
  121.                 Classes::FVector2D screenPos;
  122.                 Global::m_LocalPlayer->PlayerController->ProjectWorldLocationToScreen(pos, &screenPos);
  123.  
  124.                 if (screenPos.X == 0 && screenPos.Y == 0)
  125.                     continue;
  126.  
  127.                 // Get Distance
  128.                 float distance = Util::GetDistance(Global::m_LocalPlayer->PlayerController->AcknowledgedPawn->RootComponent->RelativeLocation, pos);
  129.                 //if (distance > 400.f)
  130.                 //  continue;
  131.                 std::wstring distanceText = Util::DistanceToString(distance);
  132.  
  133.                 // Draw Distance
  134.                 Vec2 size = renderer->getTextExtent(distanceText, FONT_SIZE, FONT_TYPE);
  135.                 renderer->drawText(Vec2(screenPos.X - size.x / 2, screenPos.Y), L"[" + distanceText + L"]", YELLOW_COLOR, 0, FONT_SIZE, FONT_TYPE);
  136.             }
  137.         }
  138.     }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement