本文整理汇总了C++中CvPlot类的典型用法代码示例。如果您正苦于以下问题:C++ CvPlot类的具体用法?C++ CvPlot怎么用?C++ CvPlot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CvPlot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFirstUnit
CvPlot* CvArmyAI::DetectNearbyEnemy(PlayerTypes eEnemy, bool bNaval)
{
UnitHandle pUnit = GetFirstUnit();
while(pUnit)
{
for(int iDirectionLoop = 0; iDirectionLoop < NUM_DIRECTION_TYPES; ++iDirectionLoop)
{
CvPlot* pAdjacentPlot = plotDirection(pUnit->getX(), pUnit->getY(), ((DirectionTypes)iDirectionLoop));
if(pAdjacentPlot != NULL && pAdjacentPlot->isWater()==bNaval && pAdjacentPlot->getOwner() == eEnemy)
{
UnitHandle pOtherUnit = pAdjacentPlot->getBestDefender(eEnemy);
if(pOtherUnit)
{
if(GC.getLogging() && GC.getAILogging())
{
CvString strMsg;
strMsg.Format("Ran into enemy unit during attack (x=%d y=%d). Need to declare war to continue!", pAdjacentPlot->getX(), pAdjacentPlot->getY());
GET_PLAYER(m_eOwner).getAIOperation(m_iOperationID)->LogOperationSpecialMessage(strMsg);
}
return pAdjacentPlot;
}
}
}
pUnit = GetNextUnit();
}
return NULL;
}
示例2: AI_plotTargetMissionAIs
int CvPlayerAI::AI_plotTargetMissionAIs(CvPlot* pPlot, MissionAITypes eMissionAI, int iRange)
{
int iCount = 0;
int iLoop;
for(CvUnit* pLoopUnit = firstUnit(&iLoop); pLoopUnit; pLoopUnit = nextUnit(&iLoop))
{
CvPlot* pMissionPlot = pLoopUnit->GetMissionAIPlot();
if(!pMissionPlot)
{
continue;
}
MissionAITypes eGroupMissionAI = pLoopUnit->GetMissionAIType();
if(eGroupMissionAI != eMissionAI)
{
continue;
}
int iDistance = plotDistance(pPlot->getX(), pPlot->getY(), pMissionPlot->getX(), pMissionPlot->getY());
if(iDistance == iRange)
{
iCount++;
}
}
return iCount;
}
示例3: GET_PLAYER
/// Add in any temporary dominance zones from tactical AI
void CvTacticalAnalysisMap::AddTemporaryZones()
{
CvTemporaryZone* pZone;
CvTacticalAI* pTacticalAI = GET_PLAYER(m_ePlayer).GetTacticalAI();
if(pTacticalAI)
{
pTacticalAI->DropObsoleteZones();
pZone = pTacticalAI->GetFirstTemporaryZone();
while(pZone)
{
// Can't be a city zone (which is just used to boost priority but not establish a new zone)
if(pZone->GetTargetType() != AI_TACTICAL_TARGET_CITY)
{
CvPlot* pPlot = GC.getMap().plot(pZone->GetX(), pZone->GetY());
if(pPlot)
{
CvTacticalDominanceZone newZone;
newZone.SetDominanceZoneID(m_DominanceZones.size());
newZone.SetTerritoryType(TACTICAL_TERRITORY_TEMP_ZONE);
newZone.SetOwner(NO_PLAYER);
newZone.SetAreaID(pPlot->getArea());
newZone.SetWater(pPlot->isWater());
newZone.Extend(pPlot);
newZone.SetNavalInvasion(pZone->IsNavalInvasion());
m_DominanceZones.push_back(newZone);
}
}
pZone = pTacticalAI->GetNextTemporaryZone();
}
}
}
示例4: GET_PLAYER
//------------------------------------------------------------------------------
void CvDllNetMessageHandler::ResponseCityBuyPlot(PlayerTypes ePlayer, int iCityID, int iX, int iY)
{
CvPlayerAI& kPlayer = GET_PLAYER(ePlayer);
CvCity* pkCity = kPlayer.getCity(iCityID);
if(pkCity != NULL)
{
CvPlot* pkPlot = NULL;
// (-1,-1) means pick a random plot to buy
if(iX == -1 && iY == -1)
{
#if defined(MOD_BALANCE_CORE)
pkPlot = pkCity->GetNextBuyablePlot(false);
#else
pkPlot = pkCity->GetNextBuyablePlot();
#endif
}
else
{
pkPlot = GC.getMap().plot(iX, iY);
}
if(pkPlot != NULL)
{
if(pkCity->CanBuyPlot(pkPlot->getX(), pkPlot->getY()))
{
pkCity->BuyPlot(pkPlot->getX(), pkPlot->getY());
if(ePlayer == GC.getGame().getActivePlayer() && GC.GetEngineUserInterface()->isCityScreenUp())
{
GC.GetEngineUserInterface()->setDirty(CityScreen_DIRTY_BIT, true);
}
}
}
}
}
示例5: PROFILE
void CvMapGenerator::addFeatures()
{
PROFILE("CvMapGenerator::addFeatures");
if (gDLL->getPythonIFace()->callFunction(gDLL->getPythonIFace()->getMapScriptModule(), "addFeatures", NULL))
{
if (!gDLL->getPythonIFace()->pythonUsingDefaultImpl())
{
return;
}
}
for (int iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++)
{
CvPlot* pPlot = GC.getMapINLINE().plotByIndexINLINE(iI);
FAssert(pPlot != NULL);
for (int iJ = 0; iJ < GC.getNumFeatureInfos(); iJ++)
{
if (pPlot->canHaveFeature((FeatureTypes)iJ))
{
if (GC.getGameINLINE().getMapRandNum(10000, "addFeaturesAtPlot") < GC.getFeatureInfo((FeatureTypes)iJ).getAppearanceProbability())
{
pPlot->setFeatureType((FeatureTypes)iJ);
}
}
}
}
}
示例6: ShouldIgnoreUnit
/// Should this unit be ignored when creating the danger plots?
bool CvDangerPlots::ShouldIgnoreUnit (CvUnit* pUnit, bool bIgnoreVisibility)
{
if (!pUnit->IsCanAttack())
{
return true;
}
if (!pUnit->plot()->isVisible(GET_PLAYER(m_ePlayer).getTeam()))
{
return true;
}
if (pUnit->isInvisible(GET_PLAYER(m_ePlayer).getTeam(), false))
{
return true;
}
CvPlot* pPlot = pUnit->plot();
CvAssertMsg(pPlot, "Plot is null?")
if (pPlot && !pPlot->isVisibleOtherUnit(m_ePlayer) && !bIgnoreVisibility)
{
return true;
}
// fix post-gold!
if (pUnit->getDomainType() == DOMAIN_AIR)
{
return true;
}
return false;
}
示例7: PROFILE_FUNC
//"Check plots for wetlands or seaWater. Returns true if found"
bool CvMap::findWater(CvPlot* pPlot, int iRange, bool bFreshWater)
{
PROFILE_FUNC();
for (int iDX = -(iRange); iDX <= iRange; iDX++)
{
for (int iDY = -(iRange); iDY <= iRange; iDY++)
{
CvPlot* pLoopPlot = plotXY(pPlot->getX_INLINE(), pPlot->getY_INLINE(), iDX, iDY);
if (pLoopPlot != NULL)
{
if (bFreshWater)
{
if (pLoopPlot->isRiver())
{
return true;
}
}
else
{
if (pLoopPlot->isWater())
{
return true;
}
}
}
}
}
return false;
}
示例8: SetTargetFlankBonusCells
// Mark cells we can use to bomb a specific target
void CvTacticalAnalysisMap::SetTargetFlankBonusCells(CvPlot* pTarget)
{
CvPlot* pLoopPlot;
int iPlotIndex;
// No flank attacks on units at sea (where all combat is bombards)
if(pTarget->isWater())
{
return;
}
for(int iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
{
pLoopPlot = plotDirection(pTarget->getX(), pTarget->getY(), ((DirectionTypes)iI));
if(pLoopPlot != NULL)
{
iPlotIndex = GC.getMap().plotNum(pLoopPlot->getX(), pLoopPlot->getY());
if(m_pPlots[iPlotIndex].IsRevealed() && !m_pPlots[iPlotIndex].IsImpassableTerrain() && !m_pPlots[iPlotIndex].IsImpassableTerritory())
{
if(!m_pPlots[iPlotIndex].IsFriendlyCity() && !m_pPlots[iPlotIndex].IsEnemyCity() && !m_pPlots[iPlotIndex].IsNeutralCity())
{
if(!m_pPlots[iPlotIndex].IsFriendlyTurnEndTile() && m_pPlots[iPlotIndex].GetEnemyMilitaryUnit() == NULL)
{
m_pPlots[iPlotIndex].SetHelpsProvidesFlankBonus(true);
}
}
}
}
}
}
示例9: setPlotTypes
void CvMapGenerator::setPlotTypes(const int* paiPlotTypes)
{
CvPlot* pLoopPlot;
int iNumPlots;
iNumPlots = GC.getMapINLINE().numPlotsINLINE();
for (int iI = 0; iI < iNumPlots; iI++)
{
gDLL->callUpdater();
GC.getMapINLINE().plotByIndexINLINE(iI)->setPlotType(((PlotTypes)(paiPlotTypes[iI])), false, false);
}
GC.getMapINLINE().recalculateAreas();
for (int iI = 0; iI < iNumPlots; iI++)
{
gDLL->callUpdater();
pLoopPlot = GC.getMapINLINE().plotByIndexINLINE(iI);
if (pLoopPlot->isWater())
{
if (pLoopPlot->isAdjacentToLand())
{
pLoopPlot->setTerrainType(((TerrainTypes)(GC.getXMLval(XML_SHALLOW_WATER_TERRAIN))), false, false);
}
else
{
pLoopPlot->setTerrainType(((TerrainTypes)(GC.getXMLval(XML_DEEP_WATER_TERRAIN))), false, false);
}
}
}
}
示例10: GetPlot
void HornOfValere::FindHorn(CvUnit* pUnit)
{
// TODO UI popup
if (pUnit)
{
m_bFound = true;
CvPlot* pkPlot = GetPlot();
if (pkPlot)
{
pkPlot->SetHasHornOfValere(false);
}
m_iOwnerPlayerID = pUnit->getOwner();
m_iOwnerUnitID = pUnit->GetID();
ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();
if (pkScriptSystem)
{
CUSTOMLOG("Calling UnitDiscoveredHornOfValere with %i owner and %i unit ID.", pUnit->getOwner(), pUnit->GetID());
CvLuaArgsHandle args;
args->Push(pUnit->getOwner());
args->Push(pUnit->GetID());
bool bResult;
LuaSupport::CallHook(pkScriptSystem, "UnitDiscoveredHornOfValere", args.get(), bResult);
}
}
}
示例11: PROFILE_FUNC
void CvMapGenerator::addLakes()
{
PROFILE_FUNC();
if (gDLL->getPythonIFace()->pythonAddLakes() && !gDLL->getPythonIFace()->pythonUsingDefaultImpl())
{
return; // Python override
}
gDLL->NiTextOut("Adding Lakes...");
CvPlot* pLoopPlot;
int iI;
for (iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++)
{
gDLL->callUpdater();
pLoopPlot = GC.getMapINLINE().plotByIndexINLINE(iI);
FAssertMsg(pLoopPlot != NULL, "LoopPlot is not assigned a valid value");
if (!(pLoopPlot->isWater()))
{
if (!(pLoopPlot->isCoastalLand()))
{
if (!(pLoopPlot->isRiver()))
{
if (GC.getGameINLINE().getMapRandNum(GC.getXMLval(XML_LAKE_PLOT_RAND), "addLakes") == 0)
{
pLoopPlot->setPlotType(PLOT_OCEAN);
}
}
}
}
}
}
示例12: plotXYWithRangeCheck
void HornOfValere::DoTurn()
{
if (!m_bFound)
{
for(int iX = -m_iDiscoveryRange; iX <= m_iDiscoveryRange; iX++)
{
for(int iY = -m_iDiscoveryRange; iY <= m_iDiscoveryRange; iY++)
{
CvPlot* pkPlot = plotXYWithRangeCheck(GetX(), GetY(), iX, iY, m_iDiscoveryRange);
if(pkPlot != NULL)
{
IDInfoVector currentUnits;
if (pkPlot->getUnits(¤tUnits) > 0)
{
for (IDInfoVector::const_iterator itr = currentUnits.begin(); itr != currentUnits.end(); ++itr)
{
CvUnit* pUnit = ::getUnit(*itr);
if(pUnit && pUnit->CanDiscoverHornOfValere())
{
FindHorn(pUnit);
return;
}
}
}
}
}
}
}
IncrementTurnsSinceHornBlown();
}
示例13: BeginTurn
// ---------------------------------------------------------------------------
/// Called every turn
void CvBarbarians::BeginTurn()
{
CvGame &kGame = GC.getGame();
const ImprovementTypes eCamp = kGame.GetBarbarianCampImprovementType();
CvMap& kMap = GC.getMap();
int iWorldNumPlots = kMap.numPlots();
for (int iPlotLoop = 0; iPlotLoop < iWorldNumPlots; iPlotLoop++)
{
if (m_aiPlotBarbCampSpawnCounter[iPlotLoop] > 0)
{
// No Camp here any more
CvPlot* pPlot = kMap.plotByIndex(iPlotLoop);
if (pPlot->getImprovementType() != eCamp)
{
m_aiPlotBarbCampSpawnCounter[iPlotLoop] = -1;
m_aiPlotBarbCampNumUnitsSpawned[iPlotLoop] = -1;
}
else
{
m_aiPlotBarbCampSpawnCounter[iPlotLoop]--;
}
}
// Counter is negative, meaning a camp was cleared here recently and isn't allowed to respawn in the area for a while
else if (m_aiPlotBarbCampSpawnCounter[iPlotLoop] < -1)
{
m_aiPlotBarbCampSpawnCounter[iPlotLoop]++;
}
}
}
示例14: IsPlotValidForBarbCamp
// ---------------------------------------------------------------------------
bool CvBarbarians::IsPlotValidForBarbCamp(CvPlot* pPlot)
{
int iRange = 4;
int iDY;
int iPlotX = pPlot->getX();
int iPlotY = pPlot->getY();
CvMap& kMap = GC.getMap();
for (int iDX = -(iRange); iDX <= iRange; iDX++)
{
for (iDY = -(iRange); iDY <= iRange; iDY++)
{
int iLoopPlotX = iPlotX + iDX;
int iLoopPlotY = iPlotY + iDY;
// Cut off corners
if (plotDistance(iPlotX, iPlotY, iLoopPlotX, iLoopPlotY) > iRange)
continue;
// If the counter is below -1 that means a camp was cleared recently
CvPlot* pLoopPlot = kMap.plot(iLoopPlotX, iLoopPlotY);
if (pLoopPlot)
{
if (m_aiPlotBarbCampSpawnCounter[pLoopPlot->GetPlotIndex()] < -1)
return false;
}
}
}
return true;
}
示例15: CvAssertMsg
/// Sums the danger values of the plots around the city to determine the danger value of the city
int CvDangerPlots::GetCityDanger (CvCity* pCity)
{
CvAssertMsg(pCity, "pCity is null");
if(!pCity) return 0;
CvAssertMsg(pCity->getOwner() == m_ePlayer, "City does not belong to us");
CvPlot* pPlot = pCity->plot();
int iEvalRange = GC.getAI_DIPLO_PLOT_RANGE_FROM_CITY_HOME_FRONT();
int iDangerValue = 0;
for (int iX = -iEvalRange; iX <= iEvalRange; iX++)
{
for (int iY = -iEvalRange; iY <= iEvalRange; iY++)
{
CvPlot* pEvalPlot = plotXYWithRangeCheck(pPlot->getX(), pPlot->getY(), iX, iY, iEvalRange);
if (!pEvalPlot)
{
continue;
}
iDangerValue += GetDanger(*pEvalPlot);
}
}
return iDangerValue;
}