g_actor.c File Reference

#include "g_local.h"
Include dependency graph for g_actor.c:

Go to the source code of this file.

Functions

qboolean G_IsLivingActor (const edict_t *ent)
 Checks whether the given edict is a living actor.
void G_ActorUseDoor (edict_t *actor, edict_t *door)
 Make the actor use (as in open/close) a door 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_ActorSetClientAction (edict_t *actor, edict_t *ent)
 Handles the client actions (interaction with the world).
int G_ActorGetReservedTUs (const edict_t *ent)
 Calculates the amount of all currently reserved TUs.
int G_ActorUsableTUs (const edict_t *ent)
 Calculates the amount of usable TUs. This is without the reserved TUs.
int G_ActorGetTUForReactionFire (const edict_t *ent)
 Calculates the amount of TUs that are needed for the current selected reaction fire mode.
void G_ActorReserveTUs (edict_t *ent, int resReaction, int resShot, int resCrouch)
 Reserves TUs for different actor actions.
edict_tG_ActorGetByUCN (const int ucn, const int team)
 Searches an actor by a unique character number.
int G_ActorDoTurn (edict_t *ent, byte dir)
 Turns an actor around.
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)
static void G_ActorStun (edict_t *ent, const edict_t *attacker)
static void G_ActorRevitalise (edict_t *ent)
void G_ActorCheckRevitalise (edict_t *ent)
static void G_ActorDie (edict_t *ent, const edict_t *attacker)
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_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_ActorReload (edict_t *ent, const invDef_t *invDef)
 Reload weapon with actor.

Detailed Description

Definition in file g_actor.c.


Function Documentation

void G_ActorCheckRevitalise ( edict_t ent  ) 
static void G_ActorDie ( edict_t ent,
const edict_t attacker 
) [static]
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().

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().

static void G_ActorRevitalise ( edict_t ent  )  [static]

Todo:
have a look at the morale value of the ent and maybe get into rage or panic?

Definition at line 308 of file g_actor.c.

References G_ActorSetMaxs(), G_CheckVis(), G_CheckVisTeamAll(), G_GetFloorItems(), G_IsStunned, G_RemoveStunned, level, level_locals_t::num_alive, qfalse, qtrue, and edict_s::team.

Referenced by G_ActorCheckRevitalise().

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 
)
static void G_ActorStun ( edict_t ent,
const edict_t attacker 
) [static]

Definition at line 300 of file g_actor.c.

References level, level_locals_t::num_stuns, edict_s::state, STATE_STUN, and edict_s::team.

Referenced by G_ActorDieOrStun().

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().

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().


Generated by  doxygen 1.6.2