Bazaar developer reference

CvAIOperationRapidResponse::FindBestTarget()

Defined in
CvAIOperation.cpp, line 5004
Class
CvAIOperationRapidResponse
Hook name
CivHooks::CvAIOperationRapidResponse_FindBestTarget

Hooks

static bool BeforeCvAIOperationRapidResponse_FindBestTarget(CvAIOperationRapidResponse* self, CvPlot*& result);static void AfterCvAIOperationRapidResponse_FindBestTarget(CvAIOperationRapidResponse* self, CvPlot*& result);static CvPlot* ReplaceCvAIOperationRapidResponse_FindBestTarget(CvPlot* (*original)(CvAIOperationRapidResponse*), CvAIOperationRapidResponse* self);CivRegisterBefore<CivHooks::CvAIOperationRapidResponse_FindBestTarget>(host, &BeforeCvAIOperationRapidResponse_FindBestTarget);CivRegisterAfter<CivHooks::CvAIOperationRapidResponse_FindBestTarget>(host, &AfterCvAIOperationRapidResponse_FindBestTarget);CivRegisterReplace<CivHooks::CvAIOperationRapidResponse_FindBestTarget>(host, &ReplaceCvAIOperationRapidResponse_FindBestTarget);

Code

5003/// Find the best blocking position against the current threats5004CvPlot* CvAIOperationRapidResponse::FindBestTarget()5005{5006	CvCity* pCity;5007	CvPlot* pPlot = NULL;5008	CvCity* pEnemyCapital;5009	int iLoop;50105011	// Defend the city most under threat5012	pCity = GET_PLAYER(m_eOwner).GetMilitaryAI()->GetMostThreatenedCity();50135014	// If no city is threatened just defend whichever of our cities is closest to the enemy capital5015	if(pCity == NULL)5016	{5017		pEnemyCapital = GET_PLAYER(m_eEnemy).getCapitalCity();5018		if(pEnemyCapital == NULL)5019		{5020			pEnemyCapital = GET_PLAYER(m_eEnemy).firstCity(&iLoop);5021		}5022		pCity = GC.getMap().findCity(pEnemyCapital->getX(), pEnemyCapital->getY(), m_eOwner, NO_TEAM, true, false, NO_TEAM, NO_DIRECTION, NULL);5023	}50245025	if(pCity != NULL)5026	{5027		pPlot = pCity->plot();5028	}50295030	return pPlot;5031}

Calls

Called by