-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwindows.cpp
107 lines (88 loc) · 3.95 KB
/
windows.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "pch.h"
#include "windows.h"
#include "ImGui/imgui.h"
#include "CppSDK/SDK/Engine_classes.hpp"
#include "CppSDK/SDK/ShooterGame_classes.hpp"
#include "CppSDK/SDK/BotPawn_classes.hpp"
namespace windows {
static bool esp_enabled = false;
static bool infinite_ammo = false;
static bool god_mode = false;
void render_menu()
{
static bool inited = false;
if (!inited) {
ImGui::SetNextWindowPos({ 0, 0 });
inited = true;
}
ImGui::Begin("by xxs");
ImGui::Checkbox("ESP", &esp_enabled);
ImGui::Checkbox("InfiniteAmmo", &infinite_ammo);
ImGui::Checkbox("GodMode", &god_mode);
ImGui::End();
// hack
auto world = SDK::UWorld::GetWorld();
if (!world)
return;
auto game_instance = world->OwningGameInstance;
if (!game_instance)
return;
auto local_players = SDK::UWorld::GetWorld()->OwningGameInstance->LocalPlayers;
if (!local_players)
return;
if (infinite_ammo) {
if (local_players.Num() == 1)
static_cast<SDK::AShooterPlayerController*>(local_players[0]->PlayerController)->bInfiniteAmmo = 1;
}
if (god_mode) {
if (local_players.Num() == 1)
static_cast<SDK::AShooterPlayerController*>(local_players[0]->PlayerController)->bGodMode = 1;
}
}
void render_esp()
{
// hack
auto world = SDK::UWorld::GetWorld();
if (!world)
return;
auto game_instance = world->OwningGameInstance;
if (!game_instance)
return;
auto local_players = game_instance->LocalPlayers;
if (!local_players)
return;
if (local_players.Num() != 1 || esp_enabled == false)
return;
RECT rt;
if (!GetWindowRect(FindWindow(NULL, L"ImGui Host"), &rt))
return;
ImGui::SetNextWindowPos(ImVec2(rt.left, rt.top), ImGuiCond_Always);
ImGui::SetNextWindowSize(ImVec2((float)(rt.right - rt.left), (float)(rt.bottom - rt.top)), ImGuiCond_Always);
ImGui::Begin(" ", (bool*)true,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs);
auto window_pos = ImGui::GetCursorScreenPos();
auto actors = world->PersistentLevel->Actors;
for (const auto& item : actors) {
if (item && item->IsA(SDK::ABotPawn_C::StaticClass())) {
auto actor = reinterpret_cast<SDK::AShooterCharacter*>(item);
if (actor->Health > 0) {
for (const auto& material : actor->Mesh->GetMaterials()) {
material->GetBaseMaterial()->bIsBlendable = 1;
material->GetBaseMaterial()->BlendMode = SDK::EBlendMode::BLEND_Additive;
material->GetBaseMaterial()->ShadingModel = SDK::EMaterialShadingModel::MSM_Unlit;
material->GetBaseMaterial()->bDisableDepthTest = 1;
material->GetBaseMaterial()->Wireframe = 1;
}
// draw box
auto world_pos = actor->RootComponent->RelativeLocation;
SDK::FVector2D screen_pos;
//auto distance = local_players[0]->PlayerController->Pawn->RootComponent->RelativeLocation.GetDistanceTo(
// actor->RootComponent->RelativeLocation);
if (local_players[0]->PlayerController->ProjectWorldLocationToScreen(world_pos, &screen_pos, false))
ImGui::GetWindowDrawList()->AddRect({window_pos.x + screen_pos.X - 10, window_pos.y + screen_pos.Y - 10 }, { window_pos.x + screen_pos.X + 10, window_pos.y + screen_pos.Y + 10 }, ImColor(1.f, 0.f, 0.f, 1.f), 0.0f, 0, 2.0f);
}
}
}
ImGui::End();
}
};