Bazaar developer reference

CvTacticalAI::PlotCounterattackMoves()

Defined in
CvTacticalAI.cpp, line 3836
Class
CvTacticalAI
Hook name
CivHooks::CvTacticalAI_PlotCounterattackMoves

Hooks

static bool BeforeCvTacticalAI_PlotCounterattackMoves(CvTacticalAI* self);static void AfterCvTacticalAI_PlotCounterattackMoves(CvTacticalAI* self);static void ReplaceCvTacticalAI_PlotCounterattackMoves(void (*original)(CvTacticalAI*), CvTacticalAI* self);CivRegisterBefore<CivHooks::CvTacticalAI_PlotCounterattackMoves>(host, &BeforeCvTacticalAI_PlotCounterattackMoves);CivRegisterAfter<CivHooks::CvTacticalAI_PlotCounterattackMoves>(host, &AfterCvTacticalAI_PlotCounterattackMoves);CivRegisterReplace<CivHooks::CvTacticalAI_PlotCounterattackMoves>(host, &ReplaceCvTacticalAI_PlotCounterattackMoves);

Code

3835/// Try to push back the invader3836void CvTacticalAI::PlotCounterattackMoves()3837{3838	// Attack priority unit targets3839	for(unsigned int iI = 0; iI < m_ZoneTargets.size(); iI++)3840	{3841		if(m_ZoneTargets[iI].GetTargetType() == AI_TACTICAL_TARGET_HIGH_PRIORITY_UNIT ||3842		        m_ZoneTargets[iI].GetTargetType() == AI_TACTICAL_TARGET_MEDIUM_PRIORITY_UNIT)3843		{3844			if(m_ZoneTargets[iI].IsTargetStillAlive(m_pPlayer->GetID()))3845			{3846				ExecutePriorityAttacksOnUnitTarget(m_ZoneTargets[iI]);3847			}3848		}3849	}3850	PlotDestroyUnitMoves(AI_TACTICAL_TARGET_HIGH_PRIORITY_UNIT, true);3851	PlotDestroyUnitMoves(AI_TACTICAL_TARGET_MEDIUM_PRIORITY_UNIT, true);38523853	// Now low priority targets3854	for(unsigned int iI = 0; iI < m_ZoneTargets.size(); iI++)3855	{3856		if(m_ZoneTargets[iI].GetTargetType() == AI_TACTICAL_TARGET_LOW_PRIORITY_UNIT)3857		{3858			if(m_ZoneTargets[iI].IsTargetStillAlive(m_pPlayer->GetID()))3859			{3860				ExecutePriorityAttacksOnUnitTarget(m_ZoneTargets[iI]);3861			}3862		}3863	}3864	PlotDestroyUnitMoves(AI_TACTICAL_TARGET_LOW_PRIORITY_UNIT, true);38653866	// Now targets we can't destroy3867	PlotDestroyUnitMoves(AI_TACTICAL_TARGET_HIGH_PRIORITY_UNIT, false);3868	PlotDestroyUnitMoves(AI_TACTICAL_TARGET_MEDIUM_PRIORITY_UNIT, false);3869	PlotDestroyUnitMoves(AI_TACTICAL_TARGET_LOW_PRIORITY_UNIT, false);3870}

Calls

Called by