g_local.h File Reference

Local definitions for game module. More...

#include "q_shared.h"
#include "inventory.h"
#include "../shared/infostring.h"
#include "lua/lua.h"
#include "game.h"
Include dependency graph for g_local.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  game_locals_t
 this structure is left intact through an entire game it should be initialized at game library load time More...
struct  level_locals_t
 this structure is cleared as each map is entered More...
struct  spawn_temp_t
 this is only used to hold entity field values that can be set from the editor, but aren't actually present in edict_t during gameplay More...
struct  shot_mock_t
 used in shot probability calculations (pseudo shots) More...
struct  moveinfo_t
 actor movement More...
struct  client_persistant_t
 client data that stays across multiple level loads More...
struct  player_s
 this structure is cleared on each PutClientInServer(), except for 'client->pers' More...
struct  AI_s
 Artificial intelligence of a character. More...
struct  edict_s
 Everything that is not in the bsp tree is an edict, the spawnpoints, the actors, the misc_models, the weapons and so on. More...

Defines

#define _(String)   String
#define ngettext(x, y, cnt)   x
#define GAME_INCLUDE
#define GAMEVERSION   "baseufo"
#define MAX_SPOT_DIST   4096
#define PM_ALL   0xFFFFFFFF
#define TEAM_ALL   0xFFFFFFFF
#define G_PlayerToPM(player)   ((player)->num < game.sv_maxplayersperteam ? 1 << ((player)->num) : 0)
#define SERVER_FRAME_SECONDS   0.1
#define TAG_GAME   765
#define TAG_LEVEL   766
#define CONTAINER(e, containerID)   ((e)->chr.i.c[(containerID)])
#define ARMOUR(e)   (CONTAINER(e, gi.csi->idArmour))
#define RIGHT(e)   (CONTAINER(e, gi.csi->idRight))
#define LEFT(e)   (CONTAINER(e, gi.csi->idLeft))
#define EXTENSION(e)   (CONTAINER(e, gi.csi->idExtension))
#define HEADGEAR(e)   (CONTAINER(e, gi.csi->idHeadgear))
#define FLOOR(e)   (CONTAINER(e, gi.csi->idFloor))
#define INVDEF(containerID)   (&gi.csi->ids[(containerID)])
#define ACTOR_VIS_100   1.0
#define ACTOR_VIS_50   0.5
#define ACTOR_VIS_10   0.1
#define ACTOR_VIS_0   0.0
#define G_FreeTags(tag)   gi.FreeTags((tag), __FILE__, __LINE__)
#define G_TagMalloc(size, tag)   gi.TagMalloc((size), (tag), __FILE__, __LINE__)
#define G_MemFree(ptr)   gi.TagFree((ptr), __FILE__, __LINE__)
#define G_PLAYER_FROM_ENT(ent)   (game.players + (ent)->pnum)
#define random()   ((rand() & 0x7fff) / ((float)0x7fff))
#define crandom()   (2.0 * (random() - 0.5))
#define G_IsState(ent, s)   ((ent)->state & (s))
#define G_IsShaken(ent)   G_IsState(ent, STATE_SHAKEN)
#define G_IsStunned(ent)   (G_IsState(ent, STATE_STUN) & ~STATE_DEAD)
#define G_IsPaniced(ent)   G_IsState(ent, STATE_PANIC)
#define G_IsReaction(ent)   G_IsState(ent, STATE_REACTION)
#define G_IsRaged(ent)   G_IsState(ent, STATE_RAGE)
#define G_IsInsane(ent)   G_IsState(ent, STATE_INSANE)
#define G_IsDazed(ent)   G_IsState(ent, STATE_DAZED)
#define G_IsCrouched(ent)   G_IsState(ent, STATE_CROUCHED)
#define G_IsDead(ent)   G_IsState(ent, STATE_DEAD)
#define G_IsActor(ent)   ((ent)->type == ET_ACTOR || (ent)->type == ET_ACTOR2x2)
#define G_IsBreakable(ent)   ((ent)->flags & FL_DESTROYABLE)
#define G_IsBrushModel(ent)   ((ent)->type == ET_BREAKABLE || (ent)->type == ET_DOOR)
#define G_IsVisibleOnBattlefield(ent)   (G_IsActor((ent)) || (ent)->type == ET_ITEM || (ent)->type == ET_PARTICLE)
#define G_IsAI(ent)   (G_PLAYER_FROM_ENT((ent))->pers.ai)
#define G_IsAIPlayer(player)   ((player)->pers.ai)
#define G_TeamToVisMask(team)   (1 << (team))
#define G_IsVisibleForTeam(ent, team)   ((ent)->visflags & G_TeamToVisMask(team))
#define G_IsCivilian(ent)   ((ent)->team == TEAM_CIVILIAN)
#define G_IsAlien(ent)   ((ent)->team == TEAM_ALIEN)
#define G_IsBlockingMovementActor(ent)   (((ent)->type == ET_ACTOR && !G_IsDead(ent)) || ent->type == ET_ACTOR2x2)
#define G_ToggleState(ent, s)   (ent)->state ^= (s)
#define G_ToggleCrouched(ent)   G_ToggleState(ent, STATE_CROUCHED)
#define G_SetState(ent, s)   (ent)->state |= (s)
#define G_SetShaken(ent)   G_SetState((ent), STATE_SHAKEN)
#define G_SetDazed(ent)   G_SetState((ent), STATE_DAZED)
#define G_SetStunned(ent)   G_SetState((ent), STATE_STUN)
#define G_SetDead(ent)   G_SetState((ent), STATE_DEAD)
#define G_SetInsane(ent)   G_SetState((ent), STATE_INSANE)
#define G_SetRage(ent)   G_SetState((ent), STATE_RAGE)
#define G_SetPanic(ent)   G_SetState((ent), STATE_PANIC)
#define G_SetCrouched(ent)   G_SetState((ent), STATE_CROUCHED)
#define G_RemoveState(ent, s)   (ent)->state &= ~(s)
#define G_RemoveShaken(ent)   G_RemoveState((ent), STATE_SHAKEN)
#define G_RemoveDazed(ent)   G_RemoveState((ent), STATE_DAZED)
#define G_RemoveStunned(ent)   G_RemoveState((ent), STATE_STUN)
#define G_RemoveDead(ent)   G_RemoveState((ent), STATE_DEAD)
#define G_RemoveInsane(ent)   G_RemoveState((ent), STATE_INSANE)
#define G_RemoveRage(ent)   G_RemoveState((ent), STATE_RAGE)
#define G_RemovePanic(ent)   G_RemoveState((ent), STATE_PANIC)
#define G_RemoveCrouched(ent)   G_RemoveState((ent), STATE_CROUCHED)
#define G_RemoveReaction(ent)   G_RemoveState((ent), STATE_REACTION)
#define FFL_SPAWNTEMP   1
#define FFL_NOSPAWN   2
#define VIS_APPEAR   1
#define VIS_PERISH   2
#define VIS_CHANGE   1
#define VIS_YES   2
#define VIS_STOP   4
#define VT_PERISH   1
#define VT_NOFRUSTUM   2
#define MORALE_RANDOM(mod)   ( (mod) * (1.0 + 0.3*crand()) )
#define MAX_DVTAB   32
#define FL_GROUPSLAVE   0x00000008
 not the first on the team
#define FL_DESTROYABLE   0x00000004
 If an edict is destroyable (like ET_BREAKABLE, ET_DOOR [if health set] or maybe a ET_MISSION [if health set]).
#define FL_TRIGGERED   0x00000100
 Trigger the edict at spawn.

Typedefs

typedef struct AI_s AI_t
 Artificial intelligence of a character.

Enumerations

enum  edictMaterial_t {
  MAT_GLASS, MAT_METAL, MAT_ELECTRICAL, MAT_WOOD,
  MAT_MAX
}
 

e.g. used for breakable objects

More...

Functions

void G_SendPlayerStats (const player_t *player)
 Write player stats to network buffer.
void G_WriteItem (const item_t *item, const invDef_t *container, int x, int y)
 Write an item to the network buffer.
void G_ReadItem (item_t *item, invDef_t **container, int *x, int *y)
 Read item from the network buffer.
void G_InventoryToFloor (edict_t *ent)
 Move items to adjacent locations if the containers on the current floor edict are full.
qboolean G_AddItemToFloor (const pos3_t pos, const char *itemID)
 Adds a new item to an existing or new floor container edict at the given grid location.
edict_tG_GetFloorItemsFromPos (const pos3_t pos)
 Callback to G_GetEdictFromPos() for given position, used to get items from position.
void G_MoraleBehaviour (int team)
 Applies morale behaviour on actors.
void G_PhysicsRun (void)
 Handles door and other objects.
void G_PhysicsStep (edict_t *ent)
void G_ActorReserveTUs (edict_t *ent, int resReaction, int resShot, int resCrouch)
 Reserves TUs for different actor actions.
int G_ActorGetTUForReactionFire (const edict_t *ent)
 Calculates the amount of TUs that are needed for the current selected reaction fire mode.
int G_ActorUsableTUs (const edict_t *ent)
 Calculates the amount of usable TUs. This is without the reserved TUs.
int G_ActorGetReservedTUs (const edict_t *ent)
 Calculates the amount of all currently reserved TUs.
void G_ActorCheckRevitalise (edict_t *ent)
qboolean G_MissionTouch (edict_t *self, edict_t *activator)
 Mission trigger.
qboolean G_MissionUse (edict_t *self, edict_t *activator)
 Mission trigger use function.
qboolean G_MissionDestroy (edict_t *self)
 Mission trigger destroy function.
void G_MissionThink (edict_t *self)
edict_tG_Find (edict_t *from, int fieldofs, char *match)
 Searches all active entities for the next one that holds the matching string at fieldofs (use the offsetof() macro) in the structure.
edict_tG_FindRadius (edict_t *from, const vec3_t org, float rad, entity_type_t type)
 Returns entities that have origins within a spherical area.
edict_tG_FindTargetEntity (const char *target)
 Searches the edict that has the given target as targetname set.
const char * G_GetPlayerName (int pnum)
 Returns the player name for a give player number.
player_tG_GetPlayerForTeam (int team)
 Gets player for given team.
int G_GetActiveTeam (void)
 Returns the current active team to the server.
const char * G_GetWeaponNameForFiredef (const fireDef_t *fd)
 Returns the corresponding weapon name for a given fire definition.
void G_PrintActorStats (const edict_t *victim, const edict_t *attacker, const fireDef_t *fd)
 Prints stats about who killed who with what and how.
void G_PrintStats (const char *buffer)
 Prints stats to game console and stats log file.
int G_TouchTriggers (edict_t *ent)
 Check the world against triggers for the current entity.
void G_TouchSolids (edict_t *ent)
 Call after linking a new trigger in or destroying a bmodel during gameplay to force all entities it covers to immediately touch it.
void G_TouchEdicts (edict_t *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.
edict_tG_Spawn (void)
 Either finds a free edict, or allocates a new one.
edict_tG_SpawnParticle (const vec3_t origin, int spawnflags, const char *particle)
void G_FreeEdict (edict_t *e)
 Marks the edict as free.
qboolean G_UseEdict (edict_t *ent, edict_t *activator)
 Call the 'use' function for the given edict and all its group members.
edict_tG_GetEdictFromPos (const pos3_t pos, const entity_type_t type)
 Searches an edict of the given type at the given grid location.
void G_TakeDamage (edict_t *ent, int damage)
 Applies the given damage value to an edict that is either an actor or has the FL_DESTROYABLE flag set.
trace_t G_Trace (const vec3_t start, const vec3_t end, const edict_t *passent, int contentmask)
 collision detection - this version is more accurate and includes entity tests
qboolean G_TestLineWithEnts (const vec3_t start, const vec3_t end)
 fast version of a line trace including entities
qboolean G_TestLine (const vec3_t start, const vec3_t end)
 fast version of a line trace but without including entities
void G_ReactionFirePreShot (const edict_t *target, const int fdTime)
 Called when 'target' is about to shoot, this forces a 'draw' to decide who gets the first shot.
void G_ReactionFirePostShot (edict_t *target)
 Called after 'target' has fired, this might trigger more reaction fire or resolve outstanding reaction fire (because target is out of time).
void G_ReactionFireReset (int team)
 Guess! Reset all "shaken" states on end of turn?
qboolean G_ReactionFireCanBeEnabled (const edict_t *ent)
 Checks whether the actor is allowed to activate reaction fire and will informs the player about the reason if this would not work.
qboolean G_ReactionFireSetDefault (edict_t *ent)
void G_ReactionFireUpdate (edict_t *ent, fireDefIndex_t fmIdx, actorHands_t hand, const objDef_t *od)
 Updates the reaction fire settings in case something was moved into a hand or from a hand that would make the current settings invalid.
qboolean G_ReactionFireOnMovement (edict_t *target)
 Called when 'target' moves, possibly triggering or resolving reaction fire.
void G_ReactionFireEndTurn (void)
 Called at the end of turn, all outstanding reaction fire is resolved.
void G_CompleteRecalcRouting (void)
void G_RecalcRouting (const edict_t *ent)
void G_GenerateEntList (const char *entList[MAX_EDICTS])
 creates an entity list
void G_EventSpawnSound (const edict_t *ent, const vec3_t origin, const char *sound)
 Spawns a sound for all connected clients (that will be spatialized on the client side).
void G_EventActorTurn (const edict_t *ent)
 Send the turn event for the given entity.
void G_EventActorFall (const edict_t *ent)
void G_EventActorDie (const edict_t *ent)
 Announce the actor die event for the clients that are seeing the actor.
void G_EventActorRevitalise (const edict_t *ent)
 Announce the actor die event for the clients that are seeing the actor.
void G_EventActorSendReservations (const edict_t *ent)
 Will inform the player about the real TU reservation.
void G_EventInventoryDelete (const edict_t *ent, int playerMask, const invDef_t *invDef, int x, int y)
 Tell the client to remove the item from the container.
void G_EventInventoryAdd (const edict_t *ent, int playerMask, int itemAmount)
 Tell the client to add the item from the container.
void G_EventPerish (const edict_t *ent)
 Send an event to all clients that are seeing the given edict, that it just has disappeared.
void G_EventDestroyEdict (const edict_t *ent)
 Unregister an edict at the client.
void G_EventInventoryAmmo (const edict_t *ent, const objDef_t *ammo, int amount, shoot_types_t shootType)
 Change the amount of available ammo for the given entity.
void G_EventStartShoot (const edict_t *ent, int visMask, shoot_types_t shootType, const pos3_t at)
 Start the shooting event.
void G_EventShootHidden (int visMask, const fireDef_t *fd, qboolean firstShoot)
 Start the shooting event for hidden actors.
void G_EventShoot (const edict_t *ent, int visMask, const fireDef_t *fd, qboolean firstShoot, shoot_types_t shootType, int flags, const trace_t *trace, const vec3_t from, const vec3_t impact)
 Do the shooting.
void G_EventSetClientAction (const edict_t *ent)
 Informs the client that an interaction with the world is possible.
void G_EventResetClientAction (const edict_t *ent)
 Reset the client actions for the given entity.
void G_EventActorStats (const edict_t *ent)
void G_EventEndRound (void)
 End of round event for the current active team.
void G_EventInventoryReload (const edict_t *ent, int playerMask, const item_t *item, const invDef_t *invDef, const invList_t *ic)
void G_EventThrow (int visMask, const fireDef_t *fd, float dt, byte flags, const vec3_t position, const vec3_t velocity)
void G_EventReactionFireChange (const edict_t *ent)
void G_EventParticleSpawn (int 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.
void G_EventSendEdict (const edict_t *ent)
 Send the bounding box info to the client.
edict_tG_ClientGetFreeSpawnPointForActorSize (const player_t *player, const actorSizeEnum_t actorSize)
 Searches a free spawning point for a given actor size.
qboolean G_ClientUseEdict (const player_t *player, edict_t *actor, edict_t *door)
 This function 'uses' the edict. E.g. it opens the door when the player wants it to open.
qboolean G_ActionCheckForCurrentTeam (const player_t *player, edict_t *ent, int TU)
 Checks whether the requested action is possible for the current active team.
qboolean G_ActionCheckWithoutTeam (const player_t *player, edict_t *ent, int TU)
 Checks whether the requested action is possible.
void G_SendStats (edict_t *ent) __attribute__((nonnull))
 Send stats to network buffer.
edict_tG_SpawnFloor (const pos3_t pos)
 Spawns a new entity at the floor.
int G_CheckVisTeam (const int team, edict_t *check, qboolean perish, const edict_t *ent)
 Checks whether an edict appear/perishes for a specific team - also updates the visflags each edict carries.
int G_CheckVisTeamAll (const int team, qboolean perish, const edict_t *ent)
 Do G_CheckVisTeam for all entities.
edict_tG_GetFloorItems (edict_t *ent) __attribute__((nonnull))
 Prepares a list of items on the floor at given entity position.
qboolean G_InventoryRemoveItemByID (const char *itemID, edict_t *ent, containerIndex_t index)
 Removes one particular item from a given container.
void G_SendState (unsigned int playerMask, const edict_t *ent)
void G_SetTeamForPlayer (player_t *player, const int team)
void G_CenterView (const edict_t *ent)
 Centers the view for all clients that are seeing the given edict on the world position of the edict.
qboolean G_ActorIsInRescueZone (const edict_t *actor)
 Checks whether the given actor is currently standing in a rescue zone.
void G_ActorSetInRescueZone (edict_t *actor, qboolean inRescueZone)
 Set the rescue zone data.
void G_ActorUseDoor (edict_t *actor, edict_t *door)
 Make the actor use (as in open/close) a door edict.
qboolean G_IsLivingActor (const edict_t *ent) __attribute__((nonnull))
 Checks whether the given edict is a living actor.
void G_ActorSetClientAction (edict_t *actor, edict_t *ent)
 Handles the client actions (interaction with the world).
edict_tG_ActorGetByUCN (const int ucn, const int team)
 Searches an actor by a unique character number.
void G_CheckForceEndRound (void)
 Check whether a forced round end should be executed.
void G_ActorDieOrStun (edict_t *ent, edict_t *attacker)
 Reports and handles death or stun of an actor. If the HP of an actor is zero the actor will die, otherwise the actor will get stunned.
void G_ActorSetMaxs (edict_t *ent)
 Sets correct bounding box for actor (state dependent).
void G_ActorGiveTimeUnits (edict_t *ent)
 Set time units for the given edict. Based on speed skills.
void G_ActorSetTU (edict_t *ent, int tus)
void G_ActorUseTU (edict_t *ent, int tus)
int G_ClientAction (player_t *player)
 The client sent us a message that he did something. We now execute the related fucntion(s) adn notify him if neccessary.
void G_ClientEndRound (player_t *player)
void G_ClientTeamInfo (const player_t *player)
 The client lets the server spawn the actors for a given player by sending their information (models, inventory, etc..) over the network.
void G_ClientInitActorStates (const player_t *player)
 This is called after the actors are spawned and will set actor states without consuming TUs.
int G_ClientGetTeamNum (const player_t *player)
 Returns the assigned team number of the player.
int G_ClientGetTeamNumPref (const player_t *player)
 Returns the preferred team number for the player.
qboolean G_ClientIsReady (const player_t *player)
void G_ClientPrintf (const player_t *player, int printlevel, const char *fmt,...) __attribute__((format(printf
void void G_ResetClientData (void)
 Called after every player has joined.
void G_ClientCommand (player_t *player)
void G_ClientUserinfoChanged (player_t *player, char *userinfo)
 called whenever the player updates a userinfo variable.
qboolean G_ClientBegin (player_t *player)
 This functions starts the client.
void G_ClientSpawn (player_t *player)
 Sets the team, init the TU and sends the player stats.
qboolean G_ClientConnect (player_t *player, char *userinfo, size_t userinfoSize)
 Checks whether the connection is valid or invalid and set some user info keys.
void G_ClientDisconnect (player_t *player)
void G_ActorReload (edict_t *ent, const invDef_t *invDef)
 Reload weapon with actor.
qboolean G_ClientCanReload (edict_t *ent, containerIndex_t containerID)
 Returns true if actor can reload weapon.
void G_ClientGetWeaponFromInventory (edict_t *ent)
 Retrieve or collect weapon from any linked container for the actor.
void G_ClientMove (const player_t *player, int visTeam, edict_t *ent, const pos3_t to)
 Generates the client events that are send over the netchannel to move an actor.
void G_ActorFall (edict_t *ent)
 Let an actor fall down if e.g. the func_breakable the actor was standing on was destroyed.
void G_MoveCalc (int team, const edict_t *movingActor, const pos3_t from, byte crouchingState, int distance)
 Precalculates a move table for a given team and a given starting position. This will calculate a routing table for all reachable fields with the given distance from the given spot with the given actorsize.
void G_MoveCalcLocal (pathing_t *pt, int team, const edict_t *movingActor, const pos3_t from, byte crouchingState, int distance)
 Same as G_MoveCalc, except that it uses the pathing table passed as the first param.
void G_ActorInvMove (edict_t *ent, const invDef_t *from, invList_t *fItem, const invDef_t *to, int tx, int ty, qboolean checkaction)
 Moves an item inside an inventory. Floors are handled special.
void G_ClientStateChange (const player_t *player, edict_t *ent, int reqState, qboolean checkaction)
 Changes the state of a player/soldier.
int G_ActorDoTurn (edict_t *ent, byte dir)
 Turns an actor around.
edict_tG_GetActorFromPos (const pos3_t pos)
 Searches an actor on the given grid position.
void G_SendInvisible (player_t *player)
 This function sends all the actors to the client that are not visible initially - this is needed because an actor can e.g. produce sounds that are send over the net. And the client can only handle them if he knows the le_t (local entity) already.
void G_GiveTimeUnits (int team)
 Network function to update the time units (TUs) for each team-member.
void G_AppearPerishEvent (unsigned int player_mask, qboolean appear, edict_t *check, const edict_t *ent)
 Send the appear or perish event to the affected clients.
unsigned int G_VisToPM (unsigned int vis_mask)
 Converts vis mask to player mask.
void G_SendInventory (unsigned int player_mask, const edict_t *ent)
 Sends whole inventory through the network buffer.
unsigned int G_TeamToPM (int team)
 Generates the player bit mask for a given team.
void G_SpawnEntities (const char *mapname, qboolean day, const char *entities)
 Creates a server's entity / program execution context by parsing textual entity definitions out of an ent file.
qboolean G_RunFrame (void)
qboolean G_FrustumVis (const edict_t *from, const vec3_t point)
 Checks whether a point is "visible" from the edicts position.
float G_ActorVis (const vec3_t from, const edict_t *check, qboolean full)
 calculate how much check is "visible" from from
void G_ClearVisFlags (int team)
 Reset the visflags for all edicts in the global list for the given team - and only for the given team.
int G_CheckVis (edict_t *check, qboolean perish)
 Check if the edict appears/perishes for the other teams. If they appear for other teams, the needed information for those clients are also send in G_CheckVisTeam resp. G_AppearPerishEvent.
int G_CheckVisPlayer (player_t *player, qboolean perish)
 Sets visible edict on player spawn.
int G_TestVis (const int team, edict_t *check, int flags)
 test if check is visible by team (or if visibility changed?)
float G_Vis (const int team, const edict_t *from, const edict_t *check, int flags)
 test if check is visible by from
qboolean G_ClientShoot (const player_t *player, edict_t *ent, const pos3_t at, shoot_types_t shootType, fireDefIndex_t firemode, shot_mock_t *mock, qboolean allowReaction, int z_align)
 Setup for shooting, either real or mock.
void G_AddToWayPointList (edict_t *ent)
void AI_Run (void)
 Every server frame one single actor is handled - always in the same order.
void AI_ActorThink (player_t *player, edict_t *ent)
 The think function for the ai controlled aliens.
player_tAI_CreatePlayer (int team)
 Spawn civilians and aliens.
qboolean AI_CheckUsingDoor (const edict_t *ent, const edict_t *door)
 Checks whether the AI controlled actor wants to use a door.
void G_ServerCommand (void)
 ServerCommand will be called when an "sv" command is issued. The game can issue gi.Cmd_Argc() / gi.Cmd_Argv() commands to get the rest of the parameters.
qboolean SV_FilterPacket (const char *from)
qboolean G_MatchIsRunning (void)
 Checks whether the game is running (active team and no intermission time).
void G_MatchEndTrigger (int team, int timeGap)
 Triggers the end of the game. Will be executed in the next server (or game) frame.
void G_MatchEndCheck (void)
 Checks whether there are still actors to fight with left. If non are the match end will be triggered.
qboolean G_MatchDoEnd (void)
 Checks whether a match is over.
edict_tG_TriggerSpawn (edict_t *owner)
void SP_trigger_hurt (edict_t *ent)
 Trigger for grid fields if they are under fire.
void SP_trigger_touch (edict_t *ent)
 Touch trigger to call the use function of the attached target.
void SP_trigger_rescue (edict_t *ent)
 Rescue trigger to mark an actor to be in the rescue zone. Aborting a game would not kill the actors inside this trigger area.
void SP_func_rotating (edict_t *ent)
 Spawns a rotating solid inline brush model.
void SP_func_door (edict_t *ent)
 func_door (0 .5 .8) ? "health" if set, door is destroyable
void SP_func_breakable (edict_t *ent)
 func_breakable (0.3 0.3 0.3) ? Used for breakable objects.
edict_tG_EdictsInit (void)
 Allocate space for the entity pointers.
void G_EdictsReset (void)
 Reset the entity pointers for eg. a new game.
edict_tG_EdictsGetNewEdict (void)
 Find an entity that is not in use.
int G_EdictsGetNumber (const edict_t *ent)
 Get an entity's ID number.
qboolean G_EdictsIsValidNum (const int idx)
 Check if the given number could point to an existing entity.
edict_tG_EdictsGetByNum (const int num)
 Get an entity by it's number.
edict_tG_EdictsGetFirst (void)
 Returns the first entity.
edict_tG_EdictsGetNext (edict_t *lastEnt)
 Iterate through the list of entities.
edict_tG_EdictsGetNextInUse (edict_t *lastEnt)
 Iterate through the entities that are in use.
edict_tG_EdictsGetNextActor (edict_t *lastEnt)
 Iterate through the actor entities (even the dead! - but skips the invisible).
edict_tG_EdictsGetNextLivingActor (edict_t *lastEnt)
 Iterate through the living actor entities.
edict_tG_EdictsGetNextLivingActorOfTeam (edict_t *lastEnt, const int team)
 Iterate through the living actor entities of the given team.
void G_EdictCalcOrigin (edict_t *ent)
 Calculate the edict's origin vector from it's grid position.
void G_EdictSetOrigin (edict_t *ent, const pos3_t newPos)
 Set the edict's pos and origin vector to the given grid position.
qboolean G_EdictPosIsSameAs (edict_t *ent, const pos3_t cmpPos)
 Set the edict's pos and origin vector to the given grid position.

Variables

game_locals_t game
level_locals_t level
game_import_t gi
game_export_t globals
cvar_tsv_maxentities
cvar_tpassword
cvar_tsv_needpass
cvar_tsv_dedicated
cvar_tlogstats
FILE * logstatsfile
cvar_tsv_filterban
cvar_tsv_maxvelocity
cvar_tsv_maxclients
cvar_tsv_shot_origin
cvar_tsv_hurtaliens
cvar_tsv_maxplayersperteam
cvar_tsv_maxsoldiersperteam
cvar_tsv_maxsoldiersperplayer
cvar_tsv_enablemorale
cvar_tsv_roundtimelimit
cvar_tsv_maxteams
cvar_tsv_ai
cvar_tsv_teamplay
cvar_tai_alien
cvar_tai_civilian
cvar_tai_equipment
cvar_tai_numaliens
cvar_tai_numcivilians
cvar_tai_numactors
cvar_tmob_death
cvar_tmob_wound
cvar_tmof_watching
cvar_tmof_teamkill
cvar_tmof_civilian
cvar_tmof_enemy
cvar_tmor_pain
cvar_tmor_default
cvar_tmor_distance
cvar_tmor_victim
cvar_tmor_attacker
cvar_tmon_teamfactor
cvar_tmor_regeneration
cvar_tmor_shaken
cvar_tmor_panic
cvar_tmor_brave
cvar_tm_sanity
cvar_tm_rage
cvar_tm_rage_stop
cvar_tm_panic_stop
cvar_tg_reaction_fair
cvar_tg_ailua
cvar_tg_aidebug
cvar_tg_drawtraces
cvar_tg_nodamage
cvar_tg_notu
cvar_tg_nospawn
cvar_tg_actorspeed
cvar_tflood_msgs
cvar_tflood_persecond
cvar_tflood_waitdelay
cvar_tdifficulty
edict_tai_waypointList

Detailed Description

Local definitions for game module.

Definition in file g_local.h.


Define Documentation

#define _ ( String   )     String

no gettext support for game lib - but we must be able to mark the strings

Definition at line 38 of file g_local.h.

#define ACTOR_VIS_0   0.0
#define ACTOR_VIS_10   0.1

Definition at line 84 of file g_local.h.

Referenced by G_ActorVis().

#define ACTOR_VIS_100   1.0

Actor visibility constants

Definition at line 82 of file g_local.h.

Referenced by G_ActorVis(), and G_Vis().

#define ACTOR_VIS_50   0.5

Definition at line 83 of file g_local.h.

Referenced by AI_CheckCrouch(), and G_ActorVis().

#define ARMOUR (  )     (CONTAINER(e, gi.csi->idArmour))

Definition at line 72 of file g_local.h.

#define CONTAINER ( e,
containerID   )     ((e)->chr.i.c[(containerID)])

Macros for faster access to the inventory-container.

Definition at line 71 of file g_local.h.

 
#define crandom (  )     (2.0 * (random() - 0.5))

Definition at line 169 of file g_local.h.

#define EXTENSION (  )     (CONTAINER(e, gi.csi->idExtension))

Definition at line 75 of file g_local.h.

#define FFL_NOSPAWN   2

Definition at line 303 of file g_local.h.

Referenced by ED_ParseField().

#define FFL_SPAWNTEMP   1

Definition at line 302 of file g_local.h.

Referenced by ED_ParseField().

#define FL_DESTROYABLE   0x00000004

If an edict is destroyable (like ET_BREAKABLE, ET_DOOR [if health set] or maybe a ET_MISSION [if health set]).

Note:
e.g. misc_mission, func_breakable, func_door
If you mark an edict as breakable, you have to provide a destroy callback, too

Definition at line 619 of file g_local.h.

Referenced by G_ClientGetFreeSpawnPointForActorSize(), G_MissionThink(), SP_func_breakable(), SP_func_door(), SP_func_rotating(), and SP_misc_mission().

#define FL_GROUPSLAVE   0x00000008

not the first on the team

See also:
groupMaster and groupChain

Definition at line 612 of file g_local.h.

Referenced by G_ClientAction(), G_FindEdictGroups(), G_UseEdict(), and Touch_DoorTrigger().

#define FL_TRIGGERED   0x00000100

Trigger the edict at spawn.

Definition at line 623 of file g_local.h.

Referenced by SP_func_door().

#define FLOOR (  )     (CONTAINER(e, gi.csi->idFloor))

Definition at line 77 of file g_local.h.

#define G_FreeTags ( tag   )     gi.FreeTags((tag), __FILE__, __LINE__)

Definition at line 87 of file g_local.h.

Referenced by G_FreeAllInventory(), G_Shutdown(), and G_SpawnEntities().

#define G_IsActor ( ent   )     ((ent)->type == ET_ACTOR || (ent)->type == ET_ACTOR2x2)
#define G_IsAI ( ent   )     (G_PLAYER_FROM_ENT((ent))->pers.ai)
#define G_IsAIPlayer ( player   )     ((player)->pers.ai)
#define G_IsAlien ( ent   )     ((ent)->team == TEAM_ALIEN)
#define G_IsBlockingMovementActor ( ent   )     (((ent)->type == ET_ACTOR && !G_IsDead(ent)) || ent->type == ET_ACTOR2x2)

Definition at line 194 of file g_local.h.

Referenced by G_ActorFall(), G_ActorShouldStopInMidMove(), and G_BuildForbiddenList().

#define G_IsBreakable ( ent   )     ((ent)->flags & FL_DESTROYABLE)
#define G_IsBrushModel ( ent   )     ((ent)->type == ET_BREAKABLE || (ent)->type == ET_DOOR)

Definition at line 184 of file g_local.h.

Referenced by G_Damage(), and G_SplashDamage().

#define G_IsCivilian ( ent   )     ((ent)->team == TEAM_CIVILIAN)
#define G_IsCrouched ( ent   )     G_IsState(ent, STATE_CROUCHED)
#define G_IsDazed ( ent   )     G_IsState(ent, STATE_DAZED)

Definition at line 178 of file g_local.h.

Referenced by G_ActorGiveTimeUnits(), G_ClientMove(), and G_ReactionFireIsPossible().

#define G_IsDead ( ent   )     G_IsState(ent, STATE_DEAD)
#define G_IsInsane ( ent   )     G_IsState(ent, STATE_INSANE)
#define G_IsPaniced ( ent   )     G_IsState(ent, STATE_PANIC)
#define G_IsRaged ( ent   )     G_IsState(ent, STATE_RAGE)

Definition at line 176 of file g_local.h.

Referenced by AI_FighterCalcBestAction(), G_MoraleBehaviour(), and G_ReactionFireShoot().

#define G_IsReaction ( ent   )     G_IsState(ent, STATE_REACTION)

Definition at line 175 of file g_local.h.

Referenced by AI_SearchBestTarget(), AIL_reactionfire(), and G_ClientStateChange().

#define G_IsShaken ( ent   )     G_IsState(ent, STATE_SHAKEN)

Definition at line 172 of file g_local.h.

Referenced by G_ClientStateChange(), G_ReactionFireIsPossible(), and G_ReactionFireShoot().

#define G_IsState ( ent,
 )     ((ent)->state & (s))

Definition at line 171 of file g_local.h.

#define G_IsStunned ( ent   )     (G_IsState(ent, STATE_STUN) & ~STATE_DEAD)
#define G_IsVisibleForTeam ( ent,
team   )     ((ent)->visflags & G_TeamToVisMask(team))
#define G_IsVisibleOnBattlefield ( ent   )     (G_IsActor((ent)) || (ent)->type == ET_ITEM || (ent)->type == ET_PARTICLE)
Note:
Every none solid (none-bmodel) edict that is visible for the client

Definition at line 186 of file g_local.h.

Referenced by G_AppearPerishEvent(), and G_Vis().

#define G_MemFree ( ptr   )     gi.TagFree((ptr), __FILE__, __LINE__)

Definition at line 89 of file g_local.h.

Referenced by G_FreeInventory().

#define G_PLAYER_FROM_ENT ( ent   )     (game.players + (ent)->pnum)
#define G_PlayerToPM ( player   )     ((player)->num < game.sv_maxplayersperteam ? 1 << ((player)->num) : 0)
#define G_RemoveCrouched ( ent   )     G_RemoveState((ent), STATE_CROUCHED)

Definition at line 217 of file g_local.h.

Referenced by G_MoralePanic().

#define G_RemoveDazed ( ent   )     G_RemoveState((ent), STATE_DAZED)

Definition at line 211 of file g_local.h.

Referenced by G_ActorGiveTimeUnits().

#define G_RemoveDead ( ent   )     G_RemoveState((ent), STATE_DEAD)

Definition at line 213 of file g_local.h.

#define G_RemoveInsane ( ent   )     G_RemoveState((ent), STATE_INSANE)

Definition at line 214 of file g_local.h.

Referenced by G_MoraleStopRage().

#define G_RemovePanic ( ent   )     G_RemoveState((ent), STATE_PANIC)

Definition at line 216 of file g_local.h.

Referenced by G_MoraleStopPanic().

#define G_RemoveRage ( ent   )     G_RemoveState((ent), STATE_RAGE)

Definition at line 215 of file g_local.h.

#define G_RemoveReaction ( ent   )     G_RemoveState((ent), STATE_REACTION)

Definition at line 218 of file g_local.h.

Referenced by G_ClientStateChange(), and G_Damage().

#define G_RemoveShaken ( ent   )     G_RemoveState((ent), STATE_SHAKEN)

Definition at line 210 of file g_local.h.

Referenced by G_ReactionFireReset(), and G_ReactionFireTryToShoot().

#define G_RemoveState ( ent,
 )     (ent)->state &= ~(s)

Definition at line 209 of file g_local.h.

#define G_RemoveStunned ( ent   )     G_RemoveState((ent), STATE_STUN)

Definition at line 212 of file g_local.h.

Referenced by G_ActorDie(), and G_ActorRevitalise().

#define G_SetCrouched ( ent   )     G_SetState((ent), STATE_CROUCHED)

Definition at line 207 of file g_local.h.

#define G_SetDazed ( ent   )     G_SetState((ent), STATE_DAZED)

Definition at line 201 of file g_local.h.

Referenced by G_Damage().

#define G_SetDead ( ent   )     G_SetState((ent), STATE_DEAD)

Definition at line 203 of file g_local.h.

Referenced by Touch_HurtTrigger().

#define G_SetInsane ( ent   )     G_SetState((ent), STATE_INSANE)

Definition at line 204 of file g_local.h.

Referenced by G_MoraleRage().

#define G_SetPanic ( ent   )     G_SetState((ent), STATE_PANIC)

Definition at line 206 of file g_local.h.

Referenced by G_MoralePanic().

#define G_SetRage ( ent   )     G_SetState((ent), STATE_RAGE)

Definition at line 205 of file g_local.h.

Referenced by G_MoraleRage().

#define G_SetShaken ( ent   )     G_SetState((ent), STATE_SHAKEN)

Definition at line 200 of file g_local.h.

Referenced by G_MoraleBehaviour().

#define G_SetState ( ent,
 )     (ent)->state |= (s)

Definition at line 199 of file g_local.h.

Referenced by G_ActorDie(), G_ClientStateChange(), and G_MoraleBehaviour().

#define G_SetStunned ( ent   )     G_SetState((ent), STATE_STUN)

Definition at line 202 of file g_local.h.

Referenced by Touch_HurtTrigger().

#define G_TagMalloc ( size,
tag   )     gi.TagMalloc((size), (tag), __FILE__, __LINE__)
#define G_TeamToVisMask ( team   )     (1 << (team))
#define G_ToggleCrouched ( ent   )     G_ToggleState(ent, STATE_CROUCHED)

Definition at line 197 of file g_local.h.

Referenced by G_ClientStateChange().

#define G_ToggleState ( ent,
 )     (ent)->state ^= (s)

Definition at line 196 of file g_local.h.

#define GAME_INCLUDE
Note:
define GAME_INCLUDE so that game.h does not define the short, server-visible player_t and edict_t structures, because we define the full size ones in this file

Definition at line 44 of file g_local.h.

#define GAMEVERSION   "baseufo"

the "gameversion" client command will print this plus compile date

Definition at line 48 of file g_local.h.

Referenced by G_Init().

#define HEADGEAR (  )     (CONTAINER(e, gi.csi->idHeadgear))

Definition at line 76 of file g_local.h.

#define INVDEF ( containerID   )     (&gi.csi->ids[(containerID)])

Definition at line 79 of file g_local.h.

#define LEFT (  )     (CONTAINER(e, gi.csi->idLeft))

Definition at line 74 of file g_local.h.

#define MAX_DVTAB   32

Definition at line 417 of file g_local.h.

Referenced by G_ClientMove().

#define MAX_SPOT_DIST   4096

Definition at line 50 of file g_local.h.

Referenced by AI_CheckCrouch(), AI_CheckUsingDoor(), G_ReactionFireIsPossible(), and G_Vis().

#define MORALE_RANDOM ( mod   )     ( (mod) * (1.0 + 0.3*crand()) )

Definition at line 415 of file g_local.h.

Referenced by G_Morale(), and G_MoraleBehaviour().

#define ngettext ( x,
y,
cnt   )     x
#define PM_ALL   0xFFFFFFFF
 
#define random (  )     ((rand() & 0x7fff) / ((float)0x7fff))

Definition at line 168 of file g_local.h.

Referenced by Com_GetActorSound(), SP_alien_start(), and SV_GetTileFromTileSet().

#define RIGHT (  )     (CONTAINER(e, gi.csi->idRight))

Definition at line 73 of file g_local.h.

#define SERVER_FRAME_SECONDS   0.1

server is running at 10 fps

Definition at line 64 of file g_local.h.

Referenced by G_PhysicsStep(), G_PhysicsThink(), and G_RunFrame().

#define TAG_GAME   765

memory tags to allow dynamic memory to be cleaned up

Definition at line 67 of file g_local.h.

Referenced by G_EdictsInit(), G_Init(), and G_Shutdown().

#define TAG_LEVEL   766

Definition at line 68 of file g_local.h.

Referenced by ED_NewString(), G_BuildForbiddenListForEntity(), G_Shutdown(), and G_SpawnEntities().

#define TEAM_ALL   0xFFFFFFFF

Bitmask for all teams

Definition at line 59 of file g_local.h.

Referenced by AIL_Init(), AIL_positionhide(), AIL_see(), and G_BuildForbiddenList().

#define VIS_APPEAR   1

Definition at line 398 of file g_local.h.

Referenced by G_ActorShouldStopInMidMove(), and G_DoTestVis().

#define VIS_CHANGE   1

the visibile changed - if it was visible - it's (the edict) now invisible

Definition at line 402 of file g_local.h.

Referenced by G_DoTestVis().

#define VIS_PERISH   2

Definition at line 399 of file g_local.h.

Referenced by G_DoTestVis().

#define VIS_STOP   4

stop the current action if actor appears

Definition at line 406 of file g_local.h.

Referenced by G_ActorDoTurn(), G_ActorShouldStopInMidMove(), G_ClientMove(), and G_DoTestVis().

#define VIS_YES   2

actor visible?

Definition at line 404 of file g_local.h.

Referenced by AI_FighterCalcBestAction(), AI_FindHidingLocation(), G_DoTestVis(), and G_TestVis().

#define VT_NOFRUSTUM   2

don't perform a frustum vis check via G_FrustumVis in G_Vis

Definition at line 413 of file g_local.h.

Referenced by AI_FighterCalcBestAction(), AI_FindHidingLocation(), AI_HideNeeded(), AIL_see(), and G_Vis().

#define VT_PERISH   1

check whether edict is still visible - it maybe is currently visible but this might have changed due to some action

Definition at line 411 of file g_local.h.

Referenced by AI_FighterCalcBestAction(), AI_FindHidingLocation(), G_DoTestVis(), and G_TestVis().


Typedef Documentation

typedef struct AI_s AI_t

Artificial intelligence of a character.


Enumeration Type Documentation

e.g. used for breakable objects

Enumerator:
MAT_GLASS 
MAT_METAL 
MAT_ELECTRICAL 
MAT_WOOD 
MAT_MAX 

Definition at line 553 of file g_local.h.


Function Documentation

void AI_ActorThink ( player_t player,
edict_t ent 
)
qboolean AI_CheckUsingDoor ( const edict_t ent,
const edict_t door 
)

Checks whether the AI controlled actor wants to use a door.

Parameters:
[in] ent The AI controlled actor
[in] door The door edict
Returns:
true if the AI wants to use (open/close) that door, false otherwise
Note:
Don't start any new events in here, don't change the actor state
See also:
Touch_DoorTrigger
Todo:
Finish implementation

Definition at line 99 of file g_ai.c.

References ACTOR_VIS_0, check, edict_s::doorState, frand(), G_ActorVis(), G_EdictsGetNextLivingActor(), G_FrustumVis(), gi, edict_s::hiding, MAX_SPOT_DIST, edict_s::origin, qfalse, qtrue, STATE_OPENED, edict_s::team, TEAM_ALIEN, TEAM_CIVILIAN, edict_s::type, and VectorDist.

Referenced by Touch_DoorTrigger().

player_t* AI_CreatePlayer ( int  team  ) 

Spawn civilians and aliens.

Parameters:
[in] team 
See also:
G_SpawnAIPlayer
Returns:
player_t pointer
Note:
see cvars ai_numaliens, ai_numcivilians, ai_numactors

Definition at line 1209 of file g_ai.c.

References client_persistant_t::ai, ai_numactors, ai_numaliens, ai_numcivilians, G_SetTeamForPlayer(), G_SpawnAIPlayer(), game, gi, i, cvar_s::integer, player_s::inuse, player_s::num, player_s::pers, game_locals_t::players, qtrue, sv_ai, sv_maxclients, game_locals_t::sv_maxplayersperteam, client_persistant_t::team, and TEAM_CIVILIAN.

Referenced by G_SpawnEntities(), and SVCmd_AI_Add_f().

void AI_Run ( void   ) 
qboolean G_ActionCheckForCurrentTeam ( const player_t player,
edict_t ent,
int  TU 
)

Checks whether the requested action is possible for the current active team.

Parameters:
[in] player Which player (human player) is trying to do the action
[in] ent Which of his units is trying to do the action.
[in] TU The time units to check against the ones ent has. the action with

Definition at line 352 of file g_client.c.

References _, level_locals_t::activeTeam, G_ActionCheck(), G_ClientPrintf(), level, player_s::pers, PRINT_HUD, qfalse, qtrue, and client_persistant_t::team.

Referenced by G_ActorInvMove(), G_ClientMove(), G_ClientShoot(), G_ClientStateChange(), G_ClientTurn(), and G_ClientUseEdict().

qboolean G_ActionCheckWithoutTeam ( const player_t player,
edict_t ent,
int  TU 
)

Checks whether the requested action is possible.

Parameters:
[in] player Which player (human player) is trying to do the action
[in] ent Which of his units is trying to do the action.
[in] TU The time units to check against the ones ent has. the action with
See also:
G_ActionCheck

Definition at line 375 of file g_client.c.

References G_ActionCheck().

Referenced by G_ClientShoot().

void G_ActorCheckRevitalise ( edict_t ent  ) 
void G_ActorDieOrStun ( edict_t ent,
edict_t attacker 
)

Reports and handles death or stun of an actor. If the HP of an actor is zero the actor will die, otherwise the actor will get stunned.

Parameters:
[in] ent Pointer to an entity being killed or stunned actor.
[in] attacker Pointer to attacker - it must be notified about state of victim.
Todo:
Discuss whether stunned actor should really drop everything to floor. Maybe it should drop only what he has in hands? Stunned actor can wake later during mission.

Definition at line 353 of file g_actor.c.

References FLOOR, G_ActorDie(), G_ActorStun(), G_CheckVis(), G_CheckVisTeamAll(), G_EventActorDie(), G_InventoryToFloor(), edict_s::HP, level, level_locals_t::num_alive, qfalse, qtrue, and edict_s::team.

Referenced by G_ClientMove(), G_Damage(), G_MatchSendResults(), and G_ThinkActorDieAfterSpawn().

int G_ActorDoTurn ( edict_t ent,
byte  dir 
)

Turns an actor around.

Parameters:
[in] ent the actor (edict) we are talking about
[in] dir the direction to turn the edict into, might be an action
Returns:
Bitmask of visible (VIS_*) values
See also:
G_CheckVisTeamAll

Todo:
If performing an action, ensure the actor is facing the direction needed to perform the action if needed (climbing ladders).

Definition at line 191 of file g_actor.c.

References byte, CORE_DIRECTIONS, edict_s::dir, directionAngles, dvleft, dvright, FLYING_DIRECTIONS, G_CheckVisTeamAll(), G_EventActorTurn(), i, PATHFINDING_DIRECTIONS, qfalse, edict_s::team, and VIS_STOP.

Referenced by AI_TurnIntoDirection(), G_ClientMove(), and G_ClientTurn().

void G_ActorFall ( edict_t ent  ) 

Let an actor fall down if e.g. the func_breakable the actor was standing on was destroyed.

Parameters:
[in,out] ent The actor that should fall down
Todo:
Handle cases where the grid position the actor would fall to is occupied by another actor already.

Definition at line 137 of file g_move.c.

References ET_NULL, FALLING_DAMAGE_FACTOR, edict_s::fieldSize, G_CheckVis(), G_EdictCalcOrigin(), G_EventActorFall(), G_GetEdictFromPos(), G_IsBlockingMovementActor, G_IsBreakable, G_TakeDamage(), gi, edict_s::pos, qtrue, and game_import_t::routingMap.

Referenced by Touch_Breakable().

edict_t* G_ActorGetByUCN ( const int  ucn,
const int  team 
)

Searches an actor by a unique character number.

Parameters:
[in] ucn The unique character number
[in] team The team to get the actor with the ucn from
Returns:
The actor edict if found, otherwise NULL

Definition at line 173 of file g_actor.c.

References edict_s::chr, G_EdictsGetNextActor(), edict_s::team, and character_s::ucn.

Referenced by G_ClientInitActorStates().

int G_ActorGetReservedTUs ( const edict_t ent  ) 

Calculates the amount of all currently reserved TUs.

Parameters:
ent The actor to calculate the reserved TUs for
Returns:
The amount of reserved TUs for the given actor edict

Definition at line 108 of file g_actor.c.

References edict_s::chr, chrReservations_s::crouch, chrReservations_s::reaction, character_s::reservedTus, and chrReservations_s::shot.

Referenced by G_ActorInvMove(), and G_ActorUsableTUs().

int G_ActorGetTUForReactionFire ( const edict_t ent  ) 

Calculates the amount of TUs that are needed for the current selected reaction fire mode.

Note:
It's assumed that there is a sane fire mode selected for reaction fire
Parameters:
[in] ent The actors edict
Returns:
The amount of TUs that are needed for the current selected reaction fire mode.

Definition at line 134 of file g_actor.c.

References ACTOR_GET_INV, edict_s::chr, FIRESH_FiredefForWeapon(), chrFiremodeSettings_s::fmIdx, chrFiremodeSettings_s::hand, invList_s::item, character_s::RFmode, item_s::t, and fireDef_s::time.

Referenced by G_ActorHasEnoughTUsReactionFire(), and G_ClientStateChange().

void G_ActorGiveTimeUnits ( edict_t ent  ) 

Set time units for the given edict. Based on speed skills.

Parameters:
ent The actor edict

Definition at line 283 of file g_actor.c.

References ABILITY_SPEED, edict_s::chr, G_ActorSetTU(), G_IsDazed, G_RemoveDazed, GET_TU, character_s::score, and chrScoreGlobal_s::skills.

Referenced by AI_SetStats(), and G_GiveTimeUnits().

void G_ActorInvMove ( edict_t ent,
const invDef_t from,
invList_t fItem,
const invDef_t to,
int  tx,
int  ty,
qboolean  checkaction 
)

Moves an item inside an inventory. Floors are handled special.

Parameters:
[in] ent The pointer to the selected/used edict/soldier.
[in] from The container (-id) the item should be moved from.
[in] fItem The item you want to move.
[in] to The container (-id) the item should be moved to.
[in] tx x position where you want the item to go in the destination container
[in] ty y position where you want the item to go in the destination container
[in] checkaction Set this to qtrue if you want to check for TUs, otherwise qfalse.
See also:
event PA_INVMOVE
AI_ActorThink

Todo:
what if we don't have enough TUs after subtracting the reserved ones?

Definition at line 393 of file g_actor.c.

References _, edict_s::chr, FLOOR, chrFiremodeSettings_s::fmIdx, G_ActionCheckForCurrentTeam(), G_ActorGetReservedTUs(), G_ActorSetTU(), G_ActorUseTU(), G_CheckVis(), G_ClientPrintf(), G_EventInventoryAdd(), G_EventInventoryDelete(), G_EventInventoryReload(), G_EventPerish(), G_FreeEdict(), G_GetFloorItems(), G_PLAYER_FROM_ENT, G_ReactionFireUpdate(), G_SendStats(), G_SpawnFloor(), G_TeamToPM(), G_VisToPM(), G_WriteItem(), game, gi, chrFiremodeSettings_s::hand, game_locals_t::i, character_s::i, IA_NONE, IA_NORELOAD, IA_NOTIME, IA_RELOAD, IA_RELOAD_SWAP, INV_IsFloorDef(), INV_IsLeftDef(), INV_IsRightDef(), INVSH_FindSpace(), INVSH_GetFirstShapePosition(), INVSH_SearchInInventory(), invList_s::item, inventoryInterface_s::MoveInInventory, NONE, edict_s::pos, PRINT_HUD, qfalse, qtrue, character_s::RFmode, item_s::t, edict_s::team, edict_s::TU, edict_s::visflags, chrFiremodeSettings_s::weapon, invList_s::x, and invList_s::y.

Referenced by AI_TryToReloadWeapon(), G_ActorReload(), G_ClientAction(), G_ClientGetWeaponFromInventory(), G_MissionTouch(), and G_MoralePanic().

qboolean G_ActorIsInRescueZone ( const edict_t actor  ) 

Checks whether the given actor is currently standing in a rescue zone.

Parameters:
[in] actor The actor to check
Returns:
true if the actor is standing in a rescue zone, false otherwise.

Definition at line 62 of file g_actor.c.

References edict_s::inRescueZone.

Referenced by G_ActorSetInRescueZone(), and G_MatchSendResults().

void G_ActorReload ( edict_t ent,
const invDef_t invDef 
)

Reload weapon with actor.

Parameters:
[in] ent Pointer to an actor reloading weapon.
[in] invDef Reloading weapon in right or left hand.
See also:
AI_ActorThink

Definition at line 567 of file g_actor.c.

References CONTAINER, game_import_t::csi, G_ActorInvMove(), gi, invDef_s::id, csi_s::idRight, INV_IsLeftDef(), INVDEF, INVSH_LoadableInWeapon(), invList_s::item, invList_s::next, csi_s::numIDs, invDef_s::out, qtrue, RIGHT, and item_s::t.

Referenced by AI_TryToReloadWeapon(), and AIL_reload().

void G_ActorReserveTUs ( edict_t ent,
int  resReaction,
int  resShot,
int  resCrouch 
)

Reserves TUs for different actor actions.

Parameters:
[in,out] ent The actor to reserve TUs for. Might not be NULL.
[in] resReaction TUs for reaction fire
[in] resShot TUs for shooting
[in] resCrouch TUs for going into crouch mode

Definition at line 156 of file g_actor.c.

References edict_s::chr, chrReservations_s::crouch, G_EventActorSendReservations(), chrReservations_s::reaction, character_s::reservedTus, chrReservations_s::shot, and edict_s::TU.

Referenced by G_ClientAction(), G_ClientStateChange(), and G_Damage().

void G_ActorSetClientAction ( edict_t actor,
edict_t ent 
)

Handles the client actions (interaction with the world).

Parameters:
actor The actors' edict
ent The edict that can be used by the actor

Definition at line 90 of file g_actor.c.

References edict_s::clientAction, G_EventResetClientAction(), and G_EventSetClientAction().

Referenced by Reset_DoorTrigger(), and Touch_DoorTrigger().

void G_ActorSetInRescueZone ( edict_t actor,
qboolean  inRescueZone 
)

Set the rescue zone data.

Parameters:
[out] actor The actor to set the rescue zone flag for
[in] inRescueZone true if the actor is in the rescue zone, false otherwise

Definition at line 72 of file g_actor.c.

References _, G_ActorIsInRescueZone(), G_ClientPrintf(), G_PLAYER_FROM_ENT, edict_s::inRescueZone, and PRINT_HUD.

Referenced by Reset_RescueTrigger(), and Touch_RescueTrigger().

void G_ActorSetMaxs ( edict_t ent  ) 

Sets correct bounding box for actor (state dependent).

Parameters:
[in] ent Pointer to entity for which bounding box is being set.
Note:
Also re-links the actor edict - because the server must know about the changed bounding box for tracing to work.

Definition at line 266 of file g_actor.c.

References G_IsCrouched, G_IsDead, gi, edict_s::maxs, PLAYER_CROUCH, PLAYER_DEAD, PLAYER_STAND, PLAYER_WIDTH, and VectorSet.

Referenced by G_ActorDie(), G_ActorRevitalise(), G_ClientStateChange(), G_MoraleBehaviour(), and G_MoralePanic().

void G_ActorSetTU ( edict_t ent,
int  tus 
)
int G_ActorUsableTUs ( const edict_t ent  ) 

Calculates the amount of usable TUs. This is without the reserved TUs.

Parameters:
[in] ent The actor to calculate the amount of usable TUs for. If ent is NULL, we return zero here
Returns:
The amount of usable TUs for the given actor edict

Definition at line 120 of file g_actor.c.

References G_ActorGetReservedTUs(), and edict_s::TU.

Referenced by G_ActionCheck().

void G_ActorUseDoor ( edict_t actor,
edict_t door 
)

Make the actor use (as in open/close) a door edict.

Note:
Will also check whether the door is still reachable (this might have changed due to the rotation) after the usage
Parameters:
actor The actor that is using the door
door The door that should be opened/closed

Definition at line 44 of file g_actor.c.

References ET_ACTOR, G_ClientUseEdict(), G_FindRadius(), G_PLAYER_FROM_ENT, G_TouchTriggers(), edict_s::origin, and UNIT_SIZE.

Referenced by G_ClientAction(), and Touch_DoorTrigger().

void G_ActorUseTU ( edict_t ent,
int  tus 
)

Definition at line 295 of file g_actor.c.

References G_ActorSetTU(), and edict_s::TU.

Referenced by G_ActorInvMove(), G_ClientStateChange(), G_ClientTurn(), and G_ClientUseEdict().

float G_ActorVis ( const vec3_t  from,
const edict_t check,
qboolean  full 
)

calculate how much check is "visible" from from

Parameters:
[in] from The world coordinate to check from
[in] check The edict to check how good (or if at all) it is visible
[in] full Perform a full check in different directions. If this is false the actor is fully visible if one vis check returned true. With true this function can also return a value != 0.0 and != 1.0. Try to only use true if you really need the full check. Full checks are of course more expensive.
Returns:
a value between 0.0 and 1.0 which reflects the visibility from 0 to 100 percent
Note:
This call isn't cheap - try to do this only if you really need the visibility check or the statement whether one particular actor see another particular actor.
See also:
CL_ActorVis

Definition at line 63 of file g_vis.c.

References ACTOR_VIS_0, ACTOR_VIS_10, ACTOR_VIS_100, ACTOR_VIS_50, G_IsCrouched, G_IsDead, G_LineVis(), i, edict_s::origin, PLAYER_CROUCH, PLAYER_DEAD, PLAYER_MIN, PLAYER_STAND, VectorCopy, VectorMA(), and VectorNormalize().

Referenced by AI_CheckCrouch(), AI_CheckUsingDoor(), AI_CivilianCalcBestAction(), AI_SearchBestTarget(), AI_SearchDestroyableObject(), AIL_positionshoot(), G_Morale(), G_ReactionFireIsPossible(), G_SplashDamage(), and G_Vis().

qboolean G_AddItemToFloor ( const pos3_t  pos,
const char *  itemID 
)

Adds a new item to an existing or new floor container edict at the given grid location.

Parameters:
pos The grid location to spawn the item on the floor
itemID The item to spawn

Definition at line 125 of file g_inventory.c.

References edict_s::chr, game_import_t::csi, G_GetFloorItemsFromPos(), G_SpawnFloor(), game, gi, character_s::i, game_locals_t::i, csi_s::idFloor, INVDEF, INVSH_GetItemByIDSilent(), NONE_AMMO, qfalse, item_s::t, and inventoryInterface_s::TryAddToInventory.

Referenced by SP_misc_item().

void G_AddToWayPointList ( edict_t ent  ) 

Definition at line 904 of file g_ai.c.

References edict_s::groupChain, and i.

Referenced by SP_civilian_target().

void G_AppearPerishEvent ( unsigned int  playerMask,
qboolean  appear,
edict_t check,
const edict_t ent 
)

Send the appear or perish event to the affected clients.

Parameters:
[in] playerMask These are the affected players or clients In case of e.g. teamplay there can be more than one client affected - thus this is a player mask
[in] appear Is this event about an appearing actor (or a perishing one)
[in] check The edict we are talking about (that appears or perishes)
[in] ent The edict that was responsible for letting the check edict appear or perish. Might be NULL.
See also:
CL_ActorAppear

Definition at line 159 of file g_client.c.

References ABILITY_MIND, ABILITY_SPEED, edict_s::body, edict_s::chr, edict_s::dir, ET_ACTOR, ET_ACTOR2x2, ET_ITEM, ET_PARTICLE, EV_ACTOR_APPEAR, EV_ACTOR_STATECHANGE, EV_ENT_PERISH, edict_s::fieldSize, G_EdictAppear(), G_IsVisibleOnBattlefield, G_SendInventory(), G_SendParticle(), G_TeamToPM(), character_s::gender, GET_MORALE, GET_TU, gi, edict_s::head, teamDef_s::idx, LEFT, MAX_SKILL, character_s::maxHP, NONE, edict_s::number, edict_s::pnum, edict_s::pos, RIGHT, character_s::score, chrScoreGlobal_s::skills, character_s::skin, SKIP_LOCAL_ENTITY, edict_s::state, STATE_PUBLIC, edict_s::team, character_s::teamDef, edict_s::type, and edict_s::visflags.

Referenced by G_DoTestVis(), G_MatchSendResults(), G_MissionThink(), and G_SplashDamage().

void G_CenterView ( const edict_t ent  ) 

Centers the view for all clients that are seeing the given edict on the world position of the edict.

Parameters:
ent The edict to use the position from

Definition at line 239 of file g_client.c.

References EV_CENTERVIEW, G_VisToPM(), gi, edict_s::pos, and edict_s::visflags.

Referenced by G_MoralePanic().

void G_CheckForceEndRound ( void   ) 
int G_CheckVis ( edict_t check,
qboolean  perish 
)

Check if the edict appears/perishes for the other teams. If they appear for other teams, the needed information for those clients are also send in G_CheckVisTeam resp. G_AppearPerishEvent.

Parameters:
[in] perish Also check for perishing events
[in] check The edict that is maybe seen by others. If NULL, all edicts are checked
Returns:
Bitmask of VIS_* values
See also:
G_CheckVisTeam

Definition at line 334 of file g_vis.c.

References G_CheckVisTeam(), G_CheckVisTeamAll(), level, MAX_TEAMS, and level_locals_t::num_alive.

Referenced by Door_Use(), G_ActorDieOrStun(), G_ActorFall(), G_ActorInvMove(), G_ActorRevitalise(), G_ClientMove(), G_ClientStateChangeUpdate(), G_Damage(), G_InventoryToFloor(), G_SpawnAIPlayer(), G_SpawnItemOnFloor(), and G_SpawnParticle().

int G_CheckVisPlayer ( player_t player,
qboolean  perish 
)

Sets visible edict on player spawn.

See also:
G_ClientSpawn
G_CheckVisTeam
G_AppearPerishEvent

Definition at line 261 of file g_vis.c.

References G_DoTestVis(), G_EdictsGetNextInUse(), G_PlayerToPM, player_s::pers, and client_persistant_t::team.

Referenced by G_ClientSpawn().

int G_CheckVisTeam ( const int  team,
edict_t check,
qboolean  perish,
const edict_t ent 
)

Checks whether an edict appear/perishes for a specific team - also updates the visflags each edict carries.

See also:
G_TestVis
Parameters:
[in] team Team to check the vis for
[in] check The edict that you want to check (and which maybe will appear or perish for the given team). If this is NULL every edict will be checked.
[in] perish Also check whether the edict (the actor) is going to become invisible for the given team
[in] ent The edict that is (maybe) seeing other edicts
Returns:
If an actor get visible who's no civilian VIS_STOP is added to the bit mask, VIS_YES means, he is visible, VIS_CHANGE means that the actor flipped its visibility (invisible to visible or vice versa), VIS_PERISH means that the actor (the edict) is getting invisible for the queried team
Note:
the edict may not only be actors, but also items of course
See also:
G_TeamToPM
G_TestVis
G_AppearPerishEvent
G_CheckVisPlayer
G_CheckVisTeamAll
Note:
If something appears, the needed information for those clients that are affected are also send in G_AppearPerishEvent

Definition at line 298 of file g_vis.c.

References G_DoTestVis(), G_TeamToPM(), and edict_s::inuse.

Referenced by Destroy_Breakable(), G_CheckVis(), and G_CheckVisTeamAll().

int G_CheckVisTeamAll ( const int  team,
qboolean  perish,
const edict_t ent 
)
void G_ClearVisFlags ( int  team  ) 

Reset the visflags for all edicts in the global list for the given team - and only for the given team.

Definition at line 355 of file g_vis.c.

References G_EdictsGetNextInUse(), G_TeamToVisMask, and edict_s::visflags.

Referenced by G_ClientSpawn(), and G_SpawnAIPlayer().

int G_ClientAction ( player_t player  ) 

The client sent us a message that he did something. We now execute the related fucntion(s) adn notify him if neccessary.

Parameters:
[in] player The player to execute the action for (the actor belongs to this player)
Note:
a client action will also send the server side edict number to determine the actor

Definition at line 610 of file g_client.c.

References byte, edict_s::chr, edict_s::clientAction, game_import_t::csi, FL_GROUPSLAVE, edict_s::flags, format, G_ActorInvMove(), G_ActorReserveTUs(), G_ActorUseDoor(), G_ClientMove(), G_ClientShoot(), G_ClientStateChange(), G_ClientTurn(), G_EdictsGetByNum(), G_ReactionFireUpdate(), gi, edict_s::groupMaster, character_s::i, i, INVDEF, INVSH_GetItemByIDX(), INVSH_SearchInInventory(), edict_s::number, csi_s::numIDs, pa_format, PA_INVMOVE, PA_MOVE, PA_NULL, PA_REACT_SELECT, PA_RESERVE_STATE, PA_SHOOT, PA_STATE, PA_TURN, PA_USE_DOOR, player_s::pers, pos, qtrue, chrReservations_s::reaction, character_s::reservedTus, client_persistant_t::team, and edict_s::type.

Referenced by GetGameAPI().

qboolean G_ClientBegin ( player_t player  ) 
qboolean G_ClientCanReload ( edict_t ent,
containerIndex_t  containerID 
)

Returns true if actor can reload weapon.

See also:
AI_ActorThink

Definition at line 502 of file g_client.c.

References CONTAINER, game_import_t::csi, gi, csi_s::idLeft, csi_s::idRight, INVSH_LoadableInWeapon(), invList_s::item, invList_s::next, csi_s::numIDs, qfalse, qtrue, RIGHT, and item_s::t.

Referenced by AI_TryToReloadWeapon(), and AIL_canreload().

void G_ClientCommand ( player_t player  ) 

Definition at line 391 of file g_cmds.c.

References game_import_t::Cmd_Argv(), G_Players_f(), G_Say_f(), gi, player_s::inuse, Q_strcasecmp, qfalse, and qtrue.

Referenced by GetGameAPI().

qboolean G_ClientConnect ( player_t player,
char *  userinfo,
size_t  userinfoSize 
)

Checks whether the connection is valid or invalid and set some user info keys.

Parameters:
[in,out] player The player that is trying to connect to the game
[in,out] userinfo The userinfo data that is checked and changed
[in] userinfoSize The size of the userinfo buffer
See also:
G_ClientDisconnect
CL_ConnectionlessPacket
Todo:
Check if the teamnum preference has already reached maxsoldiers and reject connection if so
Returns:
false if the connection is refused, true otherwise

Definition at line 1359 of file g_client.c.

References Com_Printf(), G_ClientDisconnect(), G_ClientUserinfoChanged(), G_PlayerToPM, gi, Info_SetValueForKey(), Info_ValueForKey(), player_s::inuse, client_persistant_t::netname, password, player_s::pers, PRINT_CONSOLE, qfalse, qtrue, REJ_BANNED, REJ_PASSWORD_REQUIRED_OR_INCORRECT, cvar_s::string, and SV_FilterPacket().

Referenced by GetGameAPI().

void G_ClientDisconnect ( player_t player  ) 
void G_ClientEndRound ( player_t player  ) 
edict_t* G_ClientGetFreeSpawnPointForActorSize ( const player_t player,
const actorSizeEnum_t  actorSize 
)

Searches a free spawning point for a given actor size.

Parameters:
[in] player The player to get the free spawn points for
[in] actorSize The actor size to get a spawning point for
Returns:
An actor edict or NULL if no free spawning point was found

Definition at line 974 of file g_client.c.

References ACTOR_SIZE_2x2, ACTOR_SIZE_NORMAL, edict_s::chr, ET_ACTOR, ET_ACTOR2x2, ET_ACTOR2x2SPAWN, ET_ACTORSPAWN, edict_s::fieldSize, character_s::fieldSize, FL_DESTROYABLE, edict_s::flags, G_ClientGetFreeSpawnPoint(), G_ThinkActorDieAfterSpawn(), G_ThinkActorGoCrouch(), G_TouchTriggers(), gi, edict_s::HP, level, edict_s::morale, edict_s::nextthink, player_s::num, level_locals_t::num_alive, level_locals_t::num_spawned, edict_s::pnum, edict_s::spawnflags, STATE_CROUCHED, STATE_DEAD, STATE_STUN, edict_s::team, edict_s::think, and edict_s::type.

Referenced by G_ClientTeamInfo(), and G_SpawnAIPlayer().

int G_ClientGetTeamNum ( const player_t player  ) 

Returns the assigned team number of the player.

Definition at line 831 of file g_client.c.

References player_s::pers, and client_persistant_t::team.

Referenced by GetGameAPI().

int G_ClientGetTeamNumPref ( const player_t player  ) 

Returns the preferred team number for the player.

Definition at line 840 of file g_client.c.

References Info_ValueForKey(), player_s::pers, and client_persistant_t::userinfo.

Referenced by G_GetTeam(), and GetGameAPI().

void G_ClientGetWeaponFromInventory ( edict_t ent  ) 

Retrieve or collect weapon from any linked container for the actor.

Note:
This function will also collect items from floor containers when the actor is standing on a given point.
See also:
AI_ActorThink

Definition at line 533 of file g_client.c.

References item_s::a, edict_s::chr, CONTAINER, game_import_t::csi, G_ActorInvMove(), gi, csi_s::idRight, INVDEF, invList_s::item, invList_s::next, csi_s::numIDs, invDef_s::out, qtrue, objDef_s::reload, item_s::t, character_s::teamDef, objDef_s::weapon, and teamDef_s::weapons.

Referenced by AI_ActorThink().

void G_ClientInitActorStates ( const player_t player  ) 

This is called after the actors are spawned and will set actor states without consuming TUs.

Parameters:
player The player to perform the action for

Definition at line 1133 of file g_client.c.

References G_ActorGetByUCN(), G_ActorSetTU(), G_ClientStateChange(), G_ClientStateChangeUpdate(), gi, i, player_s::pers, qfalse, client_persistant_t::team, and edict_s::TU.

Referenced by GetGameAPI().

qboolean G_ClientIsReady ( const player_t player  ) 
Returns:
true if the player is for starting the multiplayer match

Definition at line 849 of file g_client.c.

References player_s::isReady.

Referenced by GetGameAPI().

void G_ClientMove ( const player_t player,
int  visTeam,
edict_t ent,
const pos3_t  to 
)

Generates the client events that are send over the netchannel to move an actor.

Parameters:
[in] player Player who is moving an actor
[in] visTeam The team to check the visibility for - if this is 0 we build the forbidden list above all edicts - for the human controlled actors this would mean that clicking to a grid position that is not reachable because an invisible actor is standing there would not result in a single step - as the movement is aborted before. For AI movement this is in general 0 - but not if they e.g. hide.
[in] ent Edict to move
[in] to The grid position to walk to
See also:
CL_ActorStartMove
PA_MOVE

Todo:
Handle dazed via trigger_hurt

Definition at line 207 of file g_move.c.

References ACTOR_SPEED_CROUCHED, ACTOR_SPEED_NORMAL, player_s::autostand, byte, edict_s::chr, edict_s::clientAction, moveinfo_t::contentFlags, CORE_DIRECTIONS, moveinfo_t::currentStep, edict_s::dir, EV_ACTOR_MOVE, FLOOR, G_ActionCheckForCurrentTeam(), G_ActorDieOrStun(), G_ActorDoTurn(), G_ActorSetTU(), G_ActorShouldStopInMidMove(), g_actorspeed, G_CheckVis(), G_CheckVisTeamAll(), G_ClientStateChange(), G_EdictCalcOrigin(), G_EventActorTurn(), G_GetFloorItems(), G_IsCrouched, G_IsDazed, G_IsDead, G_MoveCalc(), g_notu, G_PhysicsStep(), G_PrintActorStats(), G_ReactionFireOnMovement(), G_SendStats(), G_TouchTriggers(), G_VisToPM(), getDVdir, gi, cvar_s::integer, lengthof, level, MAX_DVTAB, chrScoreMission_s::movedCrouched, chrScoreMission_s::movedNormal, edict_s::moveinfo, NewDVZ, edict_s::nextthink, edict_s::number, edict_s::origin, level_locals_t::pathingMap, PLAYER_MIN, edict_s::pos, pos, PosAddDV, PosSubDV, qfalse, qtrue, ROUTING_NOT_REACHABLE, ROUTING_UNREACHABLE, character_s::scoreMission, SHOULD_USE_AUTOSTAND, edict_s::speed, edict_s::state, STATE_CROUCHED, moveinfo_t::steps, edict_s::team, edict_s::think, level_locals_t::time, edict_s::TU, TU_CROUCH_MOVING_FACTOR, TU_MOVE_STRAIGHT, TU_TURN, cvar_s::value, VectorCompare, VectorCopy, VIS_STOP, moveinfo_t::visflags, edict_s::visflags, and game_import_t::WriteDummyByte().

Referenced by AI_ActorThink(), AI_PrepBestAction(), G_ClientAction(), and pos3L_goto().

void G_ClientPrintf ( const player_t player,
int  printlevel,
const char *  fmt,
  ... 
)
qboolean G_ClientShoot ( const player_t player,
edict_t ent,
const pos3_t  at,
shoot_types_t  shootType,
fireDefIndex_t  firemode,
shot_mock_t mock,
qboolean  allowReaction,
int  z_align 
)

Setup for shooting, either real or mock.

Parameters:
[in] player The player this action belongs to (i.e. either the ai or the player)
[in] ent the edict that is doing the shot
[in] at Position to fire on.
[in] shootType What type of shot this is (left, right reaction-left etc...).
[in] firemode The firemode index of the ammo for the used weapon.
[in] mock pseudo shooting - only for calculating mock values - NULL for real shots
[in] allowReaction Set to qtrue to check whether this has forced any reaction fire, otherwise qfalse.
Returns:
qtrue if everything went ok (i.e. the shot(s) where fired ok), otherwise qfalse.
Parameters:
[in] z_align This value may change the target z height - often GROUND_DELTA is used to calculate the alignment. This can be used for splash damage weapons. It's often useful to target the ground close to the victim. That way you don't need a 100 percent chance to hit your target. Even if you don't hit it, the splash damage might reduce the health of your target.

Todo:
check for direct shot / splash damage shot?

Reset status.

See also:
G_UpdateHitScore for the check.

Reset status.

See also:
G_UpdateHitScore for the check.

If loaded ammo is less than needed ammo from firedef then reduce shot-number relative to the difference.

Todo:
This really needs an overhaul.And it might get dumped completely when Feature Request "[1814158] Extended shot-definitions in firedef" https://sourceforge.net/tracker/?func=detail&atid=805245&aid=1814158&group_id=157793 gets implemented.

< State info so we can check if an item was already removed.

Definition at line 1064 of file g_combat.c.

References _, item_s::a, fireDef_s::ammo, AngleToDir(), edict_s::chr, CORE_DIRECTIONS, objDef_s::deplete, edict_s::dir, inventoryInterface_s::EmptyContainer, edict_s::fieldSize, chrScoreMission_s::fired, chrScoreMission_s::firedHit, chrScoreMission_s::firedSplash, chrScoreMission_s::firedSplashHit, chrScoreMission_s::firedSplashTUs, chrScoreMission_s::firedTUs, objDef_s::fireTwoHanded, G_ActionCheckForCurrentTeam(), G_ActionCheckWithoutTeam(), G_ActorSetTU(), G_CheckVisTeamAll(), G_ClientPrintf(), G_EdictPosIsSameAs(), G_EventActorTurn(), G_EventInventoryAmmo(), G_EventInventoryDelete(), G_EventShootHidden(), G_EventStartShoot(), G_GetShotOrigin(), G_IsAIPlayer, G_IsDead, G_IsVisibleForTeam, G_MatchEndCheck(), G_PrepareShot(), G_ReactionFirePostShot(), G_ReactionFirePreShot(), G_SendStats(), G_ShootGrenade(), G_ShootSingle(), G_TeamPointVis(), G_TeamToVisMask, G_VisToPM(), game, gi, fireDef_s::gravity, character_s::i, game_locals_t::i, edict_s::inuse, INVDEF, fireDef_s::irgoggles, IS_SHOT_REACTION, KILLED_NUM_TYPES, LEFT, item_s::m, MAX_TEAMS, objDef_s::oneshot, edict_s::origin, edict_s::pos, PRINT_HUD, qfalse, qtrue, fireDef_s::range, player_s::reactionLeftover, game_import_t::routingMap, character_s::scoreMission, fireDef_s::shots, invDef_s::single, fireDef_s::splrad, item_s::t, edict_s::team, objDef_s::thrown, fireDef_s::time, todeg, edict_s::TU, VectorDist, VectorMA(), VectorSubtract, edict_s::visflags, and fireDef_s::weaponSkill.

Referenced by actorL_shoot(), AI_ActorThink(), G_ClientAction(), and G_ReactionFireShoot().

void G_ClientSpawn ( player_t player  ) 
void G_ClientStateChange ( const player_t player,
edict_t ent,
int  reqState,
qboolean  checkaction 
)

Changes the state of a player/soldier.

Parameters:
[in,out] player The player who controlls the actor
[in] ent the edict to perform the state change for
[in] reqState The bit-map of the requested state change
[in] checkaction only activate the events - network stuff is handled in the calling function don't even use the G_ActionCheckForCurrentTeam function
Note:
Use checkaction true only for e.g. spawning values

Definition at line 442 of file g_client.c.

References _, edict_s::chr, chrReservations_s::crouch, G_ActionCheckForCurrentTeam(), G_ActorGetTUForReactionFire(), G_ActorReserveTUs(), G_ActorSetMaxs(), G_ActorUseTU(), G_ClientPrintf(), G_ClientStateChangeUpdate(), G_IsReaction, G_IsShaken, G_ReactionFireCanBeEnabled(), G_ReactionFireSetDefault(), G_RemoveReaction, G_SetState, G_ToggleCrouched, gi, PRINT_HUD, character_s::reservedTus, chrReservations_s::shot, STATE_CROUCHED, STATE_REACTION, STATE_REACTION_MANY, STATE_REACTION_ONCE, and TU_CROUCH.

Referenced by AI_ActorThink(), AI_InitPlayer(), AI_PrepBestAction(), AIL_crouch(), AIL_reactionfire(), G_ClientAction(), G_ClientInitActorStates(), G_ClientMove(), G_ReactionFireUpdate(), and G_ThinkActorGoCrouch().

void G_ClientTeamInfo ( const player_t player  ) 

The client lets the server spawn the actors for a given player by sending their information (models, inventory, etc..) over the network.

Parameters:
[in] player The player to spawn the actors for.
See also:
GAME_SendCurrentTeamSpawningInfo
clc_teaminfo

Definition at line 1159 of file g_client.c.

References Com_DPrintf(), Com_Printf(), DEBUG_GAME, edict_s::fieldSize, G_ActorSpawnIsAllowed(), G_ClientAssignDefaultActorValues(), G_ClientGetFreeSpawnPointForActorSize(), G_ClientReadCharacter(), G_ClientReadInventory(), G_ClientSkipActorInfo(), game, inventoryInterface_s::GetUsedSlots, gi, game_locals_t::i, i, client_persistant_t::netname, player_s::num, player_s::pers, edict_s::team, client_persistant_t::team, and TEAM_NO_ACTIVE.

Referenced by GetGameAPI().

qboolean G_ClientUseEdict ( const player_t player,
edict_t actor,
edict_t edict 
)

This function 'uses' the edict. E.g. it opens the door when the player wants it to open.

See also:
PA_USE_DOOR
Parameters:
[in] player The player is trying to activate the door
[in,out] actor The actor the player is using to activate the entity
[in,out] edict The entity that is to be used
Todo:
Do we have to change the trigger position here, too? I don't think this is really needed.
See also:
CL_ActorUseDoor
G_UseEdict

Definition at line 586 of file g_client.c.

References G_ActionCheckForCurrentTeam(), G_ActorUseTU(), G_SendStats(), G_UseEdict(), gi, qfalse, qtrue, and edict_s::TU.

Referenced by G_ActorUseDoor().

void G_ClientUserinfoChanged ( player_t player,
char *  userinfo 
)

called whenever the player updates a userinfo variable.

Note:
The game can override any of the settings in place (forcing skins or names, etc) before copying it off.

Definition at line 1307 of file g_client.c.

References player_s::autostand, Com_DPrintf(), CS_PLAYERNAMES, DEBUG_GAME, G_GetTeam(), G_MatchIsRunning(), gi, Info_Validate(), Info_ValueForKey(), player_s::isReady, client_persistant_t::netname, player_s::num, player_s::pers, Q_strncpyz(), player_s::reactionLeftover, client_persistant_t::team, TEAM_NO_ACTIVE, and client_persistant_t::userinfo.

Referenced by G_ClientConnect(), and GetGameAPI().

void G_CompleteRecalcRouting ( void   ) 
See also:
G_RecalcRouting

Definition at line 446 of file g_utils.c.

References G_EdictsGetNextInUse(), G_RecalcRouting(), and IS_BMODEL.

Referenced by G_RunFrame().

void G_EdictCalcOrigin ( edict_t ent  ) 

Calculate the edict's origin vector from it's grid position.

Functions to handle single edicts, trying to encapsulate edict->pos in the first place.

Parameters:
ent The entity

Definition at line 218 of file g_edicts.c.

References edict_s::fieldSize, gi, edict_s::origin, edict_s::pos, and game_import_t::routingMap.

Referenced by AI_FindHerdLocation(), AI_FindHidingLocation(), G_Actor2x2Spawn(), G_ActorFall(), G_ActorSpawn(), G_ClientMove(), G_SpawnEntities(), G_SpawnFloor(), and SP_civilian_target().

qboolean G_EdictPosIsSameAs ( edict_t ent,
const pos3_t  cmpPos 
)

Set the edict's pos and origin vector to the given grid position.

Parameters:
ent The entity
newPos The grid position to compare to
Returns:
qtrue if positions are equal

Definition at line 240 of file g_edicts.c.

References edict_s::pos, and VectorCompare.

Referenced by G_ClientShoot(), and G_ShootSingle().

void G_EdictSetOrigin ( edict_t ent,
const pos3_t  newPos 
)

Set the edict's pos and origin vector to the given grid position.

Parameters:
ent The entity
newPos The new grid position

Definition at line 228 of file g_edicts.c.

References edict_s::fieldSize, gi, edict_s::origin, edict_s::pos, game_import_t::routingMap, and VectorCopy.

Referenced by AI_CivilianCalcBestAction(), AI_FighterCalcBestAction(), AIL_positionherd(), and AIL_positionhide().

edict_t* G_EdictsGetByNum ( const int  num  ) 

Get an entity by it's number.

Parameters:
[in] num The entity's index in the array of entities

Definition at line 81 of file g_edicts.c.

References G_EdictsIsValidNum(), and gi.

Referenced by G_ClientAction().

edict_t* G_EdictsGetFirst ( void   ) 

Returns the first entity.

Note:
This is always a world edict - but in case of rma there might be several parts of the world spread all over the array.

Definition at line 96 of file g_edicts.c.

Referenced by G_ClientSendEdictsAndBrushModels(), G_FindEdictGroups(), G_SendBoundingBoxes(), and G_SpawnEntities().

edict_t* G_EdictsGetNewEdict ( void   ) 

Find an entity that is not in use.

Definition at line 130 of file g_edicts.c.

References G_EdictsGetNext(), game, globals, edict_s::inuse, game_export_t::num_edicts, and game_locals_t::sv_maxentities.

Referenced by G_Spawn().

edict_t* G_EdictsGetNext ( edict_t lastEnt  ) 

Iterate through the list of entities.

Parameters:
lastEnt The entity found in the previous iteration; if NULL, we start at the beginning

Definition at line 105 of file g_edicts.c.

References globals, and game_export_t::num_edicts.

Referenced by G_ClientGetFreeSpawnPoint(), G_EdictsGetNewEdict(), G_EdictsGetNextInUse(), and G_FindTargetEntity().

edict_t* G_EdictsGetNextActor ( edict_t lastEnt  ) 

Iterate through the actor entities (even the dead! - but skips the invisible).

Parameters:
lastEnt The entity found in the previous iteration; if NULL, we start at the beginning

Definition at line 201 of file g_edicts.c.

References G_EdictsGetNextInUse(), G_IsActor, globals, and game_export_t::num_edicts.

Referenced by AIL_Cleanup(), G_ActorGetByUCN(), G_MatchSendResults(), G_SendInvisible(), and G_SendPlayerStats().

edict_t* G_EdictsGetNextInUse ( edict_t lastEnt  ) 

Iterate through the entities that are in use.

Note:
we can hopefully get rid of this function once we know when it makes sense to iterate through entities that are NOT in use
Parameters:
lastEnt The entity found in the previous iteration; if NULL, we start at the beginning

Definition at line 155 of file g_edicts.c.

References G_EdictsGetNext(), and edict_s::inuse.

Referenced by AI_CheckForMissionTargets(), AI_SearchDestroyableObject(), G_BuildForbiddenList(), G_CheckVisPlayer(), G_CheckVisTeamAll(), G_ClearVisFlags(), G_ClientSendEdictsAndBrushModels(), G_CompleteRecalcRouting(), G_EdictsGetNextActor(), G_EdictsGetNextLivingActor(), G_Find(), G_FindEdictGroups(), G_FindRadius(), G_GenerateEntList(), G_GetEdictFromPos(), G_MatchSendResults(), G_MissionThink(), G_Morale(), G_MoraleBehaviour(), G_PhysicsRun(), G_ResetTriggers(), G_SendBoundingBoxes(), G_SplashDamage(), and G_TestVis().

edict_t* G_EdictsGetNextLivingActor ( edict_t lastEnt  ) 
edict_t* G_EdictsGetNextLivingActorOfTeam ( edict_t lastEnt,
const int  team 
)

Iterate through the living actor entities of the given team.

Parameters:
lastEnt The entity found in the previous iteration; if NULL, we start at the beginning
team The team we are looking for

Definition at line 186 of file g_edicts.c.

References G_EdictsGetNextLivingActor(), and edict_s::team.

Referenced by AI_CheckFF(), AI_FindHerdLocation(), AI_Run(), G_GiveTimeUnits(), G_MatchEndCheck(), G_ReactionFireReset(), G_TeamPointVis(), and G_UpdateStunState().

int G_EdictsGetNumber ( const edict_t ent  ) 

Get an entity's ID number.

Parameters:
ent The entity
Returns:
the entity's ID number, currently the index in the array
Note:
DO NOT use this number as anything other than an identifier !

Definition at line 58 of file g_edicts.c.

References globals, and game_export_t::num_edicts.

Referenced by G_InitEdict().

edict_t* G_EdictsInit ( void   ) 

Allocate space for the entity pointers.

Functions handling the storage and lifecycle of all edicts

Note:
No need to set it to zero, G_TagMalloc will do that for us

Definition at line 38 of file g_edicts.c.

References G_TagMalloc, game, game_locals_t::sv_maxentities, and TAG_GAME.

Referenced by G_Init().

qboolean G_EdictsIsValidNum ( const int  num  ) 

Check if the given number could point to an existing entity.

Note:
entity must also be 'in use' to be really valid
Parameters:
[in] num The entity's index in the array of entities

Definition at line 70 of file g_edicts.c.

References globals, game_export_t::num_edicts, qfalse, and qtrue.

Referenced by G_EdictsGetByNum().

void G_EdictsReset ( void   ) 

Reset the entity pointers for eg. a new game.

Definition at line 47 of file g_edicts.c.

References game, and game_locals_t::sv_maxentities.

Referenced by G_SpawnEntities().

void G_EventActorDie ( const edict_t ent  ) 

Announce the actor die event for the clients that are seeing the actor.

Parameters:
[in] ent The actor that is dying

Definition at line 57 of file g_events.c.

References EV_ACTOR_DIE, G_VisToPM(), gi, edict_s::number, edict_s::state, and edict_s::visflags.

Referenced by G_ActorDieOrStun().

void G_EventActorFall ( const edict_t ent  ) 
void G_EventActorRevitalise ( const edict_t ent  ) 

Announce the actor die event for the clients that are seeing the actor.

Parameters:
[in] ent The actor that was healed and woke up again

Definition at line 68 of file g_events.c.

References EV_ACTOR_REVITALISED, G_VisToPM(), gi, edict_s::number, edict_s::state, and edict_s::visflags.

Referenced by G_ActorCheckRevitalise().

void G_EventActorSendReservations ( const edict_t ent  ) 

Will inform the player about the real TU reservation.

Parameters:
ent The actors edict.

Definition at line 79 of file g_events.c.

References edict_s::chr, chrReservations_s::crouch, EV_ACTOR_RESERVATIONCHANGE, G_PLAYER_FROM_ENT, G_PlayerToPM, gi, edict_s::number, chrReservations_s::reaction, character_s::reservedTus, and chrReservations_s::shot.

Referenced by G_ActorReserveTUs().

void G_EventActorStats ( const edict_t ent  ) 
void G_EventActorTurn ( const edict_t ent  ) 

Send the turn event for the given entity.

Parameters:
ent The entity to send the turn event for
Note:
Every player that can see this ent will reveive the turn event data
Make sure that the direction to turn into is already set

Definition at line 46 of file g_events.c.

References edict_s::dir, EV_ACTOR_TURN, G_VisToPM(), gi, edict_s::number, and edict_s::visflags.

Referenced by G_ActorDoTurn(), G_ClientMove(), G_ClientShoot(), and G_ClientTurn().

void G_EventDestroyEdict ( const edict_t ent  ) 

Unregister an edict at the client.

Parameters:
ent The edict to unregister

Definition at line 136 of file g_events.c.

References EV_ENT_DESTROY, gi, edict_s::number, and PM_ALL.

Referenced by G_FreeEdict().

void G_EventEndRound ( void   ) 

End of round event for the current active team.

Note:
This event is send to every connected client

Definition at line 315 of file g_events.c.

References level_locals_t::activeTeam, EV_ENDROUND, gi, level, and PM_ALL.

Referenced by G_ClientEndRound().

void G_EventInventoryAdd ( const edict_t ent,
int  playerMask,
int  itemAmount 
)

Tell the client to add the item from the container.

Parameters:
[in] ent Pointer to entity having given inventory.
[in] playerMask The player mask to determine which clients should receive the event (e.g. G_VisToPM(ent->visflags))
[in] itemAmount How many items to add.
Note:
This event must be followed by a G_WriteItem call

Definition at line 115 of file g_events.c.

References EV_INV_ADD, gi, INV_INVENTORY_BYTES, and edict_s::number.

Referenced by G_ActorInvMove(), and G_SendInventory().

void G_EventInventoryAmmo ( const edict_t ent,
const objDef_t ammo,
int  amount,
shoot_types_t  shootType 
)

Change the amount of available ammo for the given entity.

Parameters:
ent The entity to change the amount of ammo for
ammo The ammo to change
amount The new amount of the left ammo
shootType The shooting type to determine which container to use

Definition at line 149 of file g_events.c.

References game_import_t::csi, EV_INV_AMMO, G_VisToPM(), gi, csi_s::idLeft, csi_s::idRight, objDef_s::idx, IS_SHOT_RIGHT, edict_s::number, and edict_s::visflags.

Referenced by G_ClientShoot().

void G_EventInventoryDelete ( const edict_t ent,
int  playerMask,
const invDef_t invDef,
int  x,
int  y 
)

Tell the client to remove the item from the container.

Parameters:
[in] ent Pointer to entity having given inventory.
[in] playerMask The player mask to determine which clients should receive the event (e.g. G_VisToPM(ent->visflags))
[in] invDef Pointer to inventory definition having given container.
[in] x Position of item in container.
[in] y Position of item in container.

Definition at line 99 of file g_events.c.

References EV_INV_DEL, gi, invDef_s::id, and edict_s::number.

Referenced by G_ActorInvMove(), G_ClientShoot(), and G_InventoryRemoveItemByID().

void G_EventInventoryReload ( const edict_t ent,
int  playerMask,
const item_t item,
const invDef_t invDef,
const invList_t ic 
)
void G_EventParticleSpawn ( int  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.

Parameters:
[in] name The id of the particle (see ptl_*.ufo script files in base/ufos)
[in] levelFlags Show at which levels
[in] s starting/location vector
[in] v velocity vector
[in] a acceleration vector

Definition at line 251 of file g_events.c.

References EV_PARTICLE_SPAWN, and gi.

Referenced by G_TraceDraw().

void G_EventPerish ( const edict_t ent  ) 

Send an event to all clients that are seeing the given edict, that it just has disappeared.

Parameters:
ent The edict that disappeared

Definition at line 126 of file g_events.c.

References EV_ENT_PERISH, G_VisToPM(), gi, edict_s::number, and edict_s::visflags.

Referenced by Destroy_Breakable(), G_ActorInvMove(), G_InventoryToFloor(), and G_SpawnItemOnFloor().

void G_EventReactionFireChange ( const edict_t ent  ) 
void G_EventResetClientAction ( const edict_t ent  ) 

Reset the client actions for the given entity.

Parameters:
[in] ent The entity to reset the client action for
Note:
This event is send to the player this edict belongs to

Definition at line 295 of file g_events.c.

References EV_RESET_CLIENT_ACTION, G_PLAYER_FROM_ENT, G_PlayerToPM, gi, and edict_s::number.

Referenced by G_ActorSetClientAction().

void G_EventSendEdict ( const edict_t ent  ) 

Send the bounding box info to the client.

Parameters:
[in] ent The edict to send the bounding box for

Definition at line 356 of file g_events.c.

References edict_s::absmax, edict_s::absmin, EV_ADD_EDICT, gi, edict_s::number, PM_ALL, and edict_s::type.

Referenced by G_SendBoundingBoxes().

void G_EventSetClientAction ( const edict_t ent  ) 

Informs the client that an interaction with the world is possible.

Note:
It's assumed that the clientAction is already set
Parameters:
[in] ent The edict that can execute the action (an actor)

Definition at line 279 of file g_events.c.

References edict_s::clientAction, EV_DOOR_ACTION, G_TeamToPM(), gi, edict_s::number, and edict_s::team.

Referenced by G_ActorSetClientAction().

void G_EventShoot ( const edict_t ent,
int  visMask,
const fireDef_t fd,
qboolean  firstShoot,
shoot_types_t  shootType,
int  flags,
const trace_t trace,
const vec3_t  from,
const vec3_t  impact 
)

Do the shooting.

Parameters:
ent The entity that is doing the shooting
visMask the vis mask to determine the clients from this event is send to
fd The firedefinition to use for the shoot
firstShoot Is this the first shoot
shootType The type of the shoot
flags Define some flags in a bitmask: SF_BODY, SF_IMPACT, SF_BOUNCING and SF_BOUNCING
trace The trace what was used to determine whether this shot has hit something
from The position the entity shoots from
impact The impact world vector for the shot

Definition at line 207 of file g_events.c.

References trace_s::contentFlags, trace_s::ent, EV_ACTOR_SHOOT, fireDef_s::fdIdx, G_IsBreakable, G_VisToPM(), gi, objDef_s::idx, edict_s::number, fireDef_s::obj, trace_s::plane, SKIP_LOCAL_ENTITY, and fireDef_s::weapFdsIdx.

Referenced by G_ShootSingle().

void G_EventShootHidden ( int  visMask,
const fireDef_t fd,
qboolean  firstShoot 
)

Start the shooting event for hidden actors.

Parameters:
visMask the vis mask to determine the clients from this event is send to
fd The firedefinition to use for the shoot
firstShoot Is this the first shoot

Definition at line 186 of file g_events.c.

References EV_ACTOR_SHOOT_HIDDEN, fireDef_s::fdIdx, G_VisToPM(), gi, objDef_s::idx, fireDef_s::obj, and fireDef_s::weapFdsIdx.

Referenced by G_ClientShoot(), and G_ShootSingle().

void G_EventSpawnSound ( const edict_t ent,
const vec3_t  origin,
const char *  sound 
)

Spawns a sound for all connected clients (that will be spatialized on the client side).

Parameters:
ent The edict that is causing the sound
origin The origin of the sound
sound The sound file, path relative to sounds/. If there is a + at the end of the path, a random sound will be taken.

Definition at line 35 of file g_events.c.

References gi, and PM_ALL.

Referenced by Destroy_Breakable(), and Door_Use().

void G_EventStartShoot ( const edict_t ent,
int  visMask,
shoot_types_t  shootType,
const pos3_t  at 
)

Start the shooting event.

Parameters:
ent The entity that starts the shooting
visMask the vis mask of the teams to determine the clients from this event is send to
shootType The type of the shoot
at The grid position to target to

Definition at line 171 of file g_events.c.

References EV_ACTOR_START_SHOOT, G_VisToPM(), gi, edict_s::number, and edict_s::pos.

Referenced by G_ClientShoot().

void G_EventThrow ( int  visMask,
const fireDef_t fd,
float  dt,
byte  flags,
const vec3_t  position,
const vec3_t  velocity 
)
Parameters:
[in] visMask the vis mask to determine the clients from this event is send to
[in] fd The firedefinition to use
[in] dt Delta time
[in] flags bitmask of the following values: SF_BODY, SF_IMPACT, SF_BOUNCING and SF_BOUNCED
[in] position The current position
[in] velocity The velocity of the throw

Definition at line 340 of file g_events.c.

References EV_ACTOR_THROW, fireDef_s::fdIdx, G_VisToPM(), gi, objDef_s::idx, fireDef_s::obj, and fireDef_s::weapFdsIdx.

Referenced by G_ShootGrenade().

edict_t* G_Find ( edict_t from,
int  fieldofs,
char *  match 
)

Searches all active entities for the next one that holds the matching string at fieldofs (use the offsetof() macro) in the structure.

Parameters:
[in] from If this is NULL all edicts will be searched, otherwise the given edict will be the start of the search
[in] fieldofs The field offset of the struct member (returned by the offsetof macro) of the field to search the given value for
[in] match The value of the field
Note:
Searches beginning at the edict after from, or the beginning if NULL
 while ((spot = G_Find(spot, FOFS(classname), "misc_whatever")) != NULL) {
   [..]
 }
Returns:
NULL will be returned if the end of the list is reached.

Definition at line 344 of file g_utils.c.

References byte, G_EdictsGetNextInUse(), and Q_strcasecmp.

edict_t* G_FindRadius ( edict_t from,
const vec3_t  org,
float  rad,
entity_type_t  type 
)

Returns entities that have origins within a spherical area.

Parameters:
[in] from The entity to start the search from. NULL 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.

 edict_t* ent = NULL;
 while ((ent = G_FindRadius(ent, origin, rad, type)) != NULL) {
   [...]
 }

Definition at line 391 of file g_utils.c.

References ET_NULL, G_EdictsGetNextInUse(), edict_s::maxs, edict_s::mins, edict_s::origin, edict_s::type, and VectorLength().

Referenced by G_ActorUseDoor().

edict_t* G_FindTargetEntity ( const char *  target  ) 

Searches the edict that has the given target as targetname set.

Parameters:
target The target name of the edict that you are searching
Returns:
NULL if no edict with the given target name was found, otherwise the edict that has the targetname set you were looking for.

Definition at line 365 of file g_utils.c.

References G_EdictsGetNext(), and edict_s::targetname.

Referenced by G_MissionUse(), and Touch_TouchTrigger().

void G_FreeEdict ( edict_t ent  ) 
qboolean G_FrustumVis ( const edict_t from,
const vec3_t  point 
)

Checks whether a point is "visible" from the edicts position.

See also:
FrustumVis

Definition at line 31 of file g_vis.c.

References edict_s::dir, FrustumVis(), and edict_s::origin.

Referenced by AI_CheckCrouch(), AI_CheckUsingDoor(), G_Morale(), G_ReactionFireIsPossible(), G_SplashDamage(), G_TeamPointVis(), and G_Vis().

void G_GenerateEntList ( const char *  entList[MAX_EDICTS]  ) 

creates an entity list

Parameters:
[out] entList A list of all active inline model entities
See also:
G_RecalcRouting
G_LineVis

Definition at line 418 of file g_utils.c.

References G_EdictsGetNextInUse(), i, IS_BMODEL, and edict_s::model.

Referenced by G_RecalcRouting(), and G_TestLineWithEnts().

int G_GetActiveTeam ( void   ) 

Returns the current active team to the server.

If this has the value TEAM_NO_ACTIVE there is either no
living actor for any player left, or the round wasn't started yet.

Definition at line 288 of file g_client.c.

References level_locals_t::activeTeam, and level.

Referenced by G_GetNextActiveTeam(), and GetGameAPI().

edict_t* G_GetActorFromPos ( const pos3_t  pos  ) 

Searches an actor on the given grid position.

Parameters:
pos The position to search an actor on
Returns:
The actor or NULL if no actor is standing on that grid position

Definition at line 121 of file g_move.c.

References ET_ACTOR, ET_ACTOR2x2, ET_ACTORHIDDEN, and G_GetEdictFromPos().

Referenced by G_SpawnItemOnFloor().

edict_t* G_GetEdictFromPos ( const pos3_t  pos,
const entity_type_t  type 
)

Searches an edict of the given type at the given grid location.

Parameters:
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.
Returns:
NULL if nothing was found, otherwise the entity located at the given grid position.

Definition at line 54 of file g_utils.c.

References ET_NULL, G_EdictsGetNextInUse(), edict_s::pos, edict_s::type, and VectorCompare.

Referenced by G_ActorFall(), G_ActorShouldStopInMidMove(), G_GetActorFromPos(), G_GetFloorItemsFromPos(), and G_MissionThink().

edict_t* G_GetFloorItems ( edict_t ent  ) 

Prepares a list of items on the floor at given entity position.

Parameters:
[in] ent Pointer to an entity being an actor.
Returns:
pointer to edict_t being a floor (with items) or NULL in case no items were found on the edict grid position.

Definition at line 43 of file g_inventory.c.

References FLOOR, G_GetFloorItemsFromPos(), and edict_s::pos.

Referenced by G_ActorInvMove(), G_ActorRevitalise(), G_ClientMove(), G_InventoryToFloor(), G_MissionThink(), and G_SpawnItemOnFloor().

edict_t* G_GetFloorItemsFromPos ( const pos3_t  pos  ) 

Callback to G_GetEdictFromPos() for given position, used to get items from position.

Parameters:
[in] pos A position for which items are wanted.
See also:
G_GetFloorItems

Definition at line 32 of file g_inventory.c.

References ET_ITEM, and G_GetEdictFromPos().

Referenced by G_AddItemToFloor(), G_GetFloorItems(), and G_SpawnItemOnFloor().

player_t* G_GetPlayerForTeam ( int  team  ) 

Gets player for given team.

Parameters:
[in] team The team the player data should be searched for
Returns:
The inuse player for the given team or NULL when no player found.

Definition at line 147 of file g_utils.c.

References game, i, player_s::inuse, player_s::pers, game_locals_t::players, game_locals_t::sv_maxplayersperteam, and client_persistant_t::team.

Referenced by G_ClientEndRound().

const char* G_GetPlayerName ( int  pnum  ) 

Returns the player name for a give player number.

Definition at line 230 of file g_utils.c.

References game, client_persistant_t::netname, player_s::pers, game_locals_t::players, and game_locals_t::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.

Parameters:
[in] fd Pointer to fire definition, for which item is wanted.
Returns:
id of the item to which fire definition belongs or "unknown" when no object found.
See also:
G_GetObjectForFiredef

Definition at line 133 of file g_utils.c.

References G_GetObjectForFiredef(), and objDef_s::id.

Referenced by G_PrintActorStats().

void G_GiveTimeUnits ( int  team  ) 

Network function to update the time units (TUs) for each team-member.

Parameters:
[in] team The index of the team to update the values for.
See also:
G_SendStats

Definition at line 99 of file g_client.c.

References G_ActorGiveTimeUnits(), G_EdictsGetNextLivingActorOfTeam(), and G_SendStats().

Referenced by G_ClientEndRound(), and G_ClientSpawn().

qboolean G_InventoryRemoveItemByID ( const char *  itemID,
edict_t ent,
containerIndex_t  container 
)

Removes one particular item from a given container.

Parameters:
itemID The id of the item to remove
ent The edict that holds the inventory to remove the item from
container The container in the inventory of the edict to remove the searched item from.
Returns:
true if the removal was successful, false otherwise.

Definition at line 64 of file g_inventory.c.

References edict_s::chr, CONTAINER, G_EventInventoryDelete(), G_VisToPM(), game, gi, character_s::i, game_locals_t::i, objDef_s::id, INVDEF, invList_s::item, invList_s::next, qfalse, qtrue, inventoryInterface_s::RemoveFromInventory, item_s::t, edict_s::visflags, invList_s::x, and invList_s::y.

Referenced by G_MissionThink().

void G_InventoryToFloor ( edict_t ent  ) 

Move items to adjacent locations if the containers on the current floor edict are full.

Move the whole given inventory to the floor and destroy the items that do not fit there.

Parameters:
[in] ent Pointer to an edict_t being an actor.
See also:
G_ActorDie

Definition at line 205 of file g_inventory.c.

References inventoryInterface_s::AddToInventory, item_s::amount, edict_s::chr, CONTAINER, game_import_t::csi, FLOOR, G_CheckVis(), G_EventPerish(), G_GetFloorItems(), G_InventoryDropToFloorCheck(), G_SpawnFloor(), game, gi, character_s::i, game_locals_t::i, objDef_s::id, csi_s::idArmour, csi_s::idFloor, INVDEF, invList_s::item, invList_s::next, next, NONE, edict_s::number, csi_s::numIDs, edict_s::pos, qtrue, inventoryInterface_s::RemoveFromInventory, item_s::t, and edict_s::visflags.

Referenced by G_ActorDieOrStun().

qboolean G_IsLivingActor ( const edict_t ent  ) 

Checks whether the given edict is a living actor.

Parameters:
[in] ent The edict to perform the check for
See also:
LE_IsLivingActor

Definition at line 32 of file g_actor.c.

References G_IsActor, G_IsDead, and G_IsStunned.

Referenced by Door_Use(), G_Damage(), G_EdictsGetNextLivingActor(), G_ReactionFireCanBeEnabled(), G_SplashDamage(), G_TouchTriggers(), G_Vis(), and G_VisShouldStop().

qboolean G_MatchDoEnd ( void   ) 

Checks whether a match is over.

Returns:
true if this match is over, false otherwise

Definition at line 306 of file g_match.c.

References G_MatchSendResults(), G_PrintStats(), level_locals_t::intermissionTime, level, qfalse, qtrue, level_locals_t::time, va(), and level_locals_t::winningTeam.

Referenced by G_RunFrame().

void G_MatchEndCheck ( void   ) 

Checks whether there are still actors to fight with left. If non are the match end will be triggered.

See also:
G_MatchEndTrigger

Todo:
count from 0 to get the civilians for objectives
Todo:
< 2 does not work when we count civilians

Definition at line 325 of file g_match.c.

References level_locals_t::activeTeam, G_EdictsGetNextLivingActorOfTeam(), G_IsStunned, G_MatchEndTrigger(), i, level_locals_t::intermissionTime, level, MAX_TEAMS, level_locals_t::numplayers, and TEAM_ALIEN.

Referenced by G_ClientDisconnect(), and G_ClientShoot().

void G_MatchEndTrigger ( int  team,
int  timeGap 
)

Triggers the end of the game. Will be executed in the next server (or game) frame.

Parameters:
[in] team The winning team
[in] timeGap Second to wait before really ending the game. Useful if you want to allow a last view on the scene

Definition at line 169 of file g_match.c.

References level_locals_t::intermissionTime, level, level_locals_t::time, and level_locals_t::winningTeam.

Referenced by G_MatchEndCheck(), G_MissionThink(), and SVCmd_Win_f().

qboolean G_MatchIsRunning ( void   ) 

Checks whether the game is running (active team and no intermission time).

Returns:
true if there is an active team for the current round and the end of the game was not yet triggered
See also:
G_MatchEndTrigger

Definition at line 366 of file g_match.c.

References level_locals_t::activeTeam, level_locals_t::intermissionTime, level, qfalse, and TEAM_NO_ACTIVE.

Referenced by Door_Use(), G_ClientEndRound(), G_ClientUserinfoChanged(), G_GetStartingTeam(), G_MissionThink(), G_PhysicsRun(), G_ReactionFireCanBeEnabled(), and G_RunFrame().

qboolean G_MissionDestroy ( edict_t self  ) 

Mission trigger destroy function.

Definition at line 101 of file g_mission.c.

References qtrue.

Referenced by SP_misc_mission().

void G_MissionThink ( edict_t self  ) 
qboolean G_MissionTouch ( edict_t self,
edict_t activator 
)

Mission trigger.

Todo:

use level.nextmap to spawn another map when every living actor has touched the mission trigger

use level.actualRound to determine the 'King of the Hill' time

Note:
Don't set a client action here - otherwise the movement event might be corrupted

Definition at line 38 of file g_mission.c.

References _, level_locals_t::actualRound, CONTAINER, game_import_t::csi, G_ActorInvMove(), G_IsAlien, gi, objDef_s::id, csi_s::idFloor, INVDEF, invList_s::item, level, invList_s::next, NONE, csi_s::numIDs, PRINT_HUD, qfalse, qtrue, item_s::t, edict_s::team, TEAM_ALIEN, and invDef_s::temp.

Referenced by SP_misc_mission(), and SP_misc_mission_aliens().

qboolean G_MissionUse ( edict_t self,
edict_t activator 
)

Mission trigger use function.

Definition at line 109 of file g_mission.c.

References edict_s::destroy, G_FindTargetEntity(), G_FreeEdict(), gi, edict_s::HP, qfalse, qtrue, and edict_s::use.

Referenced by SP_misc_mission().

void G_MoraleBehaviour ( int  team  ) 
void G_MoveCalc ( int  team,
const edict_t movingActor,
const pos3_t  from,
byte  crouchingState,
int  distance 
)

Precalculates a move table for a given team and a given starting position. This will calculate a routing table for all reachable fields with the given distance from the given spot with the given actorsize.

Parameters:
[in] team The current team (see G_BuildForbiddenList)
[in] from Position in the map to start the move-calculation from.
[in] crouchingState The crouching state of the actor. 0=stand, 1=crouch
[in] distance The distance in TUs to calculate the move for.
[in] movingActor The actor to calculate the move for
See also:
G_BuildForbiddenList
G_MoveCalcLocal

Definition at line 93 of file g_move.c.

References G_MoveCalcLocal(), level, and level_locals_t::pathingMap.

Referenced by AI_PrepBestAction(), AI_TurnIntoDirection(), AIL_positionshoot(), G_ClientMove(), and pos3L_goto().

void G_MoveCalcLocal ( pathing_t pt,
int  team,
const edict_t movingActor,
const pos3_t  from,
byte  crouchingState,
int  distance 
)

Same as G_MoveCalc, except that it uses the pathing table passed as the first param.

Parameters:
[in] pt the pathfinding table
[in] team The current team (see G_BuildForbiddenList)
[in] from Position in the map to start the move-calculation from.
[in] crouchingState The crouching state of the actor. 0=stand, 1=crouch
[in] distance The distance in TUs to calculate the move for.
[in] movingActor The actor to calculate the move for
See also:
G_MoveCalc
G_BuildForbiddenList

Definition at line 109 of file g_move.c.

References edict_s::fieldSize, forbiddenList, forbiddenListLength, G_BuildForbiddenList(), gi, and game_import_t::routingMap.

Referenced by AI_FindHerdLocation(), AI_FindHidingLocation(), and G_MoveCalc().

void G_PhysicsRun ( void   ) 

Handles door and other objects.

See also:
G_RunFrame

Definition at line 109 of file g_phys.c.

References level_locals_t::framenum, G_EdictsGetNextInUse(), G_MatchIsRunning(), G_PhysicsThink(), level, and edict_s::think.

Referenced by G_RunFrame().

void G_PhysicsStep ( edict_t ent  ) 
Todo:
Use this function to enable footsteps over network
Note:
Only play the water sounds if actor is not in STATE_CROUCHED mode we can assume, that moving slower and more carefully would also not produce the water sounds

Todo:
don't play foot step sounds for flying units.

Definition at line 34 of file g_phys.c.

References moveinfo_t::contentFlags, edict_s::contentFlags, CONTENTS_WATER, moveinfo_t::currentStep, level_locals_t::framenum, G_IsCrouched, G_Trace(), G_VisToPM(), game_import_t::GetFootstepSound(), gi, level, MASK_SOLID, edict_s::moveinfo, cBspSurface_s::name, edict_s::nextthink, edict_s::origin, SERVER_FRAME_SECONDS, moveinfo_t::steps, trace_s::surface, edict_s::think, UNIT_HEIGHT, VectorCopy, and moveinfo_t::visflags.

Referenced by G_ClientMove().

void G_PrintActorStats ( const edict_t victim,
const edict_t attacker,
const fireDef_t fd 
)

Prints stats about who killed who with what and how.

Parameters:
[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.
See also:
G_Damage
G_PrintStats

Definition at line 268 of file g_utils.c.

References edict_s::chr, Com_sprintf(), G_GetPlayerName(), G_GetWeaponNameForFiredef(), G_PrintStats(), edict_s::HP, fireDef_s::name, character_s::name, edict_s::pnum, edict_s::team, TEAM_ALIEN, and TEAM_CIVILIAN.

Referenced by G_ClientMove(), and G_Damage().

void G_PrintStats ( const char *  buffer  ) 

Prints stats to game console and stats log file.

See also:
G_PrintActorStats

Definition at line 242 of file g_utils.c.

References Com_sprintf(), gi, and logstatsfile.

Referenced by G_GetStartingTeam(), G_MatchDoEnd(), G_PrintActorStats(), and G_UpdateCharacterSkills().

qboolean G_ReactionFireCanBeEnabled ( const edict_t ent  ) 

Checks whether the actor is allowed to activate reaction fire and will informs the player about the reason if this would not work.

Parameters:
ent The actor to check
Returns:
true if the actor is allowed to activate it, false otherwise

Definition at line 170 of file g_reaction.c.

References _, level_locals_t::activeTeam, edict_s::chr, G_ActorHasEnoughTUsReactionFire(), G_ActorHasReactionFireEnabledWeapon(), G_ActorHasWorkingFireModeSet(), G_ClientPrintf(), G_IsLivingActor(), G_MatchIsRunning(), G_PLAYER_FROM_ENT, edict_s::inuse, level, PRINT_HUD, qfalse, qtrue, edict_s::team, character_s::teamDef, and teamDef_s::weapons.

Referenced by G_ClientStateChange().

void G_ReactionFireEndTurn ( void   ) 

Called at the end of turn, all outstanding reaction fire is resolved.

See also:
G_ClientEndRound

Definition at line 480 of file g_reaction.c.

References G_EdictsGetNextLivingActor(), G_ReactionFireTryToShoot(), and edict_s::reactionTarget.

Referenced by G_ClientEndRound().

qboolean G_ReactionFireOnMovement ( edict_t target  ) 

Called when 'target' moves, possibly triggering or resolving reaction fire.

Parameters:
[in] target The target entity
Returns:
true If any shots were (or would be) taken
See also:
G_ClientMove

Definition at line 411 of file g_reaction.c.

References G_ReactionFireCheckExecution(), and G_ReactionFireSearchTarget().

Referenced by G_ClientMove().

void G_ReactionFirePostShot ( edict_t target  ) 

Called after 'target' has fired, this might trigger more reaction fire or resolve outstanding reaction fire (because target is out of time).

Parameters:
[in] target The entity that has just fired
See also:
G_ClientShoot

Definition at line 470 of file g_reaction.c.

References G_ReactionFireCheckExecution().

Referenced by G_ClientShoot().

void G_ReactionFirePreShot ( const edict_t target,
const int  fdTime 
)

Called when 'target' is about to shoot, this forces a 'draw' to decide who gets the first shot.

Parameters:
[in] target The entity about to shoot
[in] fdTime The TU of the shoot
See also:
G_ClientShoot

Definition at line 428 of file g_reaction.c.

References G_EdictsGetNextLivingActor(), G_ReactionFireGetTUsForItem(), G_ReactionFireSearchTarget(), G_ReactionFireTryToShoot(), qtrue, edict_s::reactionNoDraw, edict_s::reactionTarget, and RIGHT.

Referenced by G_ClientShoot().

void G_ReactionFireReset ( int  team  ) 

Guess! Reset all "shaken" states on end of turn?

Note:
Normally called on end of turn.
See also:
G_ClientStateChange
Parameters:
[in] team Index of team to loop through.

Todo:
why do we send the state here and why do we change the "shaken" state? - see G_MoraleBehaviour

Definition at line 499 of file g_reaction.c.

References EV_ACTOR_STATECHANGE, G_EdictsGetNextLivingActorOfTeam(), G_RemoveShaken, G_TeamToPM(), gi, edict_s::number, qfalse, edict_s::reactionNoDraw, edict_s::reactionTarget, edict_s::reactionTUs, edict_s::state, and edict_s::team.

Referenced by G_ClientEndRound().

qboolean G_ReactionFireSetDefault ( edict_t ent  ) 
Parameters:
ent The actor to set the reaction fire for
Returns:
true if the needed settings could have been made or settings are already valid, false otherwise.

Definition at line 135 of file g_reaction.c.

References ACTOR_GET_INV, ACTOR_HAND_LEFT, ACTOR_HAND_RIGHT, edict_s::chr, chrFiremodeSettings_s::fmIdx, G_ActorHasWorkingFireModeSet(), G_EventReactionFireChange(), G_IsAI, chrFiremodeSettings_s::hand, INVSH_HasReactionFireEnabledWeapon(), qfalse, qtrue, character_s::RFmode, and chrFiremodeSettings_s::weapon.

Referenced by G_ClientStateChange().

void G_ReactionFireUpdate ( edict_t ent,
fireDefIndex_t  fmIdx,
actorHands_t  hand,
const objDef_t od 
)

Updates the reaction fire settings in case something was moved into a hand or from a hand that would make the current settings invalid.

Parameters:
ent The actor edict to check the settings for

Definition at line 102 of file g_reaction.c.

References edict_s::chr, chrFiremodeSettings_s::fmIdx, G_ActorHasWorkingFireModeSet(), G_ClientStateChange(), G_EventReactionFireChange(), G_PLAYER_FROM_ENT, chrFiremodeSettings_s::hand, qfalse, character_s::RFmode, STATE_REACTION, and chrFiremodeSettings_s::weapon.

Referenced by G_ActorInvMove(), and G_ClientAction().

void G_ReadItem ( item_t item,
invDef_t **  container,
int *  x,
int *  y 
)

Read item from the network buffer.

Parameters:
[in,out] item item_t being send through net.
[in,out] container Container which is being updated with item sent.
[in] x Position of item in given container.
[in] y Position of item in given container.
See also:
CL_NetReceiveItem
EV_INV_TRANSFER

Definition at line 286 of file g_inventory.c.

References item_s::a, item_s::amount, game_import_t::csi, gi, INVDEF, item_s::m, m, NONE, csi_s::numODs, csi_s::ods, item_s::rotated, and item_s::t.

Referenced by G_ClientReadInventory().

void G_RecalcRouting ( const edict_t ent  ) 
void void G_ResetClientData ( void   ) 

Called after every player has joined.

Definition at line 1438 of file g_client.c.

References scoreMissionNum.

Referenced by G_SpawnEntities().

qboolean G_RunFrame ( void   ) 
void G_SendInventory ( unsigned int  playerMask,
const edict_t ent 
)

Sends whole inventory through the network buffer.

Parameters:
[in] playerMask The player mask to determine which clients should receive the event (G_VisToPM(ent->visflags)).
[in] ent Pointer to an actor or floor container with inventory to send.
See also:
G_AppearPerishEvent
CL_InvAdd

Definition at line 334 of file g_inventory.c.

References CONTAINER, game_import_t::csi, G_EventInventoryAdd(), G_WriteItem(), gi, INVDEF, invList_s::item, invList_s::next, csi_s::numIDs, item_s::t, invList_s::x, and invList_s::y.

Referenced by G_AppearPerishEvent(), and G_MatchSendResults().

void G_SendInvisible ( player_t player  ) 

This function sends all the actors to the client that are not visible initially - this is needed because an actor can e.g. produce sounds that are send over the net. And the client can only handle them if he knows the le_t (local entity) already.

Note:
Call this for the first G_CheckVis call for every new actor or player
See also:
G_CheckVis
CL_ActorAdd

Definition at line 255 of file g_client.c.

References edict_s::chr, EV_ACTOR_ADD, edict_s::fieldSize, G_EdictsGetNextActor(), G_IsVisibleForTeam, G_PlayerToPM, character_s::gender, gi, teamDef_s::idx, level, NONE, level_locals_t::num_alive, edict_s::number, player_s::pers, edict_s::pnum, edict_s::pos, edict_s::state, STATE_PUBLIC, edict_s::team, client_persistant_t::team, TEAM_NO_ACTIVE, and character_s::teamDef.

Referenced by G_ClientSpawn().

void G_SendPlayerStats ( const player_t player  ) 

Write player stats to network buffer.

See also:
G_SendStats

Definition at line 46 of file g_stats.c.

References G_EdictsGetNextActor(), G_SendStats(), player_s::pers, client_persistant_t::team, and edict_s::team.

Referenced by G_ClientSpawn().

void G_SendState ( unsigned int  playerMask,
const edict_t ent 
)
void G_SendStats ( edict_t ent  ) 
void G_ServerCommand ( void   ) 

ServerCommand will be called when an "sv" command is issued. The game can issue gi.Cmd_Argc() / gi.Cmd_Argv() commands to get the rest of the parameters.

See also:
serverCommandList

Definition at line 325 of file g_svcmds.c.

References game_import_t::Cmd_Argv(), gi, Q_strcasecmp, SVCmd_AddIP_f(), SVCmd_AI_Add_f(), SVCmd_ListIP_f(), SVCmd_RemoveIP_f(), SVCmd_Win_f(), and SVCmd_WriteIP_f().

Referenced by GetGameAPI().

void G_SetTeamForPlayer ( player_t player,
const int  team 
)
edict_t* G_Spawn ( void   ) 

Either finds a free edict, or allocates a new one.

Note:
Try to avoid reusing an entity that was recently freed, because it can cause the player to think the entity morphed into something else instead of being removed and recreated, which can cause interpolated angles and bad trails.
See also:
G_InitEdict
G_FreeEdict

Definition at line 400 of file g_spawn.c.

References G_EdictsGetNewEdict(), G_InitEdict(), and gi.

Referenced by G_SpawnEntities(), G_SpawnFloor(), G_SpawnParticle(), and G_TriggerSpawn().

void G_SpawnEntities ( const char *  mapname,
qboolean  day,
const char *  entities 
)
edict_t* G_SpawnFloor ( const pos3_t  pos  ) 

Spawns a new entity at the floor.

Note:
This is e.g. used to place dropped weapons/items at the floor

Definition at line 415 of file g_spawn.c.

References ACTOR_SIZE_NORMAL, edict_s::classname, ET_ITEM, edict_s::fieldSize, G_EdictCalcOrigin(), G_Spawn(), gi, edict_s::pos, game_import_t::routingMap, edict_s::type, and VectorCopy.

Referenced by G_ActorInvMove(), G_AddItemToFloor(), G_InventoryToFloor(), and G_SpawnItemOnFloor().

edict_t* G_SpawnParticle ( const vec3_t  origin,
int  spawnflags,
const char *  particle 
)

This is only for particles that are spawned during a match - not for map particles.

Returns:
A particle edict

Definition at line 434 of file g_spawn.c.

References edict_s::classname, ET_PARTICLE, G_CheckVis(), G_Spawn(), edict_s::origin, edict_s::particle, edict_s::pos, qtrue, edict_s::spawnflags, edict_s::type, VecToPos, and VectorCopy.

Referenced by Destroy_Breakable(), G_MissionThink(), G_ShootSingle(), and G_SplashDamage().

void G_TakeDamage ( edict_t ent,
int  damage 
)

Applies the given damage value to an edict that is either an actor or has the FL_DESTROYABLE flag set.

Parameters:
ent The edict to apply the damage to.
damage The damage value.
Note:
This function assures, that the health points of the edict are never getting negative.
See also:
G_Damage

Definition at line 170 of file g_utils.c.

References G_IsActor, G_IsBreakable, and edict_s::HP.

Referenced by G_ActorFall(), G_Damage(), and Touch_HurtTrigger().

unsigned int G_TeamToPM ( int  team  ) 

Generates the player bit mask for a given team.

Parameters:
[in] team The team to create the player bit mask for
Note:
E.g. multiplayer team play can have more than one human player on the same team.

Definition at line 37 of file g_client.c.

References game, i, player_s::inuse, player_s::pers, game_locals_t::players, game_locals_t::sv_maxplayersperteam, and client_persistant_t::team.

Referenced by G_ActorInvMove(), G_AppearPerishEvent(), G_CheckVisTeam(), G_EventActorStats(), G_EventSetClientAction(), G_MatchSendResults(), G_ReactionFireReset(), and G_SendState().

qboolean G_TestLine ( const vec3_t  start,
const vec3_t  end 
)

fast version of a line trace but without including entities

Parameters:
start The start vector of the trace
end The end vector of the trace
Returns:
false if not blocked

Definition at line 209 of file g_utils.c.

References G_TraceDraw(), gi, and TL_FLAG_NONE.

Referenced by G_TeamPointVis().

qboolean G_TestLineWithEnts ( const vec3_t  start,
const vec3_t  end 
)

fast version of a line trace including entities

Parameters:
start The start vector of the trace
end The end vector of the trace
Returns:
false if not blocked

Definition at line 193 of file g_utils.c.

References G_GenerateEntList(), G_TraceDraw(), gi, MAX_EDICTS, and TL_FLAG_NONE.

Referenced by G_LineVis().

int G_TestVis ( const int  team,
edict_t check,
int  flags 
)

test if check is visible by team (or if visibility changed?)

See also:
G_CheckVisTeam
AI_FighterCalcBestAction
Parameters:
[in] team the team the edict may become visible for or perish from their view
[in] check the edict we are talking about - which may become visible or perish
[in] flags if you want to check whether the edict may also perish from other players view, you should use the VT_PERISH bits
Note:
If the edict is already visible and flags doesn't contain the bits of VT_PERISH, no further checks are performed - only the VIS_YES bits are returned

Definition at line 205 of file g_vis.c.

References g_aidebug, G_EdictsGetNextInUse(), G_IsVisibleForTeam, G_Vis(), cvar_s::integer, VIS_YES, and VT_PERISH.

Referenced by AI_FighterCalcBestAction(), AI_FindHidingLocation(), and G_DoTestVis().

void G_TouchEdicts ( edict_t 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.

Parameters:
[in] ent The edict to check.
[in] extend Extend value for the bounding box

Definition at line 541 of file g_utils.c.

References edict_s::absmax, edict_s::absmin, edict_s::chr, Com_DPrintf(), DEBUG_GAME, gi, i, edict_s::inuse, MAX_EDICTS, edict_s::model, character_s::name, and edict_s::touch.

Referenced by Destroy_Breakable().

void G_TouchSolids ( edict_t ent  ) 

Call after linking a new trigger in or destroying a bmodel during gameplay to force all entities it covers to immediately touch it.

Definition at line 513 of file g_utils.c.

References edict_s::absmax, edict_s::absmin, gi, i, edict_s::inuse, MAX_EDICTS, edict_s::solid, SOLID_TRIGGER, and edict_s::touch.

int G_TouchTriggers ( edict_t ent  ) 

Check the world against triggers for the current entity.

Parameters:
[in,out] ent The entity that maybe touches others

Definition at line 483 of file g_utils.c.

References edict_s::absmax, edict_s::absmin, G_IsLivingActor(), G_ResetTriggers(), gi, i, MAX_EDICTS, edict_s::solid, SOLID_TRIGGER, and edict_s::touch.

Referenced by G_ActorUseDoor(), G_ClientGetFreeSpawnPointForActorSize(), and G_ClientMove().

trace_t G_Trace ( const vec3_t  start,
const vec3_t  end,
const edict_t passent,
int  contentmask 
)

collision detection - this version is more accurate and includes entity tests

Note:
traces a box from start to end, ignoring entities passent, stopping if it hits an object of type specified via contentmask (MASK_*).
Returns:
The trace result

Definition at line 221 of file g_utils.c.

References G_TraceDraw(), and gi.

Referenced by G_PhysicsStep(), G_ShootGrenade(), and G_ShootSingle().

edict_t* G_TriggerSpawn ( edict_t owner  ) 
qboolean G_UseEdict ( edict_t ent,
edict_t activator 
)

Call the 'use' function for the given edict and all its group members.

Parameters:
[in] ent The edict to call the use function for
[in] activator The edict that uses ent
Returns:
qtrue when there is possibility to use edict being parameter.
See also:
G_ClientUseEdict

Definition at line 77 of file g_utils.c.

References FL_GROUPSLAVE, edict_s::flags, G_UseEdict(), edict_s::groupChain, qfalse, qtrue, and edict_s::use.

Referenced by G_ClientUseEdict(), G_UseEdict(), and SP_func_door().

float G_Vis ( const int  team,
const edict_t from,
const edict_t check,
int  flags 
)

test if check is visible by from

Parameters:
[in] team Living team members are always visible. If this is a negative number we inverse the team rules (see comments included). In combination with VT_NOFRUSTUM we can check whether there is any edict (that is no in our team) that can see check
[in] from is from team team and must be a living actor
[in] check The edict we want to get the visibility for
[in] flags VT_NOFRUSTUM, ...

Definition at line 132 of file g_vis.c.

References ACTOR_VIS_0, ACTOR_VIS_100, ET_ACTOR, ET_ACTOR2x2, ET_ITEM, ET_PARTICLE, EYE_CROUCH, EYE_STAND, G_ActorVis(), G_FrustumVis(), G_IsCivilian, G_IsCrouched, G_IsDead, G_IsLivingActor(), G_IsPaniced, G_IsVisibleOnBattlefield, G_LineVis(), edict_s::inuse, MAX_SPOT_DIST, edict_s::origin, edict_s::pos, qfalse, edict_s::team, edict_s::type, VectorCompare, VectorCopy, VectorDistSqr, and VT_NOFRUSTUM.

Referenced by AI_HideNeeded(), AIL_see(), and G_TestVis().

unsigned int G_VisToPM ( unsigned int  vis_mask  ) 

Converts vis mask to player mask.

Parameters:
[in] vis_mask The visibility bit mask (contains the team numbers) that is converted to a player mask
Returns:
Returns a playermask for all the teams of the connected players that are marked in the given vis_mask.

Definition at line 59 of file g_client.c.

References G_TeamToVisMask, game, i, player_s::inuse, player_s::pers, game_locals_t::players, game_locals_t::sv_maxplayersperteam, and client_persistant_t::team.

Referenced by G_ActorInvMove(), G_CenterView(), G_ClientMove(), G_ClientShoot(), G_ClientStateChangeUpdate(), G_EventActorDie(), G_EventActorFall(), G_EventActorRevitalise(), G_EventActorTurn(), G_EventInventoryAmmo(), G_EventPerish(), G_EventShoot(), G_EventShootHidden(), G_EventStartShoot(), G_EventThrow(), G_InventoryRemoveItemByID(), G_MatchSendResults(), G_MissionThink(), G_MoraleBehaviour(), G_MoralePanic(), G_MoraleRage(), G_MoraleStopRage(), G_PhysicsStep(), and G_SplashDamage().

void G_WriteItem ( const item_t item,
const invDef_t container,
int  x,
int  y 
)

Write an item to the network buffer.

Parameters:
[in,out] item item_t being send through net.
[in,out] container Container which is being updated with item sent.
[in] x Position of item in given container.
[in] y Position of item in given container.
See also:
CL_NetReceiveItem
EV_INV_TRANSFER

Definition at line 320 of file g_inventory.c.

References item_s::a, item_s::amount, gi, invDef_s::id, objDef_s::idx, item_s::m, NONE, item_s::rotated, and item_s::t.

Referenced by G_ActorInvMove(), and G_SendInventory().

void SP_func_breakable ( edict_t ent  ) 

func_breakable (0.3 0.3 0.3) ? Used for breakable objects.

Note:
These edicts are added client side as local models, they are stored in the lmList (because they are inline models) for tracing (see inlineList in cmodel.c)
See also:
CM_EntTestLine
LM_AddModel
SV_SetModel
G_SendEdictsAndBrushModels

Definition at line 119 of file g_func.c.

References edict_s::classname, Com_DPrintf(), DEBUG_GAME, edict_s::destroy, Destroy_Breakable(), ET_BREAKABLE, FL_DESTROYABLE, edict_s::flags, gi, edict_s::mapNum, edict_s::maxs, edict_s::mins, edict_s::model, edict_s::origin, edict_s::solid, SOLID_BSP, edict_s::touch, Touch_Breakable(), and edict_s::type.

void SP_func_door ( edict_t ent  ) 
void SP_func_rotating ( edict_t ent  ) 
void SP_trigger_hurt ( edict_t ent  ) 

Trigger for grid fields if they are under fire.

Note:
Called once for every step
See also:
Touch_HurtTrigger

Definition at line 93 of file g_trigger.c.

References edict_s::child, edict_s::classname, edict_s::dmg, ET_TRIGGER_HURT, gi, edict_s::model, edict_s::solid, SOLID_TRIGGER, edict_s::touch, Touch_HurtTrigger(), and edict_s::type.

void SP_trigger_rescue ( edict_t ent  ) 

Rescue trigger to mark an actor to be in the rescue zone. Aborting a game would not kill the actors inside this trigger area.

Note:
Called once for every step
See also:
Touch_RescueTrigger

Definition at line 192 of file g_trigger.c.

References edict_s::child, edict_s::classname, ET_TRIGGER_RESCUE, gi, edict_s::model, edict_s::reset, Reset_RescueTrigger(), edict_s::solid, SOLID_TRIGGER, edict_s::touch, Touch_RescueTrigger(), and edict_s::type.

void SP_trigger_touch ( edict_t ent  ) 

Touch trigger to call the use function of the attached target.

Note:
Called once for every step
See also:
Touch_TouchTrigger

Definition at line 143 of file g_trigger.c.

References edict_s::child, edict_s::classname, ET_TRIGGER_TOUCH, G_FreeEdict(), gi, edict_s::model, edict_s::solid, SOLID_TRIGGER, edict_s::target, edict_s::touch, Touch_TouchTrigger(), and edict_s::type.

qboolean SV_FilterPacket ( const char *  from  ) 

Definition at line 100 of file g_svcmds.c.

References byte, ipfilter_t::compare, i, cvar_s::integer, m, numipfilters, and sv_filterban.

Referenced by G_ClientConnect().


Variable Documentation

Definition at line 65 of file g_main.c.

Definition at line 66 of file g_main.c.

Definition at line 67 of file g_main.c.

Definition at line 70 of file g_main.c.

Referenced by AI_CreatePlayer(), G_SpawnEntities(), and SP_alien_start().

Definition at line 68 of file g_main.c.

Referenced by AI_CreatePlayer().

Definition at line 69 of file g_main.c.

Referenced by AI_CreatePlayer(), and SP_civilian_start().

Definition at line 902 of file g_ai.c.

Referenced by AI_CheckForMissionTargets(), and G_SpawnEntities().

Definition at line 118 of file g_main.c.

Referenced by G_Damage().

Definition at line 114 of file g_main.c.

Referenced by G_CheckFlood().

Definition at line 115 of file g_main.c.

Referenced by G_CheckFlood().

Definition at line 116 of file g_main.c.

Referenced by G_CheckFlood().

Definition at line 113 of file g_main.c.

Referenced by G_ClientMove().

Definition at line 108 of file g_main.c.

Referenced by G_TestVis().

Definition at line 107 of file g_main.c.

Referenced by AI_Run().

Definition at line 109 of file g_main.c.

Referenced by G_TraceDraw().

Definition at line 110 of file g_main.c.

Referenced by G_Damage().

Definition at line 112 of file g_main.c.

Referenced by G_SetTeamForPlayer().

Definition at line 111 of file g_main.c.

Referenced by G_ClientMove().

Definition at line 106 of file g_main.c.

Referenced by G_ReactionFireCheckExecution().

Definition at line 34 of file g_main.c.

Referenced by AI_ActorThink(), AI_CheckForMissionTargets(), AI_CheckUsingDoor(), AI_CivilianCalcBestAction(), AI_CreatePlayer(), AI_FighterCalcBestAction(), AI_FindHerdLocation(), AI_FindHidingLocation(), AI_InitPlayer(), AI_PrepBestAction(), AI_SearchBestTarget(), AI_SetCharacterValues(), AI_SetEquipment(), AI_TryToReloadWeapon(), AI_TurnIntoDirection(), AIL_ActorThink(), AIL_canreload(), AIL_Init(), AIL_InitActor(), AIL_positionshoot(), AIL_print(), AIL_reload(), AIL_Shutdown(), AIL_toTeamInt(), AIL_toTeamString(), Destroy_Breakable(), Door_Use(), ED_ParseEdict(), FS_LoadPackFile(), G_Actor2x2Spawn(), G_ActorFall(), G_ActorInvMove(), G_ActorReload(), G_ActorSetMaxs(), G_ActorSpawn(), G_AddItemToFloor(), G_AppearPerishEvent(), G_BuildForbiddenList(), G_CenterView(), G_CharacterGetMaxExperiencePerMission(), G_CheckForceEndRound(), G_ClientAction(), G_ClientAssignDefaultActorValues(), G_ClientBegin(), G_ClientCanReload(), G_ClientCommand(), G_ClientConnect(), G_ClientDisconnect(), G_ClientEndRound(), G_ClientGetFreeSpawnPointForActorSize(), G_ClientGetWeaponFromInventory(), G_ClientInitActorStates(), G_ClientMove(), G_ClientPrintf(), G_ClientReadCharacter(), G_ClientReadInventory(), G_ClientSendEdictsAndBrushModels(), G_ClientShoot(), G_ClientSkipActorInfo(), G_ClientSpawn(), G_ClientStateChange(), G_ClientStateChangeUpdate(), G_ClientTeamInfo(), G_ClientTurn(), G_ClientUseEdict(), G_ClientUserinfoChanged(), G_Damage(), G_EdictAppear(), G_EdictCalcOrigin(), G_EdictSetOrigin(), G_EdictsGetByNum(), G_EventActorDie(), G_EventActorFall(), G_EventActorRevitalise(), G_EventActorSendReservations(), G_EventActorStats(), G_EventActorTurn(), G_EventDestroyEdict(), G_EventEndRound(), G_EventInventoryAdd(), G_EventInventoryAmmo(), G_EventInventoryDelete(), G_EventInventoryReload(), G_EventParticleSpawn(), G_EventPerish(), G_EventReactionFireChange(), G_EventResetClientAction(), G_EventSendEdict(), G_EventSetClientAction(), G_EventShoot(), G_EventShootHidden(), G_EventSpawnSound(), G_EventStartShoot(), G_EventThrow(), G_FireAffectedSurface(), G_FreeEdict(), G_GetObjectForFiredef(), G_GetShotOrigin(), G_GetTeam(), G_InventoryDropToFloorCheck(), G_InventoryRemoveItemByID(), G_InventoryToFloor(), G_MatchSendResults(), G_MissionThink(), G_MissionTouch(), G_MissionUse(), G_Morale(), G_MoraleBehaviour(), G_MoralePanic(), G_MoraleRage(), G_MoveCalcLocal(), G_PhysicsStep(), G_PhysicsThink(), G_PrepareShot(), G_PrintStats(), G_ReactionFireReset(), G_ReadItem(), G_RecalcRouting(), G_Say_f(), G_SendCharacterData(), G_SendInventory(), G_SendInvisible(), G_SendParticle(), G_SendState(), G_ServerCommand(), G_SetTeamForPlayer(), G_ShootGrenade(), G_ShootSingle(), G_Spawn(), G_SpawnAIPlayer(), G_SpawnEntities(), G_SpawnFloor(), G_SpawnItemOnFloor(), G_SplashDamage(), G_TestLine(), G_TestLineWithEnts(), G_TouchEdicts(), G_TouchSolids(), G_TouchTriggers(), G_Trace(), G_TriggerSpawn(), G_WriteItem(), pos3L_goto(), SP_civilian_target(), SP_func_breakable(), SP_func_door(), SP_func_rotating(), SP_misc_item(), SP_misc_message(), SP_misc_mission(), SP_misc_mission_aliens(), SP_misc_model(), SP_trigger_hurt(), SP_trigger_rescue(), SP_trigger_touch(), SP_worldspawn(), SVCmd_AddIP_f(), SVCmd_AI_Add_f(), SVCmd_ListIP_f(), SVCmd_RemoveIP_f(), SVCmd_Win_f(), SVCmd_WriteIP_f(), and Touch_TouchTrigger().

Definition at line 49 of file g_main.c.

FILE* logstatsfile

Definition at line 50 of file g_main.c.

Referenced by G_Init(), G_PrintStats(), and G_Shutdown().

Definition at line 104 of file g_main.c.

Referenced by G_MoraleStopPanic().

Definition at line 102 of file g_main.c.

Referenced by G_MoraleBehaviour().

Definition at line 103 of file g_main.c.

Referenced by G_MoraleStopRage().

Definition at line 101 of file g_main.c.

Referenced by G_MoraleBehaviour().

Definition at line 73 of file g_main.c.

Referenced by G_Morale().

Definition at line 74 of file g_main.c.

Referenced by G_Morale().

Definition at line 77 of file g_main.c.

Referenced by G_Morale().

Definition at line 78 of file g_main.c.

Referenced by G_Morale().

Definition at line 76 of file g_main.c.

Referenced by G_Morale().

Definition at line 75 of file g_main.c.

Referenced by G_Morale().

Definition at line 94 of file g_main.c.

Referenced by G_Morale().

Definition at line 91 of file g_main.c.

Referenced by G_Morale().

Definition at line 99 of file g_main.c.

Referenced by AI_HideNeeded().

Definition at line 82 of file g_main.c.

Referenced by G_Morale().

Definition at line 85 of file g_main.c.

Referenced by G_Morale().

Definition at line 79 of file g_main.c.

Referenced by G_Morale().

Definition at line 96 of file g_main.c.

Referenced by G_MoraleBehaviour().

Definition at line 97 of file g_main.c.

Referenced by G_MoraleBehaviour(), and G_ReactionFireIsPossible().

Definition at line 88 of file g_main.c.

Referenced by G_Morale().

Definition at line 37 of file g_main.c.

Referenced by G_ClientConnect().

Definition at line 58 of file g_main.c.

Referenced by AI_CreatePlayer().

Definition at line 43 of file g_main.c.

Referenced by G_IsMoraleEnabled(), and SP_worldspawn().

Definition at line 52 of file g_main.c.

Referenced by SV_FilterPacket(), and SVCmd_WriteIP_f().

Definition at line 61 of file g_main.c.

Referenced by G_SpawnEntities().

Definition at line 60 of file g_main.c.

Definition at line 45 of file g_main.c.

Definition at line 40 of file g_main.c.

Definition at line 42 of file g_main.c.

Referenced by SP_worldspawn().

Definition at line 41 of file g_main.c.

Referenced by G_ActorSpawnIsAllowed(), SP_player_start(), and SP_worldspawn().

Definition at line 56 of file g_main.c.

Referenced by G_GetTeam(), and SP_worldspawn().

Definition at line 39 of file g_main.c.

Definition at line 44 of file g_main.c.

Referenced by G_CheckForceEndRound().

Definition at line 62 of file g_main.c.

Referenced by G_ShootSingle().

Definition at line 59 of file g_main.c.

Referenced by G_ClientBegin(), G_ClientEndRound(), and G_GetTeam().


Generated by  doxygen 1.6.2