CvTacticalAI::IdentifyPriorityBarbarianTargets()
- Defined in
- CvTacticalAI.cpp, line 5971
- Class
- CvTacticalAI
- Hook name
CivHooks::CvTacticalAI_IdentifyPriorityBarbarianTargets
Hooks
static bool BeforeCvTacticalAI_IdentifyPriorityBarbarianTargets(CvTacticalAI* self);static void AfterCvTacticalAI_IdentifyPriorityBarbarianTargets(CvTacticalAI* self);static void ReplaceCvTacticalAI_IdentifyPriorityBarbarianTargets(void (*original)(CvTacticalAI*), CvTacticalAI* self);CivRegisterBefore<CivHooks::CvTacticalAI_IdentifyPriorityBarbarianTargets>(host, &BeforeCvTacticalAI_IdentifyPriorityBarbarianTargets);CivRegisterAfter<CivHooks::CvTacticalAI_IdentifyPriorityBarbarianTargets>(host, &AfterCvTacticalAI_IdentifyPriorityBarbarianTargets);CivRegisterReplace<CivHooks::CvTacticalAI_IdentifyPriorityBarbarianTargets>(host, &ReplaceCvTacticalAI_IdentifyPriorityBarbarianTargets);
Code
5970/// Mark units that can damage our barbarian camps as priority targets5971void CvTacticalAI::IdentifyPriorityBarbarianTargets()5972{5973 CvPlot* pLoopPlot;5974 CvTacticalTarget* pTarget;59755976 for(int iI = 0; iI < GC.getMap().numPlots(); iI++)5977 {5978 pLoopPlot = GC.getMap().plotByIndexUnchecked(iI);5979 if(pLoopPlot->getImprovementType() == GC.getBARBARIAN_CAMP_IMPROVEMENT())5980 {5981 pTarget = GetFirstUnitTarget();5982 while(pTarget != NULL)5983 {5984 bool bPriorityTarget = false;59855986 // Skip if already a priority target (because was able to strike another camp)5987 if(pTarget->GetTargetType() != AI_TACTICAL_TARGET_HIGH_PRIORITY_UNIT)5988 {5989 CvPlot* pPlot = GC.getMap().plot(pTarget->GetTargetX(), pTarget->GetTargetY());5990 UnitHandle pEnemyUnit = pPlot->getVisibleEnemyDefender(m_pPlayer->GetID());5991 if(pEnemyUnit->IsCanAttackRanged() && pEnemyUnit->GetMaxRangedCombatStrength(NULL, /*pCity*/ NULL, true, true) > pEnemyUnit->GetMaxAttackStrength(NULL, pLoopPlot, NULL))5992 {5993 if(plotDistance(pEnemyUnit->getX(), pEnemyUnit->getY(), pLoopPlot->getX(), pLoopPlot->getY()) <= pEnemyUnit->GetRange())5994 {5995 if(pEnemyUnit->canEverRangeStrikeAt(pLoopPlot->getX(), pLoopPlot->getY()))5996 {5997 bPriorityTarget = true;5998 }5999 }6000 }6001 else if(CanReachInXTurns(pEnemyUnit, pLoopPlot, 1))6002 {6003 bPriorityTarget = true;6004 }6005 if(bPriorityTarget)6006 {6007 pTarget->SetTargetType(AI_TACTICAL_TARGET_HIGH_PRIORITY_UNIT);6008 }6009 }6010 pTarget = GetNextUnitTarget();6011 }6012 }6013 }6014}
Calls
- CanReachInXTurns(UnitHandle, CvPlot *, int, bool, int *)
- CvGlobals::getBARBARIAN_CAMP_IMPROVEMENT()
- CvGlobals::getMap()
- CvMap::numPlots() const
- CvMap::plot(int, int) const
- CvMap::plotByIndexUnchecked(int) const
- CvPlayer::GetID() const
- CvPlot::getImprovementType() const
- CvPlot::getVisibleEnemyDefender(PlayerTypes)
- CvPlot::getX() const
- CvPlot::getY() const
- CvTacticalAI::GetFirstUnitTarget()
- CvTacticalAI::GetNextUnitTarget()
- CvTacticalTarget::GetTargetType()
- CvTacticalTarget::GetTargetX()
- CvTacticalTarget::GetTargetY()
- CvTacticalTarget::SetTargetType(AITacticalTargetType)
- CvUnit::canEverRangeStrikeAt(int, int, const CvPlot *) const
- CvUnit::GetMaxAttackStrength(const CvPlot *, const CvPlot *, const CvUnit *) const
- CvUnit::GetMaxRangedCombatStrength(const CvUnit *, const CvCity *, bool, bool) const
- CvUnit::GetRange() const
- CvUnit::getX() const
- CvUnit::getY() const
- CvUnit::IsCanAttackRanged() const
FObjectHandle::FObjectHandleFObjectHandle::FObjectHandleFObjectHandle::operator->- plotDistance(int, int, int, int)