本文整理汇总了C++中CvTacticalDominanceZone::AddEnemyUnitCount方法的典型用法代码示例。如果您正苦于以下问题:C++ CvTacticalDominanceZone::AddEnemyUnitCount方法的具体用法?C++ CvTacticalDominanceZone::AddEnemyUnitCount怎么用?C++ CvTacticalDominanceZone::AddEnemyUnitCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvTacticalDominanceZone
的用法示例。
在下文中一共展示了CvTacticalDominanceZone::AddEnemyUnitCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalculateMilitaryStrengths
//.........这里部分代码省略.........
SetIgnoreLOS(true);
}
pZone->AddFriendlyUnitCount(1);
if(pLoopUnit->isRanged())
{
pZone->AddFriendlyRangedUnitCount(1);
}
}
}
}
}
}
// Repeat for all visible enemy units (or adjacent to visible)
for(int iPlayerLoop = 0; iPlayerLoop < MAX_CIV_PLAYERS; iPlayerLoop++)
{
CvPlayer& kPlayer = GET_PLAYER((PlayerTypes) iPlayerLoop);
if(GET_TEAM(eTeam).isAtWar(kPlayer.getTeam()))
{
for(pLoopUnit = kPlayer.firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = kPlayer.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()))
{
CvPlot* pPlot;
pPlot = pLoopUnit->plot();
if(pPlot)
{
bool bVisible = true;
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; // 4 because action may still be spread out over the zone
#else
iMultiplier = (m_iTacticalRange + 4 - iDistance); // "4" so unit strength isn't totally dominated by proximity to city
#endif
if(!pPlot->isVisible(eTeam) && !pPlot->isAdjacentVisible(eTeam, false))
{
bVisible = false;
}
if(iMultiplier > 0)
{
int iUnitStrength = pLoopUnit->GetBaseCombatStrengthConsideringDamage();
if(iUnitStrength == 0 && pLoopUnit->isEmbarked() && !pZone->IsWater())
{
iUnitStrength = pLoopUnit->GetBaseCombatStrength(true);
}
if(!bVisible)
{
iUnitStrength /= 2;
}
pZone->AddEnemyStrength(iUnitStrength * iMultiplier * m_iUnitStrengthMultiplier);
int iRangedStrength = pLoopUnit->GetMaxRangedCombatStrength(NULL, /*pCity*/ NULL, true, true);
if(!bVisible)
{
iRangedStrength /= 2;
}
pZone->AddEnemyRangedStrength(iRangedStrength);
if(bVisible)
{
pZone->AddEnemyUnitCount(1);
if(iDistance < pZone->GetRangeClosestEnemyUnit())
{
pZone->SetRangeClosestEnemyUnit(iDistance);
}
if(pLoopUnit->isRanged())
{
pZone->AddEnemyRangedUnitCount(1);
}
if(pLoopUnit->getDomainType() == DOMAIN_SEA)
{
pZone->AddEnemyNavalUnitCount(1);
}
}
}
}
}
}
}
}
}
}
}
}
}
示例2: CalculateMilitaryStrengths
//.........这里部分代码省略.........
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())
pZone->SetRangeClosestEnemyUnit(iDistance);
}
else if (bFriendly)
{
#if defined(MOD_BALANCE_CORE_MILITARY_LOGGING)
//CvString msg;
//msg.Format("Zone %d, Friendly %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->GetOverallFriendlyStrength());
//GET_PLAYER(m_ePlayer).GetTacticalAI()->LogTacticalMessage(msg, true /*bSkipLogDominanceZone*/);
#endif
if (pLoopUnit->getDomainType() == DOMAIN_SEA)
{
pZone->AddFriendlyNavalStrength(iUnitStrength*iMultiplier*m_iUnitStrengthMultiplier);
pZone->AddFriendlyNavalRangedStrength(iRangedStrength*iMultiplier*m_iUnitStrengthMultiplier);
pZone->AddFriendlyNavalUnitCount(1);
}
else
{
pZone->AddFriendlyMeleeStrength(iUnitStrength*iMultiplier*m_iUnitStrengthMultiplier);
pZone->AddFriendlyRangedStrength(iRangedStrength*iMultiplier*m_iUnitStrengthMultiplier);
pZone->AddFriendlyUnitCount(1);
}
}
else
{
//neutral has only very few stats
pZone->AddNeutralStrength(iUnitStrength*iMultiplier*m_iUnitStrengthMultiplier);
pZone->AddNeutralUnitCount(1);
}
}
}
}
}
}
示例3: AddToDominanceZones
//.........这里部分代码省略.........
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()))
{
int iStrength = pEnemyUnit->GetBaseCombatStrengthConsideringDamage();
if(iStrength == 0 && pEnemyUnit->isEmbarked() && !pZone->IsWater())
{
iStrength = pEnemyUnit->GetBaseCombatStrength(true);
}
#if defined(MOD_AI_SMART_V3)
int iEnemyRangedStrength = pEnemyUnit->GetMaxRangedCombatStrength(NULL, /*pCity*/ NULL, true, true);
if (MOD_AI_SMART_V3)
{
if (!pCell->IsVisible())
{
iStrength /= 2;
iEnemyRangedStrength /= 2;
}
iEnemyRangedStrength = iEnemyRangedStrength * m_iUnitStrengthMultiplier;
}
#endif
pZone->AddEnemyStrength(iStrength * m_iUnitStrengthMultiplier);
#if defined(MOD_AI_SMART_V3)
pZone->AddEnemyRangedStrength(iEnemyRangedStrength);
#else
pZone->AddEnemyRangedStrength(pEnemyUnit->GetMaxRangedCombatStrength(NULL, /*pCity*/ NULL, true, true));
#endif
pZone->AddEnemyUnitCount(1);
if(pEnemyUnit->isRanged())
{
pZone->AddEnemyRangedUnitCount(1);
}
if (pEnemyUnit->getDomainType() == DOMAIN_SEA)
{
pZone->AddEnemyNavalUnitCount(1);
}
}
}
}
// Set zone for this cell
pCell->SetDominanceZone(pZone->GetDominanceZoneID());
}