[Ouroboros] Tutorials and information regarding religions and pantheons.

OuroborosOrder

Warlord
Joined
Apr 3, 2016
Messages
124
Location
Alabama

====================================
{XML information regarding religions and pantheons.}
====================================



------------------------------------------------
Section 1: [Religion XML value reference]
------------------------------------------------


FILE: Civ5Religions.xml IN DEFAULT PATH: "C:\Program Files (x86)\Steam\steamapps\common\Sid Meirer's Civilization V\Assets\DLC\Expansion2\GamePlay\XML\Religions"


Beliefs Table
Spoiler :

Primary table that controls religion benefits and modifiers.


Beliefs Table Columns

Spoiler :

MinPopulation
MinFollowers
MaxDistance
CityGrowthModifier
FaithFromKills
FaithFromDyingUnits
RiverHappiness
HappinessPerCity
HappinessPerXPeacefulForeignFollowers
PlotCultureCostModifier
CityRangeStrikeModifier
CombatModifierEnemyCities
CombatModifierFriendlyCities
FriendlyHealChange
CityStateFriendshipModifier
LandBarbarianConversionPercent
WonderProductionModifier
PlayerHappiness
PlayerCultureModifier
HappinessPerFollowingCity
GoldPerFollowingCity
GoldPerXFollowers
GoldPerFirstCityConversion
SciencePerOtherReligionFollower
SpreadDistanceModifier
SpreadStrengthModifier
ProphetStrengthModifier
ProphetCostModifier
MissionaryStrengthModifier
MissionaryCostModifier
FriendlyCityStateSpreadModifier
GreatPersonExpendedFaith
CityStateMinimumInfluence
Pantheon
Founder
Follower
Enhancer
RequiresPeace
EnablesFaithBuying


Belief_TerrainYieldChanges Table
Spoiler :

... Directly controls the per terrain yield changes for each belief option.I.E. belief for tundra, plains, dessert, ect...


Belief_FeatureYieldChanges Table
Spoiler :

... Directly controls the per feature yield changes for each belief option. I.E. belief for forests, jungle, ect...


Belief_TerrainYieldChanges Table
Spoiler :

... Directly controls the per terrain yield changes for each belief option.


Belief_CityYieldChanges Table
Spoiler :

... Directly controls the per city yield changes for each belief option.
[/SIZE]


Belief_HolyCityYieldChanges Table
Spoiler :

... Directly controls the per holy city yield changes for each belief option.
[/SIZE]


Belief_YieldChangeAnySpecialist Table
Spoiler :

... Directly controls the per specialist yield changes for each belief option.


Belief_YieldChangeTradeRoute Table
Spoiler :

... Directly controls the per trade route yield changes for each belief option.


Belief_YieldChangeNaturalWonder Table
Spoiler :

... Directly controls the per natural wonder yield changes for each belief option.


Belief_YieldChangeWorldWonder Table
Spoiler :

... Directly controls the per world wonder yield changes for each belief option.


Belief_YieldModifierNaturalWonder Table
Spoiler :

... Directly controls the per natural wonder yield modifier for each belief option.
 

===================================
{DLL information regarding religions and pantheons.}
===================================



-----------------------------------------------------------------------------
Section 1 [DLL religious calculations in respect to Religion concept]
-----------------------------------------------------------------------------


Coming Soon


---------------------------------------------------
Section 2 [AI in respect to Religion concept]
---------------------------------------------------



DoPlayerTurn Method in CvReligionClasses.cpp:

Spoiler :
Code:
[COLOR="purple"]
void CvGameReligions::DoPlayerTurn(CvPlayer& kPlayer)
{
...
			// Create the pantheon
			if(kPlayer.isHuman())
			{

			else
			{
				const BeliefTypes eBelief = kPlayer.GetReligionAI()->ChoosePantheonBelief();

				FoundPantheon(ePlayer, eBelief);
			}
...
}
[/COLOR]

Ouroboros' Explanation:

The above method processes the religious aspects of the current players turn. It checks if the player is a human player or AI player. If it is an AI player it calls another Method called ChoosPantheonBelief shown below.



ChoosePantheonBelief Method in CvReligionClasses.cpp:

Spoiler :
Code:
[COLOR="Purple"]
/// Select the belief most helpful to this pantheon
BeliefTypes CvReligionAI::ChoosePantheonBelief()
{
...
	for(std::vector<BeliefTypes>::iterator it = availableBeliefs.begin();
	        it!= availableBeliefs.end(); ++it)
	{
		const BeliefTypes eBelief = (*it);
		CvBeliefEntry* pEntry = m_pBeliefs->GetEntry(eBelief);
		if(pEntry)
		{
			const int iScore = ScoreBelief(pEntry);
			if(iScore > 0)
			{
				beliefChoices.push_back(eBelief, iScore);
			}
		}
	}

	// Choose from weighted vector
	beliefChoices.SortItems();
	int iNumChoices = MIN(beliefChoices.size(),3);   // Throw out two-thirds of the choices -- this was way too loose as choices way down were being selected now only top 3
	RandomNumberDelegate fcn = MakeDelegate(&GC.getGame(), &CvGame::getJonRandNum);
	BeliefTypes rtnValue = beliefChoices.ChooseFromTopChoices(iNumChoices, &fcn, "Choosing belief from Top Choices");
	LogBeliefChoices(beliefChoices, rtnValue);

	return rtnValue;
}
[/COLOR]

Ouroboros' Explanation:

The above method creates a weighted std::vector of available beliefs to choose from (which is a type of dynamic array used here as a list). It then calls another method called ScoreBelief for each entry in the list. It then sorts the list in order of score.

It throws out the two-thirds of the scored available beliefs to reduce the choices to the top choices. Then it simply selects a random number from 0 to the max number of selected top choices. It lastly sets the belief to the random choice from the top choices.



ScoreBelief Method in CvReligionClasses.cpp:


Spoiler :
Code:
[COLOR="Purple"]
/// AI's perceived worth of a belief
int CvReligionAI::ScoreBelief(CvBeliefEntry* pEntry)
{
	int iRtnValue = 5;  // Base value since everything has SOME value

	// Loop through each plot on map
	int iPlotLoop;
	CvPlot* pPlot;
	for(iPlotLoop = 0; iPlotLoop < GC.getMap().numPlots(); iPlotLoop++)
	{
		pPlot = GC.getMap().plotByIndexUnchecked(iPlotLoop);

		// Skip if not revealed or in enemy territory
		PlayerTypes ePlotOwner = pPlot->getOwner();
		if(pPlot->isRevealed(m_pPlayer->getTeam()) && (ePlotOwner == NO_PLAYER || ePlotOwner == m_pPlayer->GetID()))
		{
			// Also skip if closest city of ours is not within 3
			CvCity* pClosestCity = m_pPlayer->GetClosestFriendlyCity(*pPlot, 3);
			if(pClosestCity)
			{
				// Score it
				int iScoreAtPlot = ScoreBeliefAtPlot(pEntry, pPlot);

				// Apply multiplier based on whether or not being worked, within culture borders, or not
				if(pPlot->isBeingWorked())
				{
					iScoreAtPlot *= GC.getRELIGION_BELIEF_SCORE_WORKED_PLOT_MULTIPLIER();
				}
				else if(ePlotOwner != NO_PLAYER)
				{
					iScoreAtPlot *= GC.getRELIGION_BELIEF_SCORE_OWNED_PLOT_MULTIPLIER();
				}
				else
				{
					iScoreAtPlot *= GC.getRELIGION_BELIEF_SCORE_UNOWNED_PLOT_MULTIPLIER();
				}

				iRtnValue += iScoreAtPlot;
			}
		}
	}

	// Add in value at city level
	int iLoop;
	CvCity* pLoopCity;
	for(pLoopCity = m_pPlayer->firstCity(&iLoop); pLoopCity != NULL; pLoopCity = m_pPlayer->nextCity(&iLoop))
	{
		int iScoreAtCity = ScoreBeliefAtCity(pEntry, pLoopCity);
		iScoreAtCity *= GC.getRELIGION_BELIEF_SCORE_CITY_MULTIPLIER();

		iRtnValue += iScoreAtCity;
	}

	// Add in player-level value
	iRtnValue += ScoreBeliefForPlayer(pEntry);

	// Divide by 2 if a Pantheon belief (to deemphasize these to Byzantine bonus belief)
	if (pEntry->IsPantheonBelief())
	{
		iRtnValue /= 2;
	}

	return iRtnValue;
}
[/COLOR]

Ouroboros' Explanation:

The above is the aforementioned ScoreBelief method, which as it name suggest scores the beliefs in order of usefulness to the AI. It first assigns a base value of 5 to all available beliefs as the programmer comments:"Everything has some value".

It then first cycles through all plots the AI civ owns and can possibly own currently by city border expansion i.e. the 3 tile city border radius. It calls another method (which I will skip for brevity as it should be self explanatory), ScoreBeliefAtPlot.

Fortunately for modders, ScoreBelief and it corresponding methods use several database values which could be changed via XML or SQL. See the section labeled "XML Information regarding Religion".
 
Back
Top Bottom