Bazaar developer reference

CvReligionAI::ScoreBelief(CvBeliefEntry *)

Defined in
CvReligionClasses.cpp, line 6128
Class
CvReligionAI
Hook name
CivHooks::CvReligionAI_ScoreBelief

Hooks

static bool BeforeCvReligionAI_ScoreBelief(CvReligionAI* self, CvBeliefEntry* pEntry, int& result);static void AfterCvReligionAI_ScoreBelief(CvReligionAI* self, CvBeliefEntry* pEntry, int& result);static int ReplaceCvReligionAI_ScoreBelief(int (*original)(CvReligionAI*, CvBeliefEntry*), CvReligionAI* self, CvBeliefEntry* pEntry);CivRegisterBefore<CivHooks::CvReligionAI_ScoreBelief>(host, &BeforeCvReligionAI_ScoreBelief);CivRegisterAfter<CivHooks::CvReligionAI_ScoreBelief>(host, &AfterCvReligionAI_ScoreBelief);CivRegisterReplace<CivHooks::CvReligionAI_ScoreBelief>(host, &ReplaceCvReligionAI_ScoreBelief);

Code

6127/// AI's perceived worth of a belief6128int CvReligionAI::ScoreBelief(CvBeliefEntry* pEntry)6129{6130	int iRtnValue = 5;  // Base value since everything has SOME value61316132	// Loop through each plot on map6133	int iPlotLoop;6134	CvPlot* pPlot;6135	for(iPlotLoop = 0; iPlotLoop < GC.getMap().numPlots(); iPlotLoop++)6136	{6137		pPlot = GC.getMap().plotByIndexUnchecked(iPlotLoop);61386139		// Skip if not revealed or in enemy territory6140		PlayerTypes ePlotOwner = pPlot->getOwner();6141		if(pPlot->isRevealed(m_pPlayer->getTeam()) && (ePlotOwner == NO_PLAYER || ePlotOwner == m_pPlayer->GetID()))6142		{6143			// Also skip if closest city of ours is not within 36144			CvCity* pClosestCity = m_pPlayer->GetClosestFriendlyCity(*pPlot, 3);6145			if(pClosestCity)6146			{6147				// Score it6148				int iScoreAtPlot = ScoreBeliefAtPlot(pEntry, pPlot);61496150				// Apply multiplier based on whether or not being worked, within culture borders, or not6151				if(pPlot->isBeingWorked())6152				{6153					iScoreAtPlot *= GC.getRELIGION_BELIEF_SCORE_WORKED_PLOT_MULTIPLIER();6154				}6155				else if(ePlotOwner != NO_PLAYER)6156				{6157					iScoreAtPlot *= GC.getRELIGION_BELIEF_SCORE_OWNED_PLOT_MULTIPLIER();6158				}6159				else6160				{6161					iScoreAtPlot *= GC.getRELIGION_BELIEF_SCORE_UNOWNED_PLOT_MULTIPLIER();6162				}61636164				iRtnValue += iScoreAtPlot;6165			}6166		}6167	}61686169	// Add in value at city level6170	int iLoop;6171	CvCity* pLoopCity;6172	for(pLoopCity = m_pPlayer->firstCity(&iLoop); pLoopCity != NULL; pLoopCity = m_pPlayer->nextCity(&iLoop))6173	{6174		int iScoreAtCity = ScoreBeliefAtCity(pEntry, pLoopCity);6175		iScoreAtCity *= GC.getRELIGION_BELIEF_SCORE_CITY_MULTIPLIER();61766177		iRtnValue += iScoreAtCity;6178	}61796180	// Add in player-level value6181	iRtnValue += ScoreBeliefForPlayer(pEntry);61826183	// Divide by 2 if a Pantheon belief (to deemphasize these to Byzantine bonus belief)6184	if (pEntry->IsPantheonBelief())6185	{6186		iRtnValue /= 2;6187	}61886189	return iRtnValue;6190}

Calls

Called by