本文整理汇总了C++中CvUnit::GetAirSweepCombatModifier方法的典型用法代码示例。如果您正苦于以下问题:C++ CvUnit::GetAirSweepCombatModifier方法的具体用法?C++ CvUnit::GetAirSweepCombatModifier怎么用?C++ CvUnit::GetAirSweepCombatModifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvUnit
的用法示例。
在下文中一共展示了CvUnit::GetAirSweepCombatModifier方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAirUnitDamage
int CvDangerPlotContents::GetAirUnitDamage(const CvUnit* pUnit, AirActionType iAirAction)
{
if (pUnit->getDomainType() != DOMAIN_AIR)
return 0;
if (iAirAction == AIR_ACTION_INTERCEPT) // Max damage from a potential air sweep against our intercept
{
int iBestAirSweepDamage = 0;
int iCurrentAirSweepDamage = 0;
for (DangerUnitVector::iterator it = m_apUnits.begin(); it < m_apUnits.end(); ++it)
{
CvUnit* pAttacker = GET_PLAYER(it->first).getUnit(it->second);
if (!pAttacker || !pAttacker->canAirSweep() || pAttacker->isDelayedDeath() || pAttacker->IsDead())
{
continue;
}
int iAttackerStrength = pAttacker->GetMaxRangedCombatStrength(pUnit, /*pCity*/ NULL, true, false);
iAttackerStrength *= (100 + pAttacker->GetAirSweepCombatModifier());
iAttackerStrength /= 100;
int iDefenderStrength = pUnit->GetMaxRangedCombatStrength(pUnit, /*pCity*/ NULL, false, false);
iCurrentAirSweepDamage = pUnit->getCombatDamage(iDefenderStrength, iAttackerStrength,
pUnit->getDamage(), /*bIncludeRand*/ false, /*bAttackerIsCity*/ false, /*bDefenderIsCity*/ false);
// It's a slower to have this in the unit loop instead of after the best damage has been calculated, but it's also more accurate
if (iCurrentAirSweepDamage >= pAttacker->GetCurrHitPoints())
{
int iReceiverDamage = pAttacker->getCombatDamage(iAttackerStrength, iDefenderStrength,
pAttacker->getDamage(), /*bIncludeRand*/ false, /*bAttackerIsCity*/ false, /*bDefenderIsCity*/ false);
if (iReceiverDamage >= pUnit->GetCurrHitPoints())
{
if (iReceiverDamage + pUnit->getDamage() > iCurrentAirSweepDamage + pAttacker->getDamage())
{
iCurrentAirSweepDamage = pUnit->GetCurrHitPoints() - 1;
}
}
}
if (iCurrentAirSweepDamage > iBestAirSweepDamage)
{
iBestAirSweepDamage = iCurrentAirSweepDamage;
}
}
return iBestAirSweepDamage;
}
else
{
CvUnit* pInterceptor = pUnit->GetBestInterceptor(*m_pPlot);
if (pInterceptor)
{
// Air sweeps take modified damage from interceptors
if (iAirAction == AIR_ACTION_SWEEP)
{
if (pInterceptor->getDomainType() != DOMAIN_AIR)
{
return (pInterceptor->GetInterceptionDamage(pUnit, false) * (100+GC.getAIR_SWEEP_INTERCEPTION_DAMAGE_MOD()))/100;
}
else
{
int iAttackerStrength = pUnit->GetMaxRangedCombatStrength(pInterceptor, /*pCity*/ NULL, true, false);
iAttackerStrength *= (100 + pUnit->GetAirSweepCombatModifier());
iAttackerStrength /= 100;
int iDefenderStrength = pInterceptor->GetMaxRangedCombatStrength(pUnit, /*pCity*/ NULL, false, false);
int iReceiveDamage = pInterceptor->getCombatDamage(iDefenderStrength, iAttackerStrength,
pInterceptor->getDamage(), /*bIncludeRand*/ false, /*bAttackerIsCity*/ false, /*bDefenderIsCity*/ false);
if (iReceiveDamage >= pUnit->GetCurrHitPoints())
{
int iDamageDealt = pUnit->getCombatDamage(iAttackerStrength, iDefenderStrength,
pUnit->getDamage(), /*bIncludeRand*/ false, /*bAttackerIsCity*/ false, /*bDefenderIsCity*/ false);
if (iDamageDealt >= pInterceptor->GetCurrHitPoints())
{
if (iDamageDealt + pInterceptor->getDamage() > iReceiveDamage + pUnit->getDamage())
{
iReceiveDamage = pUnit->GetCurrHitPoints() - 1;
}
}
}
return iReceiveDamage;
}
}
else
{
// Always assume interception is successful
return pInterceptor->GetInterceptionDamage(pUnit, false);
}
}
}
return 0;
}