Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void DrawEsp()
- {
- if (Global::m_PersistentLevel != nullptr && Global::m_LocalPlayer != nullptr && Global::m_LocalPlayer->PlayerController->AcknowledgedPawn != nullptr)
- {
- Classes::TArray<Classes::AActor*> actors = Global::m_PersistentLevel->AActors;
- for (int i = 0; i < actors.Num(); i++)
- {
- Classes::AActor* actor = Global::m_PersistentLevel->AActors[i];
- if (actor == nullptr || actor->RootComponent == nullptr)
- continue;
- if (actor->IsA(Classes::ATASC_Enforcer_C::StaticClass()))
- {
- Classes::ATASC_Enforcer_C* pawn = static_cast<Classes::ATASC_Enforcer_C*>(actor);
- if (pawn == nullptr || pawn->PlayerState == nullptr)
- continue;
- if (Util::IsLocalPlayer(actor))
- continue;
- Classes::APlayerState* state = static_cast<Classes::APlayerState*>(pawn->PlayerState);
- if (!state->PlayerName.IsValid() || pawn->RootComponent == nullptr)
- continue;
- // text size
- Vec2 size;
- // Get Name
- std::wstring playerName = state->PlayerName.c_str();
- // Draw Box
- Classes::FVector HeadPos, LeftFootPos, RightFootPos, BottomPos, SpinePos;
- Util::Engine::GetBoneLocation(pawn->Mesh, &HeadPos, Neck_01);
- Util::Engine::GetBoneLocation(pawn->Mesh, &SpinePos, Spine_03);
- Util::Engine::GetBoneLocation(pawn->Mesh, &LeftFootPos, Foot_l);
- Util::Engine::GetBoneLocation(pawn->Mesh, &RightFootPos, Foot_r);
- BottomPos = Util::Vector::Divide(Util::Vector::Add(LeftFootPos, RightFootPos), 2);
- HeadPos.Z += 20.f;
- BottomPos.Z -= 20.f;
- Classes::FVector2D ScreenHead, ScreenBottom;
- Global::m_LocalPlayer->PlayerController->ProjectWorldLocationToScreen(HeadPos, &ScreenHead);
- Global::m_LocalPlayer->PlayerController->ProjectWorldLocationToScreen(BottomPos, &ScreenBottom);
- //Util::Engine::WorldToScreen(Global::m_LocalPlayer->PlayerController, HeadPos, &ScreenHead);
- //Util::Engine::WorldToScreen(Global::m_LocalPlayer->PlayerController, BottomPos, &ScreenBottom);
- if (ScreenHead.X == 0 && ScreenHead.Y == 0)
- continue;
- float height = ScreenBottom.Y - ScreenHead.Y;
- float width = height * 0.6f;
- //renderer->drawOutlinedRect(Vec4(ScreenHead.X - width / 2, ScreenHead.Y, width, height), 2.f, RED_COLOR, TRANSPARENT_COLOR);
- // Get Distance
- float distance = Util::GetDistance(Global::m_LocalPlayer->PlayerController->AcknowledgedPawn->RootComponent->RelativeLocation, HeadPos);
- std::wstring distanceText = Util::DistanceToString(distance);
- Classes::FVector vCamera = Global::m_LocalPlayer->PlayerController->PlayerCameraManager->TransformComponent->RelativeLocation;
- //HeadPos.X += OffSetAim;
- Classes::FVector vRelative = Util::Vector::Subtract(HeadPos, vCamera);
- auto Distance = Util::GetDistance(vCamera, HeadPos);
- //if (distance > 300.f)
- // continue;
- Classes::FVector2D center(960, 540);
- auto DistanceScreen = Util::GetDistance2D(center, ScreenHead);
- if (GetAsyncKeyState(0x70))
- OffSetAim += 0.003f;
- if (GetAsyncKeyState(0x71))
- OffSetAim -= 0.003f;
- if (GetAsyncKeyState(0x72))
- OffSetAim = 0;
- std::wstring offset_text = std::to_wstring(OffSetAim);
- renderer->drawText(Vec2(14.0f, 10.0f), offset_text, RED_COLOR, 0, 12.0f, FONT_TYPE);
- //auto CurrentWeapon = Global::m_LocalPlayer->PlayerController->
- if ((GetAsyncKeyState(0x02) && DistanceScreen < 70.f) && isAiming == false)
- {
- isAiming = true;
- if (!Global::m_LocalPlayer->PlayerController->LineOfSightTo(actor, Global::m_LocalPlayer->PlayerController->SpawnLocation, false))
- {
- renderer->drawText(Vec2(14.0f, 30.0f), L"NOT IN LOS", RED_COLOR, 0, 12.0f, FONT_TYPE);
- }
- Global::m_LocalPlayer->PlayerController->ControlRotation.Pitch = -((acos(vRelative.Z / Distance) * 180.0f / M_PI) - 90.0f) + OffSetAim;
- Global::m_LocalPlayer->PlayerController->ControlRotation.Yaw = atan2(vRelative.Y, vRelative.X) * 180.0f / M_PI;
- }
- else
- isAiming = false;
- //Draw Name
- //size = renderer->getTextExtent(playerName, FONT_SIZE, FONT_TYPE);
- //renderer->drawText(Vec2(ScreenHead.X - size.x / 2, ScreenHead.Y - 13.f), playerName, RED_COLOR, 0, FONT_SIZE, FONT_TYPE);
- // Draw Distance
- size = renderer->getTextExtent(distanceText, FONT_SIZE, FONT_TYPE);
- renderer->drawText(Vec2(ScreenHead.X - size.x / 2, ScreenHead.Y + height + 1.f), distanceText, RED_COLOR, 0, FONT_SIZE, FONT_TYPE);
- }
- else if (actor->IsA(Classes::ABMXTest_C::StaticClass()))
- {
- Classes::ABMXTest_C* pawn = static_cast<Classes::ABMXTest_C*>(actor);
- if (pawn == nullptr)
- continue;
- if (pawn->RootComponent == nullptr)
- continue;
- Classes::FVector pos = pawn->RootComponent->RelativeLocation;
- Classes::FVector2D screenPos;
- Global::m_LocalPlayer->PlayerController->ProjectWorldLocationToScreen(pos, &screenPos);
- if (screenPos.X == 0 && screenPos.Y == 0)
- continue;
- // Get Distance
- float distance = Util::GetDistance(Global::m_LocalPlayer->PlayerController->AcknowledgedPawn->RootComponent->RelativeLocation, pos);
- //if (distance > 400.f)
- // continue;
- std::wstring distanceText = Util::DistanceToString(distance);
- // Draw Distance
- Vec2 size = renderer->getTextExtent(distanceText, FONT_SIZE, FONT_TYPE);
- renderer->drawText(Vec2(screenPos.X - size.x / 2, screenPos.Y), L"[" + distanceText + L"]", YELLOW_COLOR, 0, FONT_SIZE, FONT_TYPE);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement