/** * @brief Resolve the reaction fire for an entity, this checks that the entity can fire and then takes the shot * @param[in] ent The entity to resolve reaction fire for * @return true if the entity fired (or would have fired if mock), false otherwise */ static qboolean G_ReactionFireTryToShoot (edict_t *ent) { qboolean tookShot; /* check whether this ent has a reaction fire queued */ assert(ent->reactionTarget); /* ent can't take a reaction shot if it's not possible - and check that * the target is still alive */ if (!G_ReactionFireIsPossible(ent, ent->reactionTarget)) { ent->reactionTarget = NULL; return qfalse; } /* take the shot */ tookShot = G_ReactionFireShoot(G_PLAYER_FROM_ENT(ent), ent, ent->reactionTarget->pos, ST_RIGHT_REACTION, ent->chr.RFmode.fmIdx); if (tookShot) { /* clear any shakenness */ G_RemoveShaken(ent); /* check whether further reaction fire is possible */ if (G_ReactionFireIsPossible(ent, ent->reactionTarget)){ /* see how quickly ent can fire (if it can fire at all) */ const int tus = G_ReactionFireGetTUsForItem(ent, ent->reactionTarget, RIGHT(ent)); if (tus >= 0) { /* An enemy getting reaction shot gets more time before * reaction fire is repeated. */ ent->reactionTUs = max(0, ent->reactionTarget->TU - tus); } } } return tookShot; }
/** * @brief Guess! Reset all "shaken" states on end of turn? * @note Normally called on end of turn. * @sa G_ClientStateChange * @param[in] team Index of team to loop through. */ void G_ReactionFireReset (int team) { Edict *ent = nullptr; while ((ent = G_EdictsGetNextLivingActorOfTeam(ent, team))) { G_RemoveShaken(ent); } }
/** * @brief Guess! Reset all "shaken" states on end of turn? * @note Normally called on end of turn. * @sa G_ClientStateChange * @param[in] team Index of team to loop through. */ void G_ReactionFireReset (int team) { edict_t *ent = NULL; while ((ent = G_EdictsGetNextLivingActorOfTeam(ent, team))) { /** @todo why do we send the state here and why do we change the "shaken" * state? - see G_MoraleBehaviour */ G_RemoveShaken(ent); G_EventActorStateChange(G_TeamToPM(ent->team), ent); } }
/** * @brief Resolve the reaction fire for an entity, this checks that the entity can fire and then takes the shot * @param[in] shooter The entity to resolve reaction fire for * @param[in] target The victim of the reaction fire * @return true if the entity fired (or would have fired if mock), false otherwise */ static bool G_ReactionFireTryToShoot (Edict *shooter, const Edict *target) { /* check for valid target */ assert(target); /* shooter can't take a reaction shot if it's not possible - and check that * the target is still alive */ if (!G_ReactionFireIsPossible(shooter, target)) { rft.remove(shooter, target); return false; } /* take the shot */ const bool tookShot = G_ReactionFireShoot(shooter, target->pos, ST_RIGHT_REACTION, shooter->chr.RFmode.getFmIdx()); if (tookShot) { /* clear any shakenness */ G_RemoveShaken(shooter); } return tookShot; }
/** * @brief Resolve the reaction fire for an entity, this checks that the entity can fire and then takes the shot * @param[in] shooter The entity to resolve reaction fire for * @param[in] target The victim of the reaction fire * @return true if the entity fired (or would have fired if mock), false otherwise */ static bool G_ReactionFireTryToShoot (edict_t *shooter, const edict_t *target) { bool tookShot; /* check for valid target */ assert(target); /* shooter can't take a reaction shot if it's not possible - and check that * the target is still alive */ if (!G_ReactionFireIsPossible(shooter, target)) { G_ReactionFireTargetsRemove(shooter, target); return false; } /* take the shot */ tookShot = G_ReactionFireShoot(G_PLAYER_FROM_ENT(shooter), shooter, target->pos, ST_RIGHT_REACTION, shooter->chr.RFmode.fmIdx); if (tookShot) { /* clear any shakenness */ G_RemoveShaken(shooter); } return tookShot; }