Religions replacing other religions

Exorro

Chieftain
Joined
Jul 13, 2014
Messages
39
I hope that I'm putting this in the right place. It is a question about python so I'm not sure where else this question would go. Also if it looks like while I'm typing this that I don't know what I'm talking about, it's probably because I don't. I don't know much about python and thats probably why this is so confusing to me.

I've seen this system work in a few mods so far. In Dune Wars, on spread the Imperial religion is replaced by other faiths and Qizarate removes all other religions on spread as well. In Rhye's and Fall the Arabs spread their state religion on spawn and on Dawn of Civilization they not only spread their faith on spawn but remove non-state religions. I like it the most in RFC Classical World where Hellenism is almost always replaced by Christianity or Islam on spread (code seems to give it a 90% chance).

I would like to learn how this system works. It seems all the games use totally different code to reach this end of replacing religions and I don't understand how it works.

This is the python for Dune Wars. I think it's the least complicated so it's best I try to understand this first.

Spoiler :
# Religion has spread to a city. If Imperial is there remove it. ALN-leave holy city
# If Qizarate is the one spreading, remove all others. ALN-leave holy cities
def onReligionSpread(self, argsList):
iReligion, iOwner, pCity = argsList
if pCity.isHasReligion(self.iRImp) and iReligion != self.iRImp:
if not pCity.isHolyCityByType(self.iRImp):
pCity.setHasReligion(self.iRImp, false, false, false)
if iReligion == self.iRQiz:
for i in range(gc.getNumReligionInfos()):
if i == self.iRQiz: continue
if pCity.isHolyCityByType(i): continue
if pCity.isHasReligion(i):
pCity.setHasReligion(i, false, false, false)

It seems (false, false, false) is always used when removing a religion. I don't desire the part that has the holy city survive. I don't know how I'd convert this for use for other religions. I know self.iRImp means the Imperial religion but I don't know how the python knows that. Does anyone know how to implement this into the base game?
 
self.iRImp and self.iRQiz are probably defined elsewhere in the file. Just look for them.

The API says:

Code:
VOID setHasReligion (ReligionType iIndex, BOOL bNewValue, BOOL bAnnounce, BOOL bArrows)
void (ReligionID, bool bNewValue, bool bAnnounce, bool bArrows) - religion begins to spread
It tells you why you have False, False, False (1st = setReligion or purge it, 2nd = announce it, 3rd = show it with arrows on screen).
 
Spoiler :
# RELIGIONS

iNumReligions = 7
(iJudaism, iChristianity, iIslam, iHinduism, iBuddhism, iConfucianism, iTaoism) = range(iNumReligions)
iJudaism = self.GetCheckInfo ("RELIGION_JUDAISM")
iChristianity = self.GetCheckInfo ("RELIGION_CHRISTIANITY")
iIslam = self.GetCheckInfo ("RELIGION_ISLAM")
iHinduism = self.GetCheckInfo ("RELIGION_HINDUISM")
iBuddhism = self.GetCheckInfo ("RELIGION_BUDDHISM")
iConfucianism = self.GetCheckInfo ("RELIGION_CONFUCIANISM")
iTaoism = self.GetCheckInfo ("RELIGION_TAOISM")
'religionSpread' : self.onReligionSpread
def onReligionSpread(self, argsList):
iReligion, iOwner, pCity = argsList
if pCity.isHasReligion(iJudaism) and iReligion != iJudaism:
if not pCity.isHolyCityByType(iJudaism):
pCity.setHasReligion(iJudaism, false, false, false)


I'm not sure what I'm missing here. I didn't see onreligionspread being in the BTS python so my guess is thats the last thing in my way. Unless I need to somehow bring in the constants from another file or something or else something like iReligion is unread. Everything else seems to fit. If the city has Judaism and the city has a religion that is not Judaism, and it isn't the holy city for Judaism, Judaism is removed.
 
onreligionspread is in BtS CvEventManager.
 
Then I have no idea what I'm missing here.

Spoiler :
from CvPythonExtensions import *
from PyHelpers import *
from CvEventManager import *

# RELIGIONS

iNumReligions = 7
(iJudaism, iChristianity, iIslam, iHinduism, iBuddhism, iConfucianism, iTaoism) = range(iNumReligions)
iJudaism = gc.getInfoTypeForString('RELIGION_JUDAISM')
iIslam = gc.getInfoTypeForString('RELIGION_ISLAM')
if pCity.isHasReligion(iJudaism) and pCity.isHasReligion(iIslam):
if not pCity.isHolyCityByType(iJudaism):
pCity.setHasReligion(iJudaism, False, False, False)

I've tried another approach, using islam to test with now too. It still doesn't work and I have no idea why. I thought maybe I needed to import but it has done nothing as far as I can see.
 
Back
Top Bottom