Sid Meier's Civilization V

Sid Meier's Civilization V

Religion Snippets [for mod makers]
10 Comments
梁稚子 24 Apr, 2018 @ 10:29pm 
Hey Machiavelli could you make mod which all countries could have a extra belief like Byzantium. Idk where the code describe that part. Thanks.
Gilga ™ |Yonaguni| 31 Jul, 2014 @ 1:17pm 
Hey Machiavelli thanks for the code i will include it into CCTP when i got time, sure with full credit :cybereye:
lshipp 11 Jun, 2014 @ 2:56pm 
I may end up using the code in the link if I finish thinking through the rest of what I need.

But it struck me that the code you are showing here could be used to create a unit(s) special to each religion, and then allow your code shown here to control which of thee units can be trained within an individual city at any given time. So if a city went from Islam to Catholicism that city would no longer be able to train the Islam unit(s) but would be able to train the Catholicism unit(s) instead.

This just happened to synergize with a project I've been thinking about for a while. So I wondered if I could use this to control and keep track of which Religion-based unit(s) can be trained within a city at any given time. But the other code methods you suggest may look to be 'cleaner' so far as units are concerned. Though I do like the idea of extra side-benefits to a city (such as 10% more GPP) based on which religion it has.
Machiavelli  [author] 11 Jun, 2014 @ 11:05am 
If your objective is to make a unit that can only be trained in cities that are majority Islam, that is not difficult and does not require this snippet.

The second part of this post [forums.civfanatics.com] has code for a building that can only be built in majority Buddhism city. There is a CityCanTrain event that you would need to use instead but the code is 95% the same.
lshipp 11 Jun, 2014 @ 10:48am 
So if I'm following all this correctly I could add updates for each of the religion buildings that would allow training of specific units in a city based on which majority religion is in the city. I would use the <Unit_BuildingClassRequireds> table rather than a direct update of the <Buildings> definition in such a case, and I would make the required building-class be the one for each appropriate Religion. If I added a line of units for Islam and a line of units for Buddhism in this way, only cities that have Islam as their majority religion would be able to build the 'Islam' line of units, and only cities that have Buddhism as thier majority religion would be able to build the 'Buddhism' units.
Machiavelli  [author] 7 Jun, 2014 @ 2:39pm 
Sure, I've edited my most recent post in your civFanatics thread to include an example for limiting building the Stupa to majority Buddhism cities.
Ulixes 7 Jun, 2014 @ 2:15pm 
Yes, exactly. But as I said to you on civfanatics, I have almost no lua skills. If I don't ask too much, do you think you could post an example of that (maybe on civfanatics or wherever you want) when you have time?
Machiavelli  [author] 7 Jun, 2014 @ 2:00pm 
If I understand your question correctly, you plan to create a new building (Stupa for example) which will only be buildable in cities that where Buddhism is the majority. If so, that should be easy (and won't require this snippet).

You can use a "CityCanBuild" check for the Stupa that returns false unless the city.GetMajorityReligion is Buddhism.
Ulixes 7 Jun, 2014 @ 1:20pm 
I have a question: Do you know how to make a building who require a specific religion (in lua of course). For example Mosque require Islam, Mandir require Hinduism, Stupa require Buddhism X building require Catholicism and so on... I didn't find anything on civfanatics or on Steam. I thought you were the right person to ask. Thank you in advance for your time.
Ulixes 7 Jun, 2014 @ 1:12pm 
Thank you again Machiavelli, this will be very useful for all modders. I wish there were more like you.