-
Notifications
You must be signed in to change notification settings - Fork 26
/
Entity.cpp
342 lines (255 loc) · 7.32 KB
/
Entity.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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
#include "include.h"
/*I have a big dick so the skull fucking will hurt*/
Entity LocalEntity;
Entity EntityList[ 65 ];
Entity::Entity()
{
m_iIndex = NULL;
m_dwPointer = NULL;
m_dwBoneMatrix = NULL;
m_iTeamNum = NULL;
m_iHealth = NULL;
m_iFlags = NULL;
m_bDead = true;
}
Entity::~Entity()
{
}
void Entity::Update( int iIndex )
{
Clear();
m_iIndex = iIndex;
if( !m_iIndex )
return;
m_dwPointer = process->Read<DWORD_PTR>( client->GetImage() + g_pStatic->EntityListBase + 40 + m_iIndex * 8 );
if( !m_dwPointer )
return;
m_dwPointer -= 8;
m_iHealth = process->Read<int>( m_dwPointer + g_pDynamic->m_iHealth );
m_dwBoneMatrix = process->Read<DWORD_PTR>( m_dwPointer + g_pDynamic->m_BoneMatrix );
if( !m_dwBoneMatrix )
return;
process->Read( m_dwBoneMatrix, m_BoneMatrix, sizeof( Matrix3x4[ 128 ] ) );
m_vOrigin = process->Read<Vector3>( m_dwPointer + g_pDynamic->m_vecOrigin );
m_vEye = m_vOrigin + process->Read<Vector3>( m_dwPointer + g_pDynamic->m_vecViewOffset );
m_vEyeAngles = process->Read<Vector3>( m_dwPointer + g_pDynamic->m_angEyeAngles );
m_vVelocity = process->Read<Vector3>( m_dwPointer + g_pDynamic->m_vecVelocity );
m_vPunch = process->Read<Vector3>( m_dwPointer + g_pDynamic->m_aimPunchAngle );
m_iTeamNum = process->Read<int>( m_dwPointer + g_pDynamic->m_iTeamNum );
m_iFlags = process->Read<int>( m_dwPointer + g_pDynamic->m_fFlags );
m_iCrossHairID = process->Read<int>( m_dwPointer + 0xAA70 );
m_hActiveWeapon = process->Read<int>( m_dwPointer + g_pDynamic->m_hActiveWeapon );
m_iCompetitiveRanking = process->Read<int>( g_pStatic->GameResources + g_pDynamic->m_iCompetitiveRanking + m_iIndex * 4 );
m_iCompetitiveWins = process->Read<int>( g_pStatic->GameResources + g_pDynamic->m_iCompetitiveWins + m_iIndex * 4 );
m_bDead = process->Read<bool>( m_dwPointer + g_pDynamic->m_lifeState );
m_bIsDormant = process->Read<bool>( m_dwPointer + 0xE9 );
m_i64SpottedByMask = process->Read<INT64>( m_dwPointer + 0x97C );
m_bSpotted = process->Read<bool>( m_dwPointer + 0x939 );
// Player name with player_info_t
// credits to brinkz
DWORD_PTR ECX, EDX, EAX, Info;
int iEntIndex = m_iIndex - 1;
if( !g_pStatic->EnginePointer )
return;
ECX = process->Read<DWORD_PTR>( g_pStatic->EnginePointer + 0x523C );
if( !ECX )
return;
EDX = process->Read<DWORD_PTR>( ECX + 0x3C );
if( !EDX )
return;
EAX = process->Read<DWORD_PTR>( EDX + 0xC );
if( !EAX )
return;
Info = process->Read<DWORD_PTR>( EAX + 0x20 + iEntIndex * 0x34 );
if( !Info )
return;
process->Read( Info + 0x10, m_pName, 64 );
process->Read( Info + 0x94, m_pSteamID, 64 );
}
DWORD_PTR Entity::GetPointer()
{
return m_dwPointer;
}
DWORD_PTR Entity::GetLocalPointer()
{
return m_dwLocalPointer;
}
DWORD_PTR Entity::GetBoneMatrix()
{
return m_dwBoneMatrix;
}
Matrix3x4 Entity::GetBoneMatrix( int iBone )
{
return m_BoneMatrix[ iBone ];
}
Vector3 Entity::GetPunchAngles()
{
return m_vPunch;
}
Vector3 Entity::GetOrigin()
{
return m_vOrigin;
}
Vector3 Entity::GetEyeAngles()
{
return m_vEyeAngles;
}
Vector3 Entity::GetEyePosition()
{
return m_vEye;
}
Vector3 Entity::GetVelocity()
{
return m_vVelocity;
}
Vector3 Entity::GetBonePosition( int iBone )
{
return Vector3( m_BoneMatrix[ iBone ].m[ 0 ][ 3 ], m_BoneMatrix[ iBone ].m[ 1 ][ 3 ], m_BoneMatrix[ iBone ].m[ 2 ][ 3 ] );
}
int Entity::GetActiveWeapon()
{
int weaponId = process->Read<int>( GetActiveWeaponBase() + g_pDynamic->m_iWeaponId );
if( weaponId > 50 || weaponId < 0 ) // If number is greater than array size return 0 to prevent crash
weaponId = 42; // set weapon ID to knife
return weaponId;
}
DWORD_PTR Entity::GetActiveWeaponBase()
{
DWORD_PTR dwBaseCombatWeaponIndex = process->Read< DWORD_PTR >( m_dwPointer + g_pDynamic->m_hActiveWeapon );
dwBaseCombatWeaponIndex &= 0xFFF;
return process->Read<DWORD_PTR>( ( g_pStatic->EntityList + dwBaseCombatWeaponIndex * 0x10 ) - 0x10 );
}
bool Entity::IsActiveWeaponNotVaild()
{
int WeaponId = LocalEntity.GetActiveWeapon();
return( WeaponId == WEAPON_KNIFEGG || WeaponId == WEAPON_KNIFE || WeaponId == WEAPON_FLASHBANG || WeaponId == WEAPON_HEGRENADE || WeaponId == WEAPON_SMOKEGRENADE
|| WeaponId == WEAPON_MOLOTOV || WeaponId == WEAPON_DECOY || WeaponId == WEAPON_INCGRENADE || WeaponId == WEAPON_C4 );
}
bool Entity::IsActiveWeaponPistol()
{
int WeaponId = LocalEntity.GetActiveWeapon();
return( WeaponId == WEAPON_DEAGLE || WeaponId == WEAPON_ELITE || WeaponId == WEAPON_FIVESEVEN || WeaponId == WEAPON_GLOCK
|| WeaponId == WEAPON_P228 || WeaponId == WEAPON_USP || WeaponId == WEAPON_TEC9 || WeaponId == WEAPON_TASER || WeaponId == WEAPON_HKP2000 );
}
int Entity::GetTeamNum()
{
return m_iTeamNum;
}
int Entity::GetHealth()
{
return m_iHealth;
}
int Entity::GetCrosshairEnt()
{
return m_iCrossHairID;
}
int Entity::GetMatchMakingRank()
{
if( m_iCompetitiveRanking > 18 || m_iCompetitiveRanking < 0 )
return 0;
return m_iCompetitiveRanking;
}
int Entity::GetMatchMakingWins()
{
return m_iCompetitiveWins;
}
int Entity::GetFlags()
{
return m_iFlags;
}
float Entity::GetFlashDuration()
{
return process->Read<float>( m_dwPointer + g_pDynamic->m_flFlashDuration );
}
void Entity::SetFlashDuration()
{
process->Write<float>( m_dwPointer + g_pDynamic->m_flFlashDuration, 0.0f );
}
int Entity::GetTickBase()
{
return process->Read<int>( m_dwPointer + 0x17CC );
}
bool Entity::IsValid()
{
if( !GetPointer() )
return false;
if( !GetBoneMatrix() )
return false;
if( !GetTeamNum() )
return false;
if( IsDead() )
return false;
if( IsDormant() )
return false;
if( GetOrigin().IsZero() )
return false;
if( GetHealth() < 1 )
return false;
return true;
}
bool Entity::IsPlayer()
{
if( !GetPointer() )
return false;
if( !GetName() )
return false;
if( !GetTeamNum() )
return false;
return true;
}
bool Entity::IsDead()
{
return m_bDead;
}
bool Entity::IsDormant()
{
return m_bIsDormant;
}
bool Entity::IsSpottedByMask()
{
return ( m_i64SpottedByMask & ( 1 << ( g_pEngine->GetLocalPlayer() - 1 ) ) );
}
bool Entity::IsSpotted()
{
return m_bSpotted;
}
void Entity::CheckVisible( int bone )
{
std::future<bool> ret = std::async( std::launch::async, &BSPMap::Visible, g_pBSP, LocalEntity.GetEyePosition(), GetBonePosition( bone ) );
m_bVisible = ret.get(); // Spawns an async thread then return value to m_bVisible
}
bool Entity::IsVisible()
{
return m_bVisible;
}
const char* Entity::GetName()
{
return m_pName;
}
const char* Entity::GetSteamID()
{
return m_pSteamID;
}
void Entity::Clear()
{
m_iIndex = NULL;
m_flFlashDuration = NULL;
m_dwPointer = NULL;
m_dwBoneMatrix = NULL;
memset( m_BoneMatrix, NULL, sizeof( Matrix3x4[ 128 ] ) );
m_vOrigin = Vector3( 0, 0, 0 );
m_vEye = Vector3( 0, 0, 0 );
m_iTeamNum = NULL;
m_iHealth = NULL;
m_iFlags = NULL;
m_iCrossHairID = NULL;
m_hActiveWeapon = NULL;
m_iWeaponId = NULL;
m_iCompetitiveRanking = NULL;
m_iCompetitiveWins = NULL;
m_bDead = true;
m_i64SpottedByMask = NULL;
m_flFlashDuration = NULL;
m_flServerTime = NULL;
memset( m_pName, NULL, sizeof( char[ 64 ] ) );
}