コード例 #1
0
ファイル: g_reaction.cpp プロジェクト: MyWifeRules/ufoai-1
/**
 * @brief Called when 'target' is about to shoot, this forces a 'draw' to decide who gets the first shot
 * @param[in] target The entity about to shoot
 * @param[in] fdTime The TU of the shot
 * @sa G_ClientShoot
 */
void G_ReactionFirePreShot (const edict_t *target, const int fdTime)
{
	edict_t *shooter = NULL;
	bool repeat = true;

	/* Check to see whether this triggers any reaction fire */
	G_ReactionFireTargetsUpdateAll(target);

	/* if any reaction fire occurs, we have to loop through all entities again to allow
	 * multiple (fast) RF snap shots before a (slow) aimed shot from the target occurs. */
	while (repeat) {
		repeat = false;
		/* check all ents to see who wins and who loses a draw */
		while ((shooter = G_EdictsGetNextLivingActor(shooter))) {
			int entTUs = G_ReactionFireGetTUsForItem(shooter, target, RIGHT(shooter));
			if (entTUs > 1) {	/* indicates an RF weapon is there */
				if (G_ReactionFireTargetsExpired(shooter, target, fdTime)) {
					if (G_ReactionFireTryToShoot(shooter, target)) {
						repeat = true;
						G_ReactionFireTargetsAdvance(shooter, target, fdTime);
					}
				}
			}
		}
	}
}
コード例 #2
0
ファイル: g_reaction.cpp プロジェクト: MyWifeRules/ufoai-1
/**
 * @brief Called when 'target' moves, possibly triggering or resolving reaction fire
 * @param[in] target The target entity
 * @return true If any shots were (or would be) taken
 * @sa G_ClientMove
 */
bool G_ReactionFireOnMovement (edict_t *target)
{
	/* Check to see whether this resolves any reaction fire */
	const bool fired = G_ReactionFireCheckExecution(target);

	/* Check to see whether this triggers any reaction fire */
	G_ReactionFireTargetsUpdateAll(target);

	return fired;
}
コード例 #3
0
/**
 * @brief Called when 'target' moves, possibly triggering or resolving reaction fire
 * @param[in] target The target entity
 * @return true If any shots were (or would be) taken
 * @sa G_ClientMove
 */
bool G_ReactionFireOnMovement (Edict *target)
{
#if DEBUG_RF
	G_ReactionFirePrintSituation (target);
#endif
	/* Check to see whether this resolves any reaction fire */
	const bool fired = G_ReactionFireCheckExecution(target);

	/* Check to see whether this triggers any reaction fire */
	G_ReactionFireTargetsUpdateAll(target);

	return fired;
}