Religionmodding - (doHolyCity and doHolyCityTech)

Ploeperpengel

academic precarity
Joined
Feb 2, 2006
Messages
4,748
Location
Berlin
doHolyCity and doHolyCityTech both return true in Gods of Old which seemingly makes it so Religions aren't founded by Techdiscovery and no random city is set Holy.
My question is can I and if I can how can I use these functions to disable the founding of a certain Religion to any civ except one(i.e. Taoism only for China on discovering Philosophy)?
Also what do these functions do exactly?(Bonusquestion)
 
I would like to know as well. I have not even looked at the Gods of Old mod yet. Just played it a little while.
 
Ok, the python functions are overrides for the DLL functions in both cases. The DLL functions check the return value from the Python function, if it is true it breaks out of the function in the DLL. So, in laymans terms, returning true will keep the Holy Cities from being created while returning false allows the DLL to continue through it's normal process.

To use this to restrict specific religions you simply need to force it to return true as needed to disallow it, false to allow it.

In your case you'd need two checks, the first to check for the tech (is this a tech that founds a restricted religion?) and the second to check the civ if it is a restricted religion. You will do all of this in CvGameUtils.py using the doHolyCityTech() functions since that is the one out of the two listed that has any useful data passed to it (player, tech, etc).

I can't write the whole thing out for you right now since I'm short on time but your basic code should flow something like this:

if technology is for restricted religion...
...if the civ that discovered it is the civ that can found it
......if this religion hasn't been founded yet (this is the tricky part)
.........return false (this means go ahead)
......else return true (religion already exists don't found it)
...else return true (wrong civ don't found it)
else return false (not restricted, proceed as normal no checks required)

The tricky part will be checking to see if the religion has already been founded, normally this is handled by simply giving it to the first to discover the tech but you won't be able to do that since you need the first that discovered the tech and can found the religion.

A more elgant, code-free solution would be to give specific civs or cultural groups (e.g. Oriental/European) a free invisible, useless technology at the start of the game that would be required to research the technology that founds the specific religion and move the religion founding tech onto their own dead-end technologies that do nothing except found the religion. The reason I say this is more elegant is because it allows the normal rules to work without adding any complexity to the code base while still achieving the desired result. It also makes it possible (and even easy) to have religions defined by ethnic groups much like art styles, giving the religion to the first civ in that group to discover the technology.

Assuming, of course, that I understood your request :)
 
It was not really a request for me. But just curious what was going on. I was planning to just give a visible or invisible tech to each civ for early religions.

Thanks for the info though.
 
A more elgant, code-free solution would be to give specific civs or cultural groups (e.g. Oriental/European) a free invisible, useless technology at the start of the game that would be required to research the technology that founds the specific religion and move the religion founding tech onto their own dead-end technologies that do nothing except found the religion. The reason I say this is more elegant is because it allows the normal rules to work without adding any complexity to the code base while still achieving the desired result. It also makes it possible (and even easy) to have religions defined by ethnic groups much like art styles, giving the religion to the first civ in that group to discover the technology.

Assuming, of course, that I understood your request :)
You did understand my request right, however I simplyfied my request a bit here. The goal is to implement different ways of founding the same religion for different civs later(by building, Great Person or just techdiscovery). The mod has about 30 civs and 8 Religions that will have "subreligions" so I definitly will get into coding for the sake of elegance here. I don't want my techtree get cluttered with helpertechs. But first I need to figure out how to do the more "simple" stuff. Your comments help a lot thx.:)

Codesamples would still be welcome though if anyone can provide some;)
 
To get a religion so it can be 'founded' by different civs is easy if you'll still only have one holy city. For this you could even leave the holy city code alone and instead simply give a free missionary for the appropriate religion to each civ that discovers the tech if they can have the religion. I think the first city to get a religion will become the holy city without any changes in the code. If not that would be a relatively easy change to make in the DLL. Anyway, that would allow multiple civs to 'discover' a religion, but only the first would get the holy city (assuming the AI would actually use the missionary, you might have to force that). Of course you could also simply force the religion to spread to a city and avoid the missionary entirely.

You could also do fun things like change religion discovery to a chance instead of a definite. For instance you could run a check at the start of each player's turn and if they don't have the religion yet, they have the required technology and they are the required civ they have a x% chance of that religion spreading to one of their cities that turn. You could do the same with buildings & wonders.

There are several ways to do what you're asking so I guess all I'd need to know before giving you code examples that would work is how exactly do you want it to work? :)
 
To get a religion so it can be 'founded' by different civs is easy if you'll still only have one holy city. For this you could even leave the holy city code alone and instead simply give a free missionary for the appropriate religion to each civ that discovers the tech if they can have the religion. I think the first city to get a religion will become the holy city without any changes in the code. If not that would be a relatively easy change to make in the DLL. Anyway, that would allow multiple civs to 'discover' a religion, but only the first would get the holy city (assuming the AI would actually use the missionary, you might have to force that). Of course you could also simply force the religion to spread to a city and avoid the missionary entirely.
Unfortunatly it's not the case that the first founder of the religion gets the holy city if the Religion is spread first by unit or building instead of techdiscovery in vanilla(Gods of old uses python to enable the buildings processing the holy city and disables the techfounding, it also forces the AI to build the shrines if available with python since the AI indeed ignores religious buildings before having discovered the religion no matter how high you set the AI weight in xml). Do you think it's actually possible to have more than 1 Holy city for each Religion? That would be great!

You could also do fun things like change religion discovery to a chance instead of a definite. For instance you could run a check at the start of each player's turn and if they don't have the religion yet, they have the required technology and they are the required civ they have a x% chance of that religion spreading to one of their cities that turn. You could do the same with buildings & wonders.
Hm I don't think this will be fun since the player wants his reward for his achievements.

There are several ways to do what you're asking so I guess all I'd need to know before giving you code examples that would work is how exactly do you want it to work? :)

Ok I think I will write down my designideas in the warhammerforum and provide a link here later. Gimme some time!:)
 
Ok the Religionstuff I'm going to design here:

http://forums.civfanatics.com/showthread.php?t=248041

There are many gaps I know but what really will end up in the game will largely depend on what I will be able to do with python and how it plays will change a lot again. And I'm still a noob in this area...:mischief: so this:

if technology is for restricted religion...
...if the civ that discovered it is the civ that can found it
......if this religion hasn't been founded yet (this is the tricky part)
.........return false (this means go ahead)
......else return true (religion already exists don't found it)
...else return true (wrong civ don't found it)
else return false (not restricted, proceed as normal no checks required)

in a correct syntax of python would be a good start already.
 
Top Bottom