CvMilitaryAI::GetMaxPossibleInterceptions(CvPlot *, bool) const
- Defined in
- CvMilitaryAI.cpp, line 3921
- Class
- CvMilitaryAI
- Hook name
CivHooks::CvMilitaryAI_GetMaxPossibleInterceptions
Hooks
static bool BeforeCvMilitaryAI_GetMaxPossibleInterceptions(const CvMilitaryAI* self, CvPlot* pTargetPlot, bool bCountPercents, int& result);static void AfterCvMilitaryAI_GetMaxPossibleInterceptions(const CvMilitaryAI* self, CvPlot* pTargetPlot, bool bCountPercents, int& result);static int ReplaceCvMilitaryAI_GetMaxPossibleInterceptions(int (*original)(const CvMilitaryAI*, CvPlot*, bool), const CvMilitaryAI* self, CvPlot* pTargetPlot, bool bCountPercents);CivRegisterBefore<CivHooks::CvMilitaryAI_GetMaxPossibleInterceptions>(host, &BeforeCvMilitaryAI_GetMaxPossibleInterceptions);CivRegisterAfter<CivHooks::CvMilitaryAI_GetMaxPossibleInterceptions>(host, &AfterCvMilitaryAI_GetMaxPossibleInterceptions);CivRegisterReplace<CivHooks::CvMilitaryAI_GetMaxPossibleInterceptions>(host, &ReplaceCvMilitaryAI_GetMaxPossibleInterceptions);
Code
3919#if defined(MOD_AI_SMART_V3)3920/// AMS: Get all possible interceptions on that plot, doesn't use visibility to offset AI inability to remember air attacks.3921int CvMilitaryAI::GetMaxPossibleInterceptions(CvPlot* pTargetPlot, bool bCountPercents) const3922{3923 int iRtnValue = 0;3924 int iLoopUnit;3925 CvUnit* pLoopUnit;39263927 // Loop through all the players3928 for (int iI = 0; iI < MAX_PLAYERS; iI++)3929 {3930 CvPlayer& kPlayer = GET_PLAYER((PlayerTypes)iI);39313932 if (kPlayer.isAlive() && kPlayer.GetID() != m_pPlayer->GetID())3933 {3934 if (atWar(kPlayer.getTeam(), m_pPlayer->getTeam()))3935 {3936 // Loop through their units looking for intercept capable units3937 iLoopUnit = 0;3938 for (pLoopUnit = kPlayer.firstUnit(&iLoopUnit); pLoopUnit != NULL; pLoopUnit = kPlayer.nextUnit(&iLoopUnit))3939 {3940 // Must be able to intercept this turn3941 if (!pLoopUnit->isDelayedDeath() && pLoopUnit->canAirDefend() && !pLoopUnit->isInCombat() && !pLoopUnit->isOutOfInterceptions())3942 {3943 // Must either be a non-air Unit, or an air Unit that hasn't moved this turn and is on intercept duty3944 if ((pLoopUnit->getDomainType() != DOMAIN_AIR) || !(pLoopUnit->hasMoved() && pLoopUnit->GetActivityType() == ACTIVITY_INTERCEPT))3945 {3946 // Test range3947 if (plotDistance(pLoopUnit->getX(), pLoopUnit->getY(), pTargetPlot->getX(), pTargetPlot->getY()) <= pLoopUnit->getUnitInfo().GetAirInterceptRange())3948 {3949 if (pLoopUnit->currInterceptionProbability() > 0)3950 {3951 if (bCountPercents)3952 iRtnValue += pLoopUnit->currInterceptionProbability();3953 else3954 iRtnValue++;3955 }3956 }3957 }3958 }3959 }3960 }3961 }3962 }39633964 if (bCountPercents)3965 iRtnValue /= 100;39663967 return iRtnValue;3968}
Calls
- atWar(TeamTypes, TeamTypes)
- CvPlayer::firstUnit(int *, bool)
- CvPlayer::GetID() const
- CvPlayer::getTeam() const
- CvPlayer::isAlive() const
- CvPlayer::nextUnit(int *, bool)
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlot::getX() const
- CvPlot::getY() const
- CvUnit::canAirDefend(const CvPlot *) const
- CvUnit::currInterceptionProbability() const
- CvUnit::GetActivityType() const
- CvUnit::getDomainType() const
- CvUnit::getUnitInfo() const
- CvUnit::getX() const
- CvUnit::getY() const
- CvUnit::hasMoved() const
- CvUnit::isDelayedDeath() const
- CvUnit::isInCombat() const
- CvUnit::isOutOfInterceptions() const
- CvUnitEntry::GetAirInterceptRange() const
- plotDistance(int, int, int, int)