UFO: Alien Invasion
|
Misc utility functions for game module. More...
#include "g_local.h"
Go to the source code of this file.
Functions | |
void | G_FreeEdict (Edict *e) |
Marks the edict as free. More... | |
Edict * | G_GetEdictFromPos (const pos3_t pos, const entity_type_t type) |
Searches an edict of the given type at the given grid location. More... | |
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. More... | |
bool | G_UseEdict (Edict *ent, Edict *activator) |
Call the 'use' function for the given edict and all its group members. More... | |
const char * | G_GetWeaponNameForFiredef (const fireDef_t *fd) |
Returns the corresponding weapon name for a given fire definition. More... | |
Player * | G_GetPlayerForTeam (int team) |
Gets player for given team. More... | |
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. More... | |
bool | G_TestLineWithEnts (const vec3_t start, const vec3_t end) |
fast version of a line trace including entities More... | |
bool | G_TestLine (const vec3_t start, const vec3_t end) |
fast version of a line trace but without including entities More... | |
trace_t | G_Trace (const Line &trLine, const Edict *passent, int contentmask) |
collision detection - this version is more accurate and includes entity tests More... | |
const char * | G_GetPlayerName (int pnum) |
Returns the player name for a give player number. More... | |
void | G_PrintStats (const char *format,...) __attribute__((format(__printf__ |
void void | G_PrintActorStats (const Edict *victim, const Edict *attacker, const fireDef_t *fd) |
Prints stats about who killed who with what and how. More... | |
Edict * | G_FindRadius (Edict *from, const vec3_t org, float rad, entity_type_t type=ET_NULL) |
Returns entities that have origins within a spherical area. More... | |
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. More... | |
void | G_GenerateEntList (const char *entList[MAX_EDICTS]) |
creates an entity list More... | |
void | G_RecalcRouting (const char *model, const GridBox &box) |
void | G_CompleteRecalcRouting (void) |
int | G_TouchTriggers (Edict *ent, const entity_type_t type=ET_NULL) |
Check the world against triggers for the current entity. More... | |
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 the edicts' bbox. More... | |
void | G_TouchEdicts (Edict *ent, float extend) |
Call after linking a new trigger in or destroying a bmodel during gameplay to force all entities it covers to immediately touch it. More... | |
uint32_t | G_GetLevelFlagsFromPos (const pos3_t pos) |
Calculates the level flags for a given grid position. More... | |
Misc utility functions for game module.
Definition in file g_utils.h.
Definition at line 464 of file g_utils.cpp.
References Com_Printf(), GridBox::EMPTY, G_EdictsGetNextInUse(), G_RecalcRouting(), i, IS_BMODEL, and Edict::model.
Referenced by G_RunFrame(), and TEST_F().
Edict* G_FindRadius | ( | Edict * | from, |
const vec3_t | org, | ||
float | rad, | ||
entity_type_t | type | ||
) |
Returns entities that have origins within a spherical area.
[in] | from | The entity to start the search from. nullptr will start from the beginning. |
[in] | org | The origin that is the center of the circle. |
[in] | rad | radius to search an edict in. |
[in] | type | Type of entity. ET_NULL to ignore the type. |
Definition at line 408 of file g_utils.cpp.
References Edict::entBox, ET_NULL, G_EdictsGetNextInUse(), AABB::getCenter(), Edict::origin, Edict::type, and VectorLength().
Referenced by G_ActorUseDoor(), G_ClientShoot(), and G_GetClosePlayerMask().
Marks the edict as free.
ent | The edict to free. |
Definition at line 41 of file g_utils.cpp.
References Edict::classname, G_EventDestroyEdict(), gi, Edict::inuse, and Edict::nativeReset().
Referenced by Destroy_Breakable(), Destroy_Camera(), G_ActorInvMove(), G_InitCamera(), G_MissionThink(), G_MissionUse(), G_SpawnItemOnFloor(), Message_Use(), SP_2x2_start(), SP_alien_start(), SP_civilian_start(), SP_dummy(), SP_human_start(), SP_light(), SP_misc_camera(), SP_misc_item(), SP_misc_message(), SP_misc_mission(), SP_misc_model(), SP_player_start(), SP_trigger_nextmap(), SP_trigger_rescue(), SP_trigger_touch(), Think_SmokeAndFire(), and Touch_TouchTrigger().
void G_GenerateEntList | ( | const char * | entList[MAX_EDICTS] | ) |
creates an entity list
[out] | entList | A list of all active inline model entities |
Definition at line 436 of file g_utils.cpp.
References G_EdictsGetNextInUse(), i, IS_BMODEL, and Edict::model.
Referenced by G_RecalcRouting(), and G_TestLineWithEnts().
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.
[in] | origin | The center of the area to search for close actors |
[in] | radius | The radius to look in |
Definition at line 288 of file g_utils.cpp.
References G_FindRadius(), G_IsLivingActor(), G_TeamToPM(), and Edict::getTeam().
Referenced by Door_Use().
Edict* G_GetEdictFromPos | ( | const pos3_t | pos, |
const entity_type_t | type | ||
) |
Searches an edict of the given type at the given grid location.
pos | The grid location to look for an edict. |
type | The type of the edict to look for or -1 to look for any type in the search. |
nullptr
if nothing was found, otherwise the entity located at the given grid position. Definition at line 59 of file g_utils.cpp.
References ET_NULL, G_EdictsGetNextInUse(), Edict::pos, Edict::type, and VectorCompare.
Referenced by AIL_positionmission(), AIL_setwaypoint(), G_ActorFall(), G_GetFloorItemFromPos(), G_MissionThink(), and G_SpawnFieldPart().
Searches an edict that is not of the given types at the given grid location.
pos | The grid location to look for an edict. |
n | The amount of given entity_type_t values that are given via variadic arguments to this function. |
nullptr
if nothing was found, otherwise the entity located at the given grid position. Definition at line 81 of file g_utils.cpp.
References ET_MAX, G_EdictsGetNextInUse(), i, Edict::pos, Edict::type, and VectorCompare.
uint32_t G_GetLevelFlagsFromPos | ( | const pos3_t | pos | ) |
Calculates the level flags for a given grid position.
Definition at line 650 of file g_utils.cpp.
References i, and PATHFINDING_HEIGHT.
Referenced by G_SpawnFieldPart().
Player* G_GetPlayerForTeam | ( | int | team | ) |
Gets player for given team.
[in] | team | The team the player data should be searched for |
nullptr
when no player found. Definition at line 188 of file g_utils.cpp.
References G_PlayerGetNextActiveAI(), and G_PlayerGetNextActiveHuman().
Referenced by AI_CheckRespawn(), and G_ClientEndRound().
const char* G_GetPlayerName | ( | int | pnum | ) |
Returns the player name for a give player number.
Definition at line 275 of file g_utils.cpp.
References game, game_locals_s::players, and game_locals_s::sv_maxplayersperteam.
Referenced by G_PrintActorStats(), and GetGameAPI().
const char* G_GetWeaponNameForFiredef | ( | const fireDef_t * | fd | ) |
Returns the corresponding weapon name for a given fire definition.
[in] | fd | Pointer to fire definition, for which item is wanted. |
Definition at line 173 of file g_utils.cpp.
References G_GetObjectForFiredef(), and objDef_s::id.
Referenced by G_PrintActorStats().
Prints stats about who killed who with what and how.
[in] | victim | Pointer to edict being a victim. |
[in] | attacker | Pointer to edict being an attacker. |
[in] | fd | Pointer to fire definition used in attack. |
Definition at line 336 of file g_utils.cpp.
References Edict::chr, Com_sprintf(), G_GetPlayerName(), G_GetWeaponNameForFiredef(), G_PrintStats(), Edict::getIdNum(), Edict::getPlayerNum(), Edict::getTeam(), Edict::HP, Edict::isSameTeamAs(), fireDef_s::name, character_s::name, TEAM_ALIEN, and TEAM_CIVILIAN.
Referenced by G_CheckDeathOrKnockout().
void G_PrintStats | ( | const char * | format, |
... | |||
) |
Definition at line 452 of file g_utils.cpp.
References G_GenerateEntList(), gi, and MAX_EDICTS.
Referenced by Destroy_Breakable(), Door_Use(), and G_CompleteRecalcRouting().
Applies the given damage value to an edict that is either an actor or has the FL_DESTROYABLE
flag set.
ent | The edict to apply the damage to. |
damage | The damage value. |
Definition at line 215 of file g_utils.cpp.
References G_IsActor, G_IsBreakable, and Edict::HP.
Referenced by G_ActorFall(), G_BleedWounds(), G_Damage(), G_DamageActor(), and G_TreatActor().
fast version of a line trace but without including entities
start | The start vector of the trace |
end | The end vector of the trace |
false
if not blocked Definition at line 253 of file g_utils.cpp.
References G_TraceDraw(), gi, and TL_FLAG_NONE.
Referenced by G_SplashDamage(), and G_TeamPointVis().
fast version of a line trace including entities
start | The start vector of the trace |
end | The end vector of the trace |
false
if not blocked Definition at line 237 of file g_utils.cpp.
References G_GenerateEntList(), G_TraceDraw(), gi, MAX_EDICTS, and TL_FLAG_NONE.
Referenced by AIL_missiontargets(), and G_LineVis().
Call after linking a new trigger in or destroying a bmodel during gameplay to force all entities it covers to immediately touch it.
[in] | trigger | The edict to check. |
[in] | extend | Extend value for the bounding box |
Definition at line 625 of file g_utils.cpp.
References Edict::absBox, Edict::callTouch(), Edict::chr, Com_DPrintf(), DEBUG_GAME, AABB::expand(), G_GetTouchingEdicts(), Edict::hasTouch(), i, Edict::inuse, lengthof, MAX_EDICTS, Edict::model, and character_s::name.
Referenced by Destroy_Breakable().
Call after making a step to a new grid tile to immediately touch edicts whose bbox intersects with the edicts' bbox.
Definition at line 590 of file g_utils.cpp.
References Edict::absBox, Edict::callTouch(), AABB::expand(), G_GetTouchingEdicts(), G_IsLivingActor(), Edict::hasTouch(), i, Edict::inuse, lengthof, makeActor(), MAX_EDICTS, Edict::solid, and SOLID_TRIGGER.
Referenced by G_ClientMove().
int G_TouchTriggers | ( | Edict * | ent, |
const entity_type_t | type | ||
) |
Check the world against triggers for the current entity.
[in,out] | ent | The entity that maybe touches others |
[in] | type | Type of the entity |
Definition at line 547 of file g_utils.cpp.
References Edict::absBox, Edict::callTouch(), Edict::dmg, ET_NULL, G_GetTouchingEdicts(), G_IsLivingActor(), G_ResetTriggers(), G_TriggerAddToList(), Edict::hasTouch(), i, Actor::isStunned(), lengthof, makeActor(), MAX_EDICTS, Edict::solid, SOLID_TRIGGER, and Edict::type.
Referenced by G_ActorUseDoor(), G_ClientMove(), G_ClientShoot(), G_ClientTeamInfo(), G_RoundTouchTriggers(), and G_SpawnAIPlayer().
collision detection - this version is more accurate and includes entity tests
Definition at line 265 of file g_utils.cpp.
References G_TraceDraw(), and gi.
Referenced by AI_CheckLineOfFire(), G_SendFootstepSound(), G_ShootGrenade(), G_ShootSingle(), and G_SpawnFieldGroup().
Call the 'use' function for the given edict and all its group members.
[in] | ent | The edict to call the use function for |
[in] | activator | The edict that uses ent |
Definition at line 117 of file g_utils.cpp.
References Edict::groupChain, Edict::groupMaster, and Edict::use.
Referenced by G_ClientUseEdict(), G_MissionThink(), Reset_TouchTrigger(), SP_func_door(), and Touch_TouchTrigger().