Bazaar developer reference

CvCityCitizens::GetPlotValue(CvPlot *, bool)

Defined in
CvCityCitizens.cpp, line 478
Class
CvCityCitizens
Hook name
CivHooks::CvCityCitizens_GetPlotValue

Hooks

static bool BeforeCvCityCitizens_GetPlotValue(CvCityCitizens* self, CvPlot* pPlot, bool bUseAllowGrowthFlag, int& result);static void AfterCvCityCitizens_GetPlotValue(CvCityCitizens* self, CvPlot* pPlot, bool bUseAllowGrowthFlag, int& result);static int ReplaceCvCityCitizens_GetPlotValue(int (*original)(CvCityCitizens*, CvPlot*, bool), CvCityCitizens* self, CvPlot* pPlot, bool bUseAllowGrowthFlag);CivRegisterBefore<CivHooks::CvCityCitizens_GetPlotValue>(host, &BeforeCvCityCitizens_GetPlotValue);CivRegisterAfter<CivHooks::CvCityCitizens_GetPlotValue>(host, &AfterCvCityCitizens_GetPlotValue);CivRegisterReplace<CivHooks::CvCityCitizens_GetPlotValue>(host, &ReplaceCvCityCitizens_GetPlotValue);

Code

477/// What is the overall value of the current Plot?478int CvCityCitizens::GetPlotValue(CvPlot* pPlot, bool bUseAllowGrowthFlag)479{480	int iValue = 0;481482	// Yield Values483	int iFoodYieldValue = (/*12*/ GC.getAI_CITIZEN_VALUE_FOOD() * pPlot->getYield(YIELD_FOOD));484	int iProductionYieldValue = (/*8*/ GC.getAI_CITIZEN_VALUE_PRODUCTION() * pPlot->getYield(YIELD_PRODUCTION));485	int iGoldYieldValue = (/*10*/ GC.getAI_CITIZEN_VALUE_GOLD() * pPlot->getYield(YIELD_GOLD));486	int iScienceYieldValue = (/*6*/ GC.getAI_CITIZEN_VALUE_SCIENCE() * pPlot->getYield(YIELD_SCIENCE));487	int iCultureYieldValue = (GC.getAI_CITIZEN_VALUE_CULTURE() * pPlot->getYield(YIELD_CULTURE));488	int iFaithYieldValue = (GC.getAI_CITIZEN_VALUE_FAITH() * pPlot->getYield(YIELD_FAITH));489490	// How much surplus food are we making?491	int iExcessFoodTimes100 = m_pCity->getYieldRateTimes100(YIELD_FOOD, false) - (m_pCity->foodConsumption() * 100);492493	bool bAvoidGrowth = IsAvoidGrowth();494495	// City Focus496	CityAIFocusTypes eFocus = GetFocusType();497	if(eFocus == CITY_AI_FOCUS_TYPE_FOOD)498		iFoodYieldValue *= 3;499	else if(eFocus == CITY_AI_FOCUS_TYPE_PRODUCTION)500		iProductionYieldValue *= 3;501	else if(eFocus == CITY_AI_FOCUS_TYPE_GOLD)502		iGoldYieldValue *= 3;503	else if(eFocus == CITY_AI_FOCUS_TYPE_SCIENCE)504		iScienceYieldValue *= 3;505	else if(eFocus == CITY_AI_FOCUS_TYPE_CULTURE)506		iCultureYieldValue *= 3;507	else if(eFocus == CITY_AI_FOCUS_TYPE_GOLD_GROWTH)508	{509		iFoodYieldValue *= 2;510		iGoldYieldValue *= 2;511	}512	else if(eFocus == CITY_AI_FOCUS_TYPE_PROD_GROWTH)513	{514		iFoodYieldValue *= 2;515		iProductionYieldValue *= 2;516	}517	else if(eFocus == CITY_AI_FOCUS_TYPE_FAITH)518	{519		iFaithYieldValue *= 3;520	}521522	// Food can be worth less if we don't want to grow523	if(bUseAllowGrowthFlag && iExcessFoodTimes100 >= 0 && bAvoidGrowth)524	{525		// If we at least have enough Food to feed everyone, zero out the value of additional food526		iFoodYieldValue = 0;527	}528	// We want to grow here529	else530	{531		// If we have a non-default and non-food focus, only worry about getting to 0 food532		if(eFocus != NO_CITY_AI_FOCUS_TYPE && eFocus != CITY_AI_FOCUS_TYPE_FOOD && eFocus != CITY_AI_FOCUS_TYPE_PROD_GROWTH && eFocus != CITY_AI_FOCUS_TYPE_GOLD_GROWTH)533		{534			int iFoodT100NeededFor0 = -iExcessFoodTimes100;535536			if(iFoodT100NeededFor0 > 0)537			{538				iFoodYieldValue *= 8;539			}540			else541			{542				iFoodYieldValue /= 2;543			}544		}545		// If our surplus is not at least 2, really emphasize food plots546		else if(!bAvoidGrowth)547		{548			int iFoodT100NeededFor2 = 200 - iExcessFoodTimes100;549550			if(iFoodT100NeededFor2 > 0)551			{552				iFoodYieldValue *= 8;553			}554			else if (eFocus != CITY_AI_FOCUS_TYPE_FOOD)555			{556				iFoodYieldValue /= 2;557			}558		}559	}560561	if((eFocus == NO_CITY_AI_FOCUS_TYPE || eFocus == CITY_AI_FOCUS_TYPE_PROD_GROWTH || eFocus == CITY_AI_FOCUS_TYPE_GOLD_GROWTH) && !bAvoidGrowth && m_pCity->getPopulation() < 5)562	{563		iFoodYieldValue *= 4;564	}565566	iValue += iFoodYieldValue;567	iValue += iProductionYieldValue;568	iValue += iGoldYieldValue;569	iValue += iScienceYieldValue;570	iValue += iCultureYieldValue;571	iValue += iFaithYieldValue;572573	return iValue;574}

Calls

Called by