本文整理汇总了C++中CvUnit::baseCombatStr方法的典型用法代码示例。如果您正苦于以下问题:C++ CvUnit::baseCombatStr方法的具体用法?C++ CvUnit::baseCombatStr怎么用?C++ CvUnit::baseCombatStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvUnit
的用法示例。
在下文中一共展示了CvUnit::baseCombatStr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AI_sumStrength
// K-Mod. I've removed bCheckMove, and changed bCheckCanAttack to include checks for moves, and for hasAlreadyAttacked / blitz
int CvSelectionGroupAI::AI_sumStrength(const CvPlot* pAttackedPlot, DomainTypes eDomainType, bool bCheckCanAttack) const
{
CLLNode<IDInfo>* pUnitNode;
CvUnit* pLoopUnit;
int strSum = 0;
bool bDefenders = pAttackedPlot ? pAttackedPlot->isVisibleEnemyUnit(getHeadOwner()) : false; // K-Mod
bool bCountCollateral = pAttackedPlot && pAttackedPlot != plot(); // K-Mod
pUnitNode = headUnitNode();
int iBaseCollateral = bCountCollateral
? iBaseCollateral = estimateCollateralWeight(pAttackedPlot, pAttackedPlot->getTeam() == getTeam() ? NO_TEAM : pAttackedPlot->getTeam())
: 0;
while (pUnitNode != NULL)
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);
if (!pLoopUnit->isDead())
{
// K-Mod. (original checks deleted.)
if (bCheckCanAttack)
{
if (pLoopUnit->getDomainType() == DOMAIN_AIR)
{
if (!pLoopUnit->canAirAttack() || !pLoopUnit->canMove() || (pAttackedPlot && bDefenders && !pLoopUnit->canMoveInto(pAttackedPlot, true, true)))
continue; // can't attack.
}
else
{
if (!pLoopUnit->canAttack() || !pLoopUnit->canMove()
|| (pAttackedPlot && bDefenders && !pLoopUnit->canMoveInto(pAttackedPlot, true, true))
|| (!pLoopUnit->isBlitz() && pLoopUnit->isMadeAttack()))
continue; // can't attack.
}
}
// K-Mod end
if (eDomainType == NO_DOMAIN || pLoopUnit->getDomainType() == eDomainType)
{
strSum += pLoopUnit->currEffectiveStr(pAttackedPlot, pLoopUnit);
// K-Mod estimate the attack power of collateral units. (cf with calculation in AI_localAttackStrength)
if (bCountCollateral && pLoopUnit->collateralDamage() > 0)
{
int iPossibleTargets = pLoopUnit->collateralDamageMaxUnits();
// If !bCheckCanAttack, then lets not assume pAttackPlot won't get more units on it.
if (bCheckCanAttack && pAttackedPlot->isVisible(getTeam(), false))
iPossibleTargets = std::min(iPossibleTargets, pAttackedPlot->getNumVisibleEnemyDefenders(pLoopUnit) - 1);
if (iPossibleTargets > 0)
{
// collateral damage is not trivial to calculate. This estimate is pretty rough.
// (Note: collateralDamage() and iBaseCollateral both include factors of 100.)
strSum += pLoopUnit->baseCombatStr() * iBaseCollateral * pLoopUnit->collateralDamage() * iPossibleTargets / 10000;
}
}
// K-Mod end
}
}
}
return strSum;
}
示例2: AI_launchAssault
bool CvSelectionGroupAI::AI_launchAssault(CvPlot* pTargetCityPlot)
{
std::multimap<int, CvUnit*, std::greater<int> > units;
std::multimap<int, CvUnit*, std::greater<int> >::iterator units_it;
CLLNode<IDInfo>* pUnitNode = plot()->headUnitNode();
CvUnit* pLoopUnit;
while (pUnitNode != NULL)
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = plot()->nextUnitNode(pUnitNode);
if (pLoopUnit->isCargo())
{
if (pLoopUnit->getTransportUnit()->getGroup() == this)
{
int iValue = pLoopUnit->baseCombatStr();
if (pLoopUnit->canAttack())
{
iValue *= 10;
}
iValue *= 100;
units.insert(std::make_pair(iValue, pLoopUnit));
}
}
}
if (units.empty())
{
return false;
}
bool bAction = false;
for (units_it = units.begin(); units_it != units.end(); ++units_it)
{
pLoopUnit = units_it->second;
if (pLoopUnit->canMove() && pLoopUnit->canAttack())
{
// if (pLoopUnit->AI_attackFromTransport(NULL, 40, 80))
// {
// bAction = true;
// }
int iPriority = 41;
pLoopUnit->AI_setMovePriority(iPriority);
}
}
// for (units_it = units.begin(); units_it != units.end(); ++units_it)
// {
// pLoopUnit = units_it->second;
// if (pLoopUnit->canMove())
// {
// if (pLoopUnit->AI_moveFromTransport(NULL))
// {
// bAction = true;
// }
// }
// }
// for (units_it = units.begin(); units_it != units.end(); ++units_it)
// {
// pLoopUnit = units_it->second;
// if (pLoopUnit->canMove() && pLoopUnit->canAttack())
// {
// if (pLoopUnit->AI_attackFromTransport(NULL, 0, 100))
// {
// bAction = true;
// }
// }
// }
if (bAction)
{
//pushMission(MISSION_SKIP);
return true;
}
return false;
}