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
|
#define MAX_EDICT_BITS 11
#define NUM_ENT_ENTRY_BITS (MAX_EDICT_BITS + 1)
#define NUM_ENT_ENTRIES (1 << NUM_ENT_ENTRY_BITS)
#define ENT_ENTRY_MASK (NUM_ENT_ENTRIES - 1)
#define INVALID_EHANDLE_INDEX 0xFFFFFFFF
enum struct CBasePlayerOffsets
{
//...
int m_surfaceFriction;
//...
int m_hGroundEntity;
//...
int m_MoveType;
//...
}
enum struct CBaseHandleOffsets
{
int m_Index;
}
enum struct CEntInfoOffsets
{
int m_pEntity;
int m_SerialNumber;
//...
int size;
}
enum struct CBaseEntityListOffsets
{
int m_EntPtrArray;
}
enum struct BasePlayerOffsets
{
CBasePlayerOffsets cbpoffsets;
CBaseHandleOffsets cbhoffsets;
CEntInfoOffsets ceioffsets;
CBaseEntityListOffsets cbeloffsets;
}
static BasePlayerOffsets offsets;
methodmap CBasePlayer < AddressBase
{
property float m_surfaceFriction
{
public get() { return view_as<float>(LoadFromAddress(this.Address + offsets.cbpoffsets.m_surfaceFriction, NumberType_Int32)); }
}
//...
property Address m_hGroundEntity
{
public get() { return view_as<Address>(LoadFromAddress(this.Address + offsets.cbpoffsets.m_hGroundEntity, NumberType_Int32)); }
}
//...
property MoveType m_MoveType
{
public get() { return view_as<MoveType>(LoadFromAddress(this.Address + offsets.cbpoffsets.m_MoveType, NumberType_Int8)); }
}
}
methodmap CBaseEntityList < AddressBase
{
property PseudoStackArray m_EntPtrArray
{
public get() { return view_as<PseudoStackArray>(LoadFromAddress(this.Address + offsets.cbeloffsets.m_EntPtrArray, NumberType_Int32)); }
}
}
static CBaseEntityList g_pEntityList;
methodmap CBaseHandle < AddressBase
{
property int m_Index
{
public get() { return LoadFromAddress(this.Address + offsets.cbhoffsets.m_Index, NumberType_Int32); }
}
public CBaseHandle Get()
{
return LookupEntity(this);
}
public int GetEntryIndex()
{
return
}
}
methodmap CEntInfo < AddressBase
{
public static int Size()
{
return offsets.ceioffsets.size;
}
property CBaseHandle m_pEntity
{
public get() { return view_as<CBaseHandle>(LoadFromAddress(this.Address + offsets.ceioffsets.m_pEntity, NumberType_Int32)); }
}
property int m_SerialNumber
{
public get() { return LoadFromAddress(this.Address + offsets.ceioffsets.m_SerialNumber, NumberType_Int32); }
}
}
stock bool InitBasePlayer(GameData gd)
{
char buff[128];
bool early = false;
if(gEngineVersion == Engine_CSS)
{
//g_pEntityList
g_pEntityList = view_as<CBaseEntityList>(gd.GetAddress("g_pEntityList"));
ASSERT_MSG(g_pEntityList.Address != Address_Null, "Can't get \"g_pEntityList\" address from gamedata. Gamedata needs an update.");
//CBaseEntityList
ASSERT_FMT(gd.GetKeyValue("CBaseEntityList::m_EntPtrArray", buff, sizeof(buff)), "Can't get \"CBaseEntityList::m_EntPtrArray\" offset from gamedata.");
offsets.cbeloffsets.m_EntPtrArray = StringToInt(buff);
//CEntInfo
ASSERT_FMT(gd.GetKeyValue("CEntInfo::m_pEntity", buff, sizeof(buff)), "Can't get \"CEntInfo::m_pEntity\" offset from gamedata.");
offsets.ceioffsets.m_pEntity = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CEntInfo::m_SerialNumber", buff, sizeof(buff)), "Can't get \"CEntInfo::m_SerialNumber\" offset from gamedata.");
offsets.ceioffsets.m_SerialNumber = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CEntInfo::size", buff, sizeof(buff)), "Can't get \"CEntInfo::size\" offset from gamedata.");
offsets.ceioffsets.size = StringToInt(buff);
//CBaseHandle
ASSERT_FMT(gd.GetKeyValue("CBaseHandle::m_Index", buff, sizeof(buff)), "Can't get \"CBaseHandle::m_Index\" offset from gamedata.");
offsets.cbhoffsets.m_Index = StringToInt(buff);
//CBasePlayer
ASSERT_FMT(gd.GetKeyValue("CBasePlayer::m_surfaceFriction", buff, sizeof(buff)), "Can't get \"CBasePlayer::m_surfaceFriction\" offset from gamedata.");
int offs = StringToInt(buff);
int prop_offs = FindSendPropInfo("CBasePlayer", "m_szLastPlaceName");
ASSERT_FMT(prop_offs > 0, "Can't get \"CBasePlayer::m_szLastPlaceName\" offset from FindSendPropInfo().");
offsets.cbpoffsets.m_surfaceFriction = prop_offs + offs;
}
else if(gEngineVersion == Engine_CSGO)
{
//CBasePlayer
ASSERT_FMT(gd.GetKeyValue("CBasePlayer::m_surfaceFriction", buff, sizeof(buff)), "Can't get \"CBasePlayer::m_surfaceFriction\" offset from gamedata.");
int offs = StringToInt(buff);
int prop_offs = FindSendPropInfo("CBasePlayer", "m_ubEFNoInterpParity");
ASSERT_FMT(prop_offs > 0, "Can't get \"CBasePlayer::m_ubEFNoInterpParity\" offset from FindSendPropInfo().");
offsets.cbpoffsets.m_surfaceFriction = prop_offs - offs;
}
offsets.cbpoffsets.m_hGroundEntity = FindSendPropInfo("CBasePlayer", "m_hGroundEntity");
ASSERT_FMT(offsets.cbpoffsets.m_hGroundEntity > 0, "Can't get \"CBasePlayer::m_hGroundEntity\" offset from FindSendPropInfo().");
if(IsValidEntity(0))
{
offsets.cbpoffsets.m_MoveType = FindDataMapInfo(0, "m_MoveType");
ASSERT_FMT(offsets.cbpoffsets.m_MoveType != -1, "Can't get \"CBasePlayer::m_MoveType\" offset from FindDataMapInfo().");
}
else
early = true;
return early;
}
stock void LateInitBasePlayer(GameData gd)
{
ASSERT(IsValidEntity(0));
offsets.cbpoffsets.m_MoveType = FindDataMapInfo(0, "m_MoveType");
ASSERT_FMT(offsets.cbpoffsets.m_MoveType != -1, "Can't get \"CBasePlayer::m_MoveType\" offset from FindDataMapInfo().");
}
stock CBaseHandle LookupEntity(CBaseHandle handle)
{
if(handle.m_Index == INVALID_EHANDLE_INDEX)
return view_as<CBaseHandle>(0);
CEntInfo pInfo = view_as<CEntInfo>(g_pEntityList.m_EntPtrArray.Get32(handle.m_Index & ENT_ENTRY_MASK, CEntInfo.Size()));
if(pInfo.m_SerialNumber == (handle.m_Index >> NUM_ENT_ENTRY_BITS))
return pInfo.m_pEntity;
else
return view_as<CBaseHandle>(0);
}
|