Bazaar developer reference

CvMilitaryAI::RequestPureNavalAttack(PlayerTypes, int)

Defined in
CvMilitaryAI.cpp, line 633
Class
CvMilitaryAI
Hook name
CivHooks::CvMilitaryAI_RequestPureNavalAttack

Hooks

static bool BeforeCvMilitaryAI_RequestPureNavalAttack(CvMilitaryAI* self, PlayerTypes eEnemy, int iNumUnitsWillingBuild, bool& result);static void AfterCvMilitaryAI_RequestPureNavalAttack(CvMilitaryAI* self, PlayerTypes eEnemy, int iNumUnitsWillingBuild, bool& result);static bool ReplaceCvMilitaryAI_RequestPureNavalAttack(bool (*original)(CvMilitaryAI*, PlayerTypes, int), CvMilitaryAI* self, PlayerTypes eEnemy, int iNumUnitsWillingBuild);CivRegisterBefore<CivHooks::CvMilitaryAI_RequestPureNavalAttack>(host, &BeforeCvMilitaryAI_RequestPureNavalAttack);CivRegisterAfter<CivHooks::CvMilitaryAI_RequestPureNavalAttack>(host, &AfterCvMilitaryAI_RequestPureNavalAttack);CivRegisterReplace<CivHooks::CvMilitaryAI_RequestPureNavalAttack>(host, &ReplaceCvMilitaryAI_RequestPureNavalAttack);

Code

632/// Send a navy to take a city633bool CvMilitaryAI::RequestPureNavalAttack(PlayerTypes eEnemy, int iNumUnitsWillingBuild)634{635	CvAIOperation* pOperation = NULL;636	CvMilitaryTarget target;637	int iNumRequiredSlots = 0;638	int iLandReservesUsed = 0;639	int iFilledSlots = 0;640641	target = FindBestAttackTarget(AI_OPERATION_PURE_NAVAL_CITY_ATTACK, eEnemy);642	if(target.m_pTargetCity)643	{644		iFilledSlots = MilitaryAIHelpers::NumberOfFillableSlots(m_pPlayer, MUFORMATION_PURE_NAVAL_CITY_ATTACK, true, &iNumRequiredSlots, &iLandReservesUsed);645		if((iNumRequiredSlots - iFilledSlots) <= iNumUnitsWillingBuild)646		{647			pOperation = m_pPlayer->addAIOperation(AI_OPERATION_PURE_NAVAL_CITY_ATTACK, eEnemy, target.m_pTargetCity->getArea(), target.m_pTargetCity, target.m_pMusterCity);648		}649650		if(pOperation != NULL && !pOperation->ShouldAbort())651		{652			return true;653		}654	}655	return false;656}

Calls

Called by