Hooks
static bool BeforeCvAIOperationNavalBombardment_ArmyInPosition(CvAIOperationNavalBombardment* self, CvArmyAI* pArmy, bool& result);static void AfterCvAIOperationNavalBombardment_ArmyInPosition(CvAIOperationNavalBombardment* self, CvArmyAI* pArmy, bool& result);static bool ReplaceCvAIOperationNavalBombardment_ArmyInPosition(bool (*original)(CvAIOperationNavalBombardment*, CvArmyAI*), CvAIOperationNavalBombardment* self, CvArmyAI* pArmy);CivRegisterBefore<CivHooks::CvAIOperationNavalBombardment_ArmyInPosition>(host, &BeforeCvAIOperationNavalBombardment_ArmyInPosition);CivRegisterAfter<CivHooks::CvAIOperationNavalBombardment_ArmyInPosition>(host, &AfterCvAIOperationNavalBombardment_ArmyInPosition);CivRegisterReplace<CivHooks::CvAIOperationNavalBombardment_ArmyInPosition>(host, &ReplaceCvAIOperationNavalBombardment_ArmyInPosition);
Code
4015/// Same as default version except if just gathered forces, check to see if a better target has presented itself4016bool CvAIOperationNavalBombardment::ArmyInPosition(CvArmyAI* pArmy)4017{4018 bool bStateChanged = false;40194020 switch(m_eCurrentState)4021 {4022 // If we were gathering forces, let's make sure a better target hasn't presented itself4023 case AI_OPERATION_STATE_GATHERING_FORCES:4024 {4025 // First do base case processing4026 bStateChanged = CvAIOperation::ArmyInPosition(pArmy);40274028 // Now revisit target4029 CvPlot* possibleBetterTarget;4030 possibleBetterTarget = FindBestTarget();40314032 // If no target left, abort4033 if(possibleBetterTarget == NULL)4034 {4035 m_eCurrentState = AI_OPERATION_STATE_ABORTED;4036 m_eAbortReason = AI_ABORT_NO_TARGET;4037 }40384039 // If target changed, reset to this new one4040 else if(possibleBetterTarget != GetTargetPlot())4041 {4042 // Reset our destination to be a few plots shy of the final target4043 CvPlot* pDeployPt = GC.getStepFinder().GetXPlotsFromEnd(GetOwner(), GetEnemy(), pArmy->Plot(), possibleBetterTarget, GetDeployRange(), false);4044 if(pDeployPt != NULL)4045 {4046 pArmy->SetGoalPlot(pDeployPt);4047 SetTargetPlot(possibleBetterTarget);4048 }4049 }4050 }4051 break;40524053 // See if reached our target, if so give control of these units to the tactical AI4054 case AI_OPERATION_STATE_MOVING_TO_TARGET:4055 {4056 if(pArmy->Plot() == pArmy->GetGoalPlot())4057 {4058 // Notify tactical AI to focus on this area4059 CvTemporaryZone zone;4060 zone.SetX(GetTargetPlot()->getX());4061 zone.SetY(GetTargetPlot()->getY());4062 zone.SetTargetType(AI_TACTICAL_TARGET_BOMBARDMENT_ZONE);4063 zone.SetLastTurn(GC.getGame().getGameTurn() + GC.getAI_TACTICAL_MAP_BOMBARDMENT_ZONE_TURNS());4064 GET_PLAYER(m_eOwner).GetTacticalAI()->AddTemporaryZone(zone);40654066 m_eCurrentState = AI_OPERATION_STATE_SUCCESSFUL_FINISH;4067 }4068 }4069 break;40704071 // In all other cases use base class version4072 case AI_OPERATION_STATE_ABORTED:4073 case AI_OPERATION_STATE_RECRUITING_UNITS:4074 case AI_OPERATION_STATE_AT_TARGET:4075 return CvAIOperation::ArmyInPosition(pArmy);4076 break;4077 };40784079 return bStateChanged;4080}