Bazaar developer reference

CvTacticalAI::PlotFreeformNavalOperationMoves(CvAINavalOperation *)

Defined in
CvTacticalAI.cpp, line 4901
Class
CvTacticalAI
Hook name
CivHooks::CvTacticalAI_PlotFreeformNavalOperationMoves

Hooks

static bool BeforeCvTacticalAI_PlotFreeformNavalOperationMoves(CvTacticalAI* self, CvAINavalOperation* pOperation);static void AfterCvTacticalAI_PlotFreeformNavalOperationMoves(CvTacticalAI* self, CvAINavalOperation* pOperation);static void ReplaceCvTacticalAI_PlotFreeformNavalOperationMoves(void (*original)(CvTacticalAI*, CvAINavalOperation*), CvTacticalAI* self, CvAINavalOperation* pOperation);CivRegisterBefore<CivHooks::CvTacticalAI_PlotFreeformNavalOperationMoves>(host, &BeforeCvTacticalAI_PlotFreeformNavalOperationMoves);CivRegisterAfter<CivHooks::CvTacticalAI_PlotFreeformNavalOperationMoves>(host, &AfterCvTacticalAI_PlotFreeformNavalOperationMoves);CivRegisterReplace<CivHooks::CvTacticalAI_PlotFreeformNavalOperationMoves>(host, &ReplaceCvTacticalAI_PlotFreeformNavalOperationMoves);

Code

4900/// Move a naval force that is roaming for targets4901void CvTacticalAI::PlotFreeformNavalOperationMoves(CvAINavalOperation* pOperation)4902{4903	// Simplification - assume only 1 army per operation now4904	if(pOperation->GetFirstArmyID() == -1)4905	{4906		return;4907	}4908	CvArmyAI* pThisArmy = m_pPlayer->getArmyAI(pOperation->GetFirstArmyID());49094910	m_OperationUnits.clear();4911	pThisArmy->UpdateCheckpointTurns();49124913	// RECRUITING4914	if(pThisArmy->GetArmyAIState() == ARMYAISTATE_WAITING_FOR_UNITS_TO_REINFORCE)4915	{4916		// If no estimate for when recruiting will end, let the rest of the AI use these units4917		if(pThisArmy->GetTurnAtNextCheckpoint() == ARMYSLOT_UNKNOWN_TURN_AT_CHECKPOINT)4918		{4919			return;4920		}4921		else4922		{4923			for(int iI = 0; iI < pThisArmy->GetNumFormationEntries(); iI++)4924			{4925				CvArmyFormationSlot* pSlot = pThisArmy->GetFormationSlot(iI);4926				if(pSlot->GetUnitID() != NO_UNIT)4927				{4928					// See if we are just able to get to muster point in time.  If so, time for us to head over there4929					UnitHandle pUnit = m_pPlayer->getUnit(pSlot->GetUnitID());4930					if(pUnit && !pUnit->TurnProcessed())4931					{4932						CvMultiUnitFormationInfo* pkMultiUnitFormationInfo = GC.getMultiUnitFormationInfo(pThisArmy->GetFormationIndex());4933						if(pkMultiUnitFormationInfo)4934						{4935							const CvFormationSlotEntry& thisSlotEntry = pkMultiUnitFormationInfo->getFormationSlotEntry(iI);49364937							// Continue moving to target4938							if(pSlot->HasStartedOnOperation())4939							{4940								MoveWithFormation(pUnit, thisSlotEntry.m_ePositionType);4941							}4942							else4943							{4944								// See if we are just able to get to muster point in time.  If so, time for us to head over there4945								int iTurns = TurnsToReachTarget(pUnit, pOperation->GetMusterPlot(), true /*bReusePaths*/, true, true);4946								if(iTurns + GC.getGame().getGameTurn() >= pThisArmy->GetTurnAtNextCheckpoint())4947								{4948									pSlot->SetStartedOnOperation(true);4949									MoveWithFormation(pUnit, thisSlotEntry.m_ePositionType);4950								}4951							}4952						}4953					}4954				}4955			}4956			ExecuteNavalFormationMoves(pThisArmy, pOperation->GetMusterPlot());4957		}4958	}49594960	// GATHERING FORCES4961	else if(pThisArmy->GetArmyAIState() == ARMYAISTATE_WAITING_FOR_UNITS_TO_CATCH_UP)4962	{4963		// Get them moving to target without delay4964		pOperation->ArmyInPosition(pThisArmy);4965		ExecuteFleetMoveToTarget(pThisArmy, pOperation->GetTargetPlot());4966	}49674968	// MOVING TO TARGET4969	else if(pThisArmy->GetArmyAIState() == ARMYAISTATE_MOVING_TO_DESTINATION)4970	{4971		// Get them moving to target without delay4972		pOperation->ArmyInPosition(pThisArmy);4973		ExecuteFleetMoveToTarget(pThisArmy, pOperation->GetTargetPlot());4974	}4975}

Calls

Called by