Bazaar developer reference

CvCitySpecializationAI::AdjustValueBasedOnBuildings(CvCity *, YieldTypes, int)

Defined in
CvCitySpecializationAI.cpp, line 1337
Class
CvCitySpecializationAI
Hook name
CivHooks::CvCitySpecializationAI_AdjustValueBasedOnBuildings

Hooks

static bool BeforeCvCitySpecializationAI_AdjustValueBasedOnBuildings(CvCitySpecializationAI* self, CvCity* pCity, YieldTypes eYield, int iInitialValue, int& result);static void AfterCvCitySpecializationAI_AdjustValueBasedOnBuildings(CvCitySpecializationAI* self, CvCity* pCity, YieldTypes eYield, int iInitialValue, int& result);static int ReplaceCvCitySpecializationAI_AdjustValueBasedOnBuildings(int (*original)(CvCitySpecializationAI*, CvCity*, YieldTypes, int), CvCitySpecializationAI* self, CvCity* pCity, YieldTypes eYield, int iInitialValue);CivRegisterBefore<CivHooks::CvCitySpecializationAI_AdjustValueBasedOnBuildings>(host, &BeforeCvCitySpecializationAI_AdjustValueBasedOnBuildings);CivRegisterAfter<CivHooks::CvCitySpecializationAI_AdjustValueBasedOnBuildings>(host, &AfterCvCitySpecializationAI_AdjustValueBasedOnBuildings);CivRegisterReplace<CivHooks::CvCitySpecializationAI_AdjustValueBasedOnBuildings>(host, &ReplaceCvCitySpecializationAI_AdjustValueBasedOnBuildings);

Code

1336/// Multiply city value for a yield based on buildings present1337int CvCitySpecializationAI::AdjustValueBasedOnBuildings(CvCity* pCity, YieldTypes eYield, int iInitialValue)1338{1339	int iRtnValue;13401341	// Everything looks at yield modifier1342	iRtnValue = iInitialValue * (100 + pCity->getYieldRateModifier(eYield)) / 100;13431344	// ... and yield per pop1345	int iYieldPerPop = pCity->GetYieldPerPopTimes100(eYield);1346	if(iYieldPerPop > 0)1347	{1348		iRtnValue = iRtnValue * (100 + iYieldPerPop) / 100;1349	}13501351	// ... and yield per pop1352	int iYieldPerReligion = pCity->GetYieldPerReligionTimes100(eYield);1353	if(iYieldPerPop > 0)1354	{1355		iRtnValue = iRtnValue * (100 + (iYieldPerReligion * pCity->GetCityReligions()->GetNumReligionsWithFollowers())) / 100;1356	}13571358	// ... and yield changes1359	int iYieldChanges = pCity->GetBaseYieldRateFromBuildings(eYield);1360	if(iYieldChanges > 0)1361	{1362		// +20% per point of yield change1363		iRtnValue = iRtnValue * (100 + (iYieldChanges * 20)) / 100;1364	}13651366	// Other modifiers (unique by yield type)1367	switch(eYield)1368	{1369	case YIELD_FOOD:1370	{1371		int iMaxFoodKeptPercent = pCity->getMaxFoodKeptPercent();1372		if(iMaxFoodKeptPercent >= 100)1373		{1374			iMaxFoodKeptPercent = 99;1375		}1376		iRtnValue *= 100 / (100 - iMaxFoodKeptPercent);1377	}1378	break;13791380	case YIELD_PRODUCTION:1381		// Double production if any military training facilities present1382		if(pCity->getDomainFreeExperience(DOMAIN_LAND) > 0)1383		{1384			iRtnValue *= 2;1385		}1386		break;13871388	case YIELD_GOLD:1389		break;13901391	case YIELD_SCIENCE:1392		break;1393	}13941395	return iRtnValue;1396}

Calls

Called by