CvAIOperationNavalSuperiority::ArmyInPosition(CvArmyAI *)
- Defined in
- CvAIOperation.cpp, line 4258
- Class
- CvAIOperationNavalSuperiority
- Hook name
CivHooks::CvAIOperationNavalSuperiority_ArmyInPosition- Overrides
- CvAINavalOperation::ArmyInPosition(CvArmyAI *)
Hooks
static bool BeforeCvAIOperationNavalSuperiority_ArmyInPosition(CvAIOperationNavalSuperiority* self, CvArmyAI* pArmy, bool& result);static void AfterCvAIOperationNavalSuperiority_ArmyInPosition(CvAIOperationNavalSuperiority* self, CvArmyAI* pArmy, bool& result);static bool ReplaceCvAIOperationNavalSuperiority_ArmyInPosition(bool (*original)(CvAIOperationNavalSuperiority*, CvArmyAI*), CvAIOperationNavalSuperiority* self, CvArmyAI* pArmy);CivRegisterBefore<CivHooks::CvAIOperationNavalSuperiority_ArmyInPosition>(host, &BeforeCvAIOperationNavalSuperiority_ArmyInPosition);CivRegisterAfter<CivHooks::CvAIOperationNavalSuperiority_ArmyInPosition>(host, &AfterCvAIOperationNavalSuperiority_ArmyInPosition);CivRegisterReplace<CivHooks::CvAIOperationNavalSuperiority_ArmyInPosition>(host, &ReplaceCvAIOperationNavalSuperiority_ArmyInPosition);
Code
4257/// Same as default version except if just gathered forces and this operation never reaches a final target (just keeps attacking until dead or the operation is ended)4258bool CvAIOperationNavalSuperiority::ArmyInPosition(CvArmyAI* pArmy)4259{4260 bool bStateChanged = false;42614262 switch(m_eCurrentState)4263 {4264 // If we were gathering forces, let's make sure a better target hasn't presented itself4265 case AI_OPERATION_STATE_GATHERING_FORCES:4266 case AI_OPERATION_STATE_MOVING_TO_TARGET:4267 {4268 // First do base case processing4269 bStateChanged = CvAIOperation::ArmyInPosition(pArmy);42704271 // Now revisit target4272 CvPlot* possibleBetterTarget;4273 possibleBetterTarget = FindBestTarget();42744275 // If no target left, abort4276 if(possibleBetterTarget == NULL)4277 {4278 m_eCurrentState = AI_OPERATION_STATE_ABORTED;4279 m_eAbortReason = AI_ABORT_NO_TARGET;4280 }42814282 // If target changed, reset to this new one4283 else if(possibleBetterTarget != GetTargetPlot())4284 {4285 // Reset our destination to be a few plots shy of the final target4286 CvPlot* pDeployPt = GC.getStepFinder().GetXPlotsFromEnd(GetOwner(), GetEnemy(), pArmy->Plot(), possibleBetterTarget, GetDeployRange(), false);4287 if(pDeployPt != NULL)4288 {4289 pArmy->SetGoalPlot(pDeployPt);4290 SetTargetPlot(possibleBetterTarget);4291 }4292 }4293 }4294 break;42954296 // In all other cases use base class version4297 case AI_OPERATION_STATE_ABORTED:4298 case AI_OPERATION_STATE_RECRUITING_UNITS:4299 case AI_OPERATION_STATE_AT_TARGET:4300 return CvAIOperation::ArmyInPosition(pArmy);4301 break;4302 };43034304 return bStateChanged;4305}
Calls
- CvAINavalOperation::GetDeployRange() const
- CvAIOperation::ArmyInPosition(CvArmyAI *)
- CvAIOperation::GetEnemy() const
- CvAIOperation::GetOwner() const
- CvAIOperation::GetTargetPlot() const
- CvAIOperation::SetTargetPlot(CvPlot *)
- CvAIOperationNavalSuperiority::FindBestTarget()
- CvArmyAI::Plot() const
- CvArmyAI::SetGoalPlot(CvPlot *)
- CvGlobals::getStepFinder()
- CvStepPathFinder::GetXPlotsFromEnd(PlayerTypes, PlayerTypes, CvPlot *, CvPlot *, int, bool) const