CvTacticalAI::PlotWithdrawMoves()
- Defined in
- CvTacticalAI.cpp, line 3873
- Class
- CvTacticalAI
- Hook name
CivHooks::CvTacticalAI_PlotWithdrawMoves
Hooks
static bool BeforeCvTacticalAI_PlotWithdrawMoves(CvTacticalAI* self);static void AfterCvTacticalAI_PlotWithdrawMoves(CvTacticalAI* self);static void ReplaceCvTacticalAI_PlotWithdrawMoves(void (*original)(CvTacticalAI*), CvTacticalAI* self);CivRegisterBefore<CivHooks::CvTacticalAI_PlotWithdrawMoves>(host, &BeforeCvTacticalAI_PlotWithdrawMoves);CivRegisterAfter<CivHooks::CvTacticalAI_PlotWithdrawMoves>(host, &AfterCvTacticalAI_PlotWithdrawMoves);CivRegisterReplace<CivHooks::CvTacticalAI_PlotWithdrawMoves>(host, &ReplaceCvTacticalAI_PlotWithdrawMoves);
Code
3872/// Withdraw out of current dominance zone3873void CvTacticalAI::PlotWithdrawMoves()3874{3875 list<int>::iterator it;3876 m_CurrentMoveUnits.clear();3877 CvTacticalUnit unit;38783879 CvTacticalDominanceZone* pZone = m_pMap->GetZone(m_iCurrentZoneIndex);38803881 // Loop through all recruited units3882 for(it = m_CurrentTurnUnits.begin(); it != m_CurrentTurnUnits.end(); it++)3883 {3884 UnitHandle pUnit = m_pPlayer->getUnit(*it);3885 if(pUnit)3886 {3887 // Proper domain of unit?3888 if(pZone->IsWater() && pUnit->getDomainType() == DOMAIN_SEA || !pZone->IsWater() && pUnit->getDomainType() == DOMAIN_LAND)3889 {3890 // Am I in the current dominance zone?3891 int iPlotIndex = GC.getMap().plotNum(pUnit->getX(), pUnit->getY());3892 if(m_pMap->GetCell(iPlotIndex)->GetDominanceZone() == m_pMap->GetZone(m_iCurrentZoneIndex)->GetDominanceZoneID())3893 {3894 unit.SetID(pUnit->GetID());3895 m_CurrentMoveUnits.push_back(unit);3896 }38973898 // Or am I within tactical recruit range of center of zone and in danger and not in friendly territory?3899 else if(pZone->GetClosestCity() != NULL)3900 {3901 if(plotDistance(pZone->GetClosestCity()->getX(), pZone->GetClosestCity()->getY(), pUnit->getX(), pUnit->getY()) <= m_iRecruitRange)3902 {3903 CvPlot* pPlot = pUnit->plot();3904 if(m_pPlayer->GetPlotDanger(*pPlot) > 0)3905 {3906 if(pUnit->plot()->getOwner() != pUnit->getOwner())3907 {3908 unit.SetID(pUnit->GetID());3909 m_CurrentMoveUnits.push_back(unit);3910 }3911 }3912 }3913 }39143915 // Or we are withdrawing from unowned lands zone and this is a plot in danger3916 else if(pZone->GetTerritoryType() == TACTICAL_TERRITORY_NO_OWNER)3917 {3918 CvPlot* pPlot = pUnit->plot();3919 if(m_pPlayer->GetPlotDanger(*pPlot) > 0)3920 {3921 if(pUnit->plot()->getOwner() != pUnit->getOwner())3922 {3923 unit.SetID(pUnit->GetID());3924 m_CurrentMoveUnits.push_back(unit);3925 }3926 }3927 }3928 }3929 }3930 }39313932 if(m_CurrentMoveUnits.size() > 0)3933 {3934 ExecuteWithdrawMoves();3935 }3936}
Calls
- CvCity::getX() const
- CvCity::getY() const
- CvGlobals::getMap()
- CvMap::plotNum(int, int) const
- CvPlayer::GetPlotDanger(CvPlot &) const
- CvPlayer::getUnit(int)
- CvPlot::getOwner() const
- CvTacticalAI::ExecuteWithdrawMoves()
- CvTacticalAnalysisCell::GetDominanceZone() const
- CvTacticalAnalysisMap::GetCell(int)
- CvTacticalAnalysisMap::GetZone(int)
- CvTacticalDominanceZone::GetClosestCity() const
- CvTacticalDominanceZone::GetDominanceZoneID() const
- CvTacticalDominanceZone::GetTerritoryType() const
- CvTacticalDominanceZone::IsWater() const
- CvTacticalUnit::CvTacticalUnit()
- CvTacticalUnit::SetID(int)
- CvUnit::getDomainType() const
- CvUnit::GetID() const
- CvUnit::getOwner() const
- CvUnit::getX() const
- CvUnit::getY() const
- CvUnit::plot() const
FObjectHandle::FObjectHandleFObjectHandle::operator boolFObjectHandle::operator->- plotDistance(int, int, int, int)
std::list::_Const_iterator::operator!=std::list::_Iterator::_Iteratorstd::list::_Iterator::operator*std::list::_Iterator::operator++std::list::_Iterator::operator=std::list::beginstd::list::endstd::vector::clearstd::vector::push_backstd::vector::size