-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameWorld.cpp
More file actions
93 lines (79 loc) · 2.77 KB
/
GameWorld.cpp
File metadata and controls
93 lines (79 loc) · 2.77 KB
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
#include "GameWorld.hpp"
#include "Offsets.hpp"
#include "Global.hpp"
#include "Utils.h"
#include <raymath.h>
#include "mdissect/mdissect.hpp"
GameWorld GameWorld::Get() {
uintptr_t gameWorldAddressGameObject = Global::gom.GetActiveObjects().GetObject("GameWorld");
if (!gameWorldAddressGameObject) {
return GameWorld{0};
}
uintptr_t gameWorldAddress = Memory::ReadChain<uintptr_t>(
Global::pMemoryInterface,
gameWorldAddressGameObject,
{0x30, 0x18, 0x28}
);
return GameWorld{gameWorldAddress};
}
std::vector<Player>& GameWorld::GetPlayers() {
if (!this->cachedPlayers.has_value()) {
std::vector<Player> players{};
uintptr_t registeredPlayersAddress = Memory::ReadValue<uintptr_t>(
Global::pMemoryInterface,
this->address + Offsets::GameWorld::RegisteredPlayers
);
if (registeredPlayersAddress) {
std::vector<uintptr_t> playerAddresses = Memory::ReadList<uintptr_t>(Global::pMemoryInterface, registeredPlayersAddress);
for (int i = 0; i < playerAddresses.size(); i++) {
players.push_back(Player{ playerAddresses[i]});
}
}
this->cachedPlayers = players;
}
return this->cachedPlayers.value();
}
std::vector<WorldLootItem>& GameWorld::GetLoot() {
size_t filtersCount = Global::pSettings->lootESP.filters.size();
if (!this->cachedLoot.has_value()) {
std::vector<uintptr_t> addresses = Memory::ReadList<uintptr_t>(Global::pMemoryInterface, Memory::ReadValue<uintptr_t>(Global::pMemoryInterface, this->address + 0x80));
size_t length = addresses.size();
std::vector<WorldLootItem> loot{};
loot.reserve(length);
Vector3 localPlayerPosition = Global::gameWorld.GetPlayers()[0].GetPosition();
for (size_t i = 0; i < length; i++) {
std::string className = mdissect::mono_object{ addresses[i] }.vtable().mono_class().name();
bool isCorpse = className == "ObservedCorpse" || className == "Corpse";
if (className != "ObservedLootItem" && !isCorpse) {
continue;
}
WorldLootItem lootItem{ addresses[i] };
float distance = Vector3Distance(localPlayerPosition, lootItem.GetPosition());
if (distance > Global::pSettings->lootESP.distance) {
continue;
}
if (!isCorpse) {
bool isLocalized = false;
std::wstring itemName = lootItem.GetLocalizedName(&isLocalized);
if (!isLocalized) {
continue;
}
if (Global::pSettings->lootESP.useFilter && filtersCount > 0) {
bool found = false;
for (size_t i = 0; i < filtersCount; i++) {
if (Utils::ContainsIgnoreCase(itemName, Global::pSettings->lootESP.filters[i])) {
found = true;
break;
}
}
if (!found && Global::pSettings->lootESP.whitelist || found && !Global::pSettings->lootESP.whitelist) {
continue;
}
}
}
loot.push_back(lootItem);
}
this->cachedLoot = loot;
}
return this->cachedLoot.value();
}