Debian Codegraph @

code/game/g_local.h

raw symbols SCIP
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22 //
23 // g_local.h -- local definitions for game module
24
25 #include "../qcommon/q_shared.h"
26 #include "bg_public.h"
27 #include "g_public.h"
28
29 //==================================================================
30
31 // the "gameversion" client command will print this plus compile date
32 #define GAMEVERSION BASEGAME
33
34 #define BODY_QUEUE_SIZE 8
35
36 #define INFINITE 1000000
37
38 #define FRAMETIME 100 // msec
39 #define CARNAGE_REWARD_TIME 3000
40 #define REWARD_SPRITE_TIME 2000
41
42 #define INTERMISSION_DELAY_TIME 1000
43 #define SP_INTERMISSION_DELAY_TIME 5000
44
45 // gentity->flags
46 #define FL_GODMODE 0x00000010
47 #define FL_NOTARGET 0x00000020
48 #define FL_TEAMMEMBER 0x00000400 // not the first on the team
49 #define FL_NO_KNOCKBACK 0x00000800
50 #define FL_DROPPED_ITEM 0x00001000
51 #define FL_NO_BOTS 0x00002000 // spawn point not for bot use
52 #define FL_NO_HUMANS 0x00004000 // spawn point just for bots
53 #define FL_FORCE_GESTURE 0x00008000 // force gesture on client
54
55 // movers are things like doors, plats, buttons, etc
56 typedef enum {
57 MOVER_POS1,
58 MOVER_POS2,
59 MOVER_1TO2,
60 MOVER_2TO1
61 } moverState_t;
62
63 #define SP_PODIUM_MODEL "models/mapobjects/podium/podium4.md3"
64
65 //============================================================================
66
67 typedef struct gentity_s gentity_t;
68 typedef struct gclient_s gclient_t;
69
70 struct gentity_s {
71 entityState_t s; // communicated by server to clients
72 entityShared_t r; // shared by both the server system and game
73
74 // DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER
75 // EXPECTS THE FIELDS IN THAT ORDER!
76 //================================
77
78 struct gclient_s *client; // NULL if not a client
79
80 qboolean inuse;
81
82 char *classname; // set in QuakeEd
83 int spawnflags; // set in QuakeEd
84
85 qboolean neverFree; // if true, FreeEntity will only unlink
86 // bodyque uses this
87
88 int flags; // FL_* variables
89
90 char *model;
91 char *model2;
92 int freetime; // level.time when the object was freed
93
94 int eventTime; // events will be cleared EVENT_VALID_MSEC after set
95 qboolean freeAfterEvent;
96 qboolean unlinkAfterEvent;
97
98 qboolean physicsObject; // if true, it can be pushed by movers and fall off edges
99 // all game items are physicsObjects,
100 float physicsBounce; // 1.0 = continuous bounce, 0.0 = no bounce
101 int clipmask; // brushes with this content value will be collided against
102 // when moving. items and corpses do not collide against
103 // players, for instance
104
105 // movers
106 moverState_t moverState;
107 int soundPos1;
108 int sound1to2;
109 int sound2to1;
110 int soundPos2;
111 int soundLoop;
112 gentity_t *parent;
113 gentity_t *nextTrain;
114 gentity_t *prevTrain;
115 vec3_t pos1, pos2;
116
117 char *message;
118
119 int timestamp; // body queue sinking, etc
120
121 char *target;
122 char *targetname;
123 char *team;
124 char *targetShaderName;
125 char *targetShaderNewName;
126 gentity_t *target_ent;
127
128 float speed;
129 vec3_t movedir;
130
131 int nextthink;
132 void (*think)(gentity_t *self);
133 void (*reached)(gentity_t *self); // movers call this when hitting endpoint
134 void (*blocked)(gentity_t *self, gentity_t *other);
135 void (*touch)(gentity_t *self, gentity_t *other, trace_t *trace);
136 void (*use)(gentity_t *self, gentity_t *other, gentity_t *activator);
137 void (*pain)(gentity_t *self, gentity_t *attacker, int damage);
138 void (*die)(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod);
139
140 int pain_debounce_time;
141 int fly_sound_debounce_time; // wind tunnel
142 int last_move_time;
143
144 int health;
145
146 qboolean takedamage;
147
148 int damage;
149 int splashDamage; // quad will increase this without increasing radius
150 int splashRadius;
151 int methodOfDeath;
152 int splashMethodOfDeath;
153
154 int count;
155
156 gentity_t *chain;
157 gentity_t *enemy;
158 gentity_t *activator;
159 gentity_t *teamchain; // next entity in team
160 gentity_t *teammaster; // master of the team
161
162 #ifdef MISSIONPACK
163 int kamikazeTime;
164 int kamikazeShockTime;
165 #endif
166
167 int watertype;
168 int waterlevel;
169
170 int noise_index;
171
172 // timing variables
173 float wait;
174 float random;
175
176 gitem_t *item; // for bonus items
177 };
178
179
180 typedef enum {
181 CON_DISCONNECTED,
182 CON_CONNECTING,
183 CON_CONNECTED
184 } clientConnected_t;
185
186 typedef enum {
187 SPECTATOR_NOT,
188 SPECTATOR_FREE,
189 SPECTATOR_FOLLOW,
190 SPECTATOR_SCOREBOARD
191 } spectatorState_t;
192
193 typedef enum {
194 TEAM_BEGIN, // Beginning a team game, spawn at base
195 TEAM_ACTIVE // Now actively playing
196 } playerTeamStateState_t;
197
198 typedef struct {
199 playerTeamStateState_t state;
200
201 int location;
202
203 int captures;
204 int basedefense;
205 int carrierdefense;
206 int flagrecovery;
207 int fragcarrier;
208 int assists;
209
210 float lasthurtcarrier;
211 float lastreturnedflag;
212 float flagsince;
213 float lastfraggedcarrier;
214 } playerTeamState_t;
215
216 // client data that stays across multiple levels or tournament restarts
217 // this is achieved by writing all the data to cvar strings at game shutdown
218 // time and reading them back at connection time. Anything added here
219 // MUST be dealt with in G_InitSessionData() / G_ReadSessionData() / G_WriteSessionData()
220 typedef struct {
221 team_t sessionTeam;
222 int spectatorNum; // for determining next-in-line to play
223 spectatorState_t spectatorState;
224 int spectatorClient; // for chasecam and follow mode
225 int wins, losses; // tournament stats
226 qboolean teamLeader; // true when this client is a team leader
227 } clientSession_t;
228
229 //
230 #define MAX_NETNAME 36
231 #define MAX_VOTE_COUNT 3
232
233 // client data that stays across multiple respawns, but is cleared
234 // on each level change or team change at ClientBegin()
235 typedef struct {
236 clientConnected_t connected;
237 usercmd_t cmd; // we would lose angles if not persistant
238 qboolean localClient; // true if "ip" info key is "localhost"
239 qboolean initialSpawn; // the first spawn should be at a cool location
240 qboolean predictItemPickup; // based on cg_predictItems userinfo
241 qboolean pmoveFixed; //
242 char netname[MAX_NETNAME];
243 int maxHealth; // for handicapping
244 int enterTime; // level.time the client entered the game
245 playerTeamState_t teamState; // status in teamplay games
246 int voteCount; // to prevent people from constantly calling votes
247 int teamVoteCount; // to prevent people from constantly calling votes
248 qboolean teamInfo; // send team overlay updates?
249 } clientPersistant_t;
250
251
252 // this structure is cleared on each ClientSpawn(),
253 // except for 'client->pers' and 'client->sess'
254 struct gclient_s {
255 // ps MUST be the first element, because the server expects it
256 playerState_t ps; // communicated by server to clients
257
258 // the rest of the structure is private to game
259 clientPersistant_t pers;
260 clientSession_t sess;
261
262 qboolean readyToExit; // wishes to leave the intermission
263
264 qboolean noclip;
265
266 int lastCmdTime; // level.time of last usercmd_t, for EF_CONNECTION
267 // we can't just use pers.lastCommand.time, because
268 // of the g_sycronousclients case
269 int buttons;
270 int oldbuttons;
271 int latched_buttons;
272
273 vec3_t oldOrigin;
274
275 // sum up damage over an entire frame, so
276 // shotgun blasts give a single big kick
277 int damage_armor; // damage absorbed by armor
278 int damage_blood; // damage taken out of health
279 int damage_knockback; // impact damage
280 vec3_t damage_from; // origin for vector calculation
281 qboolean damage_fromWorld; // if true, don't use the damage_from vector
282
283 int accurateCount; // for "impressive" reward sound
284
285 int accuracy_shots; // total number of shots
286 int accuracy_hits; // total number of hits
287
288 //
289 int lastkilled_client; // last client that this client killed
290 int lasthurt_client; // last client that damaged this client
291 int lasthurt_mod; // type of damage the client did
292
293 // timers
294 int respawnTime; // can respawn when time > this, force after g_forcerespwan
295 int inactivityTime; // kick players when time > this
296 qboolean inactivityWarning; // qtrue if the five seoond warning has been given
297 int rewardTime; // clear the EF_AWARD_IMPRESSIVE, etc when time > this
298
299 int airOutTime;
300
301 int lastKillTime; // for multiple kill rewards
302
303 qboolean fireHeld; // used for hook
304 gentity_t *hook; // grapple hook if out
305
306 int switchTeamTime; // time the player switched teams
307
308 // timeResidual is used to handle events that happen every second
309 // like health / armor countdowns and regeneration
310 int timeResidual;
311
312 #ifdef MISSIONPACK
313 gentity_t *persistantPowerup;
314 int portalID;
315 int ammoTimes[WP_NUM_WEAPONS];
316 int invulnerabilityTime;
317 #endif
318
319 char *areabits;
320 };
321
322
323 //
324 // this structure is cleared as each map is entered
325 //
326 #define MAX_SPAWN_VARS 64
327 #define MAX_SPAWN_VARS_CHARS 4096
328
329 typedef struct {
330 struct gclient_s *clients; // [maxclients]
331
332 struct gentity_s *gentities;
333 int gentitySize;
334 int num_entities; // MAX_CLIENTS <= num_entities <= ENTITYNUM_MAX_NORMAL
335
336 int warmupTime; // restart match at this time
337
338 fileHandle_t logFile;
339
340 // store latched cvars here that we want to get at often
341 int maxclients;
342
343 int framenum;
344 int time; // in msec
345 int previousTime; // so movers can back up when blocked
346
347 int startTime; // level.time the map was started
348
349 int teamScores[TEAM_NUM_TEAMS];
350 int lastTeamLocationTime; // last time of client team location update
351
352 qboolean newSession; // don't use any old session data, because
353 // we changed gametype
354
355 qboolean restarted; // waiting for a map_restart to fire
356
357 int numConnectedClients;
358 int numNonSpectatorClients; // includes connecting clients
359 int numPlayingClients; // connected, non-spectators
360 int sortedClients[MAX_CLIENTS]; // sorted by score
361 int follow1, follow2; // clientNums for auto-follow spectators
362
363 int snd_fry; // sound index for standing in lava
364
365 int warmupModificationCount; // for detecting if g_warmup is changed
366
367 // voting state
368 char voteString[MAX_STRING_CHARS];
369 char voteDisplayString[MAX_STRING_CHARS];
370 int voteTime; // level.time vote was called
371 int voteExecuteTime; // time the vote is executed
372 int voteYes;
373 int voteNo;
374 int numVotingClients; // set by CalculateRanks
375
376 // team voting state
377 char teamVoteString[2][MAX_STRING_CHARS];
378 int teamVoteTime[2]; // level.time vote was called
379 int teamVoteYes[2];
380 int teamVoteNo[2];
381 int numteamVotingClients[2];// set by CalculateRanks
382
383 // spawn variables
384 qboolean spawning; // the G_Spawn*() functions are valid
385 int numSpawnVars;
386 char *spawnVars[MAX_SPAWN_VARS][2]; // key / value pairs
387 int numSpawnVarChars;
388 char spawnVarChars[MAX_SPAWN_VARS_CHARS];
389
390 // intermission state
391 int intermissionQueued; // intermission was qualified, but
392 // wait INTERMISSION_DELAY_TIME before
393 // actually going there so the last
394 // frag can be watched. Disable future
395 // kills during this delay
396 int intermissiontime; // time the intermission was started
397 char *changemap;
398 qboolean readyToExit; // at least one client wants to exit
399 int exitTime;
400 vec3_t intermission_origin; // also used for spectator spawns
401 vec3_t intermission_angle;
402
403 qboolean locationLinked; // target_locations get linked
404 gentity_t *locationHead; // head of the location list
405 int bodyQueIndex; // dead bodies
406 gentity_t *bodyQue[BODY_QUEUE_SIZE];
407 #ifdef MISSIONPACK
408 int portalSequence;
409 #endif
410 } level_locals_t;
411
412
413 //
414 // g_spawn.c
415 //
416 qboolean G_SpawnString( const char *key, const char *defaultString, char **out );
417 // spawn string returns a temporary reference, you must CopyString() if you want to keep it
418 qboolean G_SpawnFloat( const char *key, const char *defaultString, float *out );
419 qboolean G_SpawnInt( const char *key, const char *defaultString, int *out );
420 qboolean G_SpawnVector( const char *key, const char *defaultString, float *out );
421 void G_SpawnEntitiesFromString( void );
422 char *G_NewString( const char *string );
423
424 //
425 // g_cmds.c
426 //
427 void Cmd_Score_f (gentity_t *ent);
428 void StopFollowing( gentity_t *ent );
429 void BroadcastTeamChange( gclient_t *client, int oldTeam );
430 void SetTeam( gentity_t *ent, const char *s );
431 void Cmd_FollowCycle_f( gentity_t *ent, int dir );
432
433 //
434 // g_items.c
435 //
436 void G_CheckTeamItems( void );
437 void G_RunItem( gentity_t *ent );
438 void RespawnItem( gentity_t *ent );
439
440 void UseHoldableItem( gentity_t *ent );
441 void PrecacheItem (gitem_t *it);
442 gentity_t *Drop_Item( gentity_t *ent, gitem_t *item, float angle );
443 gentity_t *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity );
444 void SetRespawn (gentity_t *ent, float delay);
445 void G_SpawnItem (gentity_t *ent, gitem_t *item);
446 void FinishSpawningItem( gentity_t *ent );
447 void Think_Weapon (gentity_t *ent);
448 int ArmorIndex (gentity_t *ent);
449 void Add_Ammo (gentity_t *ent, int weapon, int count);
450 void Touch_Item (gentity_t *ent, gentity_t *other, trace_t *trace);
451
452 void ClearRegisteredItems( void );
453 void RegisterItem( gitem_t *item );
454 void SaveRegisteredItems( void );
455
456 //
457 // g_utils.c
458 //
459 int G_ModelIndex( char *name );
460 int G_SoundIndex( char *name );
461 void G_TeamCommand( team_t team, char *cmd );
462 void G_KillBox (gentity_t *ent);
463 gentity_t *G_Find (gentity_t *from, int fieldofs, const char *match);
464 gentity_t *G_PickTarget (char *targetname);
465 void G_UseTargets (gentity_t *ent, gentity_t *activator);
466 void G_SetMovedir ( vec3_t angles, vec3_t movedir);
467
468 void G_InitGentity( gentity_t *e );
469 gentity_t *G_Spawn (void);
470 gentity_t *G_TempEntity( vec3_t origin, int event );
471 void G_Sound( gentity_t *ent, int channel, int soundIndex );
472 void G_FreeEntity( gentity_t *e );
473 qboolean G_EntitiesFree( void );
474
475 void G_TouchTriggers (gentity_t *ent);
476
477 float *tv (float x, float y, float z);
478 char *vtos( const vec3_t v );
479
480 float vectoyaw( const vec3_t vec );
481
482 void G_AddPredictableEvent( gentity_t *ent, int event, int eventParm );
483 void G_AddEvent( gentity_t *ent, int event, int eventParm );
484 void G_SetOrigin( gentity_t *ent, vec3_t origin );
485 void AddRemap(const char *oldShader, const char *newShader, float timeOffset);
486 const char *BuildShaderStateConfig( void );
487
488 //
489 // g_combat.c
490 //
491 qboolean CanDamage (gentity_t *targ, vec3_t origin);
492 void G_Damage (gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t dir, vec3_t point, int damage, int dflags, int mod);
493 qboolean G_RadiusDamage (vec3_t origin, gentity_t *attacker, float damage, float radius, gentity_t *ignore, int mod);
494 int G_InvulnerabilityEffect( gentity_t *targ, vec3_t dir, vec3_t point, vec3_t impactpoint, vec3_t bouncedir );
495 void body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath );
496 void TossClientItems( gentity_t *self );
497 #ifdef MISSIONPACK
498 void TossClientPersistantPowerups( gentity_t *self );
499 #endif
500 void TossClientCubes( gentity_t *self );
501
502 // damage flags
503 #define DAMAGE_RADIUS 0x00000001 // damage was indirect
504 #define DAMAGE_NO_ARMOR 0x00000002 // armour does not protect from this damage
505 #define DAMAGE_NO_KNOCKBACK 0x00000004 // do not affect velocity, just view angles
506 #define DAMAGE_NO_PROTECTION 0x00000008 // armor, shields, invulnerability, and godmode have no effect
507 #ifdef MISSIONPACK
508 #define DAMAGE_NO_TEAM_PROTECTION 0x00000010 // armor, shields, invulnerability, and godmode have no effect
509 #endif
510
511 //
512 // g_missile.c
513 //
514 void G_RunMissile( gentity_t *ent );
515
516 gentity_t *fire_plasma (gentity_t *self, vec3_t start, vec3_t aimdir);
517 gentity_t *fire_grenade (gentity_t *self, vec3_t start, vec3_t aimdir);
518 gentity_t *fire_rocket (gentity_t *self, vec3_t start, vec3_t dir);
519 gentity_t *fire_bfg (gentity_t *self, vec3_t start, vec3_t dir);
520 gentity_t *fire_grapple (gentity_t *self, vec3_t start, vec3_t dir);
521 #ifdef MISSIONPACK
522 gentity_t *fire_nail( gentity_t *self, vec3_t start, vec3_t forward, vec3_t right, vec3_t up );
523 gentity_t *fire_prox( gentity_t *self, vec3_t start, vec3_t aimdir );
524 #endif
525
526
527 //
528 // g_mover.c
529 //
530 void G_RunMover( gentity_t *ent );
531 void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace );
532
533 //
534 // g_trigger.c
535 //
536 void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace );
537
538
539 //
540 // g_misc.c
541 //
542 void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles );
543 #ifdef MISSIONPACK
544 void DropPortalSource( gentity_t *ent );
545 void DropPortalDestination( gentity_t *ent );
546 #endif
547
548
549 //
550 // g_weapon.c
551 //
552 qboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker );
553 void CalcMuzzlePoint ( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint );
554 void SnapVectorTowards( vec3_t v, vec3_t to );
555 qboolean CheckGauntletAttack( gentity_t *ent );
556 void Weapon_HookFree (gentity_t *ent);
557 void Weapon_HookThink (gentity_t *ent);
558
559
560 //
561 // g_client.c
562 //
563 int TeamCount( int ignoreClientNum, team_t team );
564 int TeamLeader( int team );
565 team_t PickTeam( int ignoreClientNum );
566 void SetClientViewAngle( gentity_t *ent, vec3_t angle );
567 gentity_t *SelectSpawnPoint (vec3_t avoidPoint, vec3_t origin, vec3_t angles, qboolean isbot);
568 void CopyToBodyQue( gentity_t *ent );
569 void ClientRespawn(gentity_t *ent);
570 void BeginIntermission (void);
571 void InitBodyQue (void);
572 void ClientSpawn( gentity_t *ent );
573 void player_die (gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod);
574 void AddScore( gentity_t *ent, vec3_t origin, int score );
575 void CalculateRanks( void );
576 qboolean SpotWouldTelefrag( gentity_t *spot );
577
578 //
579 // g_svcmds.c
580 //
581 qboolean ConsoleCommand( void );
582 void G_ProcessIPBans(void);
583 qboolean G_FilterPacket (char *from);
584
585 //
586 // g_weapon.c
587 //
588 void FireWeapon( gentity_t *ent );
589 #ifdef MISSIONPACK
590 void G_StartKamikaze( gentity_t *ent );
591 #endif
592
593 //
594 // g_cmds.c
595 //
596 void DeathmatchScoreboardMessage( gentity_t *ent );
597
598 //
599 // g_main.c
600 //
601 void MoveClientToIntermission( gentity_t *ent );
602 void FindIntermissionPoint( void );
603 void SetLeader(int team, int client);
604 void CheckTeamLeader( int team );
605 void G_RunThink (gentity_t *ent);
606 void AddTournamentQueue(gclient_t *client);
607 void QDECL G_LogPrintf( const char *fmt, ... ) Q_PRINTF_FUNC(1, 2);
608 void SendScoreboardMessageToAllClients( void );
609 void QDECL G_Printf( const char *fmt, ... ) Q_PRINTF_FUNC(1, 2);
610 void QDECL G_Error( const char *fmt, ... ) Q_NO_RETURN Q_PRINTF_FUNC(1, 2);
611
612 //
613 // g_client.c
614 //
615 char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot );
616 void ClientUserinfoChanged( int clientNum );
617 void ClientDisconnect( int clientNum );
618 void ClientBegin( int clientNum );
619 void ClientCommand( int clientNum );
620
621 //
622 // g_active.c
623 //
624 void ClientThink( int clientNum );
625 void ClientEndFrame( gentity_t *ent );
626 void G_RunClient( gentity_t *ent );
627
628 //
629 // g_team.c
630 //
631 qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 );
632 void Team_CheckDroppedItem( gentity_t *dropped );
633 qboolean CheckObeliskAttack( gentity_t *obelisk, gentity_t *attacker );
634
635 //
636 // g_mem.c
637 //
638 void *G_Alloc( int size );
639 void G_InitMemory( void );
640 void Svcmd_GameMem_f( void );
641
642 //
643 // g_session.c
644 //
645 void G_ReadSessionData( gclient_t *client );
646 void G_InitSessionData( gclient_t *client, char *userinfo );
647
648 void G_InitWorldSession( void );
649 void G_WriteSessionData( void );
650
651 //
652 // g_arenas.c
653 //
654 void UpdateTournamentInfo( void );
655 void SpawnModelsOnVictoryPads( void );
656 void Svcmd_AbortPodium_f( void );
657
658 //
659 // g_bot.c
660 //
661 void G_InitBots( qboolean restart );
662 char *G_GetBotInfoByNumber( int num );
663 char *G_GetBotInfoByName( const char *name );
664 void G_CheckBotSpawn( void );
665 void G_RemoveQueuedBotBegin( int clientNum );
666 qboolean G_BotConnect( int clientNum, qboolean restart );
667 void Svcmd_AddBot_f( void );
668 void Svcmd_BotList_f( void );
669 void BotInterbreedEndMatch( void );
670
671 // ai_main.c
672 #define MAX_FILEPATH 144
673
674 //bot settings
675 typedef struct bot_settings_s
676 {
677 char characterfile[MAX_FILEPATH];
678 float skill;
679 } bot_settings_t;
680
681 int BotAISetup( int restart );
682 int BotAIShutdown( int restart );
683 int BotAILoadMap( int restart );
684 int BotAISetupClient(int client, struct bot_settings_s *settings, qboolean restart);
685 int BotAIShutdownClient( int client, qboolean restart );
686 int BotAIStartFrame( int time );
687 void BotTestAAS(vec3_t origin);
688
689 #include "g_team.h" // teamplay specific stuff
690
691
692 extern level_locals_t level;
693 extern gentity_t g_entities[MAX_GENTITIES];
694
695 #define FOFS(x) ((size_t)&(((gentity_t *)0)->x))
696
697 extern vmCvar_t g_gametype;
698 extern vmCvar_t g_dedicated;
699 extern vmCvar_t g_cheats;
700 extern vmCvar_t g_maxclients; // allow this many total, including spectators
701 extern vmCvar_t g_maxGameClients; // allow this many active
702 extern vmCvar_t g_restarted;
703
704 extern vmCvar_t g_dmflags;
705 extern vmCvar_t g_fraglimit;
706 extern vmCvar_t g_timelimit;
707 extern vmCvar_t g_capturelimit;
708 extern vmCvar_t g_friendlyFire;
709 extern vmCvar_t g_password;
710 extern vmCvar_t g_needpass;
711 extern vmCvar_t g_gravity;
712 extern vmCvar_t g_speed;
713 extern vmCvar_t g_knockback;
714 extern vmCvar_t g_quadfactor;
715 extern vmCvar_t g_forcerespawn;
716 extern vmCvar_t g_inactivity;
717 extern vmCvar_t g_debugMove;
718 extern vmCvar_t g_debugAlloc;
719 extern vmCvar_t g_debugDamage;
720 extern vmCvar_t g_weaponRespawn;
721 extern vmCvar_t g_weaponTeamRespawn;
722 extern vmCvar_t g_synchronousClients;
723 extern vmCvar_t g_motd;
724 extern vmCvar_t g_warmup;
725 extern vmCvar_t g_doWarmup;
726 extern vmCvar_t g_blood;
727 extern vmCvar_t g_allowVote;
728 extern vmCvar_t g_teamAutoJoin;
729 extern vmCvar_t g_teamForceBalance;
730 extern vmCvar_t g_banIPs;
731 extern vmCvar_t g_filterBan;
732 extern vmCvar_t g_obeliskHealth;
733 extern vmCvar_t g_obeliskRegenPeriod;
734 extern vmCvar_t g_obeliskRegenAmount;
735 extern vmCvar_t g_obeliskRespawnDelay;
736 extern vmCvar_t g_cubeTimeout;
737 extern vmCvar_t g_redteam;
738 extern vmCvar_t g_blueteam;
739 extern vmCvar_t g_smoothClients;
740 extern vmCvar_t pmove_fixed;
741 extern vmCvar_t pmove_msec;
742 extern vmCvar_t g_rankings;
743 extern vmCvar_t g_enableDust;
744 extern vmCvar_t g_enableBreath;
745 extern vmCvar_t g_singlePlayer;
746 extern vmCvar_t g_proxMineTimeout;
747 extern vmCvar_t g_localTeamPref;
748
749 void trap_Print( const char *text );
750 void trap_Error( const char *text ) Q_NO_RETURN;
751 int trap_Milliseconds( void );
752 int trap_RealTime( qtime_t *qtime );
753 int trap_Argc( void );
754 void trap_Argv( int n, char *buffer, int bufferLength );
755 void trap_Args( char *buffer, int bufferLength );
756 int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode );
757 void trap_FS_Read( void *buffer, int len, fileHandle_t f );
758 void trap_FS_Write( const void *buffer, int len, fileHandle_t f );
759 void trap_FS_FCloseFile( fileHandle_t f );
760 int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize );
761 int trap_FS_Seek( fileHandle_t f, long offset, int origin ); // fsOrigin_t
762 void trap_SendConsoleCommand( int exec_when, const char *text );
763 void trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags );
764 void trap_Cvar_Update( vmCvar_t *cvar );
765 void trap_Cvar_Set( const char *var_name, const char *value );
766 int trap_Cvar_VariableIntegerValue( const char *var_name );
767 float trap_Cvar_VariableValue( const char *var_name );
768 void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );
769 void trap_LocateGameData( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t, playerState_t *gameClients, int sizeofGameClient );
770 void trap_DropClient( int clientNum, const char *reason );
771 void trap_SendServerCommand( int clientNum, const char *text );
772 void trap_SetConfigstring( int num, const char *string );
773 void trap_GetConfigstring( int num, char *buffer, int bufferSize );
774 void trap_GetUserinfo( int num, char *buffer, int bufferSize );
775 void trap_SetUserinfo( int num, const char *buffer );
776 void trap_GetServerinfo( char *buffer, int bufferSize );
777 void trap_SetBrushModel( gentity_t *ent, const char *name );
778 void trap_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask );
779 int trap_PointContents( const vec3_t point, int passEntityNum );
780 qboolean trap_InPVS( const vec3_t p1, const vec3_t p2 );
781 qboolean trap_InPVSIgnorePortals( const vec3_t p1, const vec3_t p2 );
782 void trap_AdjustAreaPortalState( gentity_t *ent, qboolean open );
783 qboolean trap_AreasConnected( int area1, int area2 );
784 void trap_LinkEntity( gentity_t *ent );
785 void trap_UnlinkEntity( gentity_t *ent );
786 int trap_EntitiesInBox( const vec3_t mins, const vec3_t maxs, int *entityList, int maxcount );
787 qboolean trap_EntityContact( const vec3_t mins, const vec3_t maxs, const gentity_t *ent );
788 int trap_BotAllocateClient( void );
789 void trap_BotFreeClient( int clientNum );
790 void trap_GetUsercmd( int clientNum, usercmd_t *cmd );
791 qboolean trap_GetEntityToken( char *buffer, int bufferSize );
792
793 int trap_DebugPolygonCreate(int color, int numPoints, vec3_t *points);
794 void trap_DebugPolygonDelete(int id);
795
796 int trap_BotLibSetup( void );
797 int trap_BotLibShutdown( void );
798 int trap_BotLibVarSet(char *var_name, char *value);
799 int trap_BotLibVarGet(char *var_name, char *value, int size);
800 int trap_BotLibDefine(char *string);
801 int trap_BotLibStartFrame(float time);
802 int trap_BotLibLoadMap(const char *mapname);
803 int trap_BotLibUpdateEntity(int ent, void /* struct bot_updateentity_s */ *bue);
804 int trap_BotLibTest(int parm0, char *parm1, vec3_t parm2, vec3_t parm3);
805
806 int trap_BotGetSnapshotEntity( int clientNum, int sequence );
807 int trap_BotGetServerCommand(int clientNum, char *message, int size);
808 void trap_BotUserCommand(int client, usercmd_t *ucmd);
809
810 int trap_AAS_BBoxAreas(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas);
811 int trap_AAS_AreaInfo( int areanum, void /* struct aas_areainfo_s */ *info );
812 void trap_AAS_EntityInfo(int entnum, void /* struct aas_entityinfo_s */ *info);
813
814 int trap_AAS_Initialized(void);
815 void trap_AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs);
816 float trap_AAS_Time(void);
817
818 int trap_AAS_PointAreaNum(vec3_t point);
819 int trap_AAS_PointReachabilityAreaIndex(vec3_t point);
820 int trap_AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas);
821
822 int trap_AAS_PointContents(vec3_t point);
823 int trap_AAS_NextBSPEntity(int ent);
824 int trap_AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size);
825 int trap_AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v);
826 int trap_AAS_FloatForBSPEpairKey(int ent, char *key, float *value);
827 int trap_AAS_IntForBSPEpairKey(int ent, char *key, int *value);
828
829 int trap_AAS_AreaReachability(int areanum);
830
831 int trap_AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags);
832 int trap_AAS_EnableRoutingArea( int areanum, int enable );
833 int trap_AAS_PredictRoute(void /*struct aas_predictroute_s*/ *route, int areanum, vec3_t origin,
834 int goalareanum, int travelflags, int maxareas, int maxtime,
835 int stopevent, int stopcontents, int stoptfl, int stopareanum);
836
837 int trap_AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,
838 void /*struct aas_altroutegoal_s*/ *altroutegoals, int maxaltroutegoals,
839 int type);
840 int trap_AAS_Swimming(vec3_t origin);
841 int trap_AAS_PredictClientMovement(void /* aas_clientmove_s */ *move, int entnum, vec3_t origin, int presencetype, int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes, float frametime, int stopevent, int stopareanum, int visualize);
842
843
844 void trap_EA_Say(int client, char *str);
845 void trap_EA_SayTeam(int client, char *str);
846 void trap_EA_Command(int client, char *command);
847
848 void trap_EA_Action(int client, int action);
849 void trap_EA_Gesture(int client);
850 void trap_EA_Talk(int client);
851 void trap_EA_Attack(int client);
852 void trap_EA_Use(int client);
853 void trap_EA_Respawn(int client);
854 void trap_EA_Crouch(int client);
855 void trap_EA_MoveUp(int client);
856 void trap_EA_MoveDown(int client);
857 void trap_EA_MoveForward(int client);
858 void trap_EA_MoveBack(int client);
859 void trap_EA_MoveLeft(int client);
860 void trap_EA_MoveRight(int client);
861 void trap_EA_SelectWeapon(int client, int weapon);
862 void trap_EA_Jump(int client);
863 void trap_EA_DelayedJump(int client);
864 void trap_EA_Move(int client, vec3_t dir, float speed);
865 void trap_EA_View(int client, vec3_t viewangles);
866
867 void trap_EA_EndRegular(int client, float thinktime);
868 void trap_EA_GetInput(int client, float thinktime, void /* struct bot_input_s */ *input);
869 void trap_EA_ResetInput(int client);
870
871
872 int trap_BotLoadCharacter(char *charfile, float skill);
873 void trap_BotFreeCharacter(int character);
874 float trap_Characteristic_Float(int character, int index);
875 float trap_Characteristic_BFloat(int character, int index, float min, float max);
876 int trap_Characteristic_Integer(int character, int index);
877 int trap_Characteristic_BInteger(int character, int index, int min, int max);
878 void trap_Characteristic_String(int character, int index, char *buf, int size);
879
880 int trap_BotAllocChatState(void);
881 void trap_BotFreeChatState(int handle);
882 void trap_BotQueueConsoleMessage(int chatstate, int type, char *message);
883 void trap_BotRemoveConsoleMessage(int chatstate, int handle);
884 int trap_BotNextConsoleMessage(int chatstate, void /* struct bot_consolemessage_s */ *cm);
885 int trap_BotNumConsoleMessages(int chatstate);
886 void trap_BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 );
887 int trap_BotNumInitialChats(int chatstate, char *type);
888 int trap_BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 );
889 int trap_BotChatLength(int chatstate);
890 void trap_BotEnterChat(int chatstate, int client, int sendto);
891 void trap_BotGetChatMessage(int chatstate, char *buf, int size);
892 int trap_StringContains(char *str1, char *str2, int casesensitive);
893 int trap_BotFindMatch(char *str, void /* struct bot_match_s */ *match, unsigned long int context);
894 void trap_BotMatchVariable(void /* struct bot_match_s */ *match, int variable, char *buf, int size);
895 void trap_UnifyWhiteSpaces(char *string);
896 void trap_BotReplaceSynonyms(char *string, unsigned long int context);
897 int trap_BotLoadChatFile(int chatstate, char *chatfile, char *chatname);
898 void trap_BotSetChatGender(int chatstate, int gender);
899 void trap_BotSetChatName(int chatstate, char *name, int client);
900 void trap_BotResetGoalState(int goalstate);
901 void trap_BotRemoveFromAvoidGoals(int goalstate, int number);
902 void trap_BotResetAvoidGoals(int goalstate);
903 void trap_BotPushGoal(int goalstate, void /* struct bot_goal_s */ *goal);
904 void trap_BotPopGoal(int goalstate);
905 void trap_BotEmptyGoalStack(int goalstate);
906 void trap_BotDumpAvoidGoals(int goalstate);
907 void trap_BotDumpGoalStack(int goalstate);
908 void trap_BotGoalName(int number, char *name, int size);
909 int trap_BotGetTopGoal(int goalstate, void /* struct bot_goal_s */ *goal);
910 int trap_BotGetSecondGoal(int goalstate, void /* struct bot_goal_s */ *goal);
911 int trap_BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags);
912 int trap_BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, void /* struct bot_goal_s */ *ltg, float maxtime);
913 int trap_BotTouchingGoal(vec3_t origin, void /* struct bot_goal_s */ *goal);
914 int trap_BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, void /* struct bot_goal_s */ *goal);
915 int trap_BotGetNextCampSpotGoal(int num, void /* struct bot_goal_s */ *goal);
916 int trap_BotGetMapLocationGoal(char *name, void /* struct bot_goal_s */ *goal);
917 int trap_BotGetLevelItemGoal(int index, char *classname, void /* struct bot_goal_s */ *goal);
918 float trap_BotAvoidGoalTime(int goalstate, int number);
919 void trap_BotSetAvoidGoalTime(int goalstate, int number, float avoidtime);
920 void trap_BotInitLevelItems(void);
921 void trap_BotUpdateEntityItems(void);
922 int trap_BotLoadItemWeights(int goalstate, char *filename);
923 void trap_BotFreeItemWeights(int goalstate);
924 void trap_BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child);
925 void trap_BotSaveGoalFuzzyLogic(int goalstate, char *filename);
926 void trap_BotMutateGoalFuzzyLogic(int goalstate, float range);
927 int trap_BotAllocGoalState(int state);
928 void trap_BotFreeGoalState(int handle);
929
930 void trap_BotResetMoveState(int movestate);
931 void trap_BotMoveToGoal(void /* struct bot_moveresult_s */ *result, int movestate, void /* struct bot_goal_s */ *goal, int travelflags);
932 int trap_BotMoveInDirection(int movestate, vec3_t dir, float speed, int type);
933 void trap_BotResetAvoidReach(int movestate);
934 void trap_BotResetLastAvoidReach(int movestate);
935 int trap_BotReachabilityArea(vec3_t origin, int testground);
936 int trap_BotMovementViewTarget(int movestate, void /* struct bot_goal_s */ *goal, int travelflags, float lookahead, vec3_t target);
937 int trap_BotPredictVisiblePosition(vec3_t origin, int areanum, void /* struct bot_goal_s */ *goal, int travelflags, vec3_t target);
938 int trap_BotAllocMoveState(void);
939 void trap_BotFreeMoveState(int handle);
940 void trap_BotInitMoveState(int handle, void /* struct bot_initmove_s */ *initmove);
941 void trap_BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type);
942
943 int trap_BotChooseBestFightWeapon(int weaponstate, int *inventory);
944 void trap_BotGetWeaponInfo(int weaponstate, int weapon, void /* struct weaponinfo_s */ *weaponinfo);
945 int trap_BotLoadWeaponWeights(int weaponstate, char *filename);
946 int trap_BotAllocWeaponState(void);
947 void trap_BotFreeWeaponState(int weaponstate);
948 void trap_BotResetWeaponState(int weaponstate);
949
950 int trap_GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child);
951
952 void trap_SnapVector( float *v );
953