View Full Version : python randomization - what's wrong here?


Saarlaender
Jan 25, 2006, 02:18 PM
Hi everyone,

'm working on a religion mod. Already incorporated Protestantism and ancient polytheism, all works fine. Now I was trying to script it so that when a religion is spread to a city where there is already a religion, there is a chance that the people will not be added, but convert - so that the "original" religion disappears on cpnversion. Well, it doesn't seem to work.
2 possibilities:
1) on religion spread doesn't cover missionaries at all?
2) randon function horribly wrong?
3)= I can#t just put it there and it needs to be somewhere completely different?
-2 and 3 both because I don't really know what I'm doing, mainly I'm just playing with the Inquisitor mod's and Kael's scripts without actually knowing the first thing about python....

so here it goes, I hope some gracious soul will spot my mistake and hit me on the head like they shoud for what is certainly a mountain of blatant violations :)

## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005

from CvPythonExtensions import *
import CvUtil
import CvEventManager
import sys
import CustomFunctions
import CvScreensInterface
import CvDebugTools
import CvWBPopups
import PyHelpers
import Popup as PyPopup
import CvCameraControls
import CvTopCivs
import CvWorldBuilderScreen
import CvAdvisorUtils
import CvTechChooser

gc = CyGlobalContext()
cf = CustomFunctions.CustomFunctions()

# globals
################################################## #
class CvCustomEventManager(CvEventManager.CvEventManager ):
def __init__(self):
# initialize base class
self.parent = CvEventManager.CvEventManager
self.parent.__init__(self)

def onBuildingBuilt(self, argsList):
'Building Completed'
pCity, iBuildingType = argsList
game = CyGame()
if ((not self.bMultiPlayer) and (pCity.getOwner() == CyGame().getActivePlayer()) and isWorldWonderClass(gc.getBuildingInfo(iBuildingTyp e).getBuildingClassType())):
# If this is a wonder...
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTT ONPOPUP_PYTHON_SCREEN)
popupInfo.setData1(iBuildingType)
popupInfo.setData2(pCity.getID())
popupInfo.setData3(0)
popupInfo.setText(u"showWonderMovie")
popupInfo.addPopup(pCity.getOwner())

Inquisition = gc.getInfoTypeForString('BUILDING_INQUISITION')
if iBuildingType == Inquisition:
cf.Inquisit(pCity)
pCity.setHasRealBuilding(Inquisition, False)

def onReligionSpread(self, argsList):
'Religion Has Spread to a City'
iReligion, iOwner, pSpreadCity, iCatholic, iProtestant, iJewish, iHindu, iPolytheism, iIslam = argsList
iCatholic = gc.getInfoTypeForString('RELIGION_CHRISTIANITY')
iProtestant = gc.getInfoTypeForString('RELIGION_PROTESTANTISM')
iJewish = gc.getInfoTypeForString('RELIGION_JUDAISM')
iHindu = gc.getInfoTypeForString('RELIGION_HINDUISM')
iPolytheism = gc.getInfoTypeForString('RELIGION_POLYTHEISM')
iIslam = gc.getInfoTypeForString('RELIGION_ISLAM')
rand = CyGame().getSorenRandNum(100, "Bob")

player = PyPlayer(iOwner)
pPlayer = gc.getPlayer(iOwner)
if iReligion == iCatholic:
if (rand <= 40):
if (pSpreadCity.isHasReligion(iProtestant) and pSpreadCity.isHolyCityByType(iCatholic) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Katholiken sind zum Protestantismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iCatholic:
if (rand <= 20):
if (pSpreadCity.isHasReligion(iIslam) and pSpreadCity.isHolyCityByType(iCatholic) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Katholiken haben den Propheten Mohammed erkannt!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iCatholic:
if (rand <= 15):
if (pSpreadCity.isHasReligion(iHinduism) and pSpreadCity.isHolyCityByType(iCatholic) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Katholiken sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iCatholic:
if (rand <= 15):
if (pSpreadCity.isHasReligion(iJewish) and pSpreadCity.isHolyCityByType(iCatholic) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Katholiken sind zum Judentum konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if iReligion == iProtestant:
if (rand <= 20):
if (pSpreadCity.isHasReligion(iIslam) and pSpreadCity.isHolyCityByType(iProtestant) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Protestanten sind zum Islam konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pSpreadCity.getX(),p SpreadCity.getY(),True,True)

if iReligion == iProtestant:
if (rand <= 30):
if (pSpreadCity.isHasReligion(iHinduism) and pSpreadCity.isHolyCityByType(iProtestant) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Protestanten sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pSpreadCity.getX(),p SpreadCity.getY(),True,True)

if iReligion == iProtestant:
if (rand <= 30):
if (pSpreadCity.isHasReligion(iCatholic) and pSpreadCity.isHolyCityByType(iProtestant) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Protestanten sind in den Schoß der Kirche zurückgekehrt!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pSpreadCity.getX(),p SpreadCity.getY(),True,True)

if iReligion == iProtestant:
if (rand <= 30):
if (pSpreadCity.isHasReligion(iJewish) and pSpreadCity.isHolyCityByType(iProtestant) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Protestanten sind zum Judentum konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pSpreadCity.getX(),p SpreadCity.getY(),True,True)


if iReligion == iPolytheism:
if (rand <= 80):
if (pSpreadCity.isHasReligion(iIslam) and pSpreadCity.isHolyCityByType(iPolytheism) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Heiden sind zum Islam konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iPolytheism:
if (rand <= 80):
if (pSpreadCity.isHasReligion(iCatholic) and pSpreadCity.isHolyCityByType(iPolytheism) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Heiden sind zur Heiligen Kirche konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iPolytheism:
if (rand <= 80):
if (pSpreadCity.isHasReligion(iProtestantism) and pSpreadCity.isHolyCityByType(iPolytheism) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Heiden haben Jesus als ihren persönlichen Erlöser erkannt!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iPolytheism:
if (rand <= 40):
if (pSpreadCity.isHasReligion(iHinduism) and pSpreadCity.isHolyCityByType(iPolytheism) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Heiden sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iPolytheism:
if (rand <= 60):
if (pSpreadCity.isHasReligion(iJewish) and pSpreadCity.isHolyCityByType(iPolytheism) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Heiden sind zum Judentum konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if iReligion == iIslam:
if (rand <= 25):
if (pSpreadCity.isHasReligion(iCatholic) and pSpreadCity.isHolyCityByType(iIslam) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime sind zur Heiligen Kirche konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iIslam:
if (rand <= 25):
if (pSpreadCity.isHasReligion(iProtestant) and pSpreadCity.isHolyCityByType(iIslam) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime sind zum Protestantismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iIslam:
if (rand <= 15):
if (pSpreadCity.isHasReligion(iHinduism) and pSpreadCity.isHolyCityByType(iIslam) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iIslam:
if (rand <= 10):
if (pSpreadCity.isHasReligion(iPolytheism) and pSpreadCity.isHolyCityByType(iIslam) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime haben die Opfer für Zeus wiederaufgenommen!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iIslam:
if (rand <= 10):
if (pSpreadCity.isHasReligion(iJewish) and pSpreadCity.isHolyCityByType(iIslam) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime sind zum Judentum konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iJewish:
if (rand <= 10):
if (pSpreadCity.isHasReligion(iIslam) and pSpreadCity.isHolyCityByType(iJewish) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Juden sind zum Islam konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iJewish:
if (rand <= 30):
if (pSpreadCity.isHasReligion(iCatholic) and pSpreadCity.isHolyCityByType(iJewish) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Juden sind zum Katholizismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iJewish:
if (rand <= 30):
if (pSpreadCity.isHasReligion(iProtestant) and pSpreadCity.isHolyCityByType(iJewish) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Juden sind zum Protestantismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iJewish:
if (rand <= 10):
if (pSpreadCity.isHasReligion(iHinduism) and pSpreadCity.isHolyCityByType(iJewish) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Juden sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

The Great Apple
Jan 25, 2006, 02:45 PM
Firstly, if you don't already have them on, switch on Civ 4's debugging tools. In the Civ 4 main .ini file set these variables to the following values:
HidePythonExceptions = 0
ShowPythonDebugMsgs = 1
LoggingEnabled = 1
MessageLog = 1
This should make the game throw up an error if there is something wrong with the way the code is formed. Very useful!

Secondly, I can only see one thing that is a bit dodgy at first glance.iReligion, iOwner, pSpreadCity, iCatholic, iProtestant, iJewish, iHindu, iPolytheism, iIslam = argsListshould read:iReligion, iOwner, pSpreadCity = argsListI'm not sure what adding those extra things would do, but it isn't neccessary, and it may be where your code is tripping up. In the events manager I would always use the defaults for argsList - I have never had the need to do anything else.

Thirdly, I love the way that I still see "CyGame().getSorenRandNum(100, "Bob")" coming up time and time again. I'm pretty certain that "Bob" comes from some example code I posted about a month ago...


EDIT: It would also seem your code is doing the wrong thing: if iReligion == iCatholic:
if (rand <= 40):
if (pSpreadCity.isHasReligion(iProtestant) and pSpreadCity.isHolyCityByType(iCatholic) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Katholiken sind zum Protestantismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)translates into English as:

If the religion to be spread is Catholic
If the random number is less than or equal to 40
If the city has protestantism in it, and isn't the catholic holy city
Set it so that the city does is not Catholic (thereby counteracting the spread)
Make a message

From your first post it would seem that you don't want to set it so the city isn't Catholic, but so the city isn't Protestant, yes?

Saarlaender
Jan 25, 2006, 02:49 PM
ah, that's yours.. yep, I copied it from someone that was not you. But thanks. Actually, I added the extra argslist later after I saw this not working.
So - the rand here should work? I basically threw my code right after the inquicition mod's code without doing anything else (since I have no clue.) But alas, it doen't work. Does onSpreadReligion even cover religions spread by missionary?

Kidinnu
Jan 25, 2006, 02:49 PM
Yeah, onReligionSpread's beginning is definitely odd.

Python lets you pass around tuples, and Civ makes extensive use of that. So all the event handlers expect tuples, and unpack their arguments from them first thing.

onReligionSpread is being passed something like [0, 0, <rome>], when Judaism spreads into player 0's city rome. You're extracting the first three things, but then that long line tells the computer you expected half a dozen OTHER parameters which aren't there. Nothing good will come of that.

Kael
Jan 25, 2006, 02:53 PM
ah, that's yours.. yep, I copied it from someone that was not you. But thanks. Actually, I added the extra argslist later after I saw this not working.
So - the rand here should work? I basically threw my code right after the inquicition mod's code without doing anything else (since I have no clue.) But alas, it doen't work. Does onSpreadReligion even cover religions spread by missionary?

It definitly covers missionaries. It also kicks when you take over a city (even when your not adding a religion) and when you raze a city (not sure why, but it does).

And all of my SorenRand's have "Bob" in them because I copied the origional code line from TGA.

And the code all looks good, exceot the arglist line, as TGA pointed out.

Saarlaender
Jan 25, 2006, 02:57 PM
so there's the off chance, then, that nothing happened because the rands always came out leaving the religion there?

Kael
Jan 25, 2006, 03:00 PM
so there's the off chance, then, that nothing happened because the rands always came out leaving the religion there?

Doubtful, did you change the arglist line? This is my religionspread:


def onReligionSpread(self, argsList):
'Religion Has Spread to a City'
iReligion, iOwner, pSpreadCity = argsList
iOrder = gc.getInfoTypeForString('RELIGION_THE_ORDER')
iVeil = gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL')
player = PyPlayer(iOwner)
pPlayer = gc.getPlayer(iOwner)
if iReligion == iVeil:
if (pSpreadCity.isHasReligion(iOrder) and pSpreadCity.isHolyCityByType(iVeil) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(iOwner,True,25,'The Ashen Veil was removed from a city.','AS2D_ORDER_DINK',1,'Art/Interface/Buttons/Religions/Order.dds',ColorTypes(8),pSpreadCity.getX(),pSprea dCity.getY(),True,True)

if iReligion == iOrder:
if (pSpreadCity.isHasReligion(iVeil) and pSpreadCity.isHolyCityByType(iOrder) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(iOwner,True,25,'The Order was removed from a city.','AS2D_ASHEN_DINK',1,'Art/Interface/Buttons/Religions/Ashen.dds',ColorTypes(8),pSpreadCity.getX(),pSprea dCity.getY(),True,True)
if (pPlayer.getStateReligion() == iOrder and pSpreadCity.isHasReligion(iVeil) == False and pSpreadCity.getOccupationTimer() <= 0):
iRnd = CyGame().getSorenRandNum(100, "Bob")
if (iRnd <= 75):
eTeam = gc.getTeam(pPlayer.getTeam())
if eTeam.isHasTech(gc.getInfoTypeForString('TECH_FANA TICISM')):
iUnit = gc.getInfoTypeForString('UNIT_CRUSADER')
CyInterface().addMessage(iOwner,True,25,'A Crusader has joined your cause.','AS2D_UNIT_BUILD_UNIT',1,'Art/Interface/Buttons/Units/Crusader.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)
else:
iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_THE_ORDER')
CyInterface().addMessage(iOwner,True,25,'A Disciple has joined your cause.','AS2D_UNIT_BUILD_UNIT',1,'Art/Interface/Buttons/Units/Discipleorder.dds',ColorTypes(8),pSpreadCity.getX( ),pSpreadCity.getY(),True,True)
newUnit = pPlayer.initUnit(iUnit, pSpreadCity.getX(), pSpreadCity.getY(), UnitAITypes.NO_UNITAI)

if (not self.__LOG_RELIGIONSPREAD):
return
CvUtil.pyPrint('%s has spread to Player %d Civilization %s city of %s'
%(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pSpreadCity.getName()))

Saarlaender
Jan 25, 2006, 03:03 PM
yes, changed the arglist. But that wasn't the matter.

I'm sure you recognized that my code IS yours - you gave me this code last week on here, I merely adapted it to my religions.

-response to edit: yes, it shouldn't counter the spread, it should remove what's there. I'll go over that again. Thank you!

Kael
Jan 25, 2006, 03:03 PM
If that function is in another place that the CvEventManager.py then it is possible that its just not reading the changed function. I had that problem when I tried to use a custom CvEventManager.py and I ended up just trashing it is changing the real file.

Saarlaender
Jan 25, 2006, 03:08 PM
it's in a custom event manager - but with the inquisitor code which works.

Inquisitor mod which originally "made" the file, i just added to it - could it be that it doen't connect to anything? does it have to be called somewhere else? That could be the problem if it had to...

Kael
Jan 25, 2006, 03:10 PM
it's in a custom event manager - but with the inquisitor code which works.

Inquisitor mod which originally "made" the file, i just added to it - could it be that it doen't connect to anything? does it have to be called somewhere else? That could be the problem if it had to...

Try putting it in the real CvEventManager.py and see if it works.

Saarlaender
Jan 25, 2006, 03:11 PM
just drop it in? in which class block?

Kael
Jan 25, 2006, 03:12 PM
just drop it in? in which class block?

In place of the existing onReligionSpread

Saarlaender
Jan 25, 2006, 03:36 PM
no. not doing it. founded three religions, sent missionaries all around - got more and more in the same city, none got replaced.
I placed the entire onReligionSpread code in the events file (after i copied it into the mod folder, so i now have a cvEventManager in my Mods's python folder). I kept the original message tag in and overwrote the rest, like this:


def onReligionSpread(self, argsList):
'Religion Has Spread to a City'
iReligion, iOwner, pSpreadCity = argsList
iCatholic = gc.getInfoTypeForString('RELIGION_CHRISTIANITY')
iProtestant = gc.getInfoTypeForString('RELIGION_PROTESTANTISM')
iJewish = gc.getInfoTypeForString('RELIGION_JUDAISM')
iHindu = gc.getInfoTypeForString('RELIGION_HINDUISM')
iPolytheism = gc.getInfoTypeForString('RELIGION_POLYTHEISM')
iIslam = gc.getInfoTypeForString('RELIGION_ISLAM')
rand = CyGame().getSorenRandNum(100, "Bob")

player = PyPlayer(iOwner)
pPlayer = gc.getPlayer(iOwner)
if iReligion == iCatholic:
if (rand <= 40):
if (pSpreadCity.isHasReligion(iProtestant) and pSpreadCity.isHolyCityByType(iProtestant) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Katholiken sind zum Protestantismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iCatholic:
if (rand <= 20):
if (pSpreadCity.isHasReligion(iIslam) and pSpreadCity.isHolyCityByType(iIslam) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Katholiken haben den Propheten Mohammed erkannt!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iCatholic:
if (rand <= 15):
if (pSpreadCity.isHasReligion(iHinduism) and pSpreadCity.isHolyCityByType(iHinduism) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Katholiken sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iCatholic:
if (rand <= 15):
if (pSpreadCity.isHasReligion(iJewish) and pSpreadCity.isHolyCityByType(iJewish) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Katholiken sind zum Judentum konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if iReligion == iProtestant:
if (rand <= 20):
if (pSpreadCity.isHasReligion(iIslam) and pSpreadCity.isHolyCityByType(iIslam) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Protestanten sind zum Islam konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pSpreadCity.getX(),p SpreadCity.getY(),True,True)

if iReligion == iProtestant:
if (rand <= 30):
if (pSpreadCity.isHasReligion(iHinduism) and pSpreadCity.isHolyCityByType(iHinduism) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Protestanten sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pSpreadCity.getX(),p SpreadCity.getY(),True,True)

if iReligion == iProtestant:
if (rand <= 30):
if (pSpreadCity.isHasReligion(iCatholic) and pSpreadCity.isHolyCityByType(iCatholic) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Protestanten sind in den Schoß der Kirche zurückgekehrt!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pSpreadCity.getX(),p SpreadCity.getY(),True,True)

if iReligion == iProtestant:
if (rand <= 30):
if (pSpreadCity.isHasReligion(iJewish) and pSpreadCity.isHolyCityByType(iJewish) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Protestanten sind zum Judentum konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pSpreadCity.getX(),p SpreadCity.getY(),True,True)


if iReligion == iPolytheism:
if (rand <= 80):
if (pSpreadCity.isHasReligion(iIslam) and pSpreadCity.isHolyCityByType(iIslam) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Heiden sind zum Islam konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iPolytheism:
if (rand <= 80):
if (pSpreadCity.isHasReligion(iCatholic) and pSpreadCity.isHolyCityByType(iCatholic) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Heiden sind zur Heiligen Kirche konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iPolytheism:
if (rand <= 80):
if (pSpreadCity.isHasReligion(iProtestantism) and pSpreadCity.isHolyCityByType(iProtestantism) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Heiden haben Jesus als ihren persönlichen Erlöser erkannt!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iPolytheism:
if (rand <= 40):
if (pSpreadCity.isHasReligion(iHinduism) and pSpreadCity.isHolyCityByType(iHinduism) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Heiden sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iPolytheism:
if (rand <= 60):
if (pSpreadCity.isHasReligion(iJewish) and pSpreadCity.isHolyCityByType(iJewish) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Heiden sind zum Judentum konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if iReligion == iIslam:
if (rand <= 25):
if (pSpreadCity.isHasReligion(iCatholic) and pSpreadCity.isHolyCityByType(iCatholic) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime sind zur Heiligen Kirche konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iIslam:
if (rand <= 25):
if (pSpreadCity.isHasReligion(iProtestant) and pSpreadCity.isHolyCityByType(iProtestant) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime sind zum Protestantismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iIslam:
if (rand <= 15):
if (pSpreadCity.isHasReligion(iHinduism) and pSpreadCity.isHolyCityByType(iHinduism) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iIslam:
if (rand <= 10):
if (pSpreadCity.isHasReligion(iPolytheism) and pSpreadCity.isHolyCityByType(iPolytheism) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime haben die Opfer für Zeus wiederaufgenommen!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iIslam:
if (rand <= 10):
if (pSpreadCity.isHasReligion(iJewish) and pSpreadCity.isHolyCityByType(iJewish) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime sind zum Judentum konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iJewish:
if (rand <= 10):
if (pSpreadCity.isHasReligion(iIslam) and pSpreadCity.isHolyCityByType(iIslam) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Juden sind zum Islam konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iJewish:
if (rand <= 30):
if (pSpreadCity.isHasReligion(iCatholic) and pSpreadCity.isHolyCityByType(iCatholic) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Juden sind zum Katholizismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iJewish:
if (rand <= 30):
if (pSpreadCity.isHasReligion(iProtestant) and pSpreadCity.isHolyCityByType(iProtestant) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Juden sind zum Protestantismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iJewish:
if (rand <= 10):
if (pSpreadCity.isHasReligion(iHinduism) and pSpreadCity.isHolyCityByType(iHinduism) == False):
pSpreadCity.setHasReligion(iReligion, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Juden sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

CvUtil.pyPrint('%s has spread to Player %d Civilization %s city of %s'
%(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pSpreadCity.getName()))


an observation:
shouldn't the line in each if clause that now reads:
pSpreadCity.setHasReligion(iReligion, False, False, False)

have "iReligion" replaced by "i(whatever is found there)", as is queried in the first line? doesn't this code remove the spreading religion, not ther one found, as iReligion is the one that spreads?
-still, it has no effect; it should be the spread that doesn't work iof this were so, but that also blows, I just pile up more religions in the city as this compiles now..

Kael
Jan 25, 2006, 03:42 PM
I just noticed that the religion you are removing from the city is iReligion (ie: the one that is spreading). From your first post it sounded like you want it to remove the religion that already existed. If you wanted to do that you should have it read:

if iReligion == iCatholic:
if (rand <= 40):
if (pSpreadCity.isHasReligion(iProtestant) and pSpreadCity.isHolyCityByType(iProtestant) == False):
pSpreadCity.setHasReligion(iProtestant, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Katholiken sind zum Protestantismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

Saarlaender
Jan 25, 2006, 03:47 PM
yep, noticed and fixed. Still, in my trial run, it should have ot spread the religion, then (or spread and removed it, but it also didn't do that, either. It just spread normall,y like it always does, completely ignoring any code i wrote.. could it be the cache?

Kael
Jan 25, 2006, 03:53 PM
yep, noticed and fixed. Still, in my trial run, it should have ot spread the religion, then (or spread and removed it, but it also didn't do that, either. It just spread normall,y like it always does, completely ignoring any code i wrote.. could it be the cache?

Yeah, it sounds like it's not kicking. Definitly try clearing cache.

The Great Apple
Jan 26, 2006, 08:14 AM
Have you got debugging enabled, as I suggested?

If so, you could add a few print lines which will tell you the states of the variables, and to confirm that the event is firing.

Something like:
print("XXX -- onReligionSpread triggered") immediatly after the the trigger, and then maybe something to print the random number to make sure that that is working properly. The logs should be being made in the logs directory.

Saarlaender
Jan 26, 2006, 01:20 PM
strange. it is kicking, but not working. (another strange thing: even after clearing the cache, it keeps screaming about undefined taoist units that I took out in BuildingINfos - which no loonger contains this tag.)
anyhow:
Debugging got me some errors i now fixed, but should these really halt the whole routine?

When Polytheism was discovered by another civ, I got no notification, instead, I got an exception call saying:
cvEventInterface (not modded): error in onEvent.
cvEventManager (modded): error in handleEvent (not modded).
cvEventManager : error in religionSpread (modded)
global name: iProtestantism is not defined.

- that's on me. it is iProtestant in my script and I called it ism later.

Then, when Victoria converted to chistianity (which I had founded), same error, same tags, just this time: global name iHinduism is not defined.
- again on me: I defined iHindu. not ism.

but still; the religions in question were not the ones involved in the spread process. does this make the whole routine not work? the ones I needed in my trial (iJewish and iCatholic) were right. Still, no loss of religion at conversion. Just kept piling up.

Saarlaender
Jan 26, 2006, 01:50 PM
ok. I'm an idiot. How do I print the random number?
print (rand) - nope, error call.
CvUtil.pyPrint(rand) - nope.
CvUtil.pyPrint('rand is %')
%(rand) - not either.
stumbling in the dark...

Kael
Jan 26, 2006, 01:53 PM
This is going to sound dumb, but try using iRnd instead of rand as the variable name. I have had problems where I was trying to use a variable name and it wouldn't work because that name was already reserved for use for something internal.

Kidinnu
Jan 26, 2006, 02:16 PM
(another strange thing: even after clearing the cache, it keeps screaming about undefined taoist units that I took out in BuildingINfos - which no loonger contains this tag.)

If it's for Taoist buildings, possibly the entries you missed are in BuildingClassInfos?

but still; the religions in question were not the ones involved in the spread process. does this make the whole routine not work? the ones I needed in my trial (iJewish and iCatholic) were right.

If the script ran across Hinduism or Protestantism before it got to Jewish and Catholic, it would have stopped.

Nice trick for debugging this stuff - run in windowed mode. You can have another couple of windows in the background looking at the error log and debug log. If you find a bug, change the Python file and save it - when you shift focus back to Civ's window, it'll detect the change and reload python.

Saarlaender
Jan 26, 2006, 02:23 PM
I fixed the isms, and added this line for verification(might be horridly wrong) at the end:

CvUtil.pyPrint('% value'
%(iRnd))


no religion loss, no number printed. Ignores it.

The Great Apple
Jan 26, 2006, 02:41 PM
This is going to sound dumb, but try using iRnd instead of rand as the variable name. I have had problems where I was trying to use a variable name and it wouldn't work because that name was already reserved for use for something internal.This is a very good point. I would suggest coding in a program that regonises internal commands and highlights them in a different colour - avoids such trip-ups. I think Kael might be right with the dyagnosis of the problem.

As for printing the random number, the correct syntax should be:CvUtil.pyPrint("%d value"%(iRnd))Note the %d. It would seem that %d should be used when the thing to be printed is a numeral (maybe it stands for decimal? I don't know), and %s should be used if it's a string.print iRndshould work as well.

Just out of interest, does anybody know what CvUtil.pyPrint does that print doesn't do?

Saarlaender
Jan 26, 2006, 02:44 PM
changed all rand tags to iRnd, didn't seem to change anything. I'll try the new print code.

Kael
Jan 26, 2006, 03:07 PM
changed all rand tags to iRnd, didn't seem to change anything. I'll try the new print code.

Can you zip up and attached your CIV4ReligionInfo.xml file so I can check it out.

Saarlaender
Jan 26, 2006, 03:17 PM
sure, here it goes..

Kael
Jan 26, 2006, 03:41 PM
Try this one instead.

Saarlaender
Jan 26, 2006, 04:12 PM
Not sure what you changed (apart from cleaning up my mess), but I replaced it. No noticeable effect, though.
it still doesn't print the iRnd numbers, it still doesn't delete religions....

(But a weird thing I noticed: A city that had a religion became jewish on top of it through normal spread (from a different civ). Thought that wasn't posible?)

Kael
Jan 26, 2006, 04:16 PM
Not sure what you changed (apart from cleaning up my mess), but I replaced it. No noticeable effect, though.
it still doesn't print the iRnd numbers, it still doesn't delete religions....

(But a weird thing I noticed: A city that had a religion became jewish on top of it through normal spread (from a different civ). Thought that wasn't posible?)

I fixed a bunch of white space errors. Extra returns, incorrect tabbings, things like that. A city can gain all of the religions through normal spread. Having one religion doens't stop it form getting new religions.

Saarlaender
Jan 26, 2006, 04:20 PM
if thats a problem, then i have tons over tons of those in all the many files i modded. still, all of that seems to work out so far. it's just this onReligionSpread thing...

Saarlaender
Jan 26, 2006, 04:27 PM
Oneother idea, though probably nothing:

The usual civ text gets printed when a religion comes to a city. so some function is called, and the error messages proved it was actually my onReligionSpread routine. one little thing: I have the German version and the text is always in German. Yet, the print command in my EventManager has this command in English:

CvUtil.pyPrint('%s has spread to Player %d Civilization %s city of %s'
%(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pSpreadCity.getName()))


how can this be? does it get overridden somewhere else? where is that somewhere else?

Kidinnu
Jan 26, 2006, 08:08 PM
I have the German version and the text is always in German. Yet, the print command in my EventManager has this command in English:

how can this be? does it get overridden somewhere else? where is that somewhere else?

Those print commands are debugging information for the english-speaking programmers. They never appear as part of the game, just in Logs/PythonDbg.log

A city can gain all of the religions through normal spread. Having one religion doens't stop it form getting new religions.

Are you sure? I've heard otherwise, although it could be an urban legend, butI don't think I've ever seen it...

I suppose the quick way to check would be to delete the missionary units, run a game, and see if any non-holy-city ever gets multiple religions...

Saarlaender
Jan 27, 2006, 02:54 AM
could of course be that the AI sent a missionary, though I have yet to see that i n any game.
In any case, the print prints text in the LOG?? .. then how do I print on screen in the game?

And I checked the logs, no sign of my random number being printed there either (not that I really got everything there, but there's no number that could be the iRnd)

Saarlaender
Jan 27, 2006, 05:05 AM
too many if' in the original version, I guess! I had five equal if calls after one another. that must have killed it. cleaned it up, this seems to work (with one exception)



def onReligionSpread(self, argsList):
'Religion Has Spread to a City'
iReligion, iOwner, pSpreadCity = argsList
iCatholic = gc.getInfoTypeForString('RELIGION_CHRISTIANITY')
iProtestant = gc.getInfoTypeForString('RELIGION_PROTESTANTISM')
iJewish = gc.getInfoTypeForString('RELIGION_JUDAISM')
iHindu = gc.getInfoTypeForString('RELIGION_HINDUISM')
iPolytheism = gc.getInfoTypeForString('RELIGION_POLYTHEISM')
iIslam = gc.getInfoTypeForString('RELIGION_ISLAM')
player = PyPlayer(iOwner)
pPlayer = gc.getPlayer(iOwner)
iRandLoss = CyGame().getSorenRandNum(100, "Religion Loss")

if iReligion == iCatholic:
if (pSpreadCity.isHasReligion(iProtestant) and pSpreadCity.isHolyCityByType(iProtestant) == False):
if (iRandLoss <= 45):
pSpreadCity.setHasReligion(iProtestant, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Protestanen sind zur Heiligen Kirche zurückgekehrt!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if (pSpreadCity.isHasReligion(iIslam) and pSpreadCity.isHolyCityByType(iIslam) == False):
if (iRandLoss <= 30):
pSpreadCity.setHasReligion(iIslam, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime der Stadt sind katholisch geworden!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if (pSpreadCity.isHasReligion(iHindu) and pSpreadCity.isHolyCityByType(iHindu) == False):
if (iRandLoss <= 45):
pSpreadCity.setHasReligion(iHindu, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Hindus sind zur Heiligen Kirche konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if (pSpreadCity.isHasReligion(iJewish) and pSpreadCity.isHolyCityByType(iJewish) == False):
if (iRandLoss <= 50):
pSpreadCity.setHasReligion(iJewish, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Juden de Stadt sind jetzt katholisch!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if (pSpreadCity.isHasReligion(iPolytheism) and pSpreadCity.isHolyCityByType(iPolytheism) == False):
if (iRandLoss <= 85):
pSpreadCity.setHasReligion(iPolytheism, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Heiden sind zur katholischen Kirche konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)



if iReligion == iProtestant:

if (pSpreadCity.isHasReligion(iIslam) and pSpreadCity.isHolyCityByType(iIslam) == False):
if (iRandLoss <= 20):
pSpreadCity.setHasReligion(iIslam, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime sind protestantische Christen geworden!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pSpreadCity.getX(),p SpreadCity.getY(),True,True)

if (pSpreadCity.isHasReligion(iHindu) and pSpreadCity.isHolyCityByType(iHindu) == False):
if (iRandLoss <= 40):
pSpreadCity.setHasReligion(iHindu, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Hindus habe Jesus anerkannt, aber nicht den Papst!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pSpreadCity.getX(),p SpreadCity.getY(),True,True)

if (pSpreadCity.isHasReligion(iCatholic) and pSpreadCity.isHolyCityByType(iCatholic) == False):
if (iRandLoss <= 30):
pSpreadCity.setHasReligion(iCatholic, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Reformation! Die Kathoiken der Stadt sind Protestanten geworden!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pSpreadCity.getX(),p SpreadCity.getY(),True,True)

if (pSpreadCity.isHasReligion(iJewish) and pSpreadCity.isHolyCityByType(iJewish) == False):
if (iRandLoss <= 50):
pSpreadCity.setHasReligion(iJewish, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Juden der Stadt sind evangelisch geworden!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pSpreadCity.getX(),p SpreadCity.getY(),True,True)

if (pSpreadCity.isHasReligion(iPolytheism) and pSpreadCity.isHolyCityByType(iPolytheism) == False):
if (iRandLoss <= 70):
pSpreadCity.setHasReligion(iPolytheism, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Heiden sind zur evangelischen Kirche konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iPolytheism:

if (pSpreadCity.isHasReligion(iIslam) and pSpreadCity.isHolyCityByType(iIslam) == False):
if (iRandLoss <= 10):
pSpreadCity.setHasReligion(iIslam, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime haben die Opfer an Zeus wiederaufgenommen!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if (pSpreadCity.isHasReligion(iCatholic) and pSpreadCity.isHolyCityByType(iCatholic) == False):
if (iRandLoss <= 10):
pSpreadCity.setHasReligion(iCatholic, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Katholiken haben die Kulttempel wieder geöffnet!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if (pSpreadCity.isHasReligion(iProtestant) and pSpreadCity.isHolyCityByType(iProtestant) == False):
if (iRandLoss <= 10):
pSpreadCity.setHasReligion(iProtestant, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Protestanen sind zum Heidentum konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if (pSpreadCity.isHasReligion(iHindu) and pSpreadCity.isHolyCityByType(iHindu) == False):
if (iRandLoss <= 30):
pSpreadCity.setHasReligion(iHindu, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Hindus haben Zeus als König der Götter erkannt!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if (pSpreadCity.isHasReligion(iJewish) and pSpreadCity.isHolyCityByType(iJewish) == False):
if (iRandLoss <= 15):
pSpreadCity.setHasReligion(iJewish, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Juden haben Zeus als König der Götter erkannt!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if iReligion == iIslam:
if (pSpreadCity.isHasReligion(iCatholic) and pSpreadCity.isHolyCityByType(iCatholic) == False):
if (iRandLoss <= 25):
pSpreadCity.setHasReligion(iIslam, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Katholiken sind Muslime geworden!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if (pSpreadCity.isHasReligion(iProtestant) and pSpreadCity.isHolyCityByType(iProtestant) == False):
if (iRandLoss <= 25):
pSpreadCity.setHasReligion(iProtestant, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Protestanten sind Muslime geworden!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if (pSpreadCity.isHasReligion(iHindu) and pSpreadCity.isHolyCityByType(iHindu) == False):
if (iRandLoss <= 45):
pSpreadCity.setHasReligion(iHindu, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Hindus sind zum Islam konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if (pSpreadCity.isHasReligion(iPolytheism) and pSpreadCity.isHolyCityByType(iPolytheism) == False):
if (iRandLoss <= 80):
pSpreadCity.setHasReligion(iPolytheism, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Kultreligion macht Platz für den Islam!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if (pSpreadCity.isHasReligion(iJewish) and pSpreadCity.isHolyCityByType(iJewish) == False):
if (iRandLoss <= 20):
pSpreadCity.setHasReligion(iJewish, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime sind zum Judentum konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iJewish:

if (pSpreadCity.isHasReligion(iIslam) and pSpreadCity.isHolyCityByType(iIslam) == False):
if (iRandLoss <= 20):
pSpreadCity.setHasReligion(iIslam, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime sind zum Judentum konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if (pSpreadCity.isHasReligion(iCatholic) and pSpreadCity.isHolyCityByType(iCatholic) == False):
if (iRandLoss <= 20):
pSpreadCity.setHasReligion(iCatholic, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Katholiken sind zum Judentums konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if (pSpreadCity.isHasReligion(iProtestant) and pSpreadCity.isHolyCityByType(iProtestant) == False):
if (iRandLoss <= 20):
pSpreadCity.setHasReligion(iPotestant, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Protestanen sind zum Judentum konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if (pSpreadCity.isHasReligion(iHindu) and pSpreadCity.isHolyCityByType(iHindu) == False):
if (iRandLoss <= 30):
pSpreadCity.setHasReligion(iHindu, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Juden sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if (pSpreadCity.isHasReligion(iPolytheism) and pSpreadCity.isHolyCityByType(iPolytheism) == False):
if (iRandLoss <= 80):
pSpreadCity.setHasReligion(iPolytheism, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Muslime haben die Opfer für Zeus wiederaufgenommen!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if iReligion == iHindu:

if (pSpreadCity.isHasReligion(iIslam) and pSpreadCity.isHolyCityByType(iIslam) == False):
if (iRandLoss <= 20):
pSpreadCity.setHasReligion(iIslam, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Juden sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if (pSpreadCity.isHasReligion(iCatholic) and pSpreadCity.isHolyCityByType(iCatholic) == False):
if (iRandLoss <= 20):
pSpreadCity.setHasReligion(iCatholic, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Katholiken sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if (pSpreadCity.isHasReligion(iProtestant) and pSpreadCity.isHolyCityByType(iProtestant) == False):
if (iRandLoss <= 20):
pSpreadCity.setHasReligion(iProtestant, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Protestanten sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


if (pSpreadCity.isHasReligion(iJewish) and pSpreadCity.isHolyCityByType(iJewish) == False):
if (iRandLoss <= 20):
pSpreadCity.setHasReligion(iJewish, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Juden sind zum Hinduismus konvertiert!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)

if (pSpreadCity.isHasReligion(iPolytheism) and pSpreadCity.isHolyCityByType(iPolytheism) == False):
if (iRandLoss <= 40):
pSpreadCity.setHasReligion(iPolytheism, False, False, False)
CyInterface().addMessage(CyGame().getActivePlayer( ),True,25,'Die Tempel werden dem Hinduismus neu geweiht!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Catholic.dds',ColorTypes(8),pSpreadCity.getX(),pSp readCity.getY(),True,True)


CvUtil.pyPrint('%s has spread to Player %d Civilization %s city of %s'
%(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pSpreadCity.getName()))



Every once in a while, I get an exception call though:
unicode decode error - can't decode bythe 0xfc in position 29: ordinal not in range (128). don't know what that means...

talchas
Jan 27, 2006, 06:24 AM
Try replacing all you strings that are '...' with u'...'. This will make them unicode strings and I think will let you use the special characters you are using.