Bazaar developer reference

CvTacticalAI::PlotAirSweepMoves()

Defined in
CvTacticalAI.cpp, line 3341
Class
CvTacticalAI
Hook name
CivHooks::CvTacticalAI_PlotAirSweepMoves

Hooks

static bool BeforeCvTacticalAI_PlotAirSweepMoves(CvTacticalAI* self);static void AfterCvTacticalAI_PlotAirSweepMoves(CvTacticalAI* self);static void ReplaceCvTacticalAI_PlotAirSweepMoves(void (*original)(CvTacticalAI*), CvTacticalAI* self);CivRegisterBefore<CivHooks::CvTacticalAI_PlotAirSweepMoves>(host, &BeforeCvTacticalAI_PlotAirSweepMoves);CivRegisterAfter<CivHooks::CvTacticalAI_PlotAirSweepMoves>(host, &AfterCvTacticalAI_PlotAirSweepMoves);CivRegisterReplace<CivHooks::CvTacticalAI_PlotAirSweepMoves>(host, &ReplaceCvTacticalAI_PlotAirSweepMoves);

Code

3340/// Set fighters to air sweep3341void CvTacticalAI::PlotAirSweepMoves()3342{3343	list<int>::iterator it;3344	m_CurrentMoveUnits.clear();3345	CvTacticalUnit unit;3346	CvTacticalDominanceZone *pZone;33473348	// Loop through all recruited units3349	for(it = m_CurrentTurnUnits.begin(); it != m_CurrentTurnUnits.end(); it++)3350	{3351		UnitHandle pUnit = m_pPlayer->getUnit(*it);3352#if defined(MOD_UNITS_MAX_HP)3353		if(pUnit && (pUnit->getDamage() * 2) < pUnit->GetMaxHitPoints())3354#else3355		if(pUnit && (pUnit->getDamage() * 2) < GC.getMAX_HIT_POINTS())3356#endif3357		{3358			// Am I eligible to air sweep and have a target?3359			if(pUnit->canAirSweep() && !m_pPlayer->GetMilitaryAI()->WillAirUnitRebase(pUnit.pointer()) && m_pPlayer->GetMilitaryAI()->GetBestAirSweepTarget(pUnit.pointer()) != NULL)3360			{3361				CvPlot* pUnitPlot = pUnit->plot();3362				CvCity* pCity = pUnitPlot->getPlotCity();3363				pZone = NULL;33643365				// On a carrier or in a city where we are dominant?3366				if (pCity)3367				{3368					pZone = m_pMap->GetZoneByCity(pCity, false);3369				}3370				if (!pCity || !pZone || pZone->GetDominanceFlag() == TACTICAL_DOMINANCE_FRIENDLY)3371				{3372					unit.SetID(pUnit->GetID());3373					m_CurrentMoveUnits.push_back(unit);33743375					if(GC.getLogging() && GC.getAILogging())3376					{3377						CvString strLogString;3378						strLogString.Format("Ready to air sweep enemy air units at, X: %d, Y: %d", pUnit->getX(), pUnit->getY());3379						LogTacticalMessage(strLogString);3380					}3381				}3382			}3383		}3384	}33853386	if(m_CurrentMoveUnits.size() > 0)3387	{3388		ExecuteAirSweepMoves();3389	}3390}

Calls

Called by