Making Religion Founded by Building not Technology

Sanotra

Wannabe Modder
Joined
May 16, 2007
Messages
668
Location
Wa - USA
As the title says. In the Mod I'm working on, I'd like to make Religion founded by a building, just like corporations, and not by technology. I think this requires python coding right?

The order I'm looking for is:
1. Research Technology which enables civilization's unique building
2. Construct unique building.
3. Upon completion of unique building, religion is founded in that city.


It seems like it would be fairly simple to code, seeing as how corporations act in basically the same way right? The problem is, I only know how to work xml. I would be extremely grateful if someone endeavored to write this code for me! Thanks!
 
In Building infos xml, the code is:

<FoundsCorporation>NONE</FoundsCorporation>
So whatever corporation is entered here is founded when the building is constructed.

In the religion infos xml, the code is:
<TechPrereq>TECH_MONOTHEISM</TechPrereq>
So in this instance, when Monotheism is researched, Judaism is founded.
---
I'd like to see this in the xml for buildings:
<FoundsCorporation>NONE</FoundsCorporation>
<FoundsReligion>RELIGION_JUDAISM</FoundsReligion>

and this in the religion infos:
<TechPrereq>NONE</TechPrereq>
 
The way you propose would requite editing the DLL rather than Python.

I don't know if having no tech requirement would screw with things. If it does, the easiest way to go about this would probably be to make a wonder that, when built, gives you a dummy tech that founds the religion. Then the holy city could be set to whatever city built the wonder. Otherwise there's a foundReligion command that could probably be used.
 
Hmm... Interesting idea. Probably doable as is (vanilla bts) right?

I'm assuming buildings grant technology already, i'll check. Can a dummy tech be hidden from the tech tree?
 
Is there a <freetechnology/> feature in the xml for buildings? I can't find it.

There is no such tag.

Hmm... Interesting idea. Probably doable as is (vanilla bts) right?

I'm assuming buildings grant technology already, i'll check. Can a dummy tech be hidden from the tech tree?

It would require python, in the EventManager, onBuildingBuilt. Hiding the dummy tech would likely require some work with the way the tech tree is drawn.
 
Hiding the dummy tech isn't a big concern for me. I can put all of the religion techs (named after the religions, Hinduism, Judaism, Christianity, etc.) at the end of the tech tree, disconnected to the actual tree. It can be made to look decent in the tech tree I'm sure.

About editing the python in the "EventManager, onBuildingBuilt". I don't even know what that means. I've never edited anything other than art and xml, but if you were nice enough to get me started at looking at whatever file this is and what program I would need, I wouldn't mind trying to change it. I appreciate your help thus far. :)
 
Thank you lfgr, I found it!

For the community:
Find the building tag <ReligionChanges/> and modify it like this...
Spoiler :
<ReligionChanges>
<ReligionChange>
<ReligionType>RELIGION_CHRISTIANITY</ReligionType>
<iReligionChange>1</iReligionChange>
</ReligionChange>
</ReligionChanges>

I don't fully understand it, but this causes the building to spread the religion inputed. I attached this tag to the stable, built the stable, and building the stable founded Christianity. I think that researching Theology will found Christianity if no stables have been built yet. So I need to find a way to keep the required technology from founding the religion and make religion founding exclusive to just the building, not the building or the tech. However, this is definitely a start!
 
There are a couple of mods that do that sort of thing. I am not sure but the Rapture mod may have been one. The Total War mod requires you to collect a number of "concepts" (I can't remember the correct term:() and use them to build up a religion. The more "concepts" you add to the religion over time the more you can do with it.
 
Still not sure how to prevent the researching of the tech from founding the religion. A non ideal solution is available. Place the prerequisite tech at the end of the tech tree, dangling in mid air with no ability to research it. Then have another tech allow the building which is required to found the religion. Gods of Old didn't do it this way though. Does anyone know how to do this?
 
In Gods of Old, it's all done in Python.

As far as I know, your xml solution is the only xml-only solution...

Edit: apparently, it's not difficult to change it in Python. In Gods of Old - CvGameUtils.py, two functions (doHolyCity & doHolyCityTech) are set to return True instead of False. It's a bit counterintuitive but apparently it prevents the dll to react on the setting of the Holy City randomly in the player's cities and on the Tech mechanism founding another religion if the Tech one is already founded.

In addition, in CvEventManager, onBuildingBuilt sets the city that builds the Shrine as the Holy City of its religion.
 
Thanks for your informative answer isenchine. :) With my xml only solution, the building spreads religion. I think as the first building to spread religion, the building's city thus becomes the holy city. I only tested it a few times, but never for that specific purpose. I'll have to double check that. Obviously, Gods of Old has the ideal solution. I've never messed with python files before. isenchine, should I just copy and paste their mods CvGameUtils.py file into my mod? Will that work?
 
Obviously, Gods of Old has the ideal solution. I've never messed with python files before. isenchine, should I just copy and paste their mods CvGameUtils.py file into my mod? Will that work?

Boldly, I will say: yes!!! :D

Now, more seriously, there are other stuff in it that might a) not work or b) not be useful to you.

I don't know if you wanna copy all Gods of Old stuff (like Inquisitors, or the fact that when you have founded a religion, you stick to it and cannot found another one, or even the catastrophe effects plagued upon the heathen ones!).

In between, I think that if you have founded a religion with Stables, it did not automatically became a Holy City. I don't think that they coded that stuff for nothing.

If you are a serious 'wannabemodder', then dive into Python! For such things, it's not more difficult than XML merging.

In your CvGameUtils, comment out the initial BtS code and replace it like that:

Code:
	def doHolyCity(self):
		# return False
		return True

Edit: # return False is "commenting out": by starting the line with # (in Python), you make it a comment, a line that is not part of the code.

Apply the same method for the next function and test it. Easy to revert back to original code.

For CvEventManager.py, copy the function onBuildingBuilt and change the buildings appropriately, that's it!

Good luck and tell us about the results!
 
I'm really looking forward to trying this out. I havent been able to do very much the past couple of days because I've been really busy, but I should have time this weekend. I'll keep you guys posted on the progress. Thanks isenchine! :D
 
Top Bottom