OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
g_local.h
1/*
2===========================================================================
3Copyright (C) 1999-2005 Id Software, Inc.
4
5This file is part of Quake III Arena source code.
6
7Quake III Arena source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12Quake III Arena source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with Quake III Arena source code; if not, write to the Free Software
19Foundation, 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#pragma once
26
27#include "q_shared.h"
28#include "bg_public.h"
29#include "g_public.h"
30
31//==================================================================
32
33// the "gameversion" client command will print this plus compile date
34#define GAMEVERSION "OPENMOHAA"
35
36#define BODY_QUEUE_SIZE 8
37
38#define INFINITE 1000000
39
40#define FRAMETIME level.frametime // float sec
41#define CARNAGE_REWARD_TIME 3000
42#define REWARD_SPRITE_TIME 2000
43
44#define INTERMISSION_DELAY_TIME 1000
45#define SP_INTERMISSION_DELAY_TIME 5000
46
47// flags
48#define FL_FLY (1 << 0)
49#define FL_SWIM (1 << 1) // implied immunity to drowining
50#define FL_INWATER (1 << 2)
51#define FL_GODMODE (1 << 3)
52#define FL_NOTARGET (1 << 4)
53#define FL_PARTIALGROUND (1 << 5) // not all corners are valid
54#define FL_TEAMSLAVE (1 << 6) // not the first on the team
55#define FL_NO_KNOCKBACK (1 << 7)
56#define FL_THINK (1 << 8)
57#define FL_BLOOD (1 << 9) // when hit, it should bleed.
58#define FL_DIE_GIBS (1 << 10) // when it dies, it should gib
59#define FL_DIE_EXPLODE (1 << 11) // when it dies, it will explode
60#define FL_ROTATEDBOUNDS (1 << 12) // model uses rotated mins and maxs
61#define FL_DONTSAVE (1 << 13) // don't add to the savegame
62#define FL_IMMOBILE (1 << 14) // entity has been immobolized somehow
63#define FL_PARTIAL_IMMOBILE (1 << 15) // entity has been immobolized somehow
64#define FL_POSTTHINK (1 << 17) // call a think function after the physics have been run
65#define FL_TOUCH_TRIGGERS (1 << 18) // should this entity touch triggers
66#define FL_AUTOAIM (1 << 19) // Autoaim on this entity
67#define FL_ANIMATE (1 << 20) // entity has been immobolized somehow
68#define FL_UNKNOWN2 (1 << 21)
69
70#define SOUND_RADIUS 1500.0f // Sound travel distance for AI
71
72//============================================================================
73
74#include "g_main.h"
75
76class str;
77class Vector;
78class Archiver;
79class Entity;
80template<typename T>
81class Container;
82
83typedef enum {
84 SPECTATOR_NOT,
85 SPECTATOR_FREE,
86 SPECTATOR_FOLLOW,
87 SPECTATOR_SCOREBOARD
88} spectatorState_t;
89
90typedef enum {
91 TEAM_BEGIN, // Beginning a team game, spawn at base
92 TEAM_ACTIVE // Now actively playing
93} playerTeamStateState_t;
94
95typedef struct {
96 playerTeamStateState_t state;
97
98 int location;
99
100 int captures;
101 int basedefense;
102 int carrierdefense;
103 int flagrecovery;
104 int fragcarrier;
105 int assists;
106
107 float lasthurtcarrier;
108 float lastreturnedflag;
109 float flagsince;
110 float lastfraggedcarrier;
112
113// the auto following clients don't follow a specific client
114// number, but instead follow the first two active players
115#define FOLLOW_ACTIVE1 -1
116#define FOLLOW_ACTIVE2 -2
117
118// client data that stays across multiple levels or tournament restarts
119// this is achieved by writing all the data to cvar strings at game shutdown
120// time and reading them back at connection time. Anything added here
121// MUST be dealt with in G_InitSessionData() / G_ReadSessionData() / G_WriteSessionData()
122typedef struct {
123 teamtype_t sessionTeam;
124 int spectatorTime; // for determining next-in-line to play
125 spectatorState_t spectatorState;
126 int spectatorClient; // for chasecam and follow mode
127 int wins, losses; // tournament stats
128 qboolean teamLeader; // true when this client is a team leader
130
131//
132#define MAX_NETNAME 32
133#define MAX_VOTE_COUNT 3
134
135//
136// g_spawn.c
137//
138qboolean G_SpawnString(const char *key, const char *defaultString, char **out);
139// spawn string returns a temporary reference, you must CopyString() if you want to keep it
140qboolean G_SpawnFloat(const char *key, const char *defaultString, float *out);
141qboolean G_SpawnInt(const char *key, const char *defaultString, int *out);
142qboolean G_SpawnVector(const char *key, const char *defaultString, float *out);
143void G_SpawnEntitiesFromString(void);
144char *G_NewString(const char *string);
145const char *G_FixTIKIPath(const char *in);
146void G_GetNullEntityState(entityState_t *nullState);
147
148//
149// g_cmds.c
150//
151void Cmd_Score_f(gentity_t *ent);
152void StopFollowing(gentity_t *ent);
153void BroadcastTeamChange(gclient_t *client, int oldTeam);
154void SetTeam(gentity_t *ent, char *s);
155void Cmd_FollowCycle_f(gentity_t *ent, int dir);
156
157//
158// g_items.c
159//
160
161//
162// g_utils.c
163//
164
165float G_Random(void);
166float G_Random(float n);
167float G_CRandom(void);
168float G_CRandom(float n);
169
170int G_ModelIndex(const char *name);
171int G_SoundIndex(const char *name);
172void G_TeamCommand(teamtype_t team, char *cmd);
173void G_KillBox(gentity_t *ent);
174qboolean M_CheckBottom(Entity *ent);
175gentity_t *G_PickTarget(char *targetname);
176void G_UseTargets(gentity_t *ent, gentity_t *activator);
177void G_SetMovedir(vec3_t angles, vec3_t movedir);
178
179void G_InitGentity(gentity_t *e);
180gentity_t *G_Spawn(void);
181gentity_t *G_TempEntity(vec3_t origin, int event);
182void G_Sound(gentity_t *ent, int channel, int soundIndex);
183void G_FreeEntity(gentity_t *e);
184qboolean G_entitiesFree(void);
185
186Entity *G_NextEntity(Entity *ent);
187
188void G_CalcBoundsOfMove(Vector& start, Vector& end, Vector& mins, Vector& maxs, Vector *minbounds, Vector *maxbounds);
189
190float PlayersRangeFromSpot(Entity *ent);
191
192Entity *findradius(Entity *startent, Vector org, float rad);
193Entity *findclientsinradius(Entity *startent, Vector org, float rad);
194
195void G_TouchTriggers(gentity_t *ent);
196void G_TouchSolids(gentity_t *ent);
197
198void G_CenterPrintToAllClients(const char *pszString);
199void G_PrintToAllClients(const char *pszString, int iType = 1);
200void G_PrintDeathMessage(
201 const char *s1, const char *s2, const char *attackerName, const char *victimName, Player *victim, const char *type
202);
203void G_PrintDeathMessage_Old(const char *pszString);
204void G_WarnPlayer(class Player *player, const char *format, ...);
205int G_NumClients(void);
206
207int G_WeaponIndex(const char *name);
208
209class SkelMat4;
210
211orientation_t G_TIKI_Orientation(gentity_t *edict, int num);
212SkelMat4 *G_TIKI_Transform(gentity_t *edict, int num);
213qboolean G_TIKI_IsOnGround(gentity_t *edict, int num, float threshold);
214qboolean G_Command_ProcessFile(const char *filename, qboolean quiet);
215
216char *G_TimeString(float fTime);
217char *CanonicalTikiName(const char *szInName);
218
219float *tv(float x, float y, float z);
220char *vtos(const vec3_t v);
221
222void G_SetOrigin(gentity_t *ent, vec3_t origin);
223void AddRemap(const char *oldShader, const char *newShader, float timeOffset);
224const char *BuildShaderStateConfig(void);
225
226void G_DebugTargets(Entity *e, const str& from);
227void G_DebugDamage(float damage, Entity *victim, Entity *attacker, Entity *inflictor);
228void G_DebugString(Vector pos, float scale, float r, float g, float b, const char *pszText, ...);
229
230qboolean KillBox(Entity *ent);
231
232void ChangeMusic(const char *current, const char *fallback, qboolean force);
233void ChangeMusicVolume(float volume, float fade_time);
234void RestoreMusicVolume(float fade_time);
235void ChangeSoundtrack(const char *soundtrack);
236void RestoreSoundtrack(void);
237int G_AIEventTypeFromString(const char *pszType);
238const char *G_AIEventStringFromType(int iType);
239float G_AIEventRadius(int iType);
240void G_BroadcastAIEvent(Entity *originator, Vector origin, char *pszType);
241void G_BroadcastAIEvent(Entity *originator, Vector origin, int iType, float radius);
242
243void CloneEntity(Entity *dest, Entity *src);
244void G_ArchiveEdict(Archiver& arc, gentity_t *edict);
245
246const char *G_LocationNumToDispString(int iLocation);
247str G_WeaponClassNumToName(int num);
248int G_WeaponClassNameToNum(str name);
249
250//Checks for the intermission to exit.
251void G_CheckIntermissionExit(void);
252void G_CheckStartRules(void);
253void G_CheckExitRules(void);
254
255// Update the time limit
256void G_UpdateMatchEndTime(void);
257
258void G_MoveClientToIntermission(Entity *ent);
259void G_DisplayScores(Entity *ent);
260void G_HideScores(Entity *ent);
261void G_DisplayScoresToAllClients(void);
262void G_HideScoresToAllClients(void);
263
264//
265// caching commands
266//
267void G_ProcessCacheInitCommands(dtiki_t *tiki);
268
269void G_SetTrajectory(gentity_t *ent, vec3_t org);
270
271//
272// g_combat.c
273//
274qboolean CanDamage(gentity_t *targ, vec3_t origin);
275void G_Damage(
276 gentity_t *targ,
277 gentity_t *inflictor,
278 gentity_t *attacker,
279 vec3_t dir,
280 vec3_t point,
281 int damage,
282 int dflags,
283 int mod
284 );
285qboolean G_RadiusDamage(vec3_t origin, gentity_t *attacker, float damage, float radius, gentity_t *ignore, int mod);
286int G_InvulnerabilityEffect(gentity_t *targ, vec3_t dir, vec3_t point, vec3_t impactpoint, vec3_t bouncedir);
287void body_die(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath);
288void TossClientItems(gentity_t *self);
289#ifdef MISSIONPACK
290void TossClientPersistantPowerups(gentity_t *self);
291#endif
292void TossClientCubes(gentity_t *self);
293
294// damage flags
295#define DAMAGE_NONE 0
296#define DAMAGE_RADIUS 0x00000001 // damage was indirect
297#define DAMAGE_NO_ARMOR 0x00000002 // armour does not protect from this damage
298#define DAMAGE_ENERGY 0x00000004 // damage is from an energy based weapon
299#define DAMAGE_NO_KNOCKBACK 0x00000008 // do not affect velocity, just view angles
300#define DAMAGE_BULLET 0x00000010 // damage is from a bullet (used for ricochets)
301#define DAMAGE_NO_PROTECTION 0x00000020 // armor, shields, invulnerability, and godmode have no effect
302#define DAMAGE_NO_SKILL 0x00000040 // damage is not affected by skill level
303
304//
305// g_missile.c
306//
307void G_RunMissile(gentity_t *ent);
308
309gentity_t *fire_blaster(gentity_t *self, vec3_t start, vec3_t aimdir);
310gentity_t *fire_plasma(gentity_t *self, vec3_t start, vec3_t aimdir);
311gentity_t *fire_grenade(gentity_t *self, vec3_t start, vec3_t aimdir);
312gentity_t *fire_rocket(gentity_t *self, vec3_t start, vec3_t dir);
313gentity_t *fire_bfg(gentity_t *self, vec3_t start, vec3_t dir);
314gentity_t *fire_grapple(gentity_t *self, vec3_t start, vec3_t dir);
315#ifdef MISSIONPACK
316gentity_t *fire_nail(gentity_t *self, vec3_t start, vec3_t forward, vec3_t right, vec3_t up);
317gentity_t *fire_prox(gentity_t *self, vec3_t start, vec3_t aimdir);
318#endif
319
320//
321// g_mover.c
322//
323void G_RunMover(gentity_t *ent);
324void Touch_DoorTrigger(gentity_t *ent, gentity_t *other, trace_t *trace);
325void Use_BinaryMover(gentity_t *ent, gentity_t *other, gentity_t *activator);
326
327//
328// g_trigger.c
329//
330void trigger_teleporter_touch(gentity_t *self, gentity_t *other, trace_t *trace);
331
332//
333// g_misc.c
334//
335void TeleportPlayer(gentity_t *player, vec3_t origin, vec3_t angles);
336#ifdef MISSIONPACK
337void DropPortalSource(gentity_t *ent);
338void DropPortalDestination(gentity_t *ent);
339#endif
340
341//
342// g_weapon.c
343//
344qboolean LogAccuracyHit(gentity_t *target, gentity_t *attacker);
345void SnapVectorTowards(vec3_t v, vec3_t to);
346qboolean CheckGauntletAttack(gentity_t *ent);
347void Weapon_HookFree(gentity_t *ent);
348void Weapon_HookThink(gentity_t *ent);
349void CalcMuzzlePoint(gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint);
350
351//
352// g_client.c
353//
354gentity_t *G_Find(gentity_t *from, int fieldofs, const char *match);
355teamtype_t TeamCount(int ignoreClientNum, int team);
356int TeamLeader(int team);
357teamtype_t PickTeam(int ignoreClientNum);
358void SetClientViewAngle(gentity_t *ent, vec3_t angle);
359class PlayerStart *SelectSpawnPoint(Player *player);
360void CopyToBodyQue(gentity_t *ent);
361void respawn(gentity_t *ent);
362void BeginIntermission(void);
363void InitClientPersistant(gclient_t *client);
364void InitClientResp(gclient_t *client);
365void InitBodyQue(void);
366void ClientSpawn(gentity_t *ent);
367void player_die(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod);
368void AddScore(gentity_t *ent, vec3_t origin, int score);
369void CalculateRanks(void);
370
371//
372// g_svcmds.c
373//
374qboolean G_ConsoleCommand(void);
375void G_ProcessIPBans(void);
376qboolean G_FilterPacket(char *from);
377
378//
379// g_weapon.c
380//
381void FireWeapon(gentity_t *ent);
382#ifdef MISSIONPACK
383void G_StartKamikaze(gentity_t *ent);
384#endif
385
386//
387// p_hud.c
388//
389void MoveClientToIntermission(gentity_t *client);
390void G_SetStats(gentity_t *ent);
391void DeathmatchScoreboardMessage(gentity_t *client);
392
393//
394// g_cmds.c
395//
396
397//
398// g_pweapon.c
399//
400
401//
402// g_main.c
403//
404void FindIntermissionPoint(void);
405void SetLeader(int team, int client);
406void CheckTeamLeader(int team);
407void G_RunThink(gentity_t *ent);
408void QDECL G_LogPrintf(const char *fmt, ...);
409void SendScoreboardMessageToAllClients(void);
410void QDECL G_Printf(const char *fmt, ...);
411void QDECL G_Error(const char *fmt, ...) __attribute__ ((noreturn, format(printf, 1, 2)));
412void QDECL G_Error(errorParm_t type, const char *fmt, ...) __attribute__((noreturn, format(printf, 2, 3)));
413
414//
415// g_client.c
416//
417void G_BotConnect(int clientNum, qboolean firstTime, const char* userinfo);
418const char *G_ClientConnect(int clientNum, qboolean firstTime, qboolean differentMap);
419void G_ClientUserinfoChanged(gentity_t *ent, const char *userinfo);
420void G_ClientDisconnect(gentity_t *ent);
421void G_ClientBegin(gentity_t *ent, usercmd_t *cmd);
422void G_SetClientConfigString(gentity_t *ent);
423void G_ClientCommand(gentity_t *ent);
424
425void G_PrintfClient(gentity_t *ent, const char *fmt, ...);
426
427//
428// g_active.c
429//
430void G_ClientThink(gentity_t *ent, usercmd_t *cmd, usereyes_t *eyeinfo);
431void ClientEndFrame(gentity_t *ent);
432void G_ClientEndServerFrames(void);
433void G_ClientDoBlends(void);
434void FindIntermissionPoint(void);
435void G_RunClient(gentity_t *ent);
436
437//
438// g_team.c
439//
440qboolean OnSameTeam(gentity_t *ent1, gentity_t *ent2);
441void Team_CheckDroppedItem(gentity_t *dropped);
442qboolean CheckObeliskAttack(gentity_t *obelisk, gentity_t *attacker);
443
444//
445// g_mem.c
446//
447void *G_Alloc(int size);
448void G_InitMemory(void);
449void Svcmd_GameMem_f(void);
450
451//
452// g_session.c
453//
454void G_ReadClientSessionData(gclient_t *client);
455void G_InitClientPersistant(gclient_t *client, const char *userinfo);
456
457void G_InitWorldSession(void);
458void G_WriteSessionData(void);
459
460//
461// g_arenas.c
462//
463void UpdateTournamentInfo(void);
464void SpawnModelsOnVictoryPads(void);
465void Svcmd_AbortPodium_f(void);
466
467//
468// g_bot.c
469//
470
471typedef struct mmove_s {
472 vec3_t origin;
473 vec3_t velocity;
474
475 qboolean walking;
476 qboolean groundPlane;
477 vec3_t groundPlaneNormal;
478
479 float frametime;
480
481 float desired_speed;
482 int tracemask;
483 float desired_dir[2];
484
485 int entityNum;
486
487 vec3_t mins;
488 vec3_t maxs;
489
490 int numtouch;
491 int touchents[MAXTOUCH];
492
493 qboolean hit_obstacle;
494 vec3_t hit_origin;
495 int hit_temp_obstacle;
496
497 vec3_t obstacle_normal;
498} mmove_t;
499
500// g_mmove.cpp
501void MmoveSingle(mmove_t *mmove);
502
503// g_vmove.cpp
504void VmoveSingle(struct vmove_s *mmove);
505
506// ai_main.c
507#define MAX_FILEPATH 144
508
509//bot settings
510typedef struct bot_settings_s {
511 char characterfile[MAX_FILEPATH];
512 float skill;
513 char team[MAX_FILEPATH];
514} bot_settings_t;
515
516int BotAISetup(int restart);
517int BotAIShutdown();
518int BotAILoadMap(int restart);
519int BotAISetupClient(int client, struct bot_settings_s *settings, qboolean restart);
520int BotAIShutdownClient(int client, qboolean restart);
521int BotAIStartFrame(int time);
522void BotTestAAS(vec3_t origin);
523
524extern gentity_t *g_entities;
525#define FOFS(x) ((size_t) & (((gentity_t *)0)->x))
526
527#include "g_utils.h"
Definition archive.h:86
Definition container.h:85
Definition entity.h:203
Definition playerstart.h:34
Definition player.h:127
Definition vector.h:61
Definition str.h:77
Definition SkelMat4.h:355
Definition g_local.h:510
Definition g_local.h:122
Definition g_local.h:471
Definition q_shared.h:1524
Definition g_local.h:95
Definition q_shared.h:1452
Definition movegrid.h:47