本文整理汇总了C++中CvUnit::GetMaxRangedCombatStrength方法的典型用法代码示例。如果您正苦于以下问题:C++ CvUnit::GetMaxRangedCombatStrength方法的具体用法?C++ CvUnit::GetMaxRangedCombatStrength怎么用?C++ CvUnit::GetMaxRangedCombatStrength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvUnit
的用法示例。
在下文中一共展示了CvUnit::GetMaxRangedCombatStrength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalculateMilitaryStrengths
//.........这里部分代码省略.........
iDistance = plotDistance(pLoopUnit->getX(), pLoopUnit->getY(), pClosestCity->getX(), pClosestCity->getY());
if (iDistance > m_iTacticalRange)
continue;
else if (iDistance > (m_iTacticalRange / 2))
{
if (bZoneTypeMismatch)
continue;
else
bReducedStrength = true;
}
else
{
//if on another continent, they can't easily take part in the fight
if (!pClosestCity->isMatchingArea(pLoopUnit->plot()))
bReducedStrength = true;
}
}
else
{
//if there is no city, the unit must be in the zone itself
if ( GetCell(pLoopUnit->plot()->GetPlotIndex())->GetDominanceZone() != pZone->GetDominanceZoneID() )
continue;
}
int iMultiplier = m_iTacticalRange + MIN(3 - iDistance, 0); // 3 because action may still be spread out over the zone
if(iMultiplier > 0)
{
int iUnitStrength = pLoopUnit->GetBaseCombatStrengthConsideringDamage();
//unit might disembark ... so don't count it for water zone, but for adjacent land
if(iUnitStrength == 0 && pLoopUnit->isEmbarked() && !pZone->IsWater())
iUnitStrength = pLoopUnit->GetBaseCombatStrength();
int iRangedStrength = pLoopUnit->GetMaxRangedCombatStrength(NULL, /*pCity*/ NULL, true, true) / 100;
if(!bVisible || bReducedStrength)
{
iUnitStrength /= 2;
iRangedStrength /= 2;
}
if (bEnemy)
{
#if defined(MOD_BALANCE_CORE_MILITARY_LOGGING)
//CvString msg;
//msg.Format("Zone %d, Enemy %s %d with %d hp at %d,%d - distance %d, strength %d, ranged strength %d (total %d)",
// pZone->GetDominanceZoneID(), pLoopUnit->getName().c_str(), pLoopUnit->GetID(), pLoopUnit->GetCurrHitPoints(),
// pLoopUnit->getX(), pLoopUnit->getY(), iDistance, iUnitStrength, iRangedStrength, pZone->GetOverallEnemyStrength());
//GET_PLAYER(m_ePlayer).GetTacticalAI()->LogTacticalMessage(msg, true /*bSkipLogDominanceZone*/);
#endif
if (pLoopUnit->getDomainType() == DOMAIN_SEA)
{
pZone->AddEnemyNavalStrength(iUnitStrength*iMultiplier*m_iUnitStrengthMultiplier);
pZone->AddEnemyNavalRangedStrength(iRangedStrength*iMultiplier*m_iUnitStrengthMultiplier);
pZone->AddEnemyNavalUnitCount(1);
}
else
{
pZone->AddEnemyMeleeStrength(iUnitStrength*iMultiplier*m_iUnitStrengthMultiplier);
pZone->AddEnemyRangedStrength(iRangedStrength*iMultiplier*m_iUnitStrengthMultiplier);
pZone->AddEnemyUnitCount(1);
}
//again only for enemies
if(pZone->GetRangeClosestEnemyUnit()<0 || iDistance<pZone->GetRangeClosestEnemyUnit())
示例2: CalculateMilitaryStrengths
/// Calculate military presences in each owned dominance zone
void CvTacticalAnalysisMap::CalculateMilitaryStrengths()
{
// Loop through the dominance zones
CvTacticalDominanceZone* pZone;
CvCity* pClosestCity = NULL;
int iDistance;
int iMultiplier;
int iLoop;
CvUnit* pLoopUnit;
TeamTypes eTeam;
eTeam = m_pPlayer->getTeam();
for(unsigned int iI = 0; iI < m_DominanceZones.size(); iI++)
{
pZone = &m_DominanceZones[iI];
if(pZone->GetTerritoryType() != TACTICAL_TERRITORY_NO_OWNER)
{
pClosestCity = pZone->GetClosestCity();
if(pClosestCity)
{
// Start with strength of the city itself
int iCityHitPoints = pClosestCity->GetMaxHitPoints() - pClosestCity->getDamage();
int iStrength = m_iTacticalRange * pClosestCity->getStrengthValue() * iCityHitPoints / GC.getMAX_CITY_HIT_POINTS();
if(pZone->GetTerritoryType() == TACTICAL_TERRITORY_FRIENDLY)
{
pZone->AddFriendlyStrength(iStrength);
#if defined(MOD_AI_SMART_V3)
pZone->AddFriendlyRangedStrength(pClosestCity->getStrengthValue(MOD_AI_SMART_V3));
#else
pZone->AddFriendlyRangedStrength(pClosestCity->getStrengthValue());
#endif
}
#if defined(MOD_AI_SMART_V3)
else if(!MOD_AI_SMART_V3 || pZone->GetTerritoryType() == TACTICAL_TERRITORY_ENEMY)
#else
else
#endif
{
pZone->AddEnemyStrength(iStrength);
#if defined(MOD_AI_SMART_V3)
pZone->AddEnemyRangedStrength(pClosestCity->getStrengthValue(MOD_AI_SMART_V3));
#else
pZone->AddEnemyRangedStrength(pClosestCity->getStrengthValue());
#endif
}
// Loop through all of OUR units first
for(pLoopUnit = m_pPlayer->firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = m_pPlayer->nextUnit(&iLoop))
{
if(pLoopUnit->IsCombatUnit())
{
if(pLoopUnit->getDomainType() == DOMAIN_AIR ||
#if defined(MOD_AI_SMART_V3)
//ranged power is cross-domain!
(MOD_AI_SMART_V3 && pLoopUnit->isRanged()) ||
#endif
(pLoopUnit->getDomainType() == DOMAIN_LAND && !pZone->IsWater()) ||
(pLoopUnit->getDomainType() == DOMAIN_SEA && pZone->IsWater()))
{
iDistance = plotDistance(pLoopUnit->getX(), pLoopUnit->getY(), pClosestCity->getX(), pClosestCity->getY());
if (iDistance <= m_iTacticalRange)
{
#if defined(MOD_AI_SMART_V3)
int iRange = MOD_AI_SMART_V3 ? MIN(4 - iDistance, 0) : 4 - iDistance;
iMultiplier = m_iTacticalRange + iRange;
#else
iMultiplier = (m_iTacticalRange + 4 - iDistance); // "4" so unit strength isn't totally dominated by proximity to city
#endif
if(iMultiplier > 0)
{
int iUnitStrength = pLoopUnit->GetBaseCombatStrengthConsideringDamage();
if(iUnitStrength == 0 && pLoopUnit->isEmbarked() && !pZone->IsWater())
{
iUnitStrength = pLoopUnit->GetBaseCombatStrength(true);
}
pZone->AddFriendlyStrength(iUnitStrength * iMultiplier * m_iUnitStrengthMultiplier);
pZone->AddFriendlyRangedStrength(pLoopUnit->GetMaxRangedCombatStrength(NULL, /*pCity*/ NULL, true, true));
if(pLoopUnit->GetRange() > GetBestFriendlyRange())
{
SetBestFriendlyRange(pLoopUnit->GetRange());
}
if(pLoopUnit->IsRangeAttackIgnoreLOS())
{
SetIgnoreLOS(true);
}
pZone->AddFriendlyUnitCount(1);
if(pLoopUnit->isRanged())
{
pZone->AddFriendlyRangedUnitCount(1);
}
}
}
}
}
}
// Repeat for all visible enemy units (or adjacent to visible)
//.........这里部分代码省略.........
示例3: 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;
}
示例4: AddToDominanceZones
/// Add data for this cell into dominance zone information
void CvTacticalAnalysisMap::AddToDominanceZones(int iIndex, CvTacticalAnalysisCell* pCell)
{
CvPlot* pPlot = GC.getMap().plotByIndex(iIndex);
// Compute zone data for this cell
m_TempZone.SetAreaID(pPlot->getArea());
m_TempZone.SetOwner(pPlot->getOwner());
m_TempZone.SetWater(pPlot->isWater());
if(!pPlot->isOwned())
{
m_TempZone.SetTerritoryType(TACTICAL_TERRITORY_NO_OWNER);
}
else if(pPlot->getTeam() == m_pPlayer->getTeam())
{
m_TempZone.SetTerritoryType(TACTICAL_TERRITORY_FRIENDLY);
}
else if(GET_TEAM(m_pPlayer->getTeam()).isAtWar(pPlot->getTeam()))
{
m_TempZone.SetTerritoryType(TACTICAL_TERRITORY_ENEMY);
}
else
{
m_TempZone.SetTerritoryType(TACTICAL_TERRITORY_NEUTRAL);
}
m_TempZone.SetClosestCity(NULL);
if(m_TempZone.GetTerritoryType() == TACTICAL_TERRITORY_ENEMY ||
m_TempZone.GetTerritoryType() == TACTICAL_TERRITORY_NEUTRAL ||
m_TempZone.GetTerritoryType() == TACTICAL_TERRITORY_FRIENDLY)
{
int iLoop;
int iBestDistance = MAX_INT;
CvCity* pBestCity = NULL;
for(CvCity* pLoopCity = GET_PLAYER(m_TempZone.GetOwner()).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(m_TempZone.GetOwner()).nextCity(&iLoop))
{
int iDistance = plotDistance(pLoopCity->getX(), pLoopCity->getY(), pPlot->getX(), pPlot->getY());
if(iDistance < iBestDistance)
{
iBestDistance = iDistance;
pBestCity = pLoopCity;
}
}
if(pBestCity != NULL)
{
m_TempZone.SetClosestCity(pBestCity);
}
}
// Now see if we already have a matching zone
CvTacticalDominanceZone* pZone = FindExistingZone(pPlot);
if(!pZone)
{
// Data populated, now add to vector
m_TempZone.SetDominanceZoneID(m_DominanceZones.size());
m_DominanceZones.push_back(m_TempZone);
pZone = &m_DominanceZones[m_DominanceZones.size() - 1];
}
// If this isn't owned territory, update zone with military strength info
if(pZone->GetTerritoryType() == TACTICAL_TERRITORY_NO_OWNER ||
pZone->GetTerritoryType() == TACTICAL_TERRITORY_TEMP_ZONE)
{
CvUnit* pFriendlyUnit = pCell->GetFriendlyMilitaryUnit();
if(pFriendlyUnit)
{
if(pFriendlyUnit->getDomainType() == DOMAIN_AIR ||
(pFriendlyUnit->getDomainType() == DOMAIN_LAND && !pZone->IsWater()) ||
(pFriendlyUnit->getDomainType() == DOMAIN_SEA && pZone->IsWater()))
{
int iStrength = pFriendlyUnit->GetBaseCombatStrengthConsideringDamage();
if(iStrength == 0 && pFriendlyUnit->isEmbarked() && !pZone->IsWater())
{
iStrength = pFriendlyUnit->GetBaseCombatStrength(true);
}
pZone->AddFriendlyStrength(iStrength * m_iUnitStrengthMultiplier);
pZone->AddFriendlyRangedStrength(pFriendlyUnit->GetMaxRangedCombatStrength(NULL, /*pCity*/ NULL, true, true));
if(pFriendlyUnit->GetRange() > GetBestFriendlyRange())
{
SetBestFriendlyRange(pFriendlyUnit->GetRange());
}
if(pFriendlyUnit->IsRangeAttackIgnoreLOS())
{
SetIgnoreLOS(true);
}
pZone->AddFriendlyUnitCount(1);
if(pFriendlyUnit->isRanged())
{
pZone->AddFriendlyRangedUnitCount(1);
}
}
}
CvUnit* pEnemyUnit = pCell->GetEnemyMilitaryUnit();
if(pEnemyUnit)
{
if(pEnemyUnit->getDomainType() == DOMAIN_AIR ||
(pEnemyUnit->getDomainType() == DOMAIN_LAND && !pZone->IsWater()) ||
(pEnemyUnit->getDomainType() == DOMAIN_SEA && pZone->IsWater()))
//.........这里部分代码省略.........