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
|
/*
===========================================================================
Copyright (C) 2025 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#pragma once
#include "../qcommon/str.h"
class Archiver;
class Entity;
class SimpleEntity;
class SimpleArchivedEntity;
class ScriptThread;
void G_ArchivePlayerState(Archiver& arc, playerState_t *ps);
void G_ArchiveTrace(Archiver& arc, trace_t *trace);
void G_ArchiveClient(Archiver& arc, gclient_t *client);
void G_ArchiveEdict(Archiver& arc, gentity_t *edict);
void G_AllocDebugLines(void);
void G_DeAllocDebugLines(void);
void G_TouchTriggers(Entity *ent);
void G_TouchSolids(Entity *ent);
Entity *G_FindClass(Entity *ent, const char *classname);
Entity *G_NextEntity(Entity *ent);
void G_CalcBoundsOfMove(Vector& start, Vector& end, Vector& mins, Vector& maxs, Vector *minbounds, Vector *maxbounds);
void G_ShowTrace(trace_t *trace, const gentity_t *passent, const char *reason);
void G_ShowSightTrace(trace_t *trace, const gentity_t *passent, const char *reason);
bool G_SightTrace(
const Vector& start,
const Vector& mins,
const Vector& maxs,
const Vector& end,
Entity *passent,
Entity *passent2,
int contentmask,
qboolean cylindrical,
const char *reason
);
bool G_SightTrace(
const Vector& start,
const Vector& mins,
const Vector& maxs,
const Vector& end,
gentity_t *passent,
gentity_t *passent2,
int contentmask,
qboolean cylindrical,
const char *reason
);
void G_PMDrawTrace(
trace_t *results,
const vec3_t start,
const vec3_t mins,
const vec3_t maxs,
const vec3_t end,
int passEntityNum,
int contentMask,
qboolean cylinder,
qboolean traceDeep
);
trace_t G_Trace(
const Vector& start,
const Vector& mins,
const Vector& maxs,
const Vector& end,
const Entity *passent,
int contentmask,
qboolean cylindrical,
const char *reason,
qboolean tracedeep = qfalse
);
trace_t G_Trace(
vec3_t start,
vec3_t mins,
vec3_t maxs,
vec3_t end,
const gentity_t *passent,
int contentmask,
qboolean cylindrical,
const char *reason,
qboolean tracedeep = qfalse
);
void G_TraceEntities(
Vector& start,
Vector& mins,
Vector& maxs,
Vector& end,
Container<Entity *> *victimlist,
int contentmask,
qboolean bIncludeTriggers = qfalse
);
float G_VisualObfuscation(const Vector& start, const Vector& end);
void SelectSpawnPoint(Vector& org, Vector& angles, str& thread);
Entity *G_FindTarget(Entity *ent, const char *name);
Entity *G_FindRandomTarget(const char *name);
SimpleEntity *G_FindRandomSimpleTarget(const char *name);
Entity *G_NextEntity(Entity *ent);
qboolean M_CheckBottom(Entity *ent);
Vector G_GetMovedir(float angle);
float G_GetAngle(Vector movedir);
qboolean KillBox(Entity *ent);
qboolean IsNumeric(const char *str);
Entity *findradius(Entity *startent, Vector org, float rad);
Entity *findclientsinradius(Entity *startent, Vector org, float rad);
Vector G_CalculateImpulse(Vector start, Vector end, float speed, float gravity);
Vector G_PredictPosition(Vector start, Vector target, Vector targetvelocity, float speed);
qboolean G_LoadAndExecScript(const char *filename, const char *label = NULL, qboolean quiet = qfalse);
ScriptThread *ExecuteThread(str thread_name, qboolean start = true);
int MOD_string_to_int(const str& immune_string);
qboolean MOD_matches(int incoming_damage, int damage_type);
void G_MissionFailed(void);
void G_FadeOut(float delaytime);
void G_FadeSound(float delaytime);
void G_RestartLevelWithDelay(float delaytime);
void G_AutoFadeIn(void);
void G_ClearFade(void);
void G_StartCinematic(void);
void G_StopCinematic(void);
// copy the entity exactly including all its children
void CloneEntity(Entity *dest, Entity *src);
qboolean OnSameTeam(Entity *ent1, Entity *ent2);
//
// caching commands
//
void CacheResource(const char *stuff);
int modelIndex(const char *mdl);
void G_SetTrajectory(gentity_t *ent, vec3_t org);
void G_SetConstantLight(
int *constantlight, float *red, float *green, float *blue, float *radius, int *lightstyle = NULL
);
void ChangeMusic(const char *current, const char *fallback, qboolean force);
void ChangeMusicVolume(float volume, float fade_time);
void RestoreMusicVolume(float fade_time);
void ChangeSoundtrack(const char *soundtrack);
void RestoreSoundtrack(void);
void G_BroadcastSound(Entity *ent, Vector origin, float radius = SOUND_RADIUS);
SimpleArchivedEntity *G_FindArchivedClass(SimpleArchivedEntity *ent, const char *classname);
Entity *G_FindClass(Entity *ent, const char *classname);
int G_GetClientNumber(gentity_t *ent);
int G_GetClientNumber(Entity *ent);
Entity *G_GetEntityByClient(int clientNum);
int G_GetEntityIndex(int number);
int G_GetEntityIndex(gentity_t *ent);
gentity_t *G_GetGEntity(int id);
//==================================================================
//
// Inline functions
//
//==================================================================
/*
=================
G_GetEntity
Takes an index to an entity and returns pointer to it.
=================
*/
inline Entity *G_GetEntity(int entnum)
{
if ((entnum < 0) || (entnum >= globals.max_entities)) {
gi.Error(ERR_DROP, "G_GetEntity: %d out of valid range.", entnum);
}
return (Entity *)g_entities[entnum].entity;
}
/*
=================
G_Random
Returns a number from 0<= num < 1
random()
=================
*/
inline float G_Random(void)
{
return ((float)(rand() & 0x7fff)) / ((float)0x8000);
}
/*
=================
G_Random
Returns a number from 0 <= num < n
random()
=================
*/
inline float G_Random(float n)
{
return G_Random() * n;
}
/*
=================
G_CRandom
Returns a number from -1 <= num < 1
crandom()
=================
*/
inline float G_CRandom(void)
{
return G_Random(2) - 1;
}
/*
=================
G_CRandom
Returns a number from -n <= num < n
crandom()
=================
*/
inline float G_CRandom(float n)
{
return G_CRandom() * n;
}
/*
=================
G_FixSlashes
Converts all backslashes in a string to forward slashes.
Used to make filenames consistant.
=================
*/
inline str G_FixSlashes(const char *filename)
{
int i;
size_t len;
str text;
if (filename) {
// Convert all forward slashes to back slashes
text = filename;
len = text.length();
for (i = 0; i < len; i++) {
if (text[i] == '\\') {
text[i] = '/';
}
}
}
return text;
}
typedef enum {
WEAPON_MAIN,
WEAPON_OFFHAND,
WEAPON_ERROR
} weaponhand_t;
#define NUM_ACTIVE_WEAPONS WEAPON_ERROR
typedef enum {
FIRE_PRIMARY,
FIRE_SECONDARY,
MAX_FIREMODES,
FIRE_ERROR
} firemode_t;
firemode_t WeaponModeNameToNum(str mode);
const char *WeaponHandNumToName(weaponhand_t hand);
weaponhand_t WeaponHandNameToNum(str side);
void G_DebugTargets(Entity *e, str from);
void G_DebugDamage(float damage, Entity *victim, Entity *attacker, Entity *inflictor);
unsigned int G_GetWeaponCommandMask();
unsigned int G_GetWeaponCommand(unsigned int buttons);
|