CvHomelandAI::ExecuteAircraftInterceptions()
- Defined in
- CvHomelandAI.cpp, line 4722
- Class
- CvHomelandAI
- Hook name
CivHooks::CvHomelandAI_ExecuteAircraftInterceptions
Hooks
static bool BeforeCvHomelandAI_ExecuteAircraftInterceptions(CvHomelandAI* self);static void AfterCvHomelandAI_ExecuteAircraftInterceptions(CvHomelandAI* self);static void ReplaceCvHomelandAI_ExecuteAircraftInterceptions(void (*original)(CvHomelandAI*), CvHomelandAI* self);CivRegisterBefore<CivHooks::CvHomelandAI_ExecuteAircraftInterceptions>(host, &BeforeCvHomelandAI_ExecuteAircraftInterceptions);CivRegisterAfter<CivHooks::CvHomelandAI_ExecuteAircraftInterceptions>(host, &AfterCvHomelandAI_ExecuteAircraftInterceptions);CivRegisterReplace<CivHooks::CvHomelandAI_ExecuteAircraftInterceptions>(host, &ReplaceCvHomelandAI_ExecuteAircraftInterceptions);
Code
4720#if defined(MOD_AI_SMART_V3)4721// Similar to interception moves on tacticalAI, grant some interceptions based on number of enemies4722void CvHomelandAI::ExecuteAircraftInterceptions()4723{4724 MoveUnitsArray::iterator it;4725 std::vector<CvPlot*> checkedPlotList;47264727 for(it = m_CurrentMoveUnits.begin(); it != m_CurrentMoveUnits.end(); ++it)4728 {4729 UnitHandle pUnit = m_pPlayer->getUnit(it->GetID());47304731 if(pUnit)4732 {4733 // Am I eligible to intercept?4734 if(pUnit->canAirPatrol(NULL) && !m_pPlayer->GetMilitaryAI()->WillAirUnitRebase(pUnit.pointer()))4735 {4736 CvPlot* pUnitPlot = pUnit->plot();4737 int iNumNearbyBombers = m_pPlayer->GetMilitaryAI()->GetNumEnemyAirUnitsInRange(pUnitPlot, pUnit->GetRange(), false/*bCountFighters*/, true/*bCountBombers*/);4738 int iNumNearbyFighters = m_pPlayer->GetMilitaryAI()->GetNumEnemyAirUnitsInRange(pUnitPlot, pUnit->GetRange(), true/*bCountFighters*/, false/*bCountBombers*/);4739 int iNumPlotNumAlreadySet = m_pPlayer->GetTacticalAI()->SamePlotFound(checkedPlotList, pUnitPlot);47404741 if (iNumNearbyBombers == 1)4742 {4743 // To at least intercept once if only one bomber found.4744 iNumNearbyBombers++;4745 }47464747 int maxInterceptorsWanted = ((iNumNearbyBombers / 2) + (iNumNearbyFighters / 4));47484749 if (iNumPlotNumAlreadySet < maxInterceptorsWanted)4750 {4751 if(GC.getLogging() && GC.getAILogging())4752 {4753 CvString strTemp;4754 strTemp = GC.getUnitInfo(pUnit->getUnitType())->GetDescription();4755 CvString strLogString;4756 strLogString.Format("(%d of %d) - Ready to intercept enemy air units at, X: %d, Y: %d", iNumPlotNumAlreadySet, maxInterceptorsWanted, pUnit->getX(), pUnit->getY());4757 LogHomelandMessage(strLogString);4758 }47594760 checkedPlotList.push_back(pUnitPlot);4761 pUnit->PushMission(CvTypes::getMISSION_AIRPATROL());4762 pUnit->finishMoves();4763 UnitProcessed(pUnit->GetID());4764 }4765 }4766 }4767 }4768}
Calls
BaseVector::beginBaseVector::end- CvBaseInfo::GetDescription() const
- CvGlobals::getAILogging()
- CvGlobals::getLogging()
- CvGlobals::getUnitInfo(UnitTypes)
- CvHomelandAI::LogHomelandMessage(CvString &)
- CvHomelandAI::UnitProcessed(int)
- CvHomelandUnit::GetID() const
- CvMilitaryAI::GetNumEnemyAirUnitsInRange(CvPlot *, int, bool, bool) const
- CvMilitaryAI::WillAirUnitRebase(CvUnit *) const
- CvPlayer::GetMilitaryAI() const
- CvPlayer::GetTacticalAI() const
- CvPlayer::getUnit(int)
CvString::CvStringCvString::FormatCvString::operator=- CvTacticalAI::SamePlotFound(vector<CvPlot *>, CvPlot *)
- CvTypes::getMISSION_AIRPATROL()
- CvUnit::canAirPatrol(const CvPlot *) const
- CvUnit::finishMoves()
- CvUnit::GetID() const
- CvUnit::GetRange() const
- CvUnit::getUnitType() const
- CvUnit::getX() const
- CvUnit::getY() const
- CvUnit::plot() const
- CvUnit::PushMission(MissionTypes, int, int, int, bool, bool, MissionAITypes, CvPlot *, CvUnit *)
FObjectHandle::FObjectHandleFObjectHandle::operator boolFObjectHandle::operator->FObjectHandle::pointerstd::vector::push_backstd::vector::vectorstd::vector::vector