/** * @param ent The actor to set the reaction fire for * @return @c true if the needed settings could have been made or settings are * already valid, @c false otherwise. */ static bool G_ReactionFireSettingsSetDefault (Edict* ent) { if (G_ActorHasWorkingFireModeSet(ent)) return true; actorHands_t hand = ACTOR_HAND_RIGHT; const Item* item = ent->getHandItem(hand); if (!item) { hand = ACTOR_HAND_LEFT; item = ent->getHandItem(hand); } if (!item) return false; const objDef_t* weapon = item->getReactionFireWeaponType(); if (!weapon) return false; ent->chr.RFmode.set(hand, 0, weapon); /* no special firemode */ if (!G_ActorHasWorkingFireModeSet(ent)) return false; if (!G_IsAI(ent)) G_EventReactionFireChange(*ent); return true; }
/** * @param ent The actor to set the reaction fire for * @return @c true if the needed settings could have been made or settings are * already valid, @c false otherwise. */ static bool G_ReactionFireSetDefault (edict_t *ent) { if (G_ActorHasWorkingFireModeSet(ent)) return true; actorHands_t hand = ACTOR_HAND_RIGHT; const invList_t *invList = ACTOR_GET_INV(ent, hand); if (!invList) { hand = ACTOR_HAND_LEFT; invList = ACTOR_GET_INV(ent, hand); } const objDef_t *weapon = INVSH_HasReactionFireEnabledWeapon(invList); if (!weapon) return false; ent->chr.RFmode.set(hand, 0, weapon); /* no special firemode */ if (!G_ActorHasWorkingFireModeSet(ent)) return false; if (!G_IsAI(ent)) G_EventReactionFireChange(ent); return true; }
/** * @brief Checks whether the actor is allowed to activate reaction fire and will informs the player about * the reason if this would not work. * @param[in] ent The actor to check * @return @c true if the actor is allowed to activate it, @c false otherwise */ static bool G_ReactionFireCanBeEnabled (const edict_t *ent) { /* check ent is a suitable shooter */ if (!ent->inuse || !G_IsLivingActor(ent)) return false; if (G_MatchIsRunning() && ent->team != level.activeTeam) return false; /* actor may not carry weapons at all - so no further checking is needed */ if (!ent->chr.teamDef->weapons) return false; if (!G_ActorHasReactionFireEnabledWeapon(ent)) { G_ClientPrintf(G_PLAYER_FROM_ENT(ent), PRINT_HUD, _("No reaction fire enabled weapon.")); return false; } if (!G_ActorHasWorkingFireModeSet(ent)) { G_ClientPrintf(G_PLAYER_FROM_ENT(ent), PRINT_HUD, _("No fire mode selected for reaction fire.")); return false; } if (!G_ActorHasEnoughTUsReactionFire(ent)) { G_ClientPrintf(G_PLAYER_FROM_ENT(ent), PRINT_HUD, _("Not enough TUs left for activating reaction fire.")); return false; } return true; }
/** * @param ent The actor to set the reaction fire for * @return @c true if the needed settings could have been made or settings are * already valid, @c false otherwise. */ static bool G_ReactionFireSetDefault (edict_t *ent) { const objDef_t *weapon; const invList_t *invList; actorHands_t hand = ACTOR_HAND_RIGHT; if (G_ActorHasWorkingFireModeSet(ent)) return true; invList = ACTOR_GET_INV(ent, hand); if (!invList) { hand = ACTOR_HAND_LEFT; invList = ACTOR_GET_INV(ent, hand); } weapon = INVSH_HasReactionFireEnabledWeapon(invList); if (!weapon) return false; ent->chr.RFmode.fmIdx = 0; ent->chr.RFmode.hand = hand; ent->chr.RFmode.weapon = weapon; if (!G_IsAI(ent)) G_EventReactionFireChange(ent); return true; }
/** * @brief Updates the reaction fire settings in case something was moved into a hand or from a hand * that would make the current settings invalid * @param[in,out] actor The actor edict to check the settings for * @param[in] fmIdx The fire mode index that should be used for reaction fire * @param[in] hand The hand that should be used for reaction fire * @param[in] od The object/weapon for the reaction fire */ void G_ReactionFireSettingsUpdate (Actor* actor, fireDefIndex_t fmIdx, actorHands_t hand, const objDef_t* od) { actor->chr.RFmode.set(hand, fmIdx, od); /* FiremodeSettings */ if (!G_ActorHasWorkingFireModeSet(actor)) { /* Disable reaction fire if no valid firemode was found. */ G_ClientStateChange(actor->getPlayer(), actor, ~STATE_REACTION, true); return; } G_EventReactionFireChange(*actor); /* If reaction fire is active, update the reserved TUs */ if (actor->isReaction()) { G_ReactionFireSettingsReserveTUs(actor); } }
/** * @brief Updates the reaction fire settings in case something was moved into a hand or from a hand * that would make the current settings invalid * @param[in,out] ent The actor edict to check the settings for * @param[in] fmIdx The fire mode index that should be used for reaction fire * @param[in] hand The hand that should be used for reaction fire * @param[in] od The object/weapon for the reaction fire */ void G_ReactionFireUpdate (edict_t *ent, fireDefIndex_t fmIdx, actorHands_t hand, const objDef_t *od) { ent->chr.RFmode.set(hand, fmIdx, od); /* FiremodeSettings */ if (!G_ActorHasWorkingFireModeSet(ent)) { /* Disable reaction fire if no valid firemode was found. */ G_ClientStateChange(G_PLAYER_FROM_ENT(ent), ent, ~STATE_REACTION, true); return; } G_EventReactionFireChange(ent); /* If reaction fire is active, update the reserved TUs */ if (G_IsReaction(ent)) { G_ReactionFireSettingsReserveTUs(ent); } }