I've been adapting OrionVeteran's Limited Religions modcomp to work with religions founded by the birth of a Great Prophet rather than from a tech. To clarify further, a religion is automatically founded in the city where a prophet is born, not from any action of the prophet itself. I'm also attempting to adapt it so that the maximum number of religions scales 1:1 with the number of starting civs in game (there are 18 religions in my mod).
It's far from complete (for example it currently triggers off the birth of any great person) but the problem I've having at this early stage is that if the player and one or more AI found a religion on the same turn the AI's religions will all be founded correctly but the player's will not. The selection popup comes up but after a choice is made... nothing happens. However if the player gets a prophet on a turn that no AI gets one it all works fine.
Here's the relevant Limited Religion function:
And here's the callback bit from CvScreensInterface.py:
Any idea what's going on and how to fix it? This could be an issue in unaltered Limited Religions, I'm not sure. The situation of religions being founded in the same turn probably doesn't happen very often when triggered by techs. I know OrionVeteran set LR up this way so that it wouldn't break multiplayer, hopefully any necessary change wouldn't break it again.
I should also mention the mod that I'm merging this into uses BUG.
It's far from complete (for example it currently triggers off the birth of any great person) but the problem I've having at this early stage is that if the player and one or more AI found a religion on the same turn the AI's religions will all be founded correctly but the player's will not. The selection popup comes up but after a choice is made... nothing happens. However if the player gets a prophet on a turn that no AI gets one it all works fine.
Code:
Here's the modified function in CvEventManager.py:
def onGreatPersonBorn(self, argsList):
'Unit Promoted'
pUnit, iPlayer, pCity = argsList
player = PyPlayer(iPlayer)
# BEGIN Limited Religions
game = CyGame()
pPlayer = gc.getPlayer(iPlayer)
FoundRel = False
if iPlayer > -1:
# Is the game option selected for Limited Religions?
if LimitedReligions.isOC_LIMITED_RELIGIONS():
# Skip dead players and barbarians
if pPlayer.isAlive() and not pPlayer.isBarbarian():
# Must not already have a Holy City
if not LimitedReligions.OwnsHolyCity(iPlayer):
# Loop through all religions
for iSlot in range(gc.getNumReligionInfos()):
# Must be at least one religion slot available
if not game.isReligionSlotTaken(iSlot):
# The number of religious techs discovered must be greater than total religions founded.
if LimitedReligions.RelTechsGreaterThanReligions:
# PreConditions are met to found a religion.
# If the active player is Human
if iPlayer == gc.getGame().getActivePlayer() and pPlayer.isHuman:
# If Autoplay is running, Let the game pick the religion.
if( game.getAIAutoPlay() > 0 ):
FoundRel = True
break
else:
#Display the popup to pick a religion
#CyInterface().addImmediateMessage("Pick Religion", "")
LimitedReligions.doPickReligionPopup(iPlayer, iSlot)
break
else:
# Not Human, So let the game pick the religion.
#CyInterface().addImmediateMessage("Found a Religion", "")
FoundRel = True
break
if FoundRel:
# Get Civ's favorite religion or random choice if favorite religion is not available
iNewReligion = LimitedReligions.AI_chooseReligion(iPlayer)
if iNewReligion != -1:
# Found the religion
#CyInterface().addImmediateMessage("Found Favorite Religion", "")
pPlayer.foundReligion(iNewReligion, iSlot, True)
# END Limited Religions
if pUnit.isNone() or pCity.isNone():
return
if (not self.__LOG_GREATPERSON):
return
CvUtil.pyPrint('A %s was born for %s in %s' %(pUnit.getName(), player.getCivilizationName(), pCity.getName()))
Here's the relevant Limited Religion function:
Code:
def doPickReligionPopup(iPlayer, religionSlot):
# Limited Religions
pPlayer = gc.getPlayer(iPlayer)
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
popupInfo.setData1(iPlayer)
popupInfo.setData2(religionSlot)
popupInfo.setOnClickedPythonCallback("foundReligionCallback")
popupInfo.setText(CyTranslator().getText(("TXT_KEY_FOUNDED_RELIGION"),()))
for i in range(gc.getNumReligionInfos()):
if not CyGame().isReligionFounded(i):
popupInfo.addPythonButton(gc.getReligionInfo(i).getDescription(), gc.getReligionInfo(i).getButton())
popupInfo.addPopup(iPlayer)
And here's the callback bit from CvScreensInterface.py:
Code:
# BEGIN Limited Religions
def foundReligionCallback(argsList):
iButtonId = argsList[0]
iData1 = argsList[1]
iData2 = argsList[2]
iData3 = argsList[3]
iData4 = argsList[4]
szText = argsList[5]
bOption1 = argsList[6]
bOption2 = argsList[7]
pPlayer = gc.getPlayer(iData1)
CyInterface().addImmediateMessage("Callback", "")
count = -1
for i in range(gc.getNumReligionInfos()):
if not CyGame().isReligionFounded(i):
count += 1
if count == iButtonId:
pPlayer.foundReligion(i, iData2, True)
break
# END Limited Religions
Any idea what's going on and how to fix it? This could be an issue in unaltered Limited Religions, I'm not sure. The situation of religions being founded in the same turn probably doesn't happen very often when triggered by techs. I know OrionVeteran set LR up this way so that it wouldn't break multiplayer, hopefully any necessary change wouldn't break it again.
I should also mention the mod that I'm merging this into uses BUG.