Bazaar developer reference

CvReligionAI::ScoreBeliefForPlayer(CvBeliefEntry *)

Defined in
CvReligionClasses.cpp, line 6451
Class
CvReligionAI
Hook name
CivHooks::CvReligionAI_ScoreBeliefForPlayer

Hooks

static bool BeforeCvReligionAI_ScoreBeliefForPlayer(CvReligionAI* self, CvBeliefEntry* pEntry, int& result);static void AfterCvReligionAI_ScoreBeliefForPlayer(CvReligionAI* self, CvBeliefEntry* pEntry, int& result);static int ReplaceCvReligionAI_ScoreBeliefForPlayer(int (*original)(CvReligionAI*, CvBeliefEntry*), CvReligionAI* self, CvBeliefEntry* pEntry);CivRegisterBefore<CivHooks::CvReligionAI_ScoreBeliefForPlayer>(host, &BeforeCvReligionAI_ScoreBeliefForPlayer);CivRegisterAfter<CivHooks::CvReligionAI_ScoreBeliefForPlayer>(host, &AfterCvReligionAI_ScoreBeliefForPlayer);CivRegisterReplace<CivHooks::CvReligionAI_ScoreBeliefForPlayer>(host, &ReplaceCvReligionAI_ScoreBeliefForPlayer);

Code

6450/// AI's evaluation of this belief's usefulness to this player6451int CvReligionAI::ScoreBeliefForPlayer(CvBeliefEntry* pEntry)6452{6453	int iRtnValue = 0;6454	CvFlavorManager* pFlavorManager = m_pPlayer->GetFlavorManager();6455	CvGameReligions* pGameReligions = GC.getGame().GetGameReligions();64566457	//--------------------6458	// GET BACKGROUND DATA6459	//--------------------6460	int iFlavorOffense = pFlavorManager->GetPersonalityIndividualFlavor((FlavorTypes)GC.getInfoTypeForString("FLAVOR_OFFENSE"));6461	int iFlavorDefense = pFlavorManager->GetPersonalityIndividualFlavor((FlavorTypes)GC.getInfoTypeForString("FLAVOR_DEFENSE"));6462	int iFlavorHappiness = pFlavorManager->GetPersonalityIndividualFlavor((FlavorTypes)GC.getInfoTypeForString("FLAVOR_HAPPINESS"));6463	int iFlavorCulture = pFlavorManager->GetPersonalityIndividualFlavor((FlavorTypes)GC.getInfoTypeForString("FLAVOR_CULTURE"));6464	int iFlavorGold = pFlavorManager->GetPersonalityIndividualFlavor((FlavorTypes)GC.getInfoTypeForString("FLAVOR_GOLD"));6465	int iFlavorGP = pFlavorManager->GetPersonalityIndividualFlavor((FlavorTypes)GC.getInfoTypeForString("FLAVOR_GREAT_PEOPLE"));6466	int iFlavorScience = pFlavorManager->GetPersonalityIndividualFlavor((FlavorTypes)GC.getInfoTypeForString("FLAVOR_SCIENCE"));6467	int iFlavorDiplomacy = pFlavorManager->GetPersonalityIndividualFlavor((FlavorTypes)GC.getInfoTypeForString("FLAVOR_DIPLOMACY"));6468	int iFlavorExpansion = pFlavorManager->GetPersonalityIndividualFlavor((FlavorTypes)GC.getInfoTypeForString("FLAVOR_EXPANSION"));64696470	int iNumEnhancedReligions = pGameReligions->GetNumReligionsEnhanced();6471	int iReligionsEnhancedPercent = (100 * iNumEnhancedReligions) / GC.getMap().getWorldInfo().getMaxActiveReligions();64726473	//------------------------------6474	// PLAYER-LEVEL PANTHEON BELIEFS6475	//------------------------------6476	if(pEntry->GetFaithFromKills() > 0)6477	{6478		int iTemp = pEntry->GetFaithFromKills() * pEntry->GetMaxDistance() * iFlavorOffense / 100;6479		if (m_pPlayer->GetDiplomacyAI()->IsGoingForWorldConquest())6480		{6481			iTemp *= 2;6482		}6483		iRtnValue += iTemp;6484	}64856486	//-------6487	// UNUSED6488	//-------6489	iRtnValue += pEntry->GetPlayerHappiness() * iFlavorHappiness;6490	iRtnValue += pEntry->GetPlayerCultureModifier() * iFlavorCulture;64916492	//-----------------6493	// FOLLOWER BELIEFS6494	//-----------------6495	// Unlocks a building6496	for (int iI = 0; iI < GC.getNumBuildingClassInfos(); iI++)6497	{6498		if (pEntry->IsBuildingClassEnabled(iI))6499		{6500			BuildingTypes eBuilding = (BuildingTypes)m_pPlayer->getCivilizationInfo().getCivilizationBuildings(iI);6501			CvBuildingEntry* pBuildingEntry = GC.GetGameBuildings()->GetEntry(eBuilding);65026503			if(pBuildingEntry && pFlavorManager)6504			{6505				for(int iFlavorLoop = 0; iFlavorLoop < GC.getNumFlavorTypes(); iFlavorLoop++)6506				{6507					int iFlavorValue = pFlavorManager->GetPersonalityIndividualFlavor((FlavorTypes)iFlavorLoop) * pBuildingEntry->GetFlavorValue(iFlavorLoop);65086509					// If can also be built with hammers, much less valuable6510					if (pBuildingEntry->GetProductionCost() > 0)6511					{6512						iFlavorValue /= 10;6513					}6514					iRtnValue += iFlavorValue;6515				}6516			}6517		}6518	}65196520	// Unlocks units?	6521	for(int i = 0; i < GC.getNumEraInfos(); i++)6522	{6523		// Add in for each era enabled6524		if (pEntry->IsFaithUnitPurchaseEra(i))6525		{6526			int iTemp = (iFlavorOffense) + (iFlavorDefense / 2);6527			if (m_pPlayer->GetDiplomacyAI()->IsGoingForWorldConquest())6528			{6529				iTemp *= 2;6530			}6531			iRtnValue += iTemp;6532		}6533	}65346535	//----------------6536	// FOUNDER BELIEFS6537	//----------------6538	iRtnValue += (int)(pEntry->GetHappinessPerFollowingCity() * (float)(iFlavorHappiness + 2 * iFlavorOffense - iFlavorDefense));6539	if (pEntry->GetHappinessPerXPeacefulForeignFollowers() > 0 && iFlavorDefense > 0)6540	{6541		iRtnValue += (iFlavorHappiness * 10 * iFlavorDefense) / (pEntry->GetHappinessPerXPeacefulForeignFollowers() * iFlavorDefense);6542	}6543	iRtnValue += iFlavorScience * pEntry->GetSciencePerOtherReligionFollower() / 5;6544	iRtnValue += pEntry->GetGoldPerFollowingCity() * iFlavorGold;6545	if(pEntry->GetGoldPerXFollowers() > 0)6546	{6547		iRtnValue += (iFlavorGold * 4 / pEntry->GetGoldPerXFollowers());6548	}6549	iRtnValue += iFlavorGold * pEntry->GetGoldWhenCityAdopts() / 50;65506551	// Minimum influence with city states6552	iRtnValue += iFlavorDiplomacy * pEntry->GetCityStateMinimumInfluence() / 7;65536554	// Yields for foreign followers6555	for(int iI = 0; iI < NUM_YIELD_TYPES; iI++)6556	{6557		if (iI == YIELD_CULTURE)6558		{6559			iRtnValue += pEntry->GetYieldChangePerForeignCity(iI) * 2 * iFlavorCulture;6560			if (pEntry->GetYieldChangePerXForeignFollowers(iI) > 0)6561			{6562				iRtnValue += 10 * iFlavorCulture / pEntry->GetYieldChangePerXForeignFollowers(iI);6563			}6564		}6565		else6566		{6567			iRtnValue += pEntry->GetYieldChangePerForeignCity(iI) * 10;6568			if (pEntry->GetYieldChangePerXForeignFollowers(iI) > 0)6569			{6570				iRtnValue += 50 / pEntry->GetYieldChangePerXForeignFollowers(iI);6571			}6572		}6573	}65746575	//-----------------6576	// ENHANCER BELIEFS6577	//-----------------6578	iRtnValue += iFlavorGP * pEntry->GetGreatPersonExpendedFaith() / 10;6579	iRtnValue += iFlavorDiplomacy * pEntry->GetFriendlyCityStateSpreadModifier() / 20;6580	iRtnValue += iFlavorDefense * pEntry->GetCombatModifierFriendlyCities() / 4;6581	iRtnValue += iFlavorOffense * pEntry->GetCombatModifierEnemyCities() / 4;65826583	// Chosen EARLY?6584	if (iReligionsEnhancedPercent < 33)6585	{6586		// Good early6587		iRtnValue += (2 * iFlavorExpansion) + pEntry->GetSpreadDistanceModifier();6588		iRtnValue += (2 * iFlavorScience) + pEntry->GetSpreadStrengthModifier();6589		iRtnValue += pEntry->GetMissionaryStrengthModifier() * 2;6590		iRtnValue += (-1 * pEntry->GetMissionaryCostModifier()) * 2;65916592		// Poor early6593		iRtnValue += pEntry->GetProphetStrengthModifier() / 4;6594		iRtnValue += (-1 * pEntry->GetProphetCostModifier()) / 4;6595	}65966597	// Chosen in the MIDDLE?6598	else if (iReligionsEnhancedPercent < 66)6599	{6600		iRtnValue += iFlavorExpansion + pEntry->GetSpreadDistanceModifier() / 2;6601		iRtnValue += iFlavorScience + pEntry->GetSpreadStrengthModifier() / 2;6602		iRtnValue += pEntry->GetProphetStrengthModifier() / 2;6603		iRtnValue += (-1 * pEntry->GetProphetCostModifier()) / 2;6604		iRtnValue += pEntry->GetMissionaryStrengthModifier();6605		iRtnValue += (-1 * pEntry->GetMissionaryCostModifier());6606	}66076608	// Chosen LATE?6609	else6610	{6611		// Poor late6612		iRtnValue += ((2 * iFlavorExpansion) + pEntry->GetSpreadDistanceModifier()) / 4;6613		iRtnValue += ((2 * iFlavorScience) + pEntry->GetSpreadStrengthModifier()) / 4;6614		iRtnValue += pEntry->GetMissionaryStrengthModifier() / 2;6615		iRtnValue += (-1 * pEntry->GetMissionaryCostModifier()) / 2;66166617		// Good late6618		iRtnValue += pEntry->GetProphetStrengthModifier();6619		iRtnValue += (-1 * pEntry->GetProphetCostModifier());6620	}66216622	//-----------------6623	// REFORMATION BELIEFS6624	//-----------------6625	if (pEntry->FaithPurchaseAllGreatPeople())6626	{6627		// Count number of GP branches we have still to open and score based on that6628		int iTemp = 0;6629#if defined(MOD_RELIGION_POLICY_BRANCH_FAITH_GP)6630		if (MOD_RELIGION_POLICY_BRANCH_FAITH_GP)6631		{6632			// Count the number of policies we DON'T have that unlock Great People, for the time being we won't worry about multiple policies unlocking the same GP6633			for (int iPolicyLoop = 0; iPolicyLoop < m_pPlayer->GetPlayerPolicies()->GetPolicies()->GetNumPolicies(); iPolicyLoop++)6634			{6635				const PolicyTypes eLoopPolicy = static_cast<PolicyTypes>(iPolicyLoop);6636				CvPolicyEntry* pkLoopPolicyInfo = GC.getPolicyInfo(eLoopPolicy);6637				if (pkLoopPolicyInfo && !m_pPlayer->HasPolicy(eLoopPolicy))6638				{6639					// We don't have this policy, but does it permit any GP to be bought with faith6640					if (pkLoopPolicyInfo->HasFaithPurchaseUnitClasses())6641					{6642						iTemp++;6643					}6644				}6645			}6646			6647			CUSTOMLOG("FaithPurchaseAllGreatPeople unlocks %i GPs for %s", iTemp, m_pPlayer->getCivilizationDescription());6648		}6649		else6650		{6651#endif6652			PolicyBranchTypes eBranch;6653			eBranch = (PolicyBranchTypes)GC.getInfoTypeForString("POLICY_BRANCH_TRADITION", true /*bHideAssert*/);6654			if (eBranch != NO_POLICY_BRANCH_TYPE && (!m_pPlayer->GetPlayerPolicies()->IsPolicyBranchFinished(eBranch) || m_pPlayer->GetPlayerPolicies()->IsPolicyBranchBlocked(eBranch)))6655			{6656				iTemp++;6657			}6658			eBranch = (PolicyBranchTypes)GC.getInfoTypeForString("POLICY_BRANCH_HONOR", true /*bHideAssert*/);6659			if (eBranch != NO_POLICY_BRANCH_TYPE && (!m_pPlayer->GetPlayerPolicies()->IsPolicyBranchFinished(eBranch) || m_pPlayer->GetPlayerPolicies()->IsPolicyBranchBlocked(eBranch)))6660			{6661				iTemp++;6662			}6663			eBranch = (PolicyBranchTypes)GC.getInfoTypeForString("POLICY_BRANCH_AESTHETICS", true /*bHideAssert*/);6664			if (eBranch != NO_POLICY_BRANCH_TYPE && (!m_pPlayer->GetPlayerPolicies()->IsPolicyBranchFinished(eBranch) || m_pPlayer->GetPlayerPolicies()->IsPolicyBranchBlocked(eBranch)))6665			{6666				iTemp++;6667			}6668			eBranch = (PolicyBranchTypes)GC.getInfoTypeForString("POLICY_BRANCH_COMMERCE", true /*bHideAssert*/);6669			if (eBranch != NO_POLICY_BRANCH_TYPE && (!m_pPlayer->GetPlayerPolicies()->IsPolicyBranchFinished(eBranch) || m_pPlayer->GetPlayerPolicies()->IsPolicyBranchBlocked(eBranch)))6670			{6671				iTemp++;6672			}6673			eBranch = (PolicyBranchTypes)GC.getInfoTypeForString("POLICY_BRANCH_EXPLORATION", true /*bHideAssert*/);6674			if (eBranch != NO_POLICY_BRANCH_TYPE && (!m_pPlayer->GetPlayerPolicies()->IsPolicyBranchFinished(eBranch) || m_pPlayer->GetPlayerPolicies()->IsPolicyBranchBlocked(eBranch)))6675			{6676				iTemp++;6677			}6678			eBranch = (PolicyBranchTypes)GC.getInfoTypeForString("POLICY_BRANCH_RATIONALISM", true /*bHideAssert*/);6679			if (eBranch != NO_POLICY_BRANCH_TYPE && (!m_pPlayer->GetPlayerPolicies()->IsPolicyBranchFinished(eBranch) || m_pPlayer->GetPlayerPolicies()->IsPolicyBranchBlocked(eBranch)))6680			{6681				iTemp++;6682			}6683#if defined(MOD_RELIGION_POLICY_BRANCH_FAITH_GP)6684		}6685#endif66866687		iRtnValue += (iTemp * 6);6688	}6689	if (pEntry->ConvertsBarbarians())6690	{6691		MilitaryAIStrategyTypes eStrategyBarbs = (MilitaryAIStrategyTypes) GC.getInfoTypeForString("MILITARYAISTRATEGY_ERADICATE_BARBARIANS");6692		if (m_pPlayer->GetMilitaryAI()->IsUsingStrategy(eStrategyBarbs))6693		{6694			iRtnValue += 40;6695		}6696		else6697		{6698			iRtnValue += 15;6699		}6700	}6701	if (pEntry->GetCityStateInfluenceModifier() > 0)6702	{6703		iRtnValue += (pEntry->GetCityStateInfluenceModifier() * iFlavorDiplomacy / 5);6704	}6705	if (pEntry->GetInquisitorPressureRetention() > 0)6706	{6707		iRtnValue += (pEntry->GetInquisitorPressureRetention() / 2);6708	}6709	if (pEntry->GetSpyPressure() > 0)6710	{6711		iRtnValue += (pEntry->GetSpyPressure()* 5);6712	}6713	if (pEntry->GetFaithBuildingTourism() > 0)6714	{6715		iRtnValue += (pEntry->GetFaithBuildingTourism() * 20);6716	}67176718	return iRtnValue;6719}

Calls

Called by