本文整理汇总了C++中CvCity::SetThreatValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CvCity::SetThreatValue方法的具体用法?C++ CvCity::SetThreatValue怎么用?C++ CvCity::SetThreatValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvCity
的用法示例。
在下文中一共展示了CvCity::SetThreatValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateDanger
//.........这里部分代码省略.........
int iRange = pLoopUnit->baseMoves();
if (pLoopUnit->canRangeStrike())
{
iRange += pLoopUnit->GetRange();
}
CvPlot* pUnitPlot = pLoopUnit->plot();
AssignUnitDangerValue(pLoopUnit, pUnitPlot);
CvPlot* pLoopPlot = NULL;
for (int iDX = -(iRange); iDX <= iRange; iDX++)
{
for (int iDY = -(iRange); iDY <= iRange; iDY++)
{
pLoopPlot = plotXYWithRangeCheck(pUnitPlot->getX(), pUnitPlot->getY(), iDX, iDY, iRange);
if (!pLoopPlot || pLoopPlot == pUnitPlot)
{
continue;
}
if (!pLoopUnit->canMoveOrAttackInto(*pLoopPlot) && !pLoopUnit->canRangeStrikeAt(pLoopPlot->getX(),pLoopPlot->getY()))
{
continue;
}
AssignUnitDangerValue(pLoopUnit, pLoopPlot);
}
}
}
// for each city
CvCity* pLoopCity;
for (pLoopCity = loopPlayer.firstCity(&iLoop); pLoopCity != NULL; pLoopCity = loopPlayer.nextCity(&iLoop))
{
if (ShouldIgnoreCity(pLoopCity, bIgnoreVisibility))
{
continue;
}
int iRange = GC.getCITY_ATTACK_RANGE();
CvPlot* pCityPlot = pLoopCity->plot();
AssignCityDangerValue(pLoopCity, pCityPlot);
CvPlot* pLoopPlot = NULL;
for (int iDX = -(iRange); iDX <= iRange; iDX++)
{
for (int iDY = -(iRange); iDY <= iRange; iDY++)
{
pLoopPlot = plotXYWithRangeCheck(pCityPlot->getX(), pCityPlot->getY(), iDX, iDY, iRange);
if (!pLoopPlot)
{
continue;
}
AssignCityDangerValue(pLoopCity, pLoopPlot);
}
}
}
}
// Citadels
int iCitadelValue = GetDangerValueOfCitadel();
int iPlotLoop;
CvPlot *pPlot, *pAdjacentPlot;
for (iPlotLoop = 0; iPlotLoop < GC.getMap().numPlots(); iPlotLoop++)
{
pPlot = GC.getMap().plotByIndexUnchecked(iPlotLoop);
if (pPlot->isRevealed(thisTeam))
{
ImprovementTypes eImprovement = pPlot->getRevealedImprovementType(thisTeam);
if (eImprovement != NO_IMPROVEMENT && GC.getImprovementInfo(eImprovement)->GetNearbyEnemyDamage() > 0)
{
if (!ShouldIgnoreCitadel(pPlot, bIgnoreVisibility))
{
for (int iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
{
pAdjacentPlot = plotDirection(pPlot->getX(), pPlot->getY(), ((DirectionTypes)iI));
if (pAdjacentPlot != NULL)
{
AddDanger(pAdjacentPlot->getX(), pAdjacentPlot->getY(), iCitadelValue);
}
}
}
}
}
}
// testing city danger values
CvCity* pLoopCity;
int iLoopCity = 0;
for (pLoopCity = thisPlayer.firstCity(&iLoopCity); pLoopCity != NULL; pLoopCity = thisPlayer.nextCity(&iLoopCity))
{
int iThreatValue = GetCityDanger(pLoopCity);
pLoopCity->SetThreatValue(iThreatValue);
}
m_bDirty = false;
}
示例2: UpdateDanger
//.........这里部分代码省略.........
for(int iDY = -(iRange); iDY <= iRange; iDY++)
{
pLoopPlot = plotXYWithRangeCheck(pCityPlot->getX(), pCityPlot->getY(), iDX, iDY, iRange);
if(!pLoopPlot || pLoopPlot == pCityPlot)
continue;
#if defined(MOD_EVENTS_CITY_BOMBARD)
if (!bIndirectFireAllowed && !pCityPlot->canSeePlot(pLoopPlot, NO_TEAM, iRange, NO_DIRECTION))
continue;
#endif
AssignCityDangerValue(pLoopCity, pLoopPlot);
}
}
}
}
// now compare the new known units with the previous known units
for (UnitSet::iterator it = previousKnownUnits.begin(); it != previousKnownUnits.end(); ++it)
{
//might have made peace ...
if (ShouldIgnorePlayer(it->first))
continue;
if (m_knownUnits.find(*it) == m_knownUnits.end())
{
CvUnit* pVanishedUnit = GET_PLAYER(it->first).getUnit(it->second);
//it's still there, but moved out of sight - nevertheless count is, a human would do that as well
//do not add it to the known units though, so next turn we will have forgotten about it
if (pVanishedUnit)
UpdateDangerSingleUnit(pVanishedUnit, true, false);
}
}
int iPlotLoop;
CvPlot* pPlot, *pAdjacentPlot;
for(iPlotLoop = 0; iPlotLoop < GC.getMap().numPlots(); iPlotLoop++)
{
pPlot = GC.getMap().plotByIndexUnchecked(iPlotLoop);
if(pPlot->isRevealed(thisTeam))
{
//remember the plot based damage, but it depends on the unit's promotions also, so we won't apply it directly
int iPlotDamage = 0;
if (pPlot->getFeatureType() != NO_FEATURE)
iPlotDamage += (GC.getFeatureInfo(pPlot->getFeatureType())->getTurnDamage());
if (pPlot->getTerrainType() != NO_FEATURE)
iPlotDamage += (GC.getTerrainInfo(pPlot->getTerrainType())->getTurnDamage());
m_DangerPlots[iPlotLoop].m_bFlatPlotDamage = (iPlotDamage>0);
ImprovementTypes eImprovement = pPlot->getRevealedImprovementType(thisTeam);
if(eImprovement != NO_IMPROVEMENT && GC.getImprovementInfo(eImprovement)->GetNearbyEnemyDamage() > 0)
{
if(!ShouldIgnoreCitadel(pPlot, bIgnoreVisibility))
{
for(int iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
{
pAdjacentPlot = plotDirection(pPlot->getX(), pPlot->getY(), ((DirectionTypes)iI));
if(pAdjacentPlot != NULL)
{
m_DangerPlots[iPlotLoop].m_pCitadel = pPlot;
}
}
}
}
}
}
// testing city danger values
CvCity* pLoopCity;
int iLoopCity = 0;
for(pLoopCity = thisPlayer.firstCity(&iLoopCity); pLoopCity != NULL; pLoopCity = thisPlayer.nextCity(&iLoopCity))
{
//adding danger would count each unit multiple times, is biased towards fast units
//so we pretend they would all attack the city and tally up the damage
//question is, what about our own defensive units in the area. should we count those as well?
int iEvalRange = 4;
int iThreatValue = 0;
for(int iX = -iEvalRange; iX <= iEvalRange; iX++)
for(int iY = -iEvalRange; iY <= iEvalRange; iY++)
{
CvPlot* pEvalPlot = plotXYWithRangeCheck(pLoopCity->getX(), pLoopCity->getY(), iX, iY, iEvalRange);
if (pEvalPlot)
{
const CvUnit* pEnemy = pEvalPlot->getBestDefender(NO_PLAYER, thisPlayer.GetID(), NULL, true);
if (pEnemy)
{
int iAttackerDamage = 0; //to be ignored
iThreatValue += TacticalAIHelpers::GetSimulatedDamageFromAttackOnCity(pLoopCity,pEnemy,iAttackerDamage);
}
}
}
pLoopCity->SetThreatValue(iThreatValue);
}
m_bDirty = false;
}