CvTacticalAI::ExecuteMoveToTarget(CvPlot *)
- Defined in
- CvTacticalAI.cpp, line 7575
- Class
- CvTacticalAI
- Hook name
CivHooks::CvTacticalAI_ExecuteMoveToTarget
Hooks
static bool BeforeCvTacticalAI_ExecuteMoveToTarget(CvTacticalAI* self, CvPlot* pTarget);static void AfterCvTacticalAI_ExecuteMoveToTarget(CvTacticalAI* self, CvPlot* pTarget);static void ReplaceCvTacticalAI_ExecuteMoveToTarget(void (*original)(CvTacticalAI*, CvPlot*), CvTacticalAI* self, CvPlot* pTarget);CivRegisterBefore<CivHooks::CvTacticalAI_ExecuteMoveToTarget>(host, &BeforeCvTacticalAI_ExecuteMoveToTarget);CivRegisterAfter<CivHooks::CvTacticalAI_ExecuteMoveToTarget>(host, &AfterCvTacticalAI_ExecuteMoveToTarget);CivRegisterReplace<CivHooks::CvTacticalAI_ExecuteMoveToTarget>(host, &ReplaceCvTacticalAI_ExecuteMoveToTarget);
Code
7574/// Find one unit to move to target, starting with high priority list7575void CvTacticalAI::ExecuteMoveToTarget(CvPlot* pTarget)7576{7577 std::vector<CvTacticalUnit>::iterator it;75787579 // Start with high priority list7580 for(it = m_CurrentMoveHighPriorityUnits.begin(); it != m_CurrentMoveHighPriorityUnits.end(); ++it)7581 {7582 UnitHandle pUnit = m_pPlayer->getUnit(it->GetID());75837584 // Don't move high priority unit if regular priority unit is closer7585 if(m_CurrentMoveUnits.size() > 0 && m_CurrentMoveUnits.begin()->GetMovesToTarget() < it->GetMovesToTarget())7586 {7587 break;7588 }75897590 if(pUnit->plot() == pTarget && pUnit->canFortify(pUnit->plot()))7591 {7592 pUnit->PushMission(CvTypes::getMISSION_FORTIFY());7593 pUnit->SetFortifiedThisTurn(true);7594 UnitProcessed(it->GetID());7595 return;7596 }75977598 else if(pUnit && it->GetMovesToTarget() < MAX_INT)7599 {7600 pUnit->PushMission(CvTypes::getMISSION_MOVE_TO(), pTarget->getX(), pTarget->getY());7601 pUnit->finishMoves();7602 UnitProcessed(it->GetID());7603 return;7604 }7605 }76067607 // Then regular priority7608 for(it = m_CurrentMoveUnits.begin(); it != m_CurrentMoveUnits.end(); ++it)7609 {7610 UnitHandle pUnit = m_pPlayer->getUnit(it->GetID());76117612 if(pUnit->plot() == pTarget && pUnit->canFortify(pUnit->plot()))7613 {7614 pUnit->PushMission(CvTypes::getMISSION_FORTIFY());7615 pUnit->SetFortifiedThisTurn(true);7616 UnitProcessed(it->GetID());7617 return;7618 }76197620 else if(pUnit && it->GetMovesToTarget() < MAX_INT)7621 {7622 pUnit->PushMission(CvTypes::getMISSION_MOVE_TO(), pTarget->getX(), pTarget->getY());7623 pUnit->finishMoves();7624 UnitProcessed(it->GetID());7625 return;7626 }7627 }7628}
Calls
- CvPlayer::getUnit(int)
- CvPlot::getX() const
- CvPlot::getY() const
- CvTacticalAI::UnitProcessed(int, bool)
- CvTacticalUnit::GetID() const
- CvTacticalUnit::GetMovesToTarget() const
- CvTypes::getMISSION_FORTIFY()
- CvTypes::getMISSION_MOVE_TO()
- CvUnit::canFortify(const CvPlot *) const
- CvUnit::finishMoves()
- CvUnit::plot() const
- CvUnit::PushMission(MissionTypes, int, int, int, bool, bool, MissionAITypes, CvPlot *, CvUnit *)
- CvUnit::SetFortifiedThisTurn(bool)
FObjectHandle::FObjectHandleFObjectHandle::operator boolFObjectHandle::operator->std::_Vector_const_iterator::operator!=std::_Vector_iterator::_Vector_iteratorstd::_Vector_iterator::operator++std::_Vector_iterator::operator->std::_Vector_iterator::operator=std::vector::beginstd::vector::endstd::vector::size