Missionary 100% success rate

streetdog

Chieftain
Joined
Mar 6, 2009
Messages
74
Hello guys,
In the original civ4 i used to bypass the fail with the following solution (as one forum member suggested long ago):

Code:
    def onUnitSpreadReligionAttempt(self, argsList): 
        'Unit tries to spread religion to a city' 
        pUnit, iReligion, bSuccess = argsList 
        
        iX = pUnit.getX() 
        iY = pUnit.getY() 
        pPlot = CyMap().plot(iX, iY) 
        pCity = pPlot.getPlotCity() 
###100% chance of spreading start 
        if pUnit.getOwner()==pCity.getOwner(): 
                        if not bSuccess: 
                                pCity.setHasReligion(iReligion,True,True,True) 
###100% chance of spreading end

However in c2c i noticed that this has been changed to this:
Code:
    def onUnitSpreadReligionAttempt(self, argsList):
       CyUnit, iReligion, bSuccess = argsList
       if not bSuccess:
           iPlayer = CyUnit.getOwner()
           aWonderTuple = self.aWonderTuple
           if "FA_MEN_SI" in aWonderTuple[0]:
               if iPlayer == aWonderTuple[4][aWonderTuple[0].index("FA_MEN_SI")]:
                   CyCity = GC.getMap().plot(CyUnit.getX(), CyUnit.getY()).getPlotCity()
                   CyCity.setHasReligion(GC.getUnitInfo(CyUnit.getUnitType()).getPrereqReligion(), True, True, True)

Any solutions to set the missionary success rate to 100% with the new code? :D
 
Just based on the snipped posted, getting rid of all the if conditionals for the wonder check will make the FA_MEN_SI wonder effect (which makes missionaries always succeed) happen even if the wonder isn't owned.
Code:
def onUnitSpreadReligionAttempt(self, argsList):
    CyUnit, iReligion, bSuccess = argsList
    if not bSuccess:
        CyCity = GC.getMap().plot(CyUnit.getX(), CyUnit.getY()).getPlotCity()
        CyCity.setHasReligion(GC.getUnitInfo(CyUnit.getUnitType()).getPrereqReligion(), True, True, True)
Think that should work, provided the whitespace is right (watch out for tabs vs spaces...). There's probably cleaners ways to do elsewhere, but this ought to suffice for a quick hack. You'll still get the "Failed to spread!" red text I think, but the actual religion will spread regardless.

Also note this is a slightly different effect than the hack in vanilla. The vanilla hack only works for if the owner of the missionary is the same as the owner of the city, here it'll work regardless of ownership combinations of missionary and city. I think. I really need to sleep lol.
 
Last edited:
Thank you, I will try it out and see if it works, which with the pacing of c2c it will take some time :D :D
 
I see you get some error there.
Turn on python error logging in "...\Documents\My Games\Beyond the Sword\CivilizationIV.ini"
loggingenabled = 1
hidepythonexceptions = 0

And show us what error you get.
Either copy the top error from "...\Documents\My Games\Beyond the Sword\Logs\PythonErr.log" or screenshot the in game error message, whatever you find most convenient.
 


Or shortly
Code:
Traceback (most recent call last):
  File "BugEventManager", line 307, in _handleDefaultEvent
  File "CvEventManager", line 2271, in onUnitSpreadReligionAttempt
NameError: global name 'aCyCity' is not defined
 
NameError: global name 'aCyCity' is not defined
Make sure you haven't mistyped 'aCyCity' somewhere (specifically line 2271). If you're at the point where you're making a tweak to the python like this, you're probably smart enough to figure out how the errors can help guide you to the problem; give it a thought!
 
Top Bottom