forked from KaylinOwO/projectnacl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCBaseEntity.cpp
More file actions
132 lines (106 loc) · 2.81 KB
/
CBaseEntity.cpp
File metadata and controls
132 lines (106 loc) · 2.81 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
#include "SDK.h"
#include "Util.h"
int CBaseEntity::GetHealth()
{
DYNVAR_RETURN(int, this, "DT_BasePlayer", "m_iHealth");
}
int CBaseEntity::GetTeamNum()
{
DYNVAR_RETURN(int, this, "DT_BaseEntity", "m_iTeamNum");
}
int CBaseEntity::GetFlags()
{
DYNVAR_RETURN(int, this, "DT_BasePlayer", "m_fFlags");
}
BYTE CBaseEntity::GetLifeState()
{
DYNVAR_RETURN(BYTE, this, "DT_BasePlayer", "m_lifeState");
}
int CBaseEntity::GetClassNum()
{
DYNVAR_RETURN(int, this, "DT_TFPlayer", "m_PlayerClass", "m_iClass");
}
char* CBaseEntity::szGetClass()
{
DYNVAR(iClass, int, "DT_TFPlayer", "m_PlayerClass", "m_iClass");
switch (iClass.GetValue(this))
{
case TF2_Scout:
return "Scout";
case TF2_Soldier:
return "Soldier";
case TF2_Pyro:
return "Pyro";
case TF2_Demoman:
return "Demoman";
case TF2_Heavy:
return "Heavy";
case TF2_Engineer:
return "Engineer";
case TF2_Medic:
return "Medic";
case TF2_Sniper:
return "Sniper";
case TF2_Spy:
return "Spy";
default:
return "Unknown class";
}
return "Unknown class"; //Just in case
}
int CBaseEntity::GetCond()
{
DYNVAR_RETURN(int, this, "DT_TFPlayer", "m_Shared", "m_nPlayerCond");
}
CBaseCombatWeapon* CBaseEntity::GetActiveWeapon()
{
DYNVAR(pHandle, DWORD, "DT_BaseCombatCharacter", "m_hActiveWeapon");
return (CBaseCombatWeapon *)gInts.EntList->GetClientEntityFromHandle(pHandle.GetValue(this));
}
CBaseCombatWeapon* CBaseEntity::GetActiveWeaponOther()
{
DYNVAR(pHandle, HANDLE, "DT_BaseCombatCharacter", "m_hActiveWeapon");
return (CBaseCombatWeapon *)gInts.EntList2->GetClientEntityFromHandle(pHandle.GetValue(this));
}
Vector CBaseEntity::GetCollideableMins()
{
DYNVAR_RETURN(Vector, this, "DT_BaseEntity", "m_Collision", "m_vecMins");
}
Vector CBaseEntity::GetCollideableMaxs()
{
DYNVAR_RETURN(Vector, this, "DT_BaseEntity", "m_Collision", "m_vecMaxs");
}
Vector CBaseEntity::GetEyePosition()
{
DYNVAR_RETURN(Vector, this, "DT_BasePlayer", "localdata", "m_vecViewOffset[0]") + this->GetAbsOrigin();
}
Vector CBaseEntity::GetEyeAngles()
{
DYNVAR_RETURN(Vector, this, "DT_TFPlayer", "tfnonlocaldata", "m_angEyeAngles[0]");
}
Vector CBaseEntity::GetAbsEyePosition()
{
DYNVAR_RETURN(Vector, this, "DT_BasePlayer", "localdata", "m_vecViewOffset[0]");
}
Vector CBaseEntity::GetHitboxPosition(int iHitbox)
{
DWORD* model = GetModel();
if (!model)
return Vector();
studiohdr_t* hdr = gInts.ModelInfo->GetStudiomodel(model);
if (!hdr)
return Vector();
matrix3x4 matrix[128];
if (!SetupBones(matrix, 128, 0x100, gInts.globals->curtime))
return Vector();
mstudiohitboxset_t* set = hdr->GetHitboxSet(GetHitboxSet());
if (!set)
return Vector();
mstudiobbox_t* box = set->pHitbox(iHitbox);
if (!box)
return Vector();
Vector center = (box->bbmin + box->bbmax) * 0.5f;
Vector vHitbox;
Util->VectorTransform(center, matrix[box->bone], vHitbox);
return vHitbox;
}