Reaction fire code. More...
#include "g_local.h"
Go to the source code of this file.
Functions | |
static int | G_ReactionFireGetTUsForItem (const edict_t *ent, const edict_t *target, const invList_t *invList) |
Get the weapon firing TUs of the item in the right hand of the edict. | |
static qboolean | G_ActorHasReactionFireEnabledWeapon (const edict_t *ent) |
Checks whether the actor has a reaction fire enabled weapon in on of his hands. | |
static qboolean | G_ActorHasWorkingFireModeSet (const edict_t *actor) |
Checks if the currently selected firemode is usable with the defined weapon. | |
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. | |
static qboolean | G_ActorHasEnoughTUsReactionFire (const edict_t *ent) |
Checks whether an actor has enough TUs left to activate reaction fire. | |
qboolean | G_ReactionFireSetDefault (edict_t *ent) |
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. | |
static qboolean | G_ReactionFireIsPossible (const edict_t *ent, const edict_t *target) |
Check whether ent can reaction fire at target, i.e. that it can see it and neither is dead etc. | |
static void | G_ReactionFireSearchTarget (const edict_t *target) |
Check whether 'target' has just triggered any new reaction fire. | |
static qboolean | G_ReactionFireShoot (const player_t *player, edict_t *shooter, const pos3_t at, shoot_types_t type, fireDefIndex_t firemode) |
Perform the reaction fire shot. | |
static qboolean | G_ReactionFireTryToShoot (edict_t *ent) |
Resolve the reaction fire for an entity, this checks that the entity can fire and then takes the shot. | |
static qboolean | G_ReactionFireCheckExecution (const edict_t *target) |
Check all entities to see whether target has caused reaction fire to resolve. | |
qboolean | G_ReactionFireOnMovement (edict_t *target) |
Called when 'target' moves, possibly triggering or resolving reaction fire. | |
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_ReactionFireEndTurn (void) |
Called at the end of turn, all outstanding reaction fire is resolved. | |
void | G_ReactionFireReset (int team) |
Guess! Reset all "shaken" states on end of turn? |
Reaction fire code.
Definition in file g_reaction.c.
Checks whether an actor has enough TUs left to activate reaction fire.
ent | The actors edict to check for TUs for |
true
if the given actor has enough TUs left to activate reaction fire, false
otherwise. Definition at line 123 of file g_reaction.c.
References edict_s::chr, chrReservations_s::crouch, G_ActorGetTUForReactionFire(), character_s::reservedTus, chrReservations_s::shot, and edict_s::TU.
Referenced by G_ReactionFireCanBeEnabled().
Checks whether the actor has a reaction fire enabled weapon in on of his hands.
[in] | ent | The actor to check the weapons for |
NULL
if no actor has not reaction fire enabled weapons, the fire definition otherwise. Definition at line 61 of file g_reaction.c.
References INVSH_HasReactionFireEnabledWeapon(), LEFT, qtrue, and RIGHT.
Referenced by G_ReactionFireCanBeEnabled().
Checks if the currently selected firemode is usable with the defined weapon.
[in] | actor | The actor to check the firemode for. |
Definition at line 73 of file g_reaction.c.
References ACTOR_GET_INV, edict_s::chr, FIRESH_FiredefForWeapon(), chrFiremodeSettings_s::fmIdx, chrFiremodeSettings_s::hand, invList_s::item, objDef_s::numFiredefs, fireDef_s::obj, qfalse, qtrue, character_s::RFmode, SANE_FIREMODE, fireDef_s::weapFdsIdx, chrFiremodeSettings_s::weapon, and objDef_s::weapons.
Referenced by G_ReactionFireCanBeEnabled(), G_ReactionFireSetDefault(), and G_ReactionFireUpdate().
Checks whether the actor is allowed to activate reaction fire and will informs the player about the reason if this would not work.
ent | The actor to check |
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().
Check all entities to see whether target has caused reaction fire to resolve.
[in] | target | The entity that might be resolving reaction fire |
Definition at line 385 of file g_reaction.c.
References G_EdictsGetNextLivingActor(), g_reaction_fair, G_ReactionFireTryToShoot(), cvar_s::integer, qfalse, edict_s::reactionTarget, edict_s::reactionTUs, and edict_s::TU.
Referenced by G_ReactionFireOnMovement(), and G_ReactionFirePostShot().
void G_ReactionFireEndTurn | ( | void | ) |
Called at the end of turn, all outstanding reaction fire is resolved.
Definition at line 480 of file g_reaction.c.
References G_EdictsGetNextLivingActor(), G_ReactionFireTryToShoot(), and edict_s::reactionTarget.
Referenced by G_ClientEndRound().
static int G_ReactionFireGetTUsForItem | ( | const edict_t * | ent, | |
const edict_t * | target, | |||
const invList_t * | invList | |||
) | [static] |
Get the weapon firing TUs of the item in the right hand of the edict.
Definition at line 33 of file g_reaction.c.
References item_s::a, ACTOR_HAND_RIGHT, edict_s::chr, FIRESH_FiredefForWeapon(), chrFiremodeSettings_s::fmIdx, G_PLAYER_FROM_ENT, chrFiremodeSettings_s::hand, invList_s::item, item_s::m, MAX_FIREDEFS_PER_WEAPON, edict_s::origin, objDef_s::reload, character_s::RFmode, item_s::t, fireDef_s::time, VectorDist, and objDef_s::weapon.
Referenced by G_ReactionFirePreShot(), G_ReactionFireSearchTarget(), and G_ReactionFireTryToShoot().
Check whether ent can reaction fire at target, i.e. that it can see it and neither is dead etc.
[in] | ent | The entity that might be firing |
[in] | target | The entity that might be fired at |
true
if 'ent' can actually fire at 'target', false
otherwise Definition at line 207 of file g_reaction.c.
References level_locals_t::activeTeam, frand(), G_ActorVis(), G_FrustumVis(), G_IsCivilian, G_IsDazed, G_IsDead, G_IsShaken, G_IsVisibleForTeam, level, MAX_SPOT_DIST, mor_shaken, edict_s::morale, edict_s::origin, qfalse, qtrue, edict_s::state, STATE_REACTION, edict_s::team, cvar_s::value, and VectorDistSqr.
Referenced by G_ReactionFireSearchTarget(), and G_ReactionFireTryToShoot().
Called when 'target' moves, possibly triggering or resolving reaction fire.
[in] | target | The target entity |
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).
[in] | target | The entity that has just fired |
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.
[in] | target | The entity about to shoot |
[in] | fdTime | The TU of the shoot |
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?
[in] | team | Index of team to loop through. |
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().
static void G_ReactionFireSearchTarget | ( | const edict_t * | target | ) | [static] |
Check whether 'target' has just triggered any new reaction fire.
[in] | target | The entity triggering fire |
Definition at line 263 of file g_reaction.c.
References G_EdictsGetNextLivingActor(), G_ReactionFireGetTUsForItem(), G_ReactionFireIsPossible(), qfalse, edict_s::reactionNoDraw, edict_s::reactionTarget, edict_s::reactionTUs, RIGHT, and edict_s::TU.
Referenced by G_ReactionFireOnMovement(), and G_ReactionFirePreShot().
ent | The actor to set the reaction fire for |
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().
static qboolean G_ReactionFireShoot | ( | const player_t * | player, | |
edict_t * | shooter, | |||
const pos3_t | at, | |||
shoot_types_t | type, | |||
fireDefIndex_t | firemode | |||
) | [static] |
Perform the reaction fire shot.
[in] | player | The player this action belongs to (the human player or the ai) |
[in] | shooter | The actor that is trying to shoot |
[in] | at | Position to fire on. |
[in] | type | What type of shot this is (left, right reaction-left etc...). |
[in] | firemode | The firemode index of the ammo for the used weapon (objDef.fd[][x]) . |
Definition at line 304 of file g_reaction.c.
References shot_mock_t::civilian, shot_mock_t::friendCount, G_ClientShoot(), G_IsAlien, G_IsInsane, G_IsPaniced, G_IsRaged, G_IsShaken, i, and qfalse.
Referenced by G_ReactionFireTryToShoot().
Resolve the reaction fire for an entity, this checks that the entity can fire and then takes the shot.
[in] | ent | The entity to resolve reaction fire for |
Definition at line 342 of file g_reaction.c.
References edict_s::chr, chrFiremodeSettings_s::fmIdx, G_PLAYER_FROM_ENT, G_ReactionFireGetTUsForItem(), G_ReactionFireIsPossible(), G_ReactionFireShoot(), G_RemoveShaken, edict_s::pos, qfalse, edict_s::reactionTarget, edict_s::reactionTUs, character_s::RFmode, RIGHT, ST_RIGHT_REACTION, and edict_s::TU.
Referenced by G_ReactionFireCheckExecution(), G_ReactionFireEndTurn(), and G_ReactionFirePreShot().
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.
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().