-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.cpp
More file actions
147 lines (128 loc) · 3.79 KB
/
Player.cpp
File metadata and controls
147 lines (128 loc) · 3.79 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include "Player.hpp"
#include "Global.hpp"
#include <xmmintrin.h>
#include <emmintrin.h>
#include "Utils.h"
#include "Offsets.hpp"
#include "Hacks.hpp"
Player::Player(uintptr_t address) :
address(address), cachedEFTPlayerClassAddress(0),
cachedTransformAddress(0)
{
}
ProfileInfo Player::GetProfileInfo() {
if (!this->cachedProfileInfo.has_value()) {
this->cachedProfileInfo = ProfileInfo{
Memory::ReadChain<uintptr_t>(
Global::pMemoryInterface,
this->address,
{0x520, 0x28}
)
};
}
return this->cachedProfileInfo.value();
}
uintptr_t Player::GetSkeletonTransformListValues() {
if (!this->cachedEFTPlayerClassAddress) {
this->cachedEFTPlayerClassAddress = Memory::ReadChain<uintptr_t>(
Global::pMemoryInterface,
this->address,
{ 0xA8, 0x28, 0x28, 0x10 }
);
}
return this->cachedEFTPlayerClassAddress;
}
Vector3 Player::GetPosition() {
if (!this->cachedTransformAddress) {
this->cachedTransformAddress = Memory::ReadChain<uintptr_t>(
Global::pMemoryInterface,
this->GetSkeletonTransformListValues(),
{ 0x20, 0x10 }
);
}
return this->cachedTransformAddress ? Hacks::ReadPosition(this->cachedTransformAddress) : Vector3{ 0.f, 0.f, 0.f };
}
Vector3 Player::GetBone(EBone bone) {
uintptr_t boneAddress;
if (this->cachedBones.contains(bone)) {
boneAddress = this->cachedBones[bone];
}
else {
boneAddress = Memory::ReadValue<uintptr_t>(Global::pMemoryInterface, Memory::ReadValue<uintptr_t>(Global::pMemoryInterface, this->GetSkeletonTransformListValues() + 0x20 + bone * 0x8) + 0x10);
this->cachedBones[bone] = boneAddress;
}
return Hacks::ReadPosition(boneAddress);
}
void Player::DrawBones(float alpha, ProfileInfo& localPlayerInfo) {
std::map<EBone, Vector3> boneWorldToScreens{};
for (int i = 0; i < BONE_PATH_SIZE; i++) {
std::array<EBone, 2> path = Player::drawPaths[i];
Vector3 first;
if (!boneWorldToScreens.contains(path[0])) {
first = Global::activeCamera.WorldToScreen(this->GetBone(path[0]));
boneWorldToScreens[path[0]] = first;
}
else {
first = boneWorldToScreens[path[0]];
}
if (first.x == 0.f || first.y == 0.f || first.z <= 0.01f) {
continue;
}
Vector3 second;
if (!boneWorldToScreens.contains(path[1])) {
second = Global::activeCamera.WorldToScreen(this->GetBone(path[1]));
boneWorldToScreens[path[1]] = second;
}
else {
second = boneWorldToScreens[path[1]];
}
if (second.x == 0.f || second.y == 0.f || second.z <= 0.01f) {
continue;
}
DrawLine(static_cast<int>(first.x), static_cast<int>(first.y), static_cast<int>(second.x), static_cast<int>(second.y), ColorAlpha(this->GetColor(localPlayerInfo), alpha));
}
}
Color Player::GetColor(ProfileInfo inRelationTo) {
if (!this->cachedColor.has_value()) {
ProfileInfo info = this->GetProfileInfo();
const std::wstring playerGroupId = info.GetGroupID();
const std::wstring relativeId = inRelationTo.GetGroupID();
if (!IS_VALID_WSTRING(playerGroupId) || !IS_VALID_WSTRING(relativeId) || relativeId != playerGroupId) {
switch (info.GetSide()) {
case 1:
{
this->cachedColor = YELLOW;
break;
}
case 2:
{
this->cachedColor = RED;
break;
}
case 4:
{
this->cachedColor = info.IsPlayer() ? DARKBLUE : SKYBLUE;
break;
}
}
}
else {
this->cachedColor = GREEN;
}
}
return cachedColor.value();
}
InventoryController Player::GetInventoryController() {
if (!this->cachedInventoryController.has_value()) {
this->cachedInventoryController = InventoryController{
Memory::ReadValue<uintptr_t>(
Global::pMemoryInterface,
this->address + Offsets::Player::InventoryController
)
};
}
return this->cachedInventoryController.value();
}
FirearmController Player::GetFirearmController() {
return FirearmController{ Memory::ReadValue<uintptr_t>(Global::pMemoryInterface, this->address + 0x570) };
}