/** * @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; }
/** * @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 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, false); G_EventReactionFireChange(*actor); 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_ReactionFireSettingsUpdate (Edict *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(ent->getPlayer(), ent, ~STATE_REACTION, true); return; } G_EventReactionFireChange(*ent); /* If reaction fire is active, update the reserved TUs */ if (G_IsReaction(ent)) { G_ReactionFireSettingsReserveTUs(ent); } }
/** * @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) { chrFiremodeSettings_t *fm = &ent->chr.RFmode; fm->fmIdx = fmIdx; fm->hand = hand; fm->weapon = od; 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); } }