forked from duckman6969/fix-skill-issue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSense.cpp
More file actions
75 lines (72 loc) · 2.62 KB
/
Sense.cpp
File metadata and controls
75 lines (72 loc) · 2.62 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
#pragma once
#include <vector>
#include "LocalPlayer.cpp"
#include "Player.cpp"
#include "Math.cpp"
#include "Level.cpp"
#include "X11Utils.cpp"
#include "ConfigLoader.cpp"
class Sense
{
private:
ConfigLoader *m_configLoader;
Level *m_level;
LocalPlayer *m_localPlayer;
RemotePlayers *m_remotePlayers;
std::chrono::steady_clock::time_point m_lastUpdated = {};
public:
Sense(ConfigLoader *configLoader,
Level *level,
LocalPlayer *localPlayer,
RemotePlayers *remotePlayers)
{
m_configLoader = configLoader;
m_level = level;
m_localPlayer = localPlayer;
m_remotePlayers = remotePlayers;
}
void update()
{
auto now = std::chrono::steady_clock::now();
if (now - m_lastUpdated < std::chrono::milliseconds(10)) {
return;
}
m_lastUpdated = now;
int senseMaxRange = m_configLoader->getSenseMaxRange();
int senseMaxRangeOverWall = m_configLoader->getSenseMaxRangeOverWall();
int gameMode = m_configLoader->getGameMode();
double localX = m_localPlayer->getLocationX();
double localY = m_localPlayer->getLocationY();
double localZ = m_localPlayer->getLocationZ();
auto& players = m_remotePlayers->getPlayers();
for (std::size_t i = 0; i < players.size(); i++) {
Player *player = &players.at(i);
if (!player->isValid())
continue;
if (player->isSameTeam(m_localPlayer, gameMode)) {
player->setGlowEnable(1);
player->setGlowThroughWall(1);
player->setCustomGlow(0, true, true);
continue;
}
double distance = math::calculateDistanceInMeters(
localX, localY, localZ,
player->getLocationX(),
player->getLocationY(),
player->getLocationZ());
if (player->isVisible() && !player->isKnocked() && distance < senseMaxRange) {
player->setGlowEnable(1);
player->setGlowThroughWall(1);
int health = player->getShieldValue() + player->getHealthValue();
player->setCustomGlow(health, true, false);
} else if (distance < senseMaxRangeOverWall) {
player->setGlowEnable(1);
player->setGlowThroughWall(1);
player->setCustomGlow(0, false, false);
} else if (player->getGlowEnable() == 1 && player->getGlowThroughWall() == 1) {
player->setGlowEnable(0);
player->setGlowThroughWall(0);
}
}
}
};