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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
|
enum struct cplane_tOffsets
{
int normal;
int dist;
int type;
int signbits;
}
enum struct csurface_tOffsets
{
int name;
int surfaceProps;
int flags;
}
enum struct CGameTraceOffsets
{
//CBaseTrace
int startpos;
int endpos;
int plane;
int fraction;
int contents;
int dispFlags;
int allsolid;
int startsolid;
//CGameTrace
int fractionleftsolid;
int surface;
int hitgroup;
int physicsbone;
int m_pEnt;
int hitbox;
int size;
}
enum struct Ray_tOffsets
{
int m_Start;
int m_Delta;
int m_StartOffset;
int m_Extents;
int m_pWorldAxisTransform;
int m_IsRay;
int m_IsSwept;
int size;
}
enum struct CTraceFilterSimpleOffsets
{
int vptr;
int m_pPassEnt;
int m_collisionGroup;
int m_pExtraShouldHitCheckFunction;
int size;
Address vtable;
}
enum struct GameTraceOffsets
{
cplane_tOffsets cptoffsets;
csurface_tOffsets cstoffsets;
CGameTraceOffsets cgtoffsets;
Ray_tOffsets rtoffsets;
CTraceFilterSimpleOffsets ctfsoffsets;
}
static GameTraceOffsets offsets;
methodmap Cplane_t < AddressBase
{
property Vector normal
{
public get() { return view_as<Vector>(this.Address + offsets.cptoffsets.normal); }
}
property float dist
{
public get() { return view_as<float>(LoadFromAddress(this.Address + offsets.cptoffsets.dist, NumberType_Int32)); }
}
property char type
{
public get() { return view_as<char>(LoadFromAddress(this.Address + offsets.cptoffsets.type, NumberType_Int8)); }
}
property char signbits
{
public get() { return view_as<char>(LoadFromAddress(this.Address + offsets.cptoffsets.signbits, NumberType_Int8)); }
}
}
methodmap Csurface_t < AddressBase
{
property Address name
{
public get() { return view_as<Address>(LoadFromAddress(this.Address + offsets.cstoffsets.name, NumberType_Int32)); }
}
property int surfaceProps
{
public get() { return LoadFromAddress(this.Address + offsets.cstoffsets.surfaceProps, NumberType_Int16); }
}
property int flags
{
public get() { return LoadFromAddress(this.Address + offsets.cstoffsets.flags, NumberType_Int16); }
}
}
methodmap CGameTrace < AllocatableBase
{
public static int Size()
{
return offsets.cgtoffsets.size;
}
property Vector startpos
{
public get() { return view_as<Vector>(this.Address + offsets.cgtoffsets.startpos); }
}
property Vector endpos
{
public get() { return view_as<Vector>(this.Address + offsets.cgtoffsets.endpos); }
}
property Cplane_t plane
{
public get() { return view_as<Cplane_t>(this.Address + offsets.cgtoffsets.plane); }
}
property float fraction
{
public get() { return view_as<float>(LoadFromAddress(this.Address + offsets.cgtoffsets.fraction, NumberType_Int32)); }
}
property int contents
{
public get() { return LoadFromAddress(this.Address + offsets.cgtoffsets.contents, NumberType_Int32); }
}
property int dispFlags
{
public get() { return LoadFromAddress(this.Address + offsets.cgtoffsets.dispFlags, NumberType_Int16); }
}
property bool allsolid
{
public get() { return view_as<bool>(LoadFromAddress(this.Address + offsets.cgtoffsets.allsolid, NumberType_Int8)); }
}
property bool startsolid
{
public get() { return view_as<bool>(LoadFromAddress(this.Address + offsets.cgtoffsets.startsolid, NumberType_Int8)); }
}
property float fractionleftsolid
{
public get() { return view_as<float>(LoadFromAddress(this.Address + offsets.cgtoffsets.fractionleftsolid, NumberType_Int32)); }
}
property Csurface_t surface
{
public get() { return view_as<Csurface_t>(this.Address + offsets.cgtoffsets.surface); }
}
property int hitgroup
{
public get() { return LoadFromAddress(this.Address + offsets.cgtoffsets.hitgroup, NumberType_Int32); }
}
property int physicsbone
{
public get() { return LoadFromAddress(this.Address + offsets.cgtoffsets.physicsbone, NumberType_Int16); }
}
property Address m_pEnt
{
public get() { return view_as<Address>(LoadFromAddress(this.Address + offsets.cgtoffsets.m_pEnt, NumberType_Int32)); }
}
property int hitbox
{
public get() { return LoadFromAddress(this.Address + offsets.cgtoffsets.hitbox, NumberType_Int32); }
}
public CGameTrace()
{
return MALLOC(CGameTrace);
}
}
methodmap Ray_t < AllocatableBase
{
public static int Size()
{
return offsets.rtoffsets.size;
}
property Vector m_Start
{
public get() { return view_as<Vector>(this.Address + offsets.rtoffsets.m_Start); }
}
property Vector m_Delta
{
public get() { return view_as<Vector>(this.Address + offsets.rtoffsets.m_Delta); }
}
property Vector m_StartOffset
{
public get() { return view_as<Vector>(this.Address + offsets.rtoffsets.m_StartOffset); }
}
property Vector m_Extents
{
public get() { return view_as<Vector>(this.Address + offsets.rtoffsets.m_Extents); }
}
property Address m_pWorldAxisTransform
{
public get() { return view_as<Address>(LoadFromAddress(this.Address + offsets.rtoffsets.m_pWorldAxisTransform, NumberType_Int32)); }
public set(Address _worldaxistransform) { StoreToAddress(this.Address + offsets.rtoffsets.m_pWorldAxisTransform, view_as<int>(_worldaxistransform), NumberType_Int32, false); }
}
property bool m_IsRay
{
public get() { return view_as<bool>(LoadFromAddress(this.Address + offsets.rtoffsets.m_IsRay, NumberType_Int8)); }
public set(bool _isray) { StoreToAddress(this.Address + offsets.rtoffsets.m_IsRay, _isray, NumberType_Int8, false); }
}
property bool m_IsSwept
{
public get() { return view_as<bool>(LoadFromAddress(this.Address + offsets.rtoffsets.m_IsSwept, NumberType_Int8)); }
public set(bool _isswept) { StoreToAddress(this.Address + offsets.rtoffsets.m_IsSwept, _isswept, NumberType_Int8, false); }
}
public Ray_t()
{
return MALLOC(Ray_t);
}
//That function is quite heavy, linux builds have it inlined, so can't use it!
//Replacing this function with lighter alternative may increase speed by ~4 times!
//From my testings the main performance killer here is StoreToAddress()....
public void Init(float start[3], float end[3], float mins[3], float maxs[3])
{
float buff[3], buff2[3];
SubtractVectors(end, start, buff);
this.m_Delta.FromArray(buff);
if(gEngineVersion == Engine_CSGO)
this.m_pWorldAxisTransform = Address_Null;
this.m_IsSwept = (this.m_Delta.LengthSqr() != 0.0);
SubtractVectors(maxs, mins, buff);
ScaleVector(buff, 0.5);
this.m_Extents.FromArray(buff);
this.m_IsRay = (this.m_Extents.LengthSqr() < 1.0e-6);
AddVectors(mins, maxs, buff);
ScaleVector(buff, 0.5);
AddVectors(start, buff, buff2);
this.m_Start.FromArray(buff2);
NegateVector(buff);
this.m_StartOffset.FromArray(buff);
}
}
methodmap CTraceFilterSimple < AllocatableBase
{
public static int Size()
{
return offsets.ctfsoffsets.size;
}
property Address vptr
{
public get() { return view_as<Address>(LoadFromAddress(this.Address + offsets.ctfsoffsets.vptr, NumberType_Int32)); }
public set(Address _vtbladdr) { StoreToAddress(this.Address + offsets.ctfsoffsets.vptr, view_as<int>(_vtbladdr), NumberType_Int32, false); }
}
property CBaseHandle m_pPassEnt
{
public get() { return view_as<CBaseHandle>(LoadFromAddress(this.Address + offsets.ctfsoffsets.m_pPassEnt, NumberType_Int32)); }
public set(CBaseHandle _passent) { StoreToAddress(this.Address + offsets.ctfsoffsets.m_pPassEnt, view_as<int>(_passent), NumberType_Int32, false); }
}
property int m_collisionGroup
{
public get() { return LoadFromAddress(this.Address + offsets.ctfsoffsets.m_collisionGroup, NumberType_Int32); }
public set(int _collisiongroup) { StoreToAddress(this.Address + offsets.ctfsoffsets.m_collisionGroup, _collisiongroup, NumberType_Int32, false); }
}
property Address m_pExtraShouldHitCheckFunction
{
public get() { return view_as<Address>(LoadFromAddress(this.Address + offsets.ctfsoffsets.m_pExtraShouldHitCheckFunction, NumberType_Int32)); }
public set(Address _checkfnc) { StoreToAddress(this.Address + offsets.ctfsoffsets.m_pExtraShouldHitCheckFunction, view_as<int>(_checkfnc), NumberType_Int32, false); }
}
public CTraceFilterSimple()
{
CTraceFilterSimple addr = MALLOC(CTraceFilterSimple);
addr.vptr = offsets.ctfsoffsets.vtable;
return addr;
}
public void Init(CBaseHandle passentity, int collisionGroup, Address pExtraShouldHitCheckFn = Address_Null)
{
this.m_pPassEnt = passentity;
this.m_collisionGroup = collisionGroup;
this.m_pExtraShouldHitCheckFunction = pExtraShouldHitCheckFn;
}
}
static Handle gCanTraceRay;
methodmap ITraceListData < AddressBase
{
public bool CanTraceRay(Ray_t ray)
{
return SDKCall(gCanTraceRay, this.Address, ray.Address);
}
}
static Handle gTraceRay, gTraceRayAgainstLeafAndEntityList;
static Address gEngineTrace;
stock void InitGameTrace(GameData gd)
{
char buff[128];
//cplane_t
ASSERT_FMT(gd.GetKeyValue("cplane_t::normal", buff, sizeof(buff)), "Can't get \"cplane_t::normal\" offset from gamedata.");
offsets.cptoffsets.normal = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("cplane_t::dist", buff, sizeof(buff)), "Can't get \"cplane_t::dist\" offset from gamedata.");
offsets.cptoffsets.dist = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("cplane_t::type", buff, sizeof(buff)), "Can't get \"cplane_t::type\" offset from gamedata.");
offsets.cptoffsets.type = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("cplane_t::signbits", buff, sizeof(buff)), "Can't get \"cplane_t::signbits\" offset from gamedata.");
offsets.cptoffsets.signbits = StringToInt(buff);
//csurface_t
ASSERT_FMT(gd.GetKeyValue("csurface_t::name", buff, sizeof(buff)), "Can't get \"csurface_t::name\" offset from gamedata.");
offsets.cstoffsets.name = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("csurface_t::surfaceProps", buff, sizeof(buff)), "Can't get \"csurface_t::surfaceProps\" offset from gamedata.");
offsets.cstoffsets.surfaceProps = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("csurface_t::flags", buff, sizeof(buff)), "Can't get \"csurface_t::flags\" offset from gamedata.");
offsets.cstoffsets.flags = StringToInt(buff);
//CGameTrace
ASSERT_FMT(gd.GetKeyValue("CGameTrace::startpos", buff, sizeof(buff)), "Can't get \"CGameTrace::startpos\" offset from gamedata.");
offsets.cgtoffsets.startpos = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CGameTrace::endpos", buff, sizeof(buff)), "Can't get \"CGameTrace::endpos\" offset from gamedata.");
offsets.cgtoffsets.endpos = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CGameTrace::plane", buff, sizeof(buff)), "Can't get \"CGameTrace::plane\" offset from gamedata.");
offsets.cgtoffsets.plane = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CGameTrace::fraction", buff, sizeof(buff)), "Can't get \"CGameTrace::fraction\" offset from gamedata.");
offsets.cgtoffsets.fraction = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CGameTrace::contents", buff, sizeof(buff)), "Can't get \"CGameTrace::contents\" offset from gamedata.");
offsets.cgtoffsets.contents = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CGameTrace::dispFlags", buff, sizeof(buff)), "Can't get \"CGameTrace::dispFlags\" offset from gamedata.");
offsets.cgtoffsets.dispFlags = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CGameTrace::allsolid", buff, sizeof(buff)), "Can't get \"CGameTrace::allsolid\" offset from gamedata.");
offsets.cgtoffsets.allsolid = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CGameTrace::startsolid", buff, sizeof(buff)), "Can't get \"CGameTrace::startsolid\" offset from gamedata.");
offsets.cgtoffsets.startsolid = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CGameTrace::fractionleftsolid", buff, sizeof(buff)), "Can't get \"CGameTrace::fractionleftsolid\" offset from gamedata.");
offsets.cgtoffsets.fractionleftsolid = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CGameTrace::surface", buff, sizeof(buff)), "Can't get \"CGameTrace::surface\" offset from gamedata.");
offsets.cgtoffsets.surface = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CGameTrace::hitgroup", buff, sizeof(buff)), "Can't get \"CGameTrace::hitgroup\" offset from gamedata.");
offsets.cgtoffsets.hitgroup = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CGameTrace::physicsbone", buff, sizeof(buff)), "Can't get \"CGameTrace::physicsbone\" offset from gamedata.");
offsets.cgtoffsets.physicsbone = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CGameTrace::m_pEnt", buff, sizeof(buff)), "Can't get \"CGameTrace::m_pEnt\" offset from gamedata.");
offsets.cgtoffsets.m_pEnt = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CGameTrace::hitbox", buff, sizeof(buff)), "Can't get \"CGameTrace::hitbox\" offset from gamedata.");
offsets.cgtoffsets.hitbox = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CGameTrace::size", buff, sizeof(buff)), "Can't get \"CGameTrace::size\" offset from gamedata.");
offsets.cgtoffsets.size = StringToInt(buff);
//Ray_t
ASSERT_FMT(gd.GetKeyValue("Ray_t::m_Start", buff, sizeof(buff)), "Can't get \"Ray_t::m_Start\" offset from gamedata.");
offsets.rtoffsets.m_Start = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("Ray_t::m_Delta", buff, sizeof(buff)), "Can't get \"Ray_t::m_Delta\" offset from gamedata.");
offsets.rtoffsets.m_Delta = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("Ray_t::m_StartOffset", buff, sizeof(buff)), "Can't get \"Ray_t::m_StartOffset\" offset from gamedata.");
offsets.rtoffsets.m_StartOffset = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("Ray_t::m_Extents", buff, sizeof(buff)), "Can't get \"Ray_t::m_Extents\" offset from gamedata.");
offsets.rtoffsets.m_Extents = StringToInt(buff);
if(gEngineVersion == Engine_CSGO)
{
ASSERT_FMT(gd.GetKeyValue("Ray_t::m_pWorldAxisTransform", buff, sizeof(buff)), "Can't get \"Ray_t::m_pWorldAxisTransform\" offset from gamedata.");
offsets.rtoffsets.m_pWorldAxisTransform = StringToInt(buff);
}
ASSERT_FMT(gd.GetKeyValue("Ray_t::m_IsRay", buff, sizeof(buff)), "Can't get \"Ray_t::m_IsRay\" offset from gamedata.");
offsets.rtoffsets.m_IsRay = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("Ray_t::m_IsSwept", buff, sizeof(buff)), "Can't get \"Ray_t::m_IsSwept\" offset from gamedata.");
offsets.rtoffsets.m_IsSwept = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("Ray_t::size", buff, sizeof(buff)), "Can't get \"Ray_t::size\" offset from gamedata.");
offsets.rtoffsets.size = StringToInt(buff);
//CTraceFilterSimple
ASSERT_FMT(gd.GetKeyValue("CTraceFilterSimple::vptr", buff, sizeof(buff)), "Can't get \"CTraceFilterSimple::vptr\" offset from gamedata.");
offsets.ctfsoffsets.vptr = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CTraceFilterSimple::m_pPassEnt", buff, sizeof(buff)), "Can't get \"CTraceFilterSimple::m_pPassEnt\" offset from gamedata.");
offsets.ctfsoffsets.m_pPassEnt = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CTraceFilterSimple::m_collisionGroup", buff, sizeof(buff)), "Can't get \"CTraceFilterSimple::m_collisionGroup\" offset from gamedata.");
offsets.ctfsoffsets.m_collisionGroup = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CTraceFilterSimple::m_pExtraShouldHitCheckFunction", buff, sizeof(buff)), "Can't get \"CTraceFilterSimple::m_pExtraShouldHitCheckFunction\" offset from gamedata.");
offsets.ctfsoffsets.m_pExtraShouldHitCheckFunction = StringToInt(buff);
ASSERT_FMT(gd.GetKeyValue("CTraceFilterSimple::size", buff, sizeof(buff)), "Can't get \"CTraceFilterSimple::size\" offset from gamedata.");
offsets.ctfsoffsets.size = StringToInt(buff);
if(gEngineVersion == Engine_CSS)
{
offsets.ctfsoffsets.vtable = gd.GetAddress("CTraceFilterSimple::vtable");
ASSERT_MSG(offsets.ctfsoffsets.vtable != Address_Null, "Can't get \"CTraceFilterSimple::vtable\" address from gamedata. Gamedata needs an update.");
}
//enginetrace
gd.GetKeyValue("CEngineTrace", buff, sizeof(buff));
gEngineTrace = CreateInterface(buff);
ASSERT_MSG(gEngineTrace != Address_Null, "Can't create \"enginetrace\" from CreateInterface().");
//RayTrace
StartPrepSDKCall(SDKCall_Raw);
PrepSDKCall_SetVirtual(gd.GetOffset("TraceRay"));
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
gTraceRay = EndPrepSDKCall();
ASSERT(gTraceRay);
if(gEngineVersion == Engine_CSGO)
{
//TraceRayAgainstLeafAndEntityList
StartPrepSDKCall(SDKCall_Raw);
PrepSDKCall_SetVirtual(gd.GetOffset("TraceRayAgainstLeafAndEntityList"));
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
gTraceRayAgainstLeafAndEntityList = EndPrepSDKCall();
ASSERT(gTraceRayAgainstLeafAndEntityList);
//CanTraceRay
StartPrepSDKCall(SDKCall_Raw);
PrepSDKCall_SetVirtual(gd.GetOffset("CanTraceRay"));
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
PrepSDKCall_SetReturnInfo(SDKType_Bool, SDKPass_Plain);
gCanTraceRay = EndPrepSDKCall();
ASSERT(gCanTraceRay);
}
}
stock void TraceRayAgainstLeafAndEntityList(Ray_t ray, ITraceListData traceData, int mask, CTraceFilterSimple filter, CGameTrace trace)
{
SDKCall(gTraceRayAgainstLeafAndEntityList, gEngineTrace, ray.Address, traceData.Address, mask, filter.Address, trace.Address);
}
stock void TraceRay(Ray_t ray, int mask, CTraceFilterSimple filter, CGameTrace trace)
{
SDKCall(gTraceRay, gEngineTrace, ray.Address, mask, filter.Address, trace.Address);
}
|