87 assert(n <
sizeof(types));
91 for (
int i = 0;
i < n;
i++) {
98 for (
i = 0;
i < n;
i++)
99 if (ent->
type == types[
i])
129 }
else if (!ent->
use(ent, activator)) {
136 chain->
use(chain, activator);
193 if (p->getTeam() == team)
199 if (p->getTeam() == team)
218 ent->
HP = std::max(ent->
HP - damage, 0);
267 static const AABB box;
269 return gi.Trace(trLine, box, passent, contentmask);
291 Edict* closeActor =
nullptr;
313 gi.DPrintf(
"[STATS] %s\n", buffer);
319 const struct tm* t = localtime(&aclock);
321 Com_sprintf(tbuf,
sizeof(tbuf),
"%4i/%02i/%02i %02i:%02i:%02i", t->tm_year + 1900,
322 t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
324 fprintf(
logstatsfile,
"[STATS] %s - %s\n", tbuf, buffer);
340 if (attacker !=
nullptr && fd !=
nullptr) {
344 if (victimName[0] ==
'\0') {
347 victimName =
"civilian";
350 victimName =
"alien";
353 victimName =
"unknown";
357 if (attackerName[0] ==
'\0') {
360 attackerName =
"civilian";
363 attackerName =
"alien";
366 attackerName =
"unknown";
371 Com_sprintf(buffer,
sizeof(buffer),
"%s (%s) %s %s (%s) with %s of %s (entnum: %i)",
372 attackerName, attacker->
chr.
name,
373 (victim->
HP == 0 ?
"kills" :
"stuns"),
376 Com_sprintf(buffer,
sizeof(buffer),
"%s (%s) %s %s (%s) (teamkill) with %s of %s (entnum: %i)",
377 attackerName, attacker->
chr.
name,
378 (victim->
HP == 0 ?
"kills" :
"stuns"),
383 Com_sprintf(buffer,
sizeof(buffer),
"%s %s %s (own team) with %s of %s (entnum: %i)",
384 attackerName, (victim->
HP == 0 ?
"kills" :
"stuns"),
389 Com_sprintf(buffer,
sizeof(buffer),
"%s (%s) was %s (entnum: %i)",
390 victimName, victim->
chr.
name, (victim->
HP == 0 ?
"killed" :
"stunned"), victim->
getIdNum());
416 for (
int j = 0; j < 3; j++)
417 eorg[j] = org[j] - (ent->
origin[j] + center[j]);
428 #define IS_BMODEL(ent) ((ent)->model && (ent)->model[0] == '*' && (ent)->solid == SOLID_BSP) 439 Edict* ent =
nullptr;
444 entList[
i++] = ent->
model;
445 entList[
i] =
nullptr;
458 gi.GridRecalcRouting(model, box, entList);
466 double start = time(
nullptr);
468 Edict* ent =
nullptr;
476 Com_Printf(
"Rerouted for %i Edicts in %5.2fs\n",
i, time(
nullptr) - start);
487 Edict* trigger =
nullptr;
496 for (
i = 0;
i < num;
i++) {
497 if (touched[
i] == trigger)
503 if (trigger->
reset !=
nullptr)
504 trigger->
reset(trigger, ent);
562 for (
int i = 0;
i < num;
i++) {
605 for (
int i = 0;
i < num;
i++) {
634 Com_DPrintf(
DEBUG_GAME,
"G_TouchEdicts: Entities touching %s: %i (%f extent).\n", entName, num, extend);
638 for (
int i = 0;
i < num;
i++) {
652 uint32_t levelflags = 0;
655 levelflags |= (1 <<
i);
Edict * G_EdictsGetFirst(void)
Returns the first entity.
vec_t VectorLength(const vec3_t v)
Calculate the length of a vector.
Edict * G_EdictsGetNextInUse(Edict *lastEnt)
Iterate through the entities that are in use.
int G_TouchTriggers(Edict *ent, const entity_type_t type)
Check the world against triggers for the current entity.
void G_RecalcRouting(const char *model, const GridBox &box)
int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap)
Safe (null terminating) vsnprintf implementation.
trace_t G_Trace(const Line &trLine, const Edict *passent, int contentmask)
collision detection - this version is more accurate and includes entity tests
Player * G_PlayerGetNextActiveHuman(Player *lastPlayer)
Iterate through the list of players.
QGL_EXTERN GLint GLenum type
void G_PrintStats(const char *format,...)
Prints stats to game console and stats log file.
bool doesIntersect(const AABB &other) const
Checks if the aabb touches or intersects with the given aabb.
Edict * G_GetEdictFromPos(const pos3_t pos, const entity_type_t type)
Searches an edict of the given type at the given grid location.
Misc utility functions for game module.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
unsigned int playermask_t
void G_GenerateEntList(const char *entList[MAX_EDICTS])
creates an entity list
void G_EventDestroyEdict(const Edict &ent)
Unregister an edict at the client.
void Com_Printf(const char *const fmt,...)
bool isSameTeamAs(const Edict *other) const
bool callTouch(Edict *activator)
Edict * G_GetEdictFromPosExcluding(const pos3_t pos, const int n,...)
Searches an edict that is not of the given types at the given grid location.
void G_TouchEdicts(Edict *trigger, float extend)
Call after linking a new trigger in or destroying a bmodel during gameplay to force all entities it c...
const char * G_GetPlayerName(int pnum)
Returns the player name for a give player number.
bool G_IsLivingActor(const Edict *ent)
Checks whether the given edict is a living actor.
Actor * makeActor(Edict *ent)
Convert an Edict pointer into an Actor pointer.
void G_CompleteRecalcRouting(void)
playermask_t G_GetClosePlayerMask(const vec3_t origin, float radius)
Assembles a player mask for those players that have a living team member close to the given location...
Player * G_PlayerGetNextActiveAI(Player *lastPlayer)
Iterate through the list of players.
Player * G_GetPlayerForTeam(int team)
Gets player for given team.
Edict * G_FindRadius(Edict *from, const vec3_t org, float rad, entity_type_t type)
Returns entities that have origins within a spherical area.
static void G_TraceDraw(const Line &traceLine)
Renders all the traces on the client side if the cvar g_drawtraces is activated.
void G_PrintActorStats(const Edict *victim, const Edict *attacker, const fireDef_t *fd)
Prints stats about who killed who with what and how.
bool G_TestLine(const vec3_t start, const vec3_t end)
fast version of a line trace but without including entities
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
bool(* use)(Edict *self, Edict *activator)
static int G_GetTouchingEdicts(const AABB &aabb, Edict **list, int maxCount, Edict *skip)
Fills a list with edicts that are in use and are touching the given bounding box. ...
static const GridBox EMPTY
void getCenter(vec3_t center) const
Calculates the center of the bounding box.
static void G_ResetTriggers(Edict *ent, Edict **touched, int num)
Call the reset function for those triggers that are no longer touched (left the trigger zone) ...
objDef_t ods[MAX_OBJDEFS]
void G_TakeDamage(Edict *ent, int damage)
Applies the given damage value to an edict that is either an actor or has the FL_DESTROYABLE flag set...
bool G_TriggerIsInList(Edict *self, Edict *activator)
Checks whether the activator of this trigger_touch was already recognized.
#define VectorCompare(a, b)
#define PATHFINDING_HEIGHT
15 max, adjusting above 8 will require a rewrite to the DV code
uint32_t G_GetLevelFlagsFromPos(const pos3_t pos)
Calculates the level flags for a given grid position.
void G_TriggerAddToList(Edict *self, Edict *activator)
Adds the activator to the list of recognized edicts for this trigger_touch edict. ...
static const objDef_t * G_GetObjectForFiredef(const fireDef_t *fd)
Searches for the obj that has the given firedef.
void(* reset)(Edict *self, Edict *activator)
fireDefIndex_t numFiredefs[MAX_WEAPONS_PER_OBJDEF]
functions to handle the storage and lifecycle of all edicts in the game module.
void expand(const float byVal)
expand the box in all directions, but clip them to the maximum boundaries
bool G_UseEdict(Edict *ent, Edict *activator)
Call the 'use' function for the given edict and all its group members.
Defines all attributes of objects used in the inventory.
this is a fire definition for our weapons/ammo
fireDef_t fd[MAX_WEAPONS_PER_OBJDEF][MAX_FIREDEFS_PER_WEAPON]
const char * G_GetWeaponNameForFiredef(const fireDef_t *fd)
Returns the corresponding weapon name for a given fire definition.
bool G_TestLineWithEnts(const vec3_t start, const vec3_t end)
fast version of a line trace including entities
int G_TouchSolids(Edict *ent, float extend)
Call after making a step to a new grid tile to immediately touch edicts whose bbox intersects with th...
bool G_TriggerRemoveFromList(Edict *self, Edict *activator)
Removes an activator from the list of recognized edicts.
void G_FreeEdict(Edict *ent)
Marks the edict as free.
Interface for g_client.cpp.
playermask_t G_TeamToPM(int team)
Generates the player bit mask for a given team.
void format(__printf__, 1, 2)))
#define G_IsBreakable(ent)
void G_EventParticleSpawn(playermask_t playerMask, const char *name, int levelFlags, const vec3_t s, const vec3_t v, const vec3_t a)
Spawn a new particle for the client.