forked from boowampp/ApexDmaCheatUpdated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Glow.hpp
155 lines (135 loc) · 4.33 KB
/
Glow.hpp
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
148
149
150
151
152
153
154
155
#pragma once
#include <iostream>
#include <vector>
#include "Player.hpp"
#include "LocalPlayer.hpp"
#include "Offsets.hpp"
#include "Camera.hpp"
#include "GlowMode.hpp"
#include "DMALibrary/Memory/Memory.h"
#include <array>
struct Sense {
// Variables
Camera* GameCamera;
LocalPlayer* Myself;
std::vector<Player*>* Players;
int TotalSpectators = 0;
std::vector<std::string> Spectators;
uint64_t HighlightSettingsPointer;
bool ItemGlow = false;
// 15 = gold
// 46 = Purple,
// 53 = Blue
// 57 = ammo
// 64 = white (attachments/grenades)
int MinimumItemRarity = 35;
//Colors
float InvisibleGlowColor[3] = { 0, 1, 0 };
float VisibleGlowColor[3] = { 1, 0, 0 };
std::array<float, 3> highlightGlowColorRGB = { 0, 1, 0 };
Sense(std::vector<Player*>* Players, Camera* GameCamera, LocalPlayer* Myself) {
this->Players = Players;
this->GameCamera = GameCamera;
this->Myself = Myself;
}
void Initialize() {
// idk, nothing for now
}
void setCustomGlow(Player* Target, int enable, int wall, bool isVisible)
{
if (Target->GlowEnable == 0 && Target->GlowThroughWall == 0 && Target->HighlightID == 0) {
return;
}
uint64_t basePointer = Target->BasePointer;
std::array<unsigned char, 4> highlightFunctionBits = {
2, // InsideFunction
125, // OutlineFunction: HIGHLIGHT_OUTLINE_OBJECTIVE
64, // OutlineRadius: size * 255 / 8
64 // (EntityVisible << 6) | State & 0x3F | (AfterPostProcess << 7)
};
int settingIndex = 65;
int health = Target->Health;
std::array<float, 3> glowColorRGB = { 0, 0, 0 };
if (!isVisible) {
settingIndex = 65;
glowColorRGB = { 0.5, 0.5, 0.5 }; // grey
highlightGlowColorRGB = { 0.5, 0.5, 0.5 };
}
else if (health >= 205) {
settingIndex = 66;
glowColorRGB = { 1, 0, 0 }; // red shield
highlightGlowColorRGB = { 1, 0, 0 };
}
else if (health >= 190) {
settingIndex = 67;
glowColorRGB = { 0.5, 0, 0.5 }; // purple shield
highlightGlowColorRGB = { 0.5, 0, 0.5 };
}
else if (health >= 170) {
settingIndex = 68;
glowColorRGB = { 0, 0.5, 1 }; // blue shield
highlightGlowColorRGB = { 0, 0.5, 1 };
}
else if (health >= 95) {
settingIndex = 69;
glowColorRGB = { 0, 1, 0.5 }; // gray shield // cyan color
highlightGlowColorRGB = { 0, 1, 0.5 };
}
else {
settingIndex = 70;
glowColorRGB = { 0, 1, 0 }; // low health enemies // green color
highlightGlowColorRGB = { 0, 1, 0 };
}
if (Target->GlowEnable != enable) {
uint64_t glowEnableAddress = basePointer + OFF_GLOW_ENABLE;
mem.Write<int>(glowEnableAddress, enable);
}
if (Target->GlowThroughWall != wall) {
uint64_t glowThroughWallAddress = basePointer + OFF_GLOW_THROUGH_WALL;
mem.Write<int>(glowThroughWallAddress, wall);
}
uint64_t highlightIdAddress = basePointer + OFF_GLOW_HIGHLIGHT_ID;
unsigned char value = settingIndex;
mem.Write<unsigned char>(highlightIdAddress, value);
uint64_t highlightSettingsPtr = HighlightSettingsPointer;
if (mem.IsValidPointer(highlightSettingsPtr)) {
auto handle = mem.CreateScatterHandle();
// HIGHLIGHT
mem.AddScatterWriteRequest(handle, highlightSettingsPtr + OFF_GLOW_HIGHLIGHT_TYPE_SIZE * settingIndex + 0x0, &highlightFunctionBits, sizeof(highlightFunctionBits));
mem.AddScatterWriteRequest(handle, highlightSettingsPtr + OFF_GLOW_HIGHLIGHT_TYPE_SIZE * settingIndex + 0x4, &highlightGlowColorRGB, sizeof(highlightGlowColorRGB));
mem.ExecuteWriteScatter(handle);
mem.CloseScatterHandle(handle);
}
uint64_t glowFixAddress = basePointer + OFF_GLOW_FIX;
mem.Write<int>(glowFixAddress, 0);
}
Vector2D DummyVector = { 0, 0 };
void Update() {
//if (Myself->IsDead) return;
if (ItemGlow) {
uint64_t highlightSettingsPtr = HighlightSettingsPointer;
if (mem.IsValidPointer(highlightSettingsPtr)) {
uint64_t highlightSize = OFF_GLOW_HIGHLIGHT_TYPE_SIZE;
const GlowMode newGlowMode = { 137, 138, 35, 127 };
//for (int highlightId = MinimumItemRarity; highlightId < 100; highlightId++)
for (int highlightId = 15; highlightId < 64; highlightId++)
{
const GlowMode oldGlowMode = mem.Read<GlowMode>(highlightSettingsPtr + (highlightSize * highlightId) + 0, true);
if (newGlowMode != oldGlowMode) {
mem.Write<GlowMode>(highlightSettingsPtr + (highlightSize * highlightId) + 0, newGlowMode);
}
}
}
}
for (int i = 0; i < Players->size(); i++) {
Player* Target = Players->at(i);
if (!Target->IsValid()) continue;
if (Target->IsDummy()) continue;
if (Target->IsLocal) continue;
if (!Target->IsHostile) continue;
if (GameCamera->WorldToScreen(Target->LocalOrigin.ModifyZ(30), DummyVector)) {
setCustomGlow(Target, 1, 1, Target->IsVisible);
}
}
}
};