CityStrategyAIHelpers::IsTestCityStrategy_NeedNavalGrowth(AICityStrategyTypes, CvCity *)
- Defined in
- CvCityStrategyAI.cpp, line 2639
- Hook name
CivHooks::CityStrategyAIHelpers_IsTestCityStrategy_NeedNavalGrowth
Hooks
static bool BeforeCityStrategyAIHelpers_IsTestCityStrategy_NeedNavalGrowth(AICityStrategyTypes eStrategy, CvCity* pCity, bool& result);static void AfterCityStrategyAIHelpers_IsTestCityStrategy_NeedNavalGrowth(AICityStrategyTypes eStrategy, CvCity* pCity, bool& result);static bool ReplaceCityStrategyAIHelpers_IsTestCityStrategy_NeedNavalGrowth(bool (*original)(AICityStrategyTypes, CvCity*), AICityStrategyTypes eStrategy, CvCity* pCity);CivRegisterBefore<CivHooks::CityStrategyAIHelpers_IsTestCityStrategy_NeedNavalGrowth>(host, &BeforeCityStrategyAIHelpers_IsTestCityStrategy_NeedNavalGrowth);CivRegisterAfter<CivHooks::CityStrategyAIHelpers_IsTestCityStrategy_NeedNavalGrowth>(host, &AfterCityStrategyAIHelpers_IsTestCityStrategy_NeedNavalGrowth);CivRegisterReplace<CivHooks::CityStrategyAIHelpers_IsTestCityStrategy_NeedNavalGrowth>(host, &ReplaceCityStrategyAIHelpers_IsTestCityStrategy_NeedNavalGrowth);
Code
2638/// "Need Naval Growth" City Strategy: Looks at the Tiles this City can work, and if there are a lot of Ocean tiles prioritizes NAVAL_GROWTH: should give us a Harbor eventually2639bool CityStrategyAIHelpers::IsTestCityStrategy_NeedNavalGrowth(AICityStrategyTypes eStrategy, CvCity* pCity)2640{2641 int iNumOceanPlots = 0;2642 int iNumTotalWorkablePlots = 0;26432644 CvPlot* pLoopPlot;26452646 // Look at all Tiles this City could potentially work2647#if defined(MOD_GLOBAL_CITY_WORKING)2648 for(int iPlotLoop = 0; iPlotLoop < pCity->GetNumWorkablePlots(); iPlotLoop++)2649#else2650 for(int iPlotLoop = 0; iPlotLoop < NUM_CITY_PLOTS; iPlotLoop++)2651#endif2652 {2653 pLoopPlot = plotCity(pCity->getX(), pCity->getY(), iPlotLoop);26542655 if(pLoopPlot != NULL)2656 {2657 if(pLoopPlot->getOwner() == pCity->getOwner())2658 {2659 if(!pLoopPlot->isCity())2660 {2661 iNumTotalWorkablePlots++;26622663 if(pLoopPlot->isWater() && !pLoopPlot->isLake())2664 {2665 iNumOceanPlots++;;2666 }2667 }2668 }2669 }2670 }26712672 if(iNumTotalWorkablePlots > 0)2673 {2674 CvAICityStrategyEntry* pCityStrategy = pCity->GetCityStrategyAI()->GetAICityStrategies()->GetEntry(eStrategy);2675 int iWeightThresholdModifier = GetWeightThresholdModifier(eStrategy, pCity); // -1 Weight per NAVAL_GROWTH Flavor2676 int iWeightThreshold = pCityStrategy->GetWeightThreshold() + iWeightThresholdModifier; // 4026772678 // If at least 35% (Average Player) of a City's workable Tiles are low-food Water then we really should be building a Harbor2679 // [35 Weight is Average; range is 30 to 40]2680 if((iNumOceanPlots * 100) / iNumTotalWorkablePlots >= iWeightThreshold)2681 {2682 return true;2683 }2684 }26852686 return false;2687}
Calls
- CityStrategyAIHelpers::GetWeightThresholdModifier(AICityStrategyTypes, CvCity *)
- CvAICityStrategies::GetEntry(int)
- CvAICityStrategyEntry::GetWeightThreshold() const
- CvCity::GetCityStrategyAI() const
- CvCity::GetNumWorkablePlots(int) const
- CvCity::getOwner() const
- CvCity::getX() const
- CvCity::getY() const
- CvCityStrategyAI::GetAICityStrategies()
- CvPlot::getOwner() const
- CvPlot::isCity() const
- CvPlot::isLake() const
- CvPlot::isWater() const
- plotCity(int, int, int)