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; }
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; }
/// 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(); } } }
//------------------------------------------------------------------------------ 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); } } } } }
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); } } } } }
/// 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; }
//"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; }
// 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); } } } } } }
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); } } } }
void CvMap::calculateAreas() { PROFILE_FUNC(); CvPlot* pLoopPlot; CvArea* pArea; int iArea; int iI; for (iI = 0; iI < numPlotsINLINE(); iI++) { pLoopPlot = plotByIndexINLINE(iI); gDLL->callUpdater(); FAssertMsg(pLoopPlot != NULL, "LoopPlot is not assigned a valid value"); if (pLoopPlot->getArea() == FFreeList::INVALID_INDEX) { pArea = addArea(); pArea->init(pArea->getID(), pLoopPlot->isWater()); iArea = pArea->getID(); pLoopPlot->setArea(iArea); gDLL->getFAStarIFace()->GeneratePath(&GC.getAreaFinder(), pLoopPlot->getX_INLINE(), pLoopPlot->getY_INLINE(), -1, -1, pLoopPlot->isWater(), iArea); } } }
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); } } }
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); } } } } } }
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(); }
// --------------------------------------------------------------------------- /// 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]++; } } }
void CvMapGenerator::addFeatures() { PROFILE_FUNC(); CvPlot* pPlot; int iI, iJ; if (gDLL->getPythonIFace()->pythonAddFeatures() && !gDLL->getPythonIFace()->pythonUsingDefaultImpl()) { return; // Python override } for (iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++) { pPlot = GC.getMapINLINE().plotByIndexINLINE(iI); FAssert(pPlot != NULL); for (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); } } } } }
// --------------------------------------------------------------------------- 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; }
/// 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; }
/// Return the maximum amount of damage that could be dealt to a non-specific unit at this plot int CvDangerPlots::GetDanger(const CvPlot& pPlot, PlayerTypes ePlayer) { if(!m_bArrayAllocated) return 0; const int idx = pPlot.getX() + pPlot.getY() * GC.getMap().getGridWidth(); return m_DangerPlots[idx].GetDanger(ePlayer); }
/// Returns if the tile is in danger bool CvDangerPlots::IsUnderImmediateThreat(const CvPlot& pPlot, PlayerTypes ePlayer) { if(!m_bArrayAllocated) return 0; const int idx = pPlot.getX() + pPlot.getY() * GC.getMap().getGridWidth(); return m_DangerPlots[idx].IsUnderImmediateThreat(ePlayer); }
void CvMapGenerator::eraseEurope() { for (int i = 0; i < GC.getMapINLINE().numPlotsINLINE(); i++) { CvPlot* pPlot = GC.getMapINLINE().plotByIndexINLINE(i); pPlot->setEurope(NO_EUROPE); } }
void CvMapGenerator::eraseBonuses() { for (int i = 0; i < GC.getMapINLINE().numPlotsINLINE(); i++) { CvPlot* pPlot = GC.getMapINLINE().plotByIndexINLINE(i); pPlot->setBonusType(NO_BONUS); } }
void CvMapGenerator::eraseFeatures() { for (int i = 0; i < GC.getMapINLINE().numPlotsINLINE(); i++) { CvPlot* pPlot = GC.getMapINLINE().plotByIndexINLINE(i); pPlot->setFeatureType(NO_FEATURE); } }
void CvMapGenerator::addNonUniqueBonusType(BonusTypes eBonusType) { int iBonusCount = calculateNumBonusesToAdd(eBonusType); if (iBonusCount == 0) { return; } std::vector<int> aiShuffle(GC.getMapINLINE().numPlotsINLINE()); GC.getGameINLINE().getMapRand().shuffleSequence(aiShuffle, "addNonUniqueBonusType shuffle"); CvBonusInfo& pBonusInfo = GC.getBonusInfo(eBonusType); bool bIgnoreLatitude = false; gDLL->getPythonIFace()->pythonIsBonusIgnoreLatitudes(&bIgnoreLatitude); CvPlot* pPlot = NULL; for (int iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++) { pPlot = GC.getMapINLINE().plotByIndexINLINE(aiShuffle[iI]); if (canPlaceBonusAt(eBonusType, pPlot->getX_INLINE(), pPlot->getY_INLINE(), bIgnoreLatitude)) { pPlot->setBonusType(eBonusType); iBonusCount--; for (int iDX = -(pBonusInfo.getGroupRange()); iDX <= pBonusInfo.getGroupRange(); iDX++) { for (int iDY = -(pBonusInfo.getGroupRange()); iDY <= pBonusInfo.getGroupRange(); iDY++) { if (iBonusCount > 0) { CvPlot* pLoopPlot = plotXY(pPlot->getX_INLINE(), pPlot->getY_INLINE(), iDX, iDY); if (pLoopPlot != NULL) { if (canPlaceBonusAt(eBonusType, pLoopPlot->getX_INLINE(), pLoopPlot->getY_INLINE(), bIgnoreLatitude)) { if (GC.getGameINLINE().getMapRandNum(100, "addNonUniqueBonusType") < pBonusInfo.getGroupRand()) { pLoopPlot->setBonusType(eBonusType); iBonusCount--; } } } } } } FAssertMsg(iBonusCount >= 0, "iBonusCount must be >= 0"); if (iBonusCount == 0) { break; } } } }
std::vector<CvUnit*> CvDangerPlots::GetPossibleAttackers(const CvPlot& Plot) const { if(!m_bArrayAllocated) return std::vector<CvUnit*>(); const int idx = Plot.getX() + Plot.getY() * GC.getMap().getGridWidth(); return m_DangerPlots[idx].GetPossibleAttackers(); }
/// Should this unit be ignored when creating the danger plots? bool CvDangerPlots::ShouldIgnoreUnit(CvUnit* pUnit, bool bIgnoreVisibility) { if(!m_bArrayAllocated || m_ePlayer==NO_PLAYER) return true; if(!pUnit->IsCanAttack()) { return true; } #if defined(AUI_DANGER_PLOTS_SHOULD_IGNORE_UNIT_MAJORS_SEE_BARBARIANS_IN_FOG) || defined(AUI_DANGER_PLOTS_SHOULD_IGNORE_UNIT_MINORS_SEE_MAJORS) if (pUnit->isInvisible(GET_PLAYER(m_ePlayer).getTeam(), false)) { return true; } #endif // AUI_DANGER_PLOTS_SHOULD_IGNORE_UNIT_MAJORS_SEE_BARBARIANS_IN_FOG if (pUnit->getDomainType() == DOMAIN_AIR) { return true; } #ifdef AUI_DANGER_PLOTS_SHOULD_IGNORE_UNIT_MAJORS_SEE_BARBARIANS_IN_FOG if (!GET_PLAYER(m_ePlayer).isMinorCiv() && !GET_PLAYER(m_ePlayer).isBarbarian() && pUnit->isBarbarian() && pUnit->plot()->isRevealed(GET_PLAYER(m_ePlayer).getTeam())) if (pUnit->plot()->isAdjacentVisible(GET_PLAYER(m_ePlayer).getTeam())) bIgnoreVisibility = true; #endif // AUI_DANGER_PLOTS_SHOULD_IGNORE_UNIT_MAJORS_SEE_BARBARIANS_IN_FOG #ifdef AUI_DANGER_PLOTS_SHOULD_IGNORE_UNIT_MINORS_SEE_MAJORS if (GET_PLAYER(m_ePlayer).isMinorCiv() && !GET_PLAYER(pUnit->getOwner()).isMinorCiv() && !pUnit->isBarbarian() && GET_PLAYER(m_ePlayer).GetClosestCity(pUnit->plot(), AUI_DANGER_PLOTS_SHOULD_IGNORE_UNIT_MINORS_SEE_MAJORS, true)) bIgnoreVisibility = true; #endif // AUI_DANGER_PLOTS_SHOULD_IGNORE_UNIT_MINORS_SEE_MAJORS if(!pUnit->plot()->isVisible(GET_PLAYER(m_ePlayer).getTeam()) && !bIgnoreVisibility) { return true; } #if !defined(AUI_DANGER_PLOTS_SHOULD_IGNORE_UNIT_MAJORS_SEE_BARBARIANS_IN_FOG) && !defined(AUI_DANGER_PLOTS_SHOULD_IGNORE_UNIT_MINORS_SEE_MAJORS) if(pUnit->isInvisible(GET_PLAYER(m_ePlayer).getTeam(), false)) { return true; } #endif // AUI_DANGER_PLOTS_SHOULD_IGNORE_UNIT_MAJORS_SEE_BARBARIANS_IN_FOG CvPlot* pPlot = pUnit->plot(); CvAssertMsg(pPlot, "Plot is null?") if(NULL != pPlot && !pPlot->isVisibleOtherUnit(m_ePlayer) && !bIgnoreVisibility) { return true; } return false; }
// ----------------------------------------------------------------------------------------------- int CvDistanceMap::GetClosestFeatureDistance(const CvPlot& plot) { if (m_bDirty) Update(); if (m_bArrayAllocated) return m_vDistance[ GC.getMap().plotNum( plot.getX(), plot.getY() ) ]; return INT_MAX; }
// ----------------------------------------------------------------------------------------------- int CvDistanceMap::GetClosestFeatureOwner(const CvPlot& plot) { if (m_bDirty) Update(); if (m_bArrayAllocated) return UNPACK_OWNER( m_vClosestFeature[ GC.getMap().plotNum( plot.getX(), plot.getY() ) ] ); return -1; }
void CvMapGenerator::eraseGoodies() { for (int i = 0; i < GC.getMapINLINE().numPlotsINLINE(); i++) { CvPlot* pPlot = GC.getMapINLINE().plotByIndexINLINE(i); if (pPlot->isGoody()) { pPlot->removeGoody(); } } }
// --------------------------------------------------------------------------- /// 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]++; } #if defined(MOD_DIPLOMACY_CITYSTATES_QUESTS) if (m_aiPlotBarbCitySpawnCounter[iPlotLoop] > 0) { // No City here any more CvPlot* pPlot = kMap.plotByIndex(iPlotLoop); if (pPlot->isCity() && pPlot->getOwner() != BARBARIAN_PLAYER) { m_aiPlotBarbCitySpawnCounter[iPlotLoop] = -1; m_aiPlotBarbCityNumUnitsSpawned[iPlotLoop] = -1; } else { m_aiPlotBarbCitySpawnCounter[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_aiPlotBarbCitySpawnCounter[iPlotLoop] < -1) { m_aiPlotBarbCitySpawnCounter[iPlotLoop]++; } #endif } }
/// Return the maximum amount of damage a unit could take at this plot int CvDangerPlots::GetDanger(const CvPlot& pPlot, const CvUnit* pUnit, AirActionType iAirAction) { if(!m_bArrayAllocated) return 0; const int idx = pPlot.getX() + pPlot.getY() * GC.getMap().getGridWidth(); if (pUnit) { return m_DangerPlots[idx].GetDanger(pUnit, iAirAction); } return m_DangerPlots[idx].GetDanger(NO_PLAYER); }