本文整理汇总了C++中CvUnit::LFBgetBetterAttacker方法的典型用法代码示例。如果您正苦于以下问题:C++ CvUnit::LFBgetBetterAttacker方法的具体用法?C++ CvUnit::LFBgetBetterAttacker怎么用?C++ CvUnit::LFBgetBetterAttacker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvUnit
的用法示例。
在下文中一共展示了CvUnit::LFBgetBetterAttacker方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AI_getBestGroupAttacker
CvUnit* CvSelectionGroupAI::AI_getBestGroupAttacker(const CvPlot* pPlot, bool bPotentialEnemy, int& iUnitOdds, bool bForce, bool bNoBlitz) const
{
PROFILE_FUNC();
int iBestValue = 0;
int iBestOdds = 0;
CvUnit* pBestUnit = NULL;
CLLNode<IDInfo>* pUnitNode = headUnitNode();
bool bIsHuman = (pUnitNode != NULL) ? GET_PLAYER(::getUnit(pUnitNode->m_data)->getOwnerINLINE()).isHuman() : true;
while (pUnitNode != NULL)
{
CvUnit* pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);
if (!pLoopUnit->isDead())
{
bool bCanAttack = false;
if (pLoopUnit->getDomainType() == DOMAIN_AIR)
{
bCanAttack = pLoopUnit->canAirAttack();
}
else
{
bCanAttack = pLoopUnit->canAttack();
if (bCanAttack && bNoBlitz && pLoopUnit->isBlitz() && pLoopUnit->isMadeAttack())
{
bCanAttack = false;
}
}
if (bCanAttack)
{
if (bForce || pLoopUnit->canMove())
{
if (bForce || pLoopUnit->canMoveInto(pPlot, /*bAttack*/ true, /*bDeclareWar*/ bPotentialEnemy))
{
/************************************************************************************************/
/* BETTER_BTS_AI_MOD 02/21/10 jdog5000 */
/* */
/* Lead From Behind */
/************************************************************************************************/
// From Lead From Behind by UncutDragon
if (GC.getLFBEnable() && GC.getLFBUseCombatOdds())
{
//pLoopUnit->LFBgetBetterAttacker(&pBestUnit, pPlot, bPotentialEnemy, iBestOdds, iValue);
pLoopUnit->LFBgetBetterAttacker(&pBestUnit, pPlot, bPotentialEnemy, iBestOdds, iBestValue); // K-Mod.
}
else
{
int iOdds = pLoopUnit->AI_attackOdds(pPlot, bPotentialEnemy);
int iValue = iOdds;
FAssertMsg(iValue > 0, "iValue is expected to be greater than 0");
if (pLoopUnit->collateralDamage() > 0)
{
int iPossibleTargets = std::min((pPlot->getNumVisibleEnemyDefenders(pLoopUnit) - 1), pLoopUnit->collateralDamageMaxUnits());
if (iPossibleTargets > 0)
{
iValue *= (100 + ((pLoopUnit->collateralDamage() * iPossibleTargets) / 5));
iValue /= 100;
}
}
// if non-human, prefer the last unit that has the best value (so as to avoid splitting the group)
if (iValue > iBestValue || (!bIsHuman && iValue > 0 && iValue == iBestValue))
{
iBestValue = iValue;
iBestOdds = iOdds;
pBestUnit = pLoopUnit;
}
}
/************************************************************************************************/
/* BETTER_BTS_AI_MOD END */
/************************************************************************************************/
}
}
}
}
}
iUnitOdds = iBestOdds;
return pBestUnit;
}