Bazaar developer reference

CvTacticalAI::FindAirUnitsToAirSweep(CvPlot *)

Defined in
CvTacticalAI.cpp, line 9529
Class
CvTacticalAI
Hook name
CivHooks::CvTacticalAI_FindAirUnitsToAirSweep

Hooks

static bool BeforeCvTacticalAI_FindAirUnitsToAirSweep(CvTacticalAI* self, CvPlot* pTarget);static void AfterCvTacticalAI_FindAirUnitsToAirSweep(CvTacticalAI* self, CvPlot* pTarget);static void ReplaceCvTacticalAI_FindAirUnitsToAirSweep(void (*original)(CvTacticalAI*, CvPlot*), CvTacticalAI* self, CvPlot* pTarget);CivRegisterBefore<CivHooks::CvTacticalAI_FindAirUnitsToAirSweep>(host, &BeforeCvTacticalAI_FindAirUnitsToAirSweep);CivRegisterAfter<CivHooks::CvTacticalAI_FindAirUnitsToAirSweep>(host, &AfterCvTacticalAI_FindAirUnitsToAirSweep);CivRegisterReplace<CivHooks::CvTacticalAI_FindAirUnitsToAirSweep>(host, &ReplaceCvTacticalAI_FindAirUnitsToAirSweep);

Code

9527#if defined(MOD_AI_SMART_V3)9528//AMS: Fills m_CurrentAirUnits with all units able to sweep at target plot.9529void CvTacticalAI::FindAirUnitsToAirSweep(CvPlot* pTarget)9530{9531	list<int>::iterator it;9532	UnitHandle pLoopUnit;9533	m_CurrentAirUnits.clear();9534	int interceptionsOnPlot = m_pPlayer->GetMilitaryAI()->GetMaxPossibleInterceptions(pTarget, true);95359536	// Loop through all units available to tactical AI this turn9537	for (it = m_CurrentTurnUnits.begin(); it != m_CurrentTurnUnits.end() && interceptionsOnPlot > 0; ++it)9538	{9539		pLoopUnit = m_pPlayer->getUnit(*it);95409541		if (pLoopUnit)9542		{9543			// Is an air unit.9544			if (pLoopUnit->getDomainType() == DOMAIN_AIR && pLoopUnit->canMove())9545			{9546				// Is able to sweep at target9547				if (pLoopUnit->canAirSweepAt(pTarget->getX(), pTarget->getY()))9548				{95499550					int iAttackStrength = pLoopUnit->GetMaxAttackStrength(NULL, NULL, NULL);9551					// Mod to air sweep strength9552					iAttackStrength *= (100 + pLoopUnit->GetAirSweepCombatModifier());9553					iAttackStrength /= 100;9554					CvTacticalUnit unit;9555					unit.SetID(pLoopUnit->GetID());9556					unit.SetAttackStrength(iAttackStrength);9557					unit.SetHealthPercent(pLoopUnit->GetCurrHitPoints(), pLoopUnit->GetMaxHitPoints());9558					m_CurrentAirUnits.push_back(unit);95599560					interceptionsOnPlot--;95619562					// We also remove the unit from m_CurrentMoveUnits9563					std::vector<CvTacticalUnit>::iterator itM;95649565					for (itM = m_CurrentMoveUnits.begin(); itM != m_CurrentMoveUnits.end(); itM++)9566					{9567						if ((*itM).GetID() == pLoopUnit->GetID())9568						{9569							m_CurrentMoveUnits.erase(itM);9570							break;9571						}9572					}9573				}9574			}9575		}9576	}95779578	std::stable_sort(m_CurrentAirUnits.begin(), m_CurrentAirUnits.end());9579}

Calls

Called by