UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
g_events.h File Reference

Event related headers. More...

#include "g_vis.h"

Go to the source code of this file.

Macros

#define PM_ALL   0xFFFFFFFF
 
#define G_PlayerToPM(player)   ((player).getNum() < game.sv_maxplayersperteam ? 1 << ((player).getNum()) : 0)
 

Typedefs

typedef unsigned int playermask_t
 

Functions

void G_EventActorAdd (playermask_t playerMask, const Edict &ent, const bool instant=false)
 
void G_EventActorAppear (playermask_t playerMask, const Actor &check, const Edict *ent)
 
void G_EventActorDie (const Edict &ent, bool attacker)
 Announce the actor die event for the clients that are seeing the actor. More...
 
void G_EventActorFall (const Edict &ent)
 
void G_EventActorRevitalise (const Edict &ent)
 Announce the actor revitalize event for the clients that are seeing the actor. More...
 
void G_EventActorSendReservations (const Edict &ent)
 Will inform the player about the real TU reservation. More...
 
void G_EventActorStateChange (playermask_t playerMask, const Edict &ent)
 
void G_EventActorStats (const Edict &ent, playermask_t playerMask)
 
void G_EventActorTurn (const Edict &ent)
 Send the turn event for the given entity. More...
 
void G_EventAddBrushModel (playermask_t playerMask, const Edict &ent)
 
void G_EventCenterView (const Edict &ent)
 Centers the view for all clients that are seeing the given edict on the world position of the edict. More...
 
void G_EventCenterViewAt (playermask_t playerMask, const pos3_t pos)
 Centers the view for all clients that are seeing the given edict on the world position of the edict. More...
 
void G_EventMoveCameraTo (playermask_t playerMask, const pos3_t pos)
 Centers the view for all clients that are seeing the given edict on the world position of the edict. More...
 
void G_EventDoorClose (const Edict &door)
 
void G_EventDoorOpen (const Edict &door)
 
void G_EventDestroyEdict (const Edict &ent)
 Unregister an edict at the client. More...
 
void G_EventEdictAppear (playermask_t playerMask, const Edict &ent)
 Send an appear event to the client. More...
 
void G_EventEdictPerish (playermask_t playerMask, const Edict &ent)
 Send disappear event. More...
 
void G_EventCameraAppear (playermask_t playerMask, const Edict &ent)
 Send an appear event to the client. More...
 
void G_EventEndRound (void)
 End of turn event for the current active team. More...
 
void G_EventEndRoundAnnounce (const Player &player)
 
void G_EventInventoryAdd (const Edict &ent, playermask_t playerMask, int itemAmount)
 Tell the client to add the item from the container. More...
 
void G_EventInventoryAmmo (const Edict &ent, const objDef_t *ammo, int amount, shoot_types_t shootType)
 Change the amount of available ammo for the given entity. More...
 
void G_EventInventoryDelete (const Edict &ent, playermask_t playerMask, const containerIndex_t containerId, int x, int y)
 Tell the client to remove the item from the container. More...
 
void G_EventInventoryReload (const Edict &ent, playermask_t playerMask, const Item *item, const invDef_t *invDef, const Item *ic)
 
void G_EventModelExplodeTriggered (const Edict &ent, const char *sound)
 
void G_EventModelExplode (const Edict &ent, const char *sound)
 
void G_EventParticleSpawn (playermask_t playerMask, const char *name, int levelFlags, const vec3_t s, const vec3_t v, const vec3_t a)
 Spawn a new particle for the client. More...
 
void G_EventPerish (const Edict &ent)
 Send an event to all clients that are seeing the given edict, that it just has disappeared. More...
 
void G_EventReactionFireChange (const Edict &ent)
 
void G_EventReset (const Player &player, int activeTeam)
 
void G_EventResetClientAction (const Edict &ent)
 Reset the client actions for the given entity. More...
 
void G_EventSendEdict (const Edict &ent)
 Send the bounding box info to the client. More...
 
void G_EventSendParticle (playermask_t playerMask, const Edict &ent)
 
void G_EventSendState (playermask_t playerMask, const Edict &ent)
 
void G_EventSetClientAction (const Edict &ent)
 Informs the client that an interaction with the world is possible. More...
 
void G_EventShootHidden (teammask_t teamMask, const fireDef_t *fd, bool firstShoot, const vec3_t impact, int flags, const Edict *targetEdict)
 Start the shooting event for hidden actors. More...
 
void G_EventShoot (const Edict &ent, teammask_t teamMask, const fireDef_t *fd, bool firstShoot, shoot_types_t shootType, int flags, const trace_t *trace, const vec3_t from, const vec3_t impact)
 Do the shooting. More...
 
void G_EventSpawnSound (playermask_t playerMask, const Edict &ent, const vec3_t origin, const char *sound)
 Spawns a sound (that will be spatialized on the client side) More...
 
void G_EventSpawnFootstepSound (const Edict &ent, const char *sound)
 
void G_EventStart (const Player &player, bool teamplay)
 
void G_EventStartShoot (const Edict &ent, teammask_t teamMask, shoot_types_t shootType, const pos3_t at)
 Start the shooting event. More...
 
void G_EventEndShoot (const Edict &ent, teammask_t teamMask)
 Ends the shooting event. More...
 
void G_EventThrow (teammask_t teamMask, const fireDef_t *fd, float dt, byte flags, const vec3_t position, const vec3_t velocity)
 
void G_EventAdd (playermask_t playerMask, int eType, int entnum)
 
void G_EventEnd (void)
 
void G_EventActorWound (const Edict &ent, const int bodyPart)
 Send info about an actor's wounds to the client. More...
 
void G_EventReactionFireAddTarget (const Edict &shooter, const Edict &target, int tusG_EventReactionFireAddTarget, int step)
 
void G_EventReactionFireRemoveTarget (const Edict &shooter, const Edict &target, int step)
 
void G_EventReactionFireTargetUpdate (const Edict &shooter, const Edict &target, int tus, int step)
 
void G_EventReactionFireAbortShot (const Edict &shooter, const Edict &target, int step)
 

Detailed Description

Event related headers.

Definition in file g_events.h.

Macro Definition Documentation

Typedef Documentation

typedef unsigned int playermask_t

Definition at line 34 of file g_events.h.

Function Documentation

void G_EventActorDie ( const Edict ent,
bool  attacker 
)

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

Parameters
[in]entThe actor that is dying
[in]attackerWhether the actor was killed or just died

Definition at line 89 of file g_events.cpp.

References EV_ACTOR_DIE, G_EventAdd(), G_EventEnd(), G_VisToPM(), Edict::getIdNum(), Edict::getPlayerNum(), gi, Edict::state, and Edict::visflags.

Referenced by G_ActorDieOrStun().

void G_EventActorFall ( const Edict ent)
void G_EventActorRevitalise ( const Edict ent)

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

Parameters
[in]entThe actor that was healed and woke up again

Definition at line 102 of file g_events.cpp.

References EV_ACTOR_REVITALISED, G_EventAdd(), G_EventEnd(), G_VisToPM(), Edict::getIdNum(), gi, Edict::state, and Edict::visflags.

Referenced by G_ActorCheckRevitalise().

void G_EventActorSendReservations ( const Edict ent)

Will inform the player about the real TU reservation.

Parameters
entThe actors edict.

Definition at line 113 of file g_events.cpp.

References Edict::chr, EV_ACTOR_RESERVATIONCHANGE, G_EventAdd(), G_EventEnd(), G_PlayerToPM, Edict::getIdNum(), Edict::getPlayer(), gi, and character_s::reservedTus.

Referenced by G_ActorReserveTUs().

void G_EventActorStateChange ( playermask_t  playerMask,
const Edict ent 
)
void G_EventActorStats ( const Edict ent,
playermask_t  playerMask 
)
void G_EventActorTurn ( const Edict ent)

Send the turn event for the given entity.

Parameters
entThe 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 77 of file g_events.cpp.

References Edict::dir, EV_ACTOR_TURN, G_EventAdd(), G_EventEnd(), G_VisToPM(), Edict::getIdNum(), gi, and Edict::visflags.

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

void G_EventActorWound ( const Edict ent,
const int  bodyPart 
)

Send info about an actor's wounds to the client.

Parameters
[in]entThe actor whose wound status we are sending.
[in]bodyPartThe body part index we are sending wound info about.
Note
This event is sent to the player this actor belongs to

Definition at line 399 of file g_events.cpp.

References Edict::chr, EV_ACTOR_WOUND, G_EventAdd(), G_EventEnd(), G_PlayerToPM, Edict::getIdNum(), Edict::getPlayer(), gi, woundInfo_s::treatmentLevel, woundInfo_s::woundLevel, and character_s::wounds.

Referenced by G_SendWoundStats().

void G_EventCameraAppear ( playermask_t  playerMask,
const Edict ent 
)

Send an appear event to the client.

Parameters
playerMaskThe players to send the event to
entThe camera that should appear to the players included in the given mask.

Definition at line 543 of file g_events.cpp.

References Edict::camera, camera_edict_data_s::cameraType, Edict::dir, EV_CAMERA_APPEAR, G_EventAdd(), G_EventEnd(), Edict::getIdNum(), Edict::getTeam(), gi, Edict::origin, camera_edict_data_s::rotate, and Edict::spawnflags.

Referenced by G_AppearPerishEvent().

void G_EventCenterView ( const Edict ent)

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

Parameters
[in]entThe edict to use the position from

Definition at line 479 of file g_events.cpp.

References G_EventCenterViewAt(), G_VisToPM(), Edict::pos, and Edict::visflags.

Referenced by G_MoralePanic().

void G_EventCenterViewAt ( playermask_t  playerMask,
const pos3_t  pos 
)

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

Parameters
playerMaskThe clients that should see the edict
posThe position to center the view

Definition at line 489 of file g_events.cpp.

References EV_CENTERVIEW, G_EventAdd(), G_EventEnd(), and gi.

Referenced by G_EventCenterView(), and Think_NextMapTrigger().

void G_EventDestroyEdict ( const Edict ent)

Unregister an edict at the client.

Parameters
entThe edict to unregister

Definition at line 167 of file g_events.cpp.

References EV_ENT_DESTROY, G_EventAdd(), G_EventEnd(), Edict::getIdNum(), Edict::inuse, and PM_ALL.

Referenced by G_FreeEdict().

void G_EventDoorClose ( const Edict door)

Definition at line 683 of file g_events.cpp.

References EV_DOOR_CLOSE, G_EventAdd(), G_EventEnd(), Edict::getIdNum(), and PM_ALL.

Referenced by Door_Use().

void G_EventDoorOpen ( const Edict door)

Definition at line 677 of file g_events.cpp.

References EV_DOOR_OPEN, G_EventAdd(), G_EventEnd(), Edict::getIdNum(), and PM_ALL.

Referenced by Door_Use().

void G_EventEdictAppear ( playermask_t  playerMask,
const Edict ent 
)

Send an appear event to the client.

Parameters
playerMaskThe players to send the event to
entThe edict that should appear to the players included in the given mask.
Note
Each following event that is relying on the fact that this edict must already be known in the client, must also adopt the client side parsing of the event times.

Definition at line 563 of file g_events.cpp.

References EV_ENT_APPEAR, G_EventAdd(), G_EventEnd(), Edict::getIdNum(), gi, Edict::pos, and Edict::type.

Referenced by G_AppearPerishEvent().

void G_EventEdictPerish ( playermask_t  playerMask,
const Edict ent 
)

Send disappear event.

Parameters
[in]playerMaskThe bitmask to determine the clients this event is send to
[in,out]entThe edict that perished

Definition at line 624 of file g_events.cpp.

References EV_ENT_PERISH, G_EventAdd(), G_EventEnd(), Edict::getIdNum(), gi, Edict::inuse, and Edict::type.

Referenced by G_AppearPerishEvent(), G_EventPerish(), and Think_SmokeAndFire().

void G_EventEndRound ( void  )

End of turn event for the current active team.

Note
This event is send to every connected client

Definition at line 414 of file g_events.cpp.

References level_locals_s::activeTeam, EV_ENDROUND, G_EventAdd(), G_EventEnd(), gi, level, and PM_ALL.

Referenced by G_ClientEndRound().

void G_EventEndRoundAnnounce ( const Player &  player)

Definition at line 654 of file g_events.cpp.

References EV_ENDROUNDANNOUNCE, G_EventAdd(), G_EventEnd(), gi, and PM_ALL.

Referenced by G_ClientEndRound().

void G_EventEndShoot ( const Edict ent,
teammask_t  teamMask 
)

Ends the shooting event.

Parameters
entThe entity that starts the shooting
teamMaskthe vis mask of the teams to determine the clients from this event is send to

Definition at line 217 of file g_events.cpp.

References EV_ACTOR_END_SHOOT, G_EventAdd(), G_EventEnd(), G_VisToPM(), and Edict::getIdNum().

Referenced by G_ClientShoot().

void G_EventInventoryAdd ( const Edict ent,
playermask_t  playerMask,
int  itemAmount 
)

Tell the client to add the item from the container.

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

Definition at line 147 of file g_events.cpp.

References EV_INV_ADD, G_EventAdd(), Edict::getIdNum(), and gi.

Referenced by G_ActorInvMove(), and G_SendInventory().

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

Change the amount of available ammo for the given entity.

Parameters
entThe entity to change the amount of ammo for
ammoThe ammo to change
amountThe new amount of the left ammo
shootTypeThe shooting type to determine which container to use

Definition at line 181 of file g_events.cpp.

References CID_LEFT, CID_RIGHT, EV_INV_AMMO, G_EventAdd(), G_EventEnd(), G_VisToPM(), Edict::getIdNum(), gi, objDef_s::idx, IS_SHOT_RIGHT, and Edict::visflags.

Referenced by G_ClientShoot().

void G_EventInventoryDelete ( const Edict ent,
playermask_t  playerMask,
const containerIndex_t  containerId,
int  x,
int  y 
)

Tell the client to remove the item from the container.

Parameters
[in]entPointer to entity having given inventory.
[in]playerMaskThe player mask to determine which clients should receive the event (e.g. G_VisToPM(ent->visflags))
[in]containerIdId of the container the item is in.
[in]x,yPosition of item in container.

Definition at line 131 of file g_events.cpp.

References EV_INV_DEL, G_EventAdd(), G_EventEnd(), Edict::getIdNum(), and gi.

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

void G_EventInventoryReload ( const Edict ent,
playermask_t  playerMask,
const Item item,
const invDef_t invDef,
const Item ic 
)
void G_EventModelExplode ( const Edict ent,
const char *  sound 
)

Definition at line 697 of file g_events.cpp.

References EV_MODEL_EXPLODE, G_EventAdd(), G_EventEnd(), Edict::getIdNum(), gi, Edict::inuse, and PM_ALL.

Referenced by Destroy_Breakable().

void G_EventModelExplodeTriggered ( const Edict ent,
const char *  sound 
)
void G_EventMoveCameraTo ( playermask_t  playerMask,
const pos3_t  pos 
)

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

Parameters
[in]playerMaskThe clients that should see the edict
[in]posThe position to center the view

Definition at line 501 of file g_events.cpp.

References EV_MOVECAMERA, G_EventAdd(), G_EventEnd(), and gi.

Referenced by G_ClientMove().

void G_EventParticleSpawn ( playermask_t  playerMask,
const char *  name,
int  levelFlags,
const vec3_t  s,
const vec3_t  v,
const vec3_t  a 
)

Spawn a new particle for the client.

Parameters
[in]playerMaskA bit mask. One bit for each affected player
[in]nameThe id of the particle (see ptl_*.ufo script files in base/ufos)
[in]levelFlagsShow at which levels
[in]sstarting/location vector
[in]vvelocity vector
[in]aacceleration vector

Definition at line 334 of file g_events.cpp.

References EV_PARTICLE_SPAWN, G_EventAdd(), G_EventEnd(), and gi.

Referenced by G_TraceDraw().

void G_EventPerish ( const Edict ent)

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

Parameters
entThe edict that disappeared

Definition at line 158 of file g_events.cpp.

References G_EventEdictPerish(), G_VisToPM(), and Edict::visflags.

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

void G_EventReactionFireAbortShot ( const Edict shooter,
const Edict target,
int  step 
)
void G_EventReactionFireAddTarget ( const Edict shooter,
const Edict target,
int  tusG_EventReactionFireAddTarget,
int  step 
)
void G_EventReactionFireRemoveTarget ( const Edict shooter,
const Edict target,
int  step 
)
void G_EventReactionFireTargetUpdate ( const Edict shooter,
const Edict target,
int  tus,
int  step 
)
void G_EventReset ( const Player &  player,
int  activeTeam 
)

Definition at line 669 of file g_events.cpp.

References EV_RESET, EVENT_INSTANTLY, G_EventAdd(), G_EventEnd(), G_PlayerToPM, and gi.

Referenced by G_ClientStartMatch().

void G_EventResetClientAction ( const Edict ent)

Reset the client actions for the given entity.

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

Definition at line 376 of file g_events.cpp.

References EV_RESET_CLIENT_ACTION, G_EventAdd(), G_EventEnd(), G_PlayerToPM, Edict::getIdNum(), and Edict::getPlayer().

Referenced by G_ActorSetClientAction().

void G_EventSendEdict ( const Edict ent)

Send the bounding box info to the client.

Parameters
[in]entThe edict to send the bounding box for

Definition at line 457 of file g_events.cpp.

References Edict::absBox, EV_ADD_EDICT, G_EventAdd(), G_EventEnd(), Edict::getIdNum(), gi, AABB::maxs, AABB::mins, PM_ALL, and Edict::type.

Referenced by G_SendBoundingBoxes().

void G_EventSendParticle ( playermask_t  playerMask,
const Edict ent 
)

Send a particle spawn event to the client

Parameters
[in]playerMaskThe clients that should see the particle
[in]entThe particle to spawn

Definition at line 529 of file g_events.cpp.

References EV_PARTICLE_APPEAR, G_EventAdd(), G_EventEnd(), Edict::getIdNum(), gi, Edict::origin, Edict::particle, and Edict::spawnflags.

Referenced by G_AppearPerishEvent().

void G_EventSetClientAction ( const Edict ent)

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

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

Definition at line 360 of file g_events.cpp.

References Edict::clientAction, EV_CLIENT_ACTION, FL_CLIENTACTION, Edict::flags, G_EventAdd(), G_EventEnd(), G_TeamToPM(), Edict::getIdNum(), Edict::getTeam(), and gi.

Referenced by G_ActorSetClientAction().

void G_EventShoot ( const Edict ent,
teammask_t  teamMask,
const fireDef_t fd,
bool  firstShoot,
shoot_types_t  shootType,
int  flags,
const trace_t trace,
const vec3_t  from,
const vec3_t  impact 
)

Do the shooting.

Parameters
entThe entity that is doing the shooting
teamMaskthe vis mask to determine the clients from this event is send to
fdThe firedefinition to use for the shoot
firstShootIs this the first shoot
shootTypeThe type of the shoot
flagsDefine some flags in a bitmask: SF_BODY, SF_IMPACT, SF_BOUNCING and SF_BOUNCED
traceThe trace what was used to determine whether this shot has hit something
fromThe position the entity shoots from
impactThe impact world vector for the shot

Definition at line 260 of file g_events.cpp.

References trace_s::contentFlags, trace_s::entNum, EV_ACTOR_SHOOT, fireDef_s::fdIdx, G_EdictsGetByNum(), G_EventAdd(), G_EventEnd(), G_IsBreakable, G_VisToPM(), Edict::getIdNum(), gi, objDef_s::idx, fireDef_s::obj, trace_s::plane, SKIP_LOCAL_ENTITY, and fireDef_s::weapFdsIdx.

Referenced by G_ShootSingle().

void G_EventShootHidden ( teammask_t  teamMask,
const fireDef_t fd,
bool  firstShoot,
const vec3_t  impact,
int  flags,
const Edict targetEdict 
)

Start the shooting event for hidden actors.

Parameters
teamMaskthe vis mask to determine the clients from this event is send to
fdThe firedefinition to use for the shoot
firstShootIs this the first shoot
impactImpact position
flagsImpact (sound) flags
targetEdictTarget of the shot

Definition at line 232 of file g_events.cpp.

References EV_ACTOR_SHOOT_HIDDEN, fireDef_s::fdIdx, G_EventAdd(), G_EventEnd(), G_IsBreakable, G_VisToPM(), Edict::getIdNum(), gi, objDef_s::idx, fireDef_s::obj, SKIP_LOCAL_ENTITY, and fireDef_s::weapFdsIdx.

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

void G_EventSpawnFootstepSound ( const Edict ent,
const char *  sound 
)
void G_EventSpawnSound ( playermask_t  playerMask,
const Edict ent,
const vec3_t  origin,
const char *  sound 
)

Spawns a sound (that will be spatialized on the client side)

Parameters
playerMaskA bit mask. One bit for each affected player
entThe edict that is causing the sound
originThe origin of the sound
soundThe sound file, path relative to sounds/. If there is a + at the end the client will choose a random sound. See the event function for more information. of the path, a random sound will be taken.

Definition at line 40 of file g_events.cpp.

References Edict::entBox, EV_SOUND, G_EventAdd(), G_EventEnd(), AABB::getCenter(), Edict::getIdNum(), gi, Edict::origin, Edict::solid, SOLID_BSP, vec3_origin, and VectorAdd.

Referenced by Door_Use(), G_SplashDamage(), and Touch_HurtTrigger().

void G_EventStart ( const Player &  player,
bool  teamplay 
)

Definition at line 662 of file g_events.cpp.

References EV_START, EVENT_INSTANTLY, G_EventAdd(), G_EventEnd(), G_PlayerToPM, and gi.

Referenced by G_ClientBegin().

void G_EventStartShoot ( const Edict ent,
teammask_t  teamMask,
shoot_types_t  shootType,
const pos3_t  at 
)

Start the shooting event.

Parameters
entThe entity that starts the shooting
teamMaskthe vis mask of the teams to determine the clients from this event is send to
shootTypeThe type of the shoot
atThe grid position to target to

Definition at line 203 of file g_events.cpp.

References EV_ACTOR_START_SHOOT, G_EventAdd(), G_EventEnd(), G_VisToPM(), Edict::getIdNum(), gi, and Edict::pos.

Referenced by G_ClientShoot().

void G_EventThrow ( teammask_t  teamMask,
const fireDef_t fd,
float  dt,
byte  flags,
const vec3_t  position,
const vec3_t  velocity 
)
Parameters
[in]teamMaskthe vis mask to determine the clients from this event is send to
[in]fdThe firedefinition to use
[in]dtDelta time
[in]flagsbitmask of the following values: SF_BODY, SF_IMPACT, SF_BOUNCING and SF_BOUNCED
[in]positionThe current position
[in]velocityThe velocity of the throw

Definition at line 440 of file g_events.cpp.

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

Referenced by G_ShootGrenade().