Bazaar developer reference

CvTacticalAI::PlotSitAndBombardMoves()

Defined in
CvTacticalAI.cpp, line 3576
Class
CvTacticalAI
Hook name
CivHooks::CvTacticalAI_PlotSitAndBombardMoves

Hooks

static bool BeforeCvTacticalAI_PlotSitAndBombardMoves(CvTacticalAI* self);static void AfterCvTacticalAI_PlotSitAndBombardMoves(CvTacticalAI* self);static void ReplaceCvTacticalAI_PlotSitAndBombardMoves(void (*original)(CvTacticalAI*), CvTacticalAI* self);CivRegisterBefore<CivHooks::CvTacticalAI_PlotSitAndBombardMoves>(host, &BeforeCvTacticalAI_PlotSitAndBombardMoves);CivRegisterAfter<CivHooks::CvTacticalAI_PlotSitAndBombardMoves>(host, &AfterCvTacticalAI_PlotSitAndBombardMoves);CivRegisterReplace<CivHooks::CvTacticalAI_PlotSitAndBombardMoves>(host, &ReplaceCvTacticalAI_PlotSitAndBombardMoves);

Code

3575/// Win an attrition campaign with bombardments3576void CvTacticalAI::PlotSitAndBombardMoves()3577{3578	// Find primary target for zone (i.e. enemy city)3579	CvTacticalTarget target;3580	CvPlot* pTarget;3581	bool bAttackUnderway;3582	bool bAttackMade;35833584	CvTacticalDominanceZone* pZone = GC.getGame().GetTacticalAnalysisMap()->GetZone(m_iCurrentZoneIndex);3585	if(pZone->GetClosestCity() != NULL)3586	{3587		// Turn off moves we don't want to mix with this posture3588		TurnOffMove((TacticalAIMoveTypes)m_CachedInfoTypes[eTACTICAL_DAMAGE_CITY]);35893590		target.SetTargetType(AI_TACTICAL_TARGET_CITY);3591		target.SetTargetPlayer(pZone->GetClosestCity()->getOwner());3592		target.SetTargetX(pZone->GetClosestCity()->plot()->getX());3593		target.SetTargetY(pZone->GetClosestCity()->plot()->getY());3594		target.SetDominanceZone(pZone->GetDominanceZoneID());35953596		m_pMap->ClearDynamicFlags();3597		pTarget = GC.getMap().plot(target.GetTargetX(), target.GetTargetY());3598		m_pMap->SetTargetBombardCells(pTarget, m_pMap->GetBestFriendlyRange(), m_pMap->CanIgnoreLOS());35993600		// Attack primary target (city)3601		bAttackUnderway = ExecuteSafeBombards(target);3602		if(target.IsTargetStillAlive(m_pPlayer->GetID()))3603		{3604			bAttackMade = PlotCaptureCityMoves();3605			if(bAttackMade)3606			{3607				bAttackUnderway = true;3608			}3609			if(target.IsTargetStillAlive(m_pPlayer->GetID()))3610			{3611				bAttackMade = ExecuteProtectedBombards(target, bAttackUnderway);3612				if(bAttackMade)3613				{3614					bAttackUnderway = true;3615				}3616				if(target.IsTargetStillAlive(m_pPlayer->GetID()))3617				{3618					PlotCaptureCityMoves();3619				}3620			}3621		}36223623		// Attack ancillary target (nearby units)3624		for(unsigned int iI = 0; iI < m_ZoneTargets.size(); iI++)3625		{3626			// Is the target of an appropriate type?3627			if(m_ZoneTargets[iI].GetTargetType() == AI_TACTICAL_TARGET_HIGH_PRIORITY_UNIT ||3628			        m_ZoneTargets[iI].GetTargetType() == AI_TACTICAL_TARGET_MEDIUM_PRIORITY_UNIT ||3629			        m_ZoneTargets[iI].GetTargetType() == AI_TACTICAL_TARGET_LOW_PRIORITY_UNIT)3630			{3631				if(m_ZoneTargets[iI].IsTargetStillAlive(m_pPlayer->GetID()))3632				{3633					m_pMap->ClearDynamicFlags();3634					pTarget = GC.getMap().plot(m_ZoneTargets[iI].GetTargetX(), m_ZoneTargets[iI].GetTargetY());3635					m_pMap->SetTargetBombardCells(pTarget, m_pMap->GetBestFriendlyRange(), m_pMap->CanIgnoreLOS());36363637					bAttackUnderway = ExecuteSafeBombards(m_ZoneTargets[iI]);3638					if(m_ZoneTargets[iI].IsTargetStillAlive(m_pPlayer->GetID()))3639					{3640						ExecuteProtectedBombards(m_ZoneTargets[iI], bAttackUnderway);3641					}3642				}3643			}3644		}36453646		PlotCloseOnTarget(true /*bCheckDominance*/);3647	}3648}

Calls

Called by