CvAIOperationNavalAttack::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)
- Defined in
- CvAIOperation.cpp, line 5343
- Class
- CvAIOperationNavalAttack
- Hook name
CivHooks::CvAIOperationNavalAttack_Init- Overrides
- CvAINavalEscortedOperation::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)
Hooks
static bool BeforeCvAIOperationNavalAttack_Init(CvAIOperationNavalAttack* self, int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int iDefaultArea, CvCity* pTarget, CvCity* pMuster);static void AfterCvAIOperationNavalAttack_Init(CvAIOperationNavalAttack* self, int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int iDefaultArea, CvCity* pTarget, CvCity* pMuster);static void ReplaceCvAIOperationNavalAttack_Init(void (*original)(CvAIOperationNavalAttack*, int, PlayerTypes, PlayerTypes, int, CvCity*, CvCity*), CvAIOperationNavalAttack* self, int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int iDefaultArea, CvCity* pTarget, CvCity* pMuster);CivRegisterBefore<CivHooks::CvAIOperationNavalAttack_Init>(host, &BeforeCvAIOperationNavalAttack_Init);CivRegisterAfter<CivHooks::CvAIOperationNavalAttack_Init>(host, &AfterCvAIOperationNavalAttack_Init);CivRegisterReplace<CivHooks::CvAIOperationNavalAttack_Init>(host, &ReplaceCvAIOperationNavalAttack_Init);
Code
5342/// Kick off this operation5343void CvAIOperationNavalAttack::Init(int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int iDefaultArea, CvCity* pTarget, CvCity* pMuster)5344{5345 Reset();5346 m_eMoveType = AI_OPERATION_MOVETYPE_NAVAL_ESCORT;5347 m_iID = iID;5348 m_eOwner = eOwner;5349 m_eEnemy = eEnemy;5350 SetDefaultArea(iDefaultArea);53515352 SetStartCityPlot(pMuster->plot());53535354 if(iID != -1)5355 {5356 if(pTarget)5357 {5358 SetTargetPlot(pTarget->plot());53595360 // create the armies that are needed and set the state to ARMYAISTATE_WAITING_FOR_UNITS_TO_REINFORCE5361 CvArmyAI* pArmyAI = GET_PLAYER(m_eOwner).addArmyAI();5362 if(pArmyAI)5363 {5364 m_viArmyIDs.push_back(pArmyAI->GetID());5365 pArmyAI->Init(pArmyAI->GetID(),m_eOwner,m_iID);5366 pArmyAI->SetArmyAIState(ARMYAISTATE_WAITING_FOR_UNITS_TO_REINFORCE);5367 pArmyAI->SetFormationIndex(GetFormation());53685369 pArmyAI->SetGoalPlot(GetTargetPlot());5370 SetMusterPlot(GetStartCityPlot());5371 pArmyAI->SetXY(GetStartCityPlot()->getX(), GetStartCityPlot()->getY());53725373 BuildListOfUnitsWeStillNeedToBuild();53745375 // Try to get as many units as possible from existing units that are waiting around5376 if(GrabUnitsFromTheReserves(GetMusterPlot(), NULL))5377 {5378 pArmyAI->SetArmyAIState(ARMYAISTATE_WAITING_FOR_UNITS_TO_CATCH_UP);5379 m_eCurrentState = AI_OPERATION_STATE_GATHERING_FORCES;5380 }5381 else5382 {5383 m_eCurrentState = AI_OPERATION_STATE_RECRUITING_UNITS;5384 }5385 LogOperationStart();5386 }5387 }53885389 else5390 {5391 // Lost our target, abort5392 m_eCurrentState = AI_OPERATION_STATE_ABORTED;5393 m_eAbortReason = AI_ABORT_LOST_TARGET;5394 }5395 }5396}
Calls
- CvAIOperation::BuildListOfUnitsWeStillNeedToBuild()
- CvAIOperation::GetMusterPlot() const
- CvAIOperation::GetStartCityPlot() const
- CvAIOperation::GetTargetPlot() const
- CvAIOperation::GrabUnitsFromTheReserves(CvPlot *, CvPlot *)
- CvAIOperation::LogOperationStart()
- CvAIOperation::Reset()
- CvAIOperation::SetDefaultArea(int)
- CvAIOperation::SetMusterPlot(CvPlot *)
- CvAIOperation::SetStartCityPlot(CvPlot *)
- CvAIOperation::SetTargetPlot(CvPlot *)
- CvAIOperationNavalAttack::GetFormation() const
- CvArmyAI::GetID()
- CvArmyAI::Init(int, PlayerTypes, int)
- CvArmyAI::SetArmyAIState(ArmyAIState)
- CvArmyAI::SetFormationIndex(int)
- CvArmyAI::SetGoalPlot(CvPlot *)
- CvArmyAI::SetXY(int, int)
- CvCity::plot() const
- CvPlayer::addArmyAI()
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlot::getX() const
- CvPlot::getY() const
std::vector::push_back