-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dormant.cpp
95 lines (69 loc) · 2.35 KB
/
Dormant.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
#include "Dormant.h"
#include "Hooks.h"
void CDormantEsp::Start()
{
m_utlCurSoundList.RemoveAll();
interfaces.engine_sound->GetActiveSounds(m_utlCurSoundList);
if (!m_utlCurSoundList.Count())
return;
if (!csgo->local)
return;
for (auto i = 0; i < m_utlCurSoundList.Count(); i++)
{
auto& sound = m_utlCurSoundList[i];
if (sound.m_nSoundSource < 1 || sound.m_nSoundSource > 64)
continue;
if (sound.m_pOrigin->IsZero())
continue;
if (!IsValidSound(sound))
continue;
auto player = interfaces.ent_list->GetClientEntity(sound.m_nSoundSource);
if (!player
|| !player->isAlive()
|| !player->IsPlayer()
|| player->EntIndex() == interfaces.engine->GetLocalPlayer()
|| player->GetTeam() == csgo->local->GetTeam())
continue;
StartAdjust(player, sound);
m_cSoundPlayers[sound.m_nSoundSource].Override(sound);
}
m_utlvecSoundBuffer = m_utlCurSoundList;
}
void CDormantEsp::StartAdjust(IBasePlayer* player, SndInfo_t& sound)
{
Vector src3D, dst3D;
trace_t tr;
Ray_t ray;
CTraceFilter filter;
src3D = *sound.m_pOrigin + Vector(0.0f, 0.0f, 1.0f);
dst3D = src3D - Vector(0.0f, 0.0f, 100.0f);
filter.pSkip = player;
ray.Init(src3D, dst3D);
interfaces.trace->TraceRay(ray, MASK_PLAYERSOLID, &filter, &tr);
if (tr.allsolid)
m_cSoundPlayers[sound.m_nSoundSource].m_iReceiveTime = -1;
*sound.m_pOrigin = tr.fraction <= 0.97f ? tr.endpos : *sound.m_pOrigin;
m_cSoundPlayers[sound.m_nSoundSource].m_nFlags = player->GetFlags();
m_cSoundPlayers[sound.m_nSoundSource].m_nFlags |= (tr.fraction < 0.50f ? FL_DUCKING : 0) | (tr.fraction < 1.0f ? FL_ONGROUND : 0);
m_cSoundPlayers[sound.m_nSoundSource].m_nFlags &= (tr.fraction >= 0.50f ? ~FL_DUCKING : 0) | (tr.fraction >= 1.0f ? ~FL_ONGROUND : 0);
}
bool CDormantEsp::AdjustSound(IBasePlayer* entity)
{
auto i = entity->EntIndex();
auto sound_player = m_cSoundPlayers[i];
auto expired = false;
if (fabs(interfaces.global_vars->realtime - sound_player.m_iReceiveTime) > 10.0f)
expired = true;
entity->TargetSpotted() = true;
entity->GetFlagsPtr() = sound_player.m_nFlags;
entity->SetAbsOrigin(sound_player.m_vecOrigin);
csgo->LastSeenTime[i] = csgo->get_absolute_time();
return !expired;
}
bool CDormantEsp::IsValidSound(SndInfo_t& sound)
{
for (auto i = 0; i < m_utlvecSoundBuffer.Count(); i++)
if (m_utlvecSoundBuffer[i].m_nGuid == sound.m_nGuid)
return false;
return true;
}