Spreading religion

ArneHD

Just a little bit mad
Joined
May 16, 2006
Messages
3,153
Location
Tromsø, Norway
I wonder is there a mod that will increase the rate at which religions spread? I like to play really long games and find that religion spreads far to slowly for my tastes. I searched and could find none.

Also, is it possible to make a mod in which the religious buildings are automaticaly added when a religion spreads to a city?
(It would certanly cut down on the amount of micromanagment if it is, I like to have cities with lots of buildings as well).
 
ArneHD said:
I wonder is there a mod that will increase the rate at which religions spread? I like to play really long games and find that religion spreads far to slowly for my tastes. I searched and could find none.

Also, is it possible to make a mod in which the religious buildings are automaticaly added when a religion spreads to a city?
(It would certanly cut down on the amount of micromanagment if it is, I like to have cities with lots of buildings as well).

The spread rate is defined in the CIV4ReligionInfos.xml file. Increasing that number will increase how fast it spreads.

And yes, as Dalek said, it will require python to automatically add buildings when a religion spreads but its not to hard to do.
 
Kael, how about religions spreading to cities that already have a religion? A lot of people seem to complain about this from TAM, but I haven't noticed it ... I thought that a religion could in fact spread to a city that already had a religion. Can you provide your input on this?
 
Shqype said:
Kael, how about religions spreading to cities that already have a religion? A lot of people seem to complain about this from TAM, but I haven't noticed it ... I thought that a religion could in fact spread to a city that already had a religion. Can you provide your input on this?
The spreading into cities with a religion happens, but with much lower possibility.
 
Would you happen to know where this is defined? I'de definitely like to tweak those values...
 
Same here, also, does religion spread naturaly into a city that already has a religion?
 
Religions dont spread naturally if a city already has a religion. It is handled in the void CvCity::doReligion() function in CvCity.cpp:

Code:
void CvCity::doReligion()
{
	CvCity* pLoopCity;
	int iRandThreshold;
	int iSpread;
	int iLoop;
	int iI, iJ;

	CyCity* pyCity = new CyCity(this);
	CyArgsList argsList;
	argsList.add(gDLL->getPythonIFace()->makePythonObject(pyCity));	// pass in city class
	long lResult=0;
	gDLL->getPythonIFace()->callFunction(PYGameModule, "doReligion", argsList.makeFunctionArgs(), &lResult);
	delete pyCity;	// python fxn must not hold on to this pointer
	if (lResult == 1)
	{
		return;
	}

[b]	if (getReligionCount() == 0)[/b]
	{
		for (iI = 0; iI < GC.getNumReligionInfos(); iI++)
		{
			if (!isHasReligion((ReligionTypes)iI))
			{
				if ((iI == GET_PLAYER(getOwnerINLINE()).getStateReligion()) || !(GET_PLAYER(getOwnerINLINE()).isNoNonStateReligionSpread()))
				{
					iRandThreshold = 0;

					for (iJ = 0; iJ < MAX_PLAYERS; iJ++)
					{
						if (GET_PLAYER((PlayerTypes)iJ).isAlive())
						{
							for (pLoopCity = GET_PLAYER((PlayerTypes)iJ).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)iJ).nextCity(&iLoop))
							{
								if (pLoopCity->isConnectedTo(this))
								{
									iSpread = pLoopCity->getReligionInfluence((ReligionTypes)iI);

									iSpread *= GC.getReligionInfo((ReligionTypes)iI).getSpreadFactor();

									if (iSpread > 0)
									{
										iSpread /= max(1, (((GC.getDefineINT("RELIGION_SPREAD_DISTANCE_DIVISOR") * plotDistance(getX_INLINE(), getY_INLINE(), pLoopCity->getX_INLINE(), pLoopCity->getY_INLINE())) / GC.getMapINLINE().maxPlotDistance()) - 5));

										//iSpread /= (getReligionCount() + 1);
										iRandThreshold = max(iRandThreshold, iSpread);
									}
								}
							}
						}
					}

					if (GC.getGameINLINE().getSorenRandNum(GC.getDefineINT("RELIGION_SPREAD_RAND"), "Religion Spread") < iRandThreshold)
					{
						setHasReligion(((ReligionTypes)iI), true, true);
						break;
					}
				}
			}
		}
	}
}

Note the bolded check which only allows the spread function to run if the city doesn't already have a religion.

The following is the doReligion we use in FfH2:

Code:
void CvCity::doReligion()
{
	CvCity* pLoopCity;
	int iRandThreshold;
	int iSpread;
	int iLoop;
	int iI, iJ;

	CyCity* pyCity = new CyCity(this);
	CyArgsList argsList;
	argsList.add(gDLL->getPythonIFace()->makePythonObject(pyCity));	// pass in city class
	long lResult=0;
	gDLL->getPythonIFace()->callFunction(PYGameModule, "doReligion", argsList.makeFunctionArgs(), &lResult);
	delete pyCity;	// python fxn must not hold on to this pointer
	if (lResult == 1)
	{
		return;
	}

[b]//FfH: Modified by Kael 05/17/2006 to allow up to 3 religions to spread naturally
//	if (getReligionCount() == 0)

	if (getReligionCount() < 3)

//FfH: End Modify[/b]

	{
		for (iI = 0; iI < GC.getNumReligionInfos(); iI++)
		{

[b]//FfH: Modified by Chalid 05/17/2006 to block opposed religion spreads
//			if (!isHasReligion((ReligionTypes)iI))

			if (!isHasReligion((ReligionTypes)iI) &&
                !(isHasReligion((ReligionTypes)GC.getInfoTypeForString("RELIGION_THE_ORDER")) && iI == GC.getInfoTypeForString("RELIGION_THE_ASHEN_VEIL")) &&
                !(isHasReligion((ReligionTypes)GC.getInfoTypeForString("RELIGION_THE_ASHEN_VEIL")) && iI == GC.getInfoTypeForString("RELIGION_THE_ORDER")))

//FfH: End Modify[/b]

			{
				if ((iI == GET_PLAYER(getOwnerINLINE()).getStateReligion()) || !(GET_PLAYER(getOwnerINLINE()).isNoNonStateReligionSpread()))
				{
					iRandThreshold = 0;

					for (iJ = 0; iJ < MAX_PLAYERS; iJ++)
					{
						if (GET_PLAYER((PlayerTypes)iJ).isAlive())
						{
							for (pLoopCity = GET_PLAYER((PlayerTypes)iJ).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)iJ).nextCity(&iLoop))
							{
								if (pLoopCity->isConnectedTo(this))
								{
									iSpread = pLoopCity->getReligionInfluence((ReligionTypes)iI);

									iSpread *= GC.getReligionInfo((ReligionTypes)iI).getSpreadFactor();

									if (iSpread > 0)
									{
										iSpread /= max(1, (((GC.getDefineINT("RELIGION_SPREAD_DISTANCE_DIVISOR") * plotDistance(getX_INLINE(), getY_INLINE(), pLoopCity->getX_INLINE(), pLoopCity->getY_INLINE())) / GC.getMapINLINE().maxPlotDistance()) - 5));

										//iSpread /= (getReligionCount() + 1);

[b]//FfH: Added by Kael 05/17/2006 to modify the spread chances

                                        if (GET_PLAYER(getOwnerINLINE()).hasTrait((TraitTypes)GC.getInfoTypeForString("TRAIT_AGNOSTIC")))
                                        {
                                            iSpread = iSpread / 2;
                                        }

                                        iSpread = iSpread / ((getReligionCount() + 1) * (getReligionCount() + 1));

//FfH: End Add[/b]

										iRandThreshold = max(iRandThreshold, iSpread);
									}
								}
							}
						}
					}

					if (GC.getGameINLINE().getSorenRandNum(GC.getDefineINT("RELIGION_SPREAD_RAND"), "Religion Spread") < iRandThreshold)
					{
						setHasReligion(((ReligionTypes)iI), true, true);
						break;
					}
				}
			}
		}
	}
}

The stopping of spread on the opposed spread of the Ashen Veil and the Order and the modification of the spread chances if the leader has the Agnostic trait are FfH specific and probably aren't of much interest to you (unless you'd like to do something similiar). But the change of the amount of religions that will spread naturally to 3 (the number we felt was a fair amount for spread) and the exponential decrease in spread chance based on the number of existing religions is probably what you are looking for.
 
Yes it is, Kael! Thanks so much :goodjob:
 
I'm sorry, but I can't find CvCity.cpp.

Where is it located?
 
ArneHD said:
I'm sorry, but I can't find CvCity.cpp.

Where is it located?

Its a file in the SDK.
 
Yes, I got got it, thank you.

Have to stop thinking Java.
 
Alright Kael, I finally got my hands on the SDK! I just installed the Visual Studio 2003 and opened CvCity.cpp right up. Now I can change the code to my liking, but what's the best way to compile a new DLL?
 
Shqype said:
Alright Kael, I finally got my hands on the SDK! I just installed the Visual Studio 2003 and opened CvCity.cpp right up. Now I can change the code to my liking, but what's the best way to compile a new DLL?

I dont know, I use codeblocks. Can anyone else answer this?
 
Kael said:
I dont know, I use codeblocks. Can anyone else answer this?

Could you explain what a codeblock is please?
 
Kael said:
I dont know, I use codeblocks. Can anyone else answer this?

I can answer this. With Visual Studio 2003, you change the build to "final release", done from the drop down menu in the middle of the upper part of the screen. Then choose "Build Solution" or "Build CvGameCore.DLL" or whatever it is called. If this isnt clear enough I can post some screen shots tomorrow???
 
Uhh.. I'm not sure I did it properly. In order to get a "Final Release" choice I must have the CvGameCoreDLL file open ... so first I make changes to the files, save them, and then open up the CvGameCoreDLL file. Both options "Build Solution" and "Build CvGameCoreDLL" are available. I chose the latter and ended up with a Final Release folder which new files in it. Not sure what to do with them..
 
Top Bottom