CvAIOperationPillageEnemy::ArmyMoved(CvArmyAI *)
- Defined in
- CvAIOperation.cpp, line 2612
- Class
- CvAIOperationPillageEnemy
- Hook name
CivHooks::CvAIOperationPillageEnemy_ArmyMoved- Overrides
- CvAIOperation::ArmyMoved(CvArmyAI *)
Hooks
static bool BeforeCvAIOperationPillageEnemy_ArmyMoved(CvAIOperationPillageEnemy* self, CvArmyAI* pArmy, bool& result);static void AfterCvAIOperationPillageEnemy_ArmyMoved(CvAIOperationPillageEnemy* self, CvArmyAI* pArmy, bool& result);static bool ReplaceCvAIOperationPillageEnemy_ArmyMoved(bool (*original)(CvAIOperationPillageEnemy*, CvArmyAI*), CvAIOperationPillageEnemy* self, CvArmyAI* pArmy);CivRegisterBefore<CivHooks::CvAIOperationPillageEnemy_ArmyMoved>(host, &BeforeCvAIOperationPillageEnemy_ArmyMoved);CivRegisterAfter<CivHooks::CvAIOperationPillageEnemy_ArmyMoved>(host, &AfterCvAIOperationPillageEnemy_ArmyMoved);CivRegisterReplace<CivHooks::CvAIOperationPillageEnemy_ArmyMoved>(host, &ReplaceCvAIOperationPillageEnemy_ArmyMoved);
Code
2611/// Every time the army moves on its way to the destination lets double-check that we don't have a better target2612bool CvAIOperationPillageEnemy::ArmyMoved(CvArmyAI* pArmy)2613{2614 bool bStateChanged = false;2615 CvPlot* pBetterTarget;26162617 switch(m_eCurrentState)2618 {2619 case AI_OPERATION_STATE_MOVING_TO_TARGET:2620 {2621 // Find best pillage target2622 pBetterTarget = FindBestTarget();26232624 // No targets at all! Abort2625 if(pBetterTarget == NULL)2626 {2627 m_eCurrentState = AI_OPERATION_STATE_ABORTED;2628 m_eAbortReason = AI_ABORT_NO_TARGET;2629 }26302631 // If this is a new target, switch to it2632 else if(pBetterTarget != GetTargetPlot())2633 {2634 SetTargetPlot(pBetterTarget);2635 pArmy->SetGoalPlot(pBetterTarget);26362637 // Reset our destination to be a few plots shy of the final target2638 CvPlot* pDeployPt;2639 pDeployPt = GC.getStepFinder().GetXPlotsFromEnd(GetOwner(), GetEnemy(), pArmy->Plot(), pBetterTarget, GC.getAI_OPERATIONAL_PILLAGE_ENEMY_DEPLOY_RANGE(), false);2640 pArmy->SetGoalPlot(pDeployPt);2641 }2642 }2643 break;26442645 // In all other cases use base class version2646 case AI_OPERATION_STATE_AT_TARGET:2647 case AI_OPERATION_STATE_RECRUITING_UNITS:2648 case AI_OPERATION_STATE_GATHERING_FORCES:2649 case AI_OPERATION_STATE_ABORTED:2650 return CvAIOperation::ArmyMoved(pArmy);2651 break;2652 };26532654 return bStateChanged;2655}
Calls
- CvAIOperation::ArmyMoved(CvArmyAI *)
- CvAIOperation::GetEnemy() const
- CvAIOperation::GetOwner() const
- CvAIOperation::GetTargetPlot() const
- CvAIOperation::SetTargetPlot(CvPlot *)
- CvAIOperationPillageEnemy::FindBestTarget()
- CvArmyAI::Plot() const
- CvArmyAI::SetGoalPlot(CvPlot *)
- CvGlobals::getAI_OPERATIONAL_PILLAGE_ENEMY_DEPLOY_RANGE()
- CvGlobals::getStepFinder()
- CvStepPathFinder::GetXPlotsFromEnd(PlayerTypes, PlayerTypes, CvPlot *, CvPlot *, int, bool) const