コード例 #1
0
ファイル: g_reaction.cpp プロジェクト: MyWifeRules/ufoai-1
/**
 * @brief Checks whether the actor has a reaction fire enabled weapon in one of his hands.
 * @param[in] ent The actor to check the weapons for
 * @return @c NULL if no actor has not reaction fire enabled weapons, the fire definition otherwise.
 */
static bool G_ActorHasReactionFireEnabledWeapon (const edict_t *ent)
{
	const objDef_t *weapon = INVSH_HasReactionFireEnabledWeapon(RIGHT(ent));
	if (weapon)
		return true;
	return INVSH_HasReactionFireEnabledWeapon(LEFT(ent)) != NULL;
}
コード例 #2
0
ファイル: g_reaction.cpp プロジェクト: MyWifeRules/ufoai-1
/**
 * @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;
}
コード例 #3
0
ファイル: g_reaction.cpp プロジェクト: jklemmack/ufoai
/**
 * @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;
}