forked from haithun/CoD4X17a_testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity.h
484 lines (344 loc) · 12.7 KB
/
entity.h
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
481
482
483
484
/*
===========================================================================
Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of CoD4X17a-Server source code.
CoD4X17a-Server source code is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
CoD4X17a-Server source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
===========================================================================
*/
#ifndef __ENTITY_H__
#define __ENTITY_H__
#include "q_math.h"
#include "q_shared.h"
#define g_entities ((gentity_t*)(0x841ffe0))
typedef int clipHandle_t;
typedef enum {
TR_STATIONARY,
TR_INTERPOLATE, // non-parametric, but interpolate between snapshots
TR_LINEAR,
TR_LINEAR_STOP,
TR_SINE, // value = base + sin( time / duration ) * delta
TR_GRAVITY
} trType_t;
typedef struct {
trType_t trType;
int trTime;
int trDuration; // if non 0, trTime + trDuration = stop time
vec3_t trBase;
vec3_t trDelta; // velocity, etc
} trajectory_t;
typedef struct{
int cullDist;
int period;
}lerp_loopFx_t;
typedef struct{
int bodyPitch;
int bodyRoll;
int steerYaw;
int materialTime;
int gunPitch;
int gunYaw;
int teamAndOwnerIndex;
}lerp_vehicle_t;
typedef struct{
int lerp;
}lerp_soundBlend_t;
typedef struct{
int launchTime;
}lerp_missile_t;
typedef struct{
int leanf;
int movementDir;
}lerp_player_t;
typedef struct{
int data[6];
}lerp_anonymous_t;
typedef struct {
int eFlags;
trajectory_t pos; // for calculating position 0x0c
trajectory_t apos; // for calculating angles 0x30
union{
lerp_anonymous_t anonymous;
lerp_player_t player;
lerp_missile_t missile;
lerp_soundBlend_t soundBlend;
lerp_loopFx_t loopFx;
lerp_vehicle_t vehicle;
}u;
}lerp_t;
// entityState_t is the information conveyed from the server
// in an update message about entities that the client will
// need to render in some way
// Different eTypes may use the information in different ways
// The messages are delta compressed, so it doesn't really matter if
// the structure size is fairly large
typedef struct entityState_s {//Confirmed names and offsets but not types
int number; // entity index //0x00
int eType; // entityType_t //0x04
lerp_t lerp;
int time2; //0x70
int otherEntityNum; //0x74 shotgun sources, etc
int attackerEntityNum; //0x78
int groundEntityNum; //0x7c -1 = in air
int loopSound; //0x80 constantly loop this sound
int surfType; //0x84
clipHandle_t index; //0x88
int clientNum; //0x8c 0 to (MAX_CLIENTS - 1), for players and corpses
int iHeadIcon; //0x90
int iHeadIconTeam; //0x94
int solid; //0x98 for client side prediction, trap_linkentity sets this properly 0x98
int eventParm; //0x9c impulse events -- muzzle flashes, footsteps, etc
int eventSequence; //0xa0
vec4_t events; //0xa4
vec4_t eventParms; //0xb4
// for players
int weapon; //0xc4 determines weapon and flash model, etc
int weaponModel; //0xc8
int legsAnim; //0xcc mask off ANIM_TOGGLEBIT
int torsoAnim; //0xd0 mask off ANIM_TOGGLEBIT
union{
int helicopterStage; //0xd4
}un1;
int un2; //0xd8
int fTorsoPitch; //0xdc
int fWaistPitch; //0xe0
vec4_t partBits; //0xe4
} entityState_t; //sizeof(entityState_t): 0xf4
typedef struct {
//entityState_t s; //Duplicated struct is removed
byte linked; //0xf4 qfalse if not in any good cluster
byte bmodel; //0xf5 if false, assume an explicit mins / maxs bounding box
// only set by trap_SetBrushModel
short unknown1;
int unknown2[4];
vec3_t mins, maxs; //0x108 //0x114 from SharedEntity_t
int contents; // CONTENTS_TRIGGER, CONTENTS_SOLID, CONTENTS_BODY, etc
// a non-solid entity should set to 0
vec3_t absmin, absmax; //0x124 //0x130 derived from mins/maxs and origin + rotation
// currentOrigin will be used for all collision detection and world linking.
// it will not necessarily be the same as the trajectory evaluation for the current
// time, because each entity must be moved one at a time after time is advanced
// to avoid simultanious collision issues
vec3_t currentOrigin; //0x13c
vec3_t currentAngles; //0x148
// when a trace call is made and passEntityNum != ENTITYNUM_NONE,
// an ent will be excluded from testing if:
// ent->s.number == passEntityNum (don't interact with self)
// ent->r.ownerNum == passEntityNum (don't interact with your own missiles)
// entity[ent->r.ownerNum].r.ownerNum == passEntityNum (don't interact with other missiles from owner)
short ownerNum; //0x154
short unknown3;
int eventTime;
} entityShared_t;
// the server looks at a sharedEntity, which is the start of the game's gentity_t structure
typedef struct {
entityState_t s; // communicated by server to clients
entityShared_t r; // shared by both the server system and game
} sharedEntity_t;
typedef struct gentity_s gentity_t;
struct gentity_s {
entityState_t s;
entityShared_t r; // shared by both the server system and game
// DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER
// EXPECTS THE FIELDS IN THAT ORDER!
//================================
struct gclient_s *client; // NULL if not a client 0x15c
qboolean inuse;
byte unknown[0x110]; //0x164
/*
char *classname; // set in QuakeEd
int spawnflags; // set in QuakeEd
qboolean neverFree; // if true, FreeEntity will only unlink
// bodyque uses this
int flags; // FL_* variables
char *model;
char *model2;
int freetime; // level.time when the object was freed
int eventTime; // events will be cleared EVENT_VALID_MSEC after set
qboolean freeAfterEvent;
qboolean unlinkAfterEvent;
qboolean physicsObject; // if true, it can be pushed by movers and fall off edges
// all game items are physicsObjects,
float physicsBounce; // 1.0 = continuous bounce, 0.0 = no bounce
int clipmask; // brushes with this content value will be collided against
// when moving. items and corpses do not collide against
// players, for instance
// movers
moverState_t moverState;
int soundPos1;
int sound1to2;
int sound2to1;
int soundPos2;
int soundLoop;
// JOSEPH 1-26-00
int sound2to3;
int sound3to2;
int soundPos3;
// END JOSEPH
int soundKicked;
int soundKickedEnd;
int soundSoftopen;
int soundSoftendo;
int soundSoftclose;
int soundSoftendc;
gentity_t *parent;
gentity_t *nextTrain;
gentity_t *prevTrain;
// JOSEPH 1-26-00
vec3_t pos1, pos2, pos3;
// END JOSEPH
char *message;
int timestamp; // body queue sinking, etc //0x1bc
float angle; // set in editor, -1 = up, -2 = down
char *target;
char *targetname;
char *team;
char *targetShaderName;
char *targetShaderNewName;
gentity_t *target_ent;
float speed;
float closespeed; // for movers that close at a different speed than they open
vec3_t movedir;
int gDuration;
int gDurationBack;
vec3_t gDelta;
vec3_t gDeltaBack;
int nextthink;
void ( *think )( gentity_t *self );
void ( *reached )( gentity_t *self ); // movers call this when hitting endpoint
void ( *blocked )( gentity_t *self, gentity_t *other );
void ( *touch )( gentity_t *self, gentity_t *other, trace_t *trace );
void ( *use )( gentity_t *self, gentity_t *other, gentity_t *activator );
void ( *pain )( gentity_t *self, gentity_t *attacker, int damage, vec3_t point );
void ( *die )( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod );
int pain_debounce_time;
int fly_sound_debounce_time; // wind tunnel
int last_move_time;
int health; //0x1A0 ??
qboolean takedamage; //0x16b
int damage;
int splashDamage; // quad will increase this without increasing radius
int splashRadius;
int methodOfDeath;
int splashMethodOfDeath;
int count;
gentity_t *chain;
gentity_t *enemy;
gentity_t *activator;
gentity_t *teamchain; // next entity in team
gentity_t *teammaster; // master of the team
int watertype;
int waterlevel;
int noise_index;
// timing variables
float wait; //
float random; //
// Rafael - sniper variable
// sniper uses delay, random, radius
int radius;
float delay;
// JOSEPH 10-11-99
int TargetFlag;
float duration;
vec3_t rotate;
vec3_t TargetAngles;
// END JOSEPH
gitem_t *item; // for bonus items
// Ridah, AI fields
char *aiAttributes;
char *aiName;
int aiTeam;
void ( *AIScript_AlertEntity )( gentity_t *ent );
qboolean aiInactive;
int aiCharacter; // the index of the type of character we are (from aicast_soldier.c)
// done.
char *aiSkin;
char *aihSkin;
vec3_t dl_color;
char *dl_stylestring;
char *dl_shader;
int dl_atten;
int key; // used by: target_speaker->nopvs,
qboolean active; //0x16c
qboolean botDelayBegin;
// Rafael - mg42
float harc;
float varc;
int props_frame_state;
// Ridah
int missionLevel; // mission we are currently trying to complete
// gets reset each new level
// done.
// Rafael
qboolean is_dead;
// done
int start_size;
int end_size;
// Rafael props
qboolean isProp;
int mg42BaseEnt;
gentity_t *melee;
char *spawnitem;
qboolean nopickup;
int flameQuota, flameQuotaTime, flameBurnEnt;
int count2;
int grenadeExplodeTime; // we've caught a grenade, which was due to explode at this time
int grenadeFired; // the grenade entity we last fired
int mg42ClampTime; // time to wait before an AI decides to ditch the mg42
char *track;
// entity scripting system
char *scriptName;
int numScriptEvents;
g_script_event_t *scriptEvents; // contains a list of actions to perform for each event type
g_script_status_t scriptStatus; // current status of scripting
// the accumulation buffer
int scriptAccumBuffer[G_MAX_SCRIPT_ACCUM_BUFFERS];
qboolean AASblocking;
float accuracy;
char *tagName; // name of the tag we are attached to
gentity_t *tagParent;
float headshotDamageScale;
int lastHintCheckTime; // DHM - Nerve
// -------------------------------------------------------------------------------------------
// if working on a post release patch, new variables should ONLY be inserted after this point
// DHM - Nerve :: the above warning does not really apply to MP, but I'll follow it for good measure
int voiceChatSquelch; // DHM - Nerve
int voiceChatPreviousTime; // DHM - Nerve
int lastBurnedFrameNumber; // JPW - Nerve : to fix FT instant-kill exploit*/
};//Size: 0x274
/***************** Verified *******************************/
#define GENTITYNUM_BITS 10 // JPW NERVE put q3ta default back for testing // don't need to send any more
//#define GENTITYNUM_BITS 11 // don't need to send any more (SA) upped 4/21/2001 adjusted: tr_local.h (802-822), tr_main.c (1501), sv_snapshot (206)
#define MAX_GENTITIES ( 1 << GENTITYNUM_BITS )
// entitynums are communicated with GENTITY_BITS, so any reserved
// values thatare going to be communcated over the net need to
// also be in this range
#define ENTITYNUM_NONE ( MAX_GENTITIES - 1 )
/**********************************************************/
#define ENTITYNUM_WORLD ( MAX_GENTITIES - 2 )
#define ENTITYNUM_MAX_NORMAL ( MAX_GENTITIES - 2 )
#define MAX_ENT_CLUSTERS 16
// contents flags are seperate bits
// a given brush can contribute multiple content bits
// multiple brushes can be in a single leaf
// these definitions also need to be in q_shared.h!
// lower bits are stronger, and will eat weaker brushes completely
#define CONTENTS_SOLID 1 // an eye is never valid in a solid
#define CONTENTS_PLAYERCLIP 0x10000
#define CONTENTS_MONSTERCLIP 0x20000
#define CONTENTS_VEHICLECLIP //??
#define CONTENTS_ITEMCLIP
#define CONTENTS_NODROP
#define CONTENTS_NONSOLID
#define CONTENTS_BODY 0x2000000 // should never be on a brush, only in game
#define PLAYER_SOLIDMASK 0x00600000
#endif