Hooks
static bool BeforeCvAIOperationPureNavalCityAttack_Init(CvAIOperationPureNavalCityAttack* self, int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int arg3, CvCity* pTarget, CvCity* pMuster);static void AfterCvAIOperationPureNavalCityAttack_Init(CvAIOperationPureNavalCityAttack* self, int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int arg3, CvCity* pTarget, CvCity* pMuster);static void ReplaceCvAIOperationPureNavalCityAttack_Init(void (*original)(CvAIOperationPureNavalCityAttack*, int, PlayerTypes, PlayerTypes, int, CvCity*, CvCity*), CvAIOperationPureNavalCityAttack* self, int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int arg3, CvCity* pTarget, CvCity* pMuster);CivRegisterBefore<CivHooks::CvAIOperationPureNavalCityAttack_Init>(host, &BeforeCvAIOperationPureNavalCityAttack_Init);CivRegisterAfter<CivHooks::CvAIOperationPureNavalCityAttack_Init>(host, &AfterCvAIOperationPureNavalCityAttack_Init);CivRegisterReplace<CivHooks::CvAIOperationPureNavalCityAttack_Init>(host, &ReplaceCvAIOperationPureNavalCityAttack_Init);
Code
4539/// Kick off this operation4540void CvAIOperationPureNavalCityAttack::Init(int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int /*iDefaultArea*/, CvCity* pTarget, CvCity* pMuster)4541{4542 Reset();4543 m_eMoveType = AI_OPERATION_MOVETYPE_ENEMY_TERRITORY;4544 m_iID = iID;4545 m_eOwner = eOwner;4546 m_eEnemy = eEnemy;45474548 if(iID != -1)4549 {4550 // create the armies that are needed and set the state to ARMYAISTATE_WAITING_FOR_UNITS_TO_REINFORCE4551 CvPlayer& kPlayer = GET_PLAYER(m_eOwner);4552 CvArmyAI* pArmyAI = kPlayer.addArmyAI();4553 if(pArmyAI)4554 {4555 m_viArmyIDs.push_back(pArmyAI->GetID());4556 pArmyAI->Init(pArmyAI->GetID(),m_eOwner,m_iID);4557 pArmyAI->SetArmyAIState(ARMYAISTATE_WAITING_FOR_UNITS_TO_REINFORCE);4558 pArmyAI->SetFormationIndex(GetFormation());45594560 if(pTarget)4561 {4562 SetTargetPlot(pTarget->plot());4563 pArmyAI->SetGoalPlot(GetTargetPlot());45644565 // Muster just off the coast4566 CvPlot *pCoastalMuster = kPlayer.GetMilitaryAI()->GetCoastalPlotAdjacentToTarget(pMuster->plot(), pArmyAI);4567 if (pCoastalMuster)4568 {4569 SetDefaultArea(pCoastalMuster->getArea());4570 SetStartCityPlot(pCoastalMuster);4571 SetMusterPlot(GetStartCityPlot());4572 pArmyAI->SetXY(GetStartCityPlot()->getX(), GetStartCityPlot()->getY());45734574 // Find the list of units we need to build before starting this operation in earnest4575 BuildListOfUnitsWeStillNeedToBuild();45764577 // try to get as many units as possible from existing units that are waiting around4578 if(GrabUnitsFromTheReserves(GetMusterPlot(), GetMusterPlot()))4579 {4580 pArmyAI->SetArmyAIState(ARMYAISTATE_WAITING_FOR_UNITS_TO_CATCH_UP);4581 m_eCurrentState = AI_OPERATION_STATE_GATHERING_FORCES;4582 }4583 else4584 {4585 m_eCurrentState = AI_OPERATION_STATE_RECRUITING_UNITS;4586 }45874588 LogOperationStart();4589 }4590 else4591 {4592 // No muster point, abort4593 m_eCurrentState = AI_OPERATION_STATE_ABORTED;4594 m_eAbortReason = AI_ABORT_NO_MUSTER;4595 }4596 }45974598 else4599 {4600 // Lost our target, abort4601 m_eCurrentState = AI_OPERATION_STATE_ABORTED;4602 m_eAbortReason = AI_ABORT_LOST_TARGET;4603 }4604 }4605 }4606}