HELP with merging my mod and BUG!!!

This has nothing to do with removing the duplicated code. In one function you refer to

BUILDING_CIRCUSHAGENBECK​

yet in another function you use

BUILDING_CIRCUS_HAGENBECK​

Figure out which is correct and fix the ones that aren't matched.
 
No worries; this is part of the learning process. When you get an assert about a missing XML object, search in your code for that exact string. You would have found it. Then search in your XML for where you define the object to make sure its <Type> matches.

I think most people in this forum are more than happy to help if you first try your best to find the problem. I only get annoyed when people post things like "Can someone do this for me?" or "Here's 1000 lines of code. What did I do wrong?" :gripe:
 
Now it is time to see if I actually get this or not. I am going to attempt to add the effects for my King Richard's Crusade wonder. First this is the code I plan on using:

Code:
    def onCityAcquiredAndKept(self, argsList): 
        'City Acquired and Kept' 
        iOwner,pCity = argsList 
[COLOR="Orange"]        ###from here 
        pPlayer = gc.getPlayer(iOwner) 
        if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_CRUSADE"))>0: 
            iStateReligion = pPlayer.getStateReligion () 
            if iStateReligion>=0: 
                if not pCity.isHasReligion(iStateReligion): 
                    pCity.setHasReligion(iStateReligion,True,True,True)[/COLOR]

If you'd like to know, the code comes from The_J (from this post ). Anyway, in my DiplomacyEventManager.py file this def or whatever isn't present, so I'll take it from the BtS python file which is here:

Code:
	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
		iOwner,pCity = argsList
		CvUtil.pyPrint('City Acquired and Kept Event: %s' %(pCity.getName()))

Okay, so the first thing I have to do is add it to my DiplomacyEventManager.py file for this action. Since I'm not sure if it has to be in a specific order I'll just put it in the order it appears in the CvEventManager.py file, in this case it would be right underneath the onCityRazed part:

Code:
	def onCityRazed(self, argsList):
		'City Razed'
		city, iPlayer = argsList
		iOwner = city.findHighestCulture()

		# Partisans!
		if city.getPopulation > 1 and iOwner != -1 and iPlayer != -1:
			owner = gc.getPlayer(iOwner)
			if not owner.isBarbarian() and owner.getNumCities() > 0:
				if gc.getTeam(owner.getTeam()).isAtWar(gc.getPlayer(iPlayer).getTeam()):
					if gc.getNumEventTriggerInfos() > 0: # prevents mods that don't have events from getting an error
						iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_PARTISANS')
						if iEvent != -1 and gc.getGame().isEventActive(iEvent) and owner.getEventTriggerWeight(iEvent) < 0:
							triggerData = owner.initTriggeredData(iEvent, true, -1, city.getX(), city.getY(), iPlayer, city.getID(), -1, -1, -1, -1)
			
		#Raze the Arcology
		owner = PyPlayer(city.getOwner())
		razor = PyPlayer(iPlayer)
		
		self.iArcologyCityID = -1
		
		if city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY")) or city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING")) or city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
			self.iArcologyCityID = city.getID()
	
[COLOR="DarkOrange"]	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
		iOwner,pCity = argsList
		CvUtil.pyPrint('City Acquired and Kept Event: %s' %(pCity.getName()))    [/COLOR]
    
	def onCityDoTurn(self, argsList):
		'City Production'
		pCity = argsList[0]
		iPlayer = argsList[1]

So alright, I have that in now, then I check to see if I need an eventhandler. Apparently I do, so I'll try to put it in order in my file. Since it is right after onCityRazed I put it right underneath that:

Code:
class DiplomacyEventManager:
	def __init__(self, eventManager):
		eventManager.addEventHandler("GameStart", self.onGameStart)
		eventManager.addEventHandler("OnLoad", self.onLoadGame)
		eventManager.addEventHandler("GameStart", self.onGameStart)
		eventManager.addEventHandler("BeginGameTurn", self.onBeginGameTurn)
		eventManager.addEventHandler("cityRazed", self.onCityRazed)
[COLOR="DarkOrange"]		eventManager.addEventHandler("cityAcquiredAndKept", self.onCityAcquiredAndKept) [/COLOR]       
		eventManager.addEventHandler("cityDoTurn", self.onCityDoTurn)

Okay, so I have that part done, now I just add the original code from The_J so now it looks like this:

Code:
		#Raze the Arcology
		owner = PyPlayer(city.getOwner())
		razor = PyPlayer(iPlayer)
		
		self.iArcologyCityID = -1
		
		if city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY")) or city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING")) or city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
			self.iArcologyCityID = city.getID()
	
	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
		iOwner,pCity = argsList
[COLOR="DarkOrange"]        ###from here 
        pPlayer = gc.getPlayer(iOwner) 
        if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_CRUSADE"))>0: 
            iStateReligion = pPlayer.getStateReligion () 
            if iStateReligion>=0: 
                if not pCity.isHasReligion(iStateReligion): 
                    pCity.setHasReligion(iStateReligion,True,True,True) [/COLOR]       
		CvUtil.pyPrint('City Acquired and Kept Event: %s' %(pCity.getName()))    
    
	def onCityDoTurn(self, argsList):
		'City Production'
		pCity = argsList[0]
		iPlayer = argsList[1]

So just so you can see the whole thing, this is what the changes I have made look like...

Code:
## Sid Meier's Civilization 4
## Copyright Firaxis Games 2006
## 
## CvEventManager
## This class is passed an argsList from CvAppInterface.onEvent
## The argsList can contain anything from mouse location to key info
## The EVENTLIST that are being notified can be found 


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

import pickle

# BUG - Next War Merge - start
import SdToolkit
SD_MOD_ID = "NextWar"
SD_NUKES_ID = "NumNukes"
# BUG - Next War Merge - end

gc = CyGlobalContext()
localText = CyTranslator()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo


# globals
###################################################


g_iNumNukesWarningMessage = 7
g_iNumNukesGameOver = 20



class DiplomacyEventManager:
	def __init__(self, eventManager):
		eventManager.addEventHandler("GameStart", self.onGameStart)
		eventManager.addEventHandler("OnLoad", self.onLoadGame)
		eventManager.addEventHandler("GameStart", self.onGameStart)
		eventManager.addEventHandler("BeginGameTurn", self.onBeginGameTurn)
		eventManager.addEventHandler("cityRazed", self.onCityRazed)
[COLOR="DarkOrange"]		eventManager.addEventHandler("cityAcquiredAndKept", self.onCityAcquiredAndKept)  [/COLOR]      
		eventManager.addEventHandler("cityDoTurn", self.onCityDoTurn)

		###circus hagenbeck start part 1
                self.oldcity = [-1,-1]
                ###circus hagenbeck end part 1        
		
		# Next War tracks cities that have been razed
		self.iArcologyCityID = -1
		
	def onLoadGame(self, argsList):
		CvAdvisorUtils.resetNoLiberateCities()
# BUG - Next War Merge - start
		# convert old script data list to SdToolkit for old saves
		data = gc.getGame().getScriptData()
		if isinstance(data, list):
			CvUtil.pyPrint('converting script data: %s' % data)
			iNukes = list[0]
			gc.getGame().setScriptData("")
			SdToolkit.sdSetGlobal(SD_MOD_ID, SD_NUKES_ID, iNukes)
# BUG - Next War Merge - end
		return 0

	def onGameStart(self, argsList):
		'Called at the start of the game'

		self.initScriptData()
		
		### circus hagenbeck start part 2
	        if (gc.getGame().getGameTurnYear() <> gc.getDefineINT("START_YEAR")):
                        for iPlayer in range (gc.getMAX_PLAYERS()):
                                player = gc.getPlayer(iPlayer)
				if player.isAlive():
                                        numbuildings = player.countNumBuildings(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"))
                                        if numbuildings>0:
                                                for iCity in range(player.getNumCities()):
                                                        pCity = player.getCity(iCity)
                                                        if pCity.getNumBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"))>0:
                                                                self.oldcity = [iPlayer,iCity]
                                                                return
                ###circus hagenbeck end part 2          
		# Are we using the scenario file? If so, then show the backstory popup
		if (CyMap().plot(0,0).getScriptData() == "Scenario"):
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
					szTitle = u"<font=4b>" + localText.getText("TXT_KEY_NEXT_WAR_BACKSTORY_TITLE", ()) + u"</font>"
					szBody = u"<font=3>" + localText.getText("TXT_KEY_NEXT_WAR_BACKSTORY_TEXT", ()) + u"</font>"
					popupInfo.setText(szTitle + u"\n\n" + szBody)
					popupInfo.addPopup(iPlayer)

		if gc.getGame().isPbem():
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_DETAILS)
					popupInfo.setOption1(true)
					popupInfo.addPopup(iPlayer)
																	
		CvAdvisorUtils.resetNoLiberateCities()

	def onBeginGameTurn(self, argsList):
		'Called at the beginning of the end of each turn'
		iGameTurn = argsList[0]
###circus hagenbeck start part 3		
		if (CyGame().getTurnYear(iGameTurn)>=1890) and ( iGameTurn % 3 ==0 ):
                        counter = 0
                        while True:
                                counter = counter+1
                                if counter>=100:break
                                dice = gc.getGame().getMapRand()
                                iPlayer = dice.get(gc.getMAX_PLAYERS (), "Players")
                                pPlayer = gc.getPlayer(iPlayer)
                                if pPlayer.isNone():continue
                                if pPlayer.isAlive():
                                        iCity = dice.get(pPlayer.getNumCities () , "Cities" )
                                        pCity = pPlayer.getCity(iCity)
                                        if pCity.isNone():continue
                                        pCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"),1)
                                        CyInterface().addMessage(iPlayer,false,20,CyTranslator().getText("TXT_KEY_CIRCUS_MOVED",(pCity.getName (),pCity.getName ())),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pCity.getX(), pCity.getY(), True,True) 
                                        if self.oldcity <>[-1,-1]:
                                                otherplayer = gc.getPlayer(self.oldcity[0])
                                                othercity = otherplayer.getCity(self.oldcity[1])
                                                if not othercity.isNone():
                                                        othercity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"),0)
                                                        CyInterface().addMessage(self.oldcity[0],false,20,CyTranslator().getText("TXT_KEY_CIRCUS_LOST",(othercity.getName (),othercity.getName ())),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), othercity.getX(), othercity.getY(), True,True)
                                        self.oldcity = [iPlayer,iCity]                                 
                                        
                                        break
###circus hagenbeck end part 3         
		
	def onCityRazed(self, argsList):
		'City Razed'
		city, iPlayer = argsList
		iOwner = city.findHighestCulture()

		# Partisans!
		if city.getPopulation > 1 and iOwner != -1 and iPlayer != -1:
			owner = gc.getPlayer(iOwner)
			if not owner.isBarbarian() and owner.getNumCities() > 0:
				if gc.getTeam(owner.getTeam()).isAtWar(gc.getPlayer(iPlayer).getTeam()):
					if gc.getNumEventTriggerInfos() > 0: # prevents mods that don't have events from getting an error
						iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_PARTISANS')
						if iEvent != -1 and gc.getGame().isEventActive(iEvent) and owner.getEventTriggerWeight(iEvent) < 0:
							triggerData = owner.initTriggeredData(iEvent, true, -1, city.getX(), city.getY(), iPlayer, city.getID(), -1, -1, -1, -1)
			
		#Raze the Arcology
		owner = PyPlayer(city.getOwner())
		razor = PyPlayer(iPlayer)
		
		self.iArcologyCityID = -1
		
		if city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY")) or city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING")) or city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
			self.iArcologyCityID = city.getID()
	
	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
		iOwner,pCity = argsList
[COLOR="DarkOrange"]        ###from here 
        pPlayer = gc.getPlayer(iOwner) 
        if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_CRUSADE"))>0: 
            iStateReligion = pPlayer.getStateReligion () 
            if iStateReligion>=0: 
                if not pCity.isHasReligion(iStateReligion): 
                    pCity.setHasReligion(iStateReligion,True,True,True)   [/COLOR]     
		CvUtil.pyPrint('City Acquired and Kept Event: %s' %(pCity.getName()))    
    
	def onCityDoTurn(self, argsList):
		'City Production'
		pCity = argsList[0]
		iPlayer = argsList[1]
        
# no anger defying UN resolutions start #
		iGovernmentCivicOption = CvUtil.findInfoTypeNum(gc.getCivicOptionInfo,gc.getNumCivicOptionInfos(),'CIVICOPTION_GOVERNMENT')
		iPoliceState = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_POLICE_STATE')
		pPlayer = gc.getPlayer(iPlayer)
		iGovernmentCivic = pPlayer.getCivics(iGovernmentCivicOption)

		if (iGovernmentCivic == iPoliceState):
			pCity.changeDefyResolutionAngerTimer(pCity.getDefyResolutionAngerTimer())
# no anger defying UN resolutions end #        

####### Next War Functions ######
## Added Fort to doCheckDepletion -- otherwise bonuses worked via forts would never be subject to resource depletion.   JKP


	def doCheckDepletion(self):
		self.doCheckWorkedResource("BONUS_ALUMINUM", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_ALUMINUM", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_BANANA", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_BANANA", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_CLAM", "IMPROVEMENT_FISHING_BOATS", 880)
		self.doCheckWorkedResource("BONUS_COAL", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_COAL", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_COPPER", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_COPPER", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_CORN", "IMPROVEMENT_FARM", 1120)
		self.doCheckWorkedResource("BONUS_CORN", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_COW", "IMPROVEMENT_PASTURE", 1120)
		self.doCheckWorkedResource("BONUS_COW", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_CRAB", "IMPROVEMENT_FISHING_BOATS", 1120)
		self.doCheckWorkedResource("BONUS_DEER", "IMPROVEMENT_CAMP", 780)
		self.doCheckWorkedResource("BONUS_DEER", "IMPROVEMENT_FORT", 780)
		self.doCheckWorkedResource("BONUS_DYE", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_DYE", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_FISH", "IMPROVEMENT_FISHING_BOATS", 880)
		self.doCheckWorkedResource("BONUS_FUR", "IMPROVEMENT_CAMP", 560)
		self.doCheckWorkedResource("BONUS_FUR", "IMPROVEMENT_FORT", 560)
		self.doCheckWorkedResource("BONUS_GEMS", "IMPROVEMENT_MINE", 1120)
		self.doCheckWorkedResource("BONUS_GEMS", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_GOLD", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_GOLD", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_HORSE", "IMPROVEMENT_PASTURE", 1120)
		self.doCheckWorkedResource("BONUS_HORSE", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_IRON", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_IRON", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_IVORY", "IMPROVEMENT_CAMP", 560)
		self.doCheckWorkedResource("BONUS_IVORY", "IMPROVEMENT_FORT", 560)
		self.doCheckWorkedResource("BONUS_MARBLE", "IMPROVEMENT_QUARRY", 750)
		self.doCheckWorkedResource("BONUS_MARBLE", "IMPROVEMENT_FORT", 750)
		self.doCheckWorkedResource("BONUS_OIL", "IMPROVEMENT_WELL", 880)
		self.doCheckWorkedResource("BONUS_OIL", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_OIL", "IMPROVEMENT_OFFSHORE_PLATFORM", 880)
		self.doCheckWorkedResource("BONUS_PIG", "IMPROVEMENT_PASTURE", 1120)
		self.doCheckWorkedResource("BONUS_PIG", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_RICE", "IMPROVEMENT_FARM", 1120)
		self.doCheckWorkedResource("BONUS_RICE", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_SILK", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_SILK", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_SILVER", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_SILVER", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_SPICES", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_SPICES", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_STONE", "IMPROVEMENT_QUARRY", 750)
		self.doCheckWorkedResource("BONUS_STONE", "IMPROVEMENT_FORT", 750)
		self.doCheckWorkedResource("BONUS_SUGAR", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_SUGAR", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_URANIUM", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_URANIUM", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_WHALE", "IMPROVEMENT_WHALING_BOATS", 560)
		self.doCheckWorkedResource("BONUS_WHEAT", "IMPROVEMENT_FARM", 1120)
		self.doCheckWorkedResource("BONUS_WHEAT", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_WINE", "IMPROVEMENT_WINERY", 1120)
		self.doCheckWorkedResource("BONUS_WINE", "IMPROVEMENT_FORT", 1120)

	def doCheckWorkedResource(self, bonus, improvement, randomInt):
            
		iBonus = CvUtil.findInfoTypeNum(gc.getBonusInfo, gc.getNumBonusInfos(), bonus)
        
		if (iBonus == -1):
			return
        
		lValidPlots = self.getPlotListbyBonus(iBonus)
        
		if len(lValidPlots) == 0:
			return
                
##If you have the requisite improvement (incl. fort) or if the plot is being worked by a City, continue.
                        
			for plot in lValidPlots:
				P = False
                
				if plot.getImprovementType() == CvUtil.findInfoTypeNum(gc.getImprovementInfo, gc.getNumImprovementInfos(), improvement):
					P = True
				elif plot.isCity():
					P = True

				if P == True:
					if self.getRandomNumber(randomInt) == 0:
                    
						pBonusInfo = gc.getBonusInfo(iBonus)
                    
						plot.setBonusType(-1)
                    
						szTitle = localText.getText("TEXT_KEY_NEXT_WAR_RESOURCE_DEPLETED_TITLE", ())# (pBonusInfo.getDescription(), plotgetX(), plot.getY()))
                        #szText = localText.getText("TEXT_KEY_NEXT_WAR_RESOURCE_DEPLETED", (pBonusInfo.getDescription(), plot.getX(), plot.getY()))
                        #Not sure what the above commented out code for (debugging?) -- it was commented out in PM's original NextWar code.  JKP1187
                        
						CyInterface().addMessage(plot.getOwner(), False, gc.getEVENT_MESSAGE_TIME(), szTitle, "AS2D_DISCOVERBONUS", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT, pBonusInfo.getButton(), gc.getInfoTypeForString("COLOR_GREEN"), plot.getX(), plot.getY(), True, True)		
				else:
					return
				

### Below are additional functions necessary to the activity of the resource depl'n code:

	def getPlotListbyBonus(self, iBonus):
		lPlots = []
		totalPlots = gc.getMap().numPlots()
		
		for i in range(totalPlots):
			plot = gc.getMap().plotByIndex(i)
			iOwner = plot.getOwner()
			if (iOwner != -1):
				if plot.getBonusType(gc.getPlayer(iOwner).getTeam()) == iBonus:
					lPlots.append(plot)
		return lPlots

	def getRandomNumber(self, int):
		return gc.getGame().getSorenRandNum(int, "Next War")


# BUG - Next War Merge - start
	def initScriptData(self):
		
		# Set default script data manually since we need defaults for all values in the array before any functions can be called on them
		iDefaultNumNukesFired = 0
		SdToolkit.sdSetGlobal(SD_MOD_ID, SD_NUKES_ID, iDefaultNumNukesFired)
		
	def getGameNumNukes(self):
		return SdToolkit.sdGetGlobal(SD_MOD_ID, SD_NUKES_ID)

	def setGameNumNukes(self, iValue):
		SdToolkit.sdSetGlobal(SD_MOD_ID, SD_NUKES_ID, iValue)
		self.checkNukeStuff(iValue)
		
	def changeGameNumNukes(self, iChange):
		self.setGameNumNukes(self.getGameNumNukes() + iChange)
# BUG - Next War Merge - end

Is that right? Please say yes (but if it isn't, say no).

EDIT: I just realized that might be a bad font color choice for this, I use the black/charcoal colored skin at CFC, I forgot some people use the original one.
 
That code you inserted uses spaces instead of tabs, so you'll get indentation errors. As you can see by looking at it in your post, it's not at the correct level. You can do a find/replace in your editor to replace " " (four spaces, omit the quotes) with "\t" (a tab character if the editor is good, omit the quotes). If that doesn't work (you see \t in your code) you need to swap the spaces to tabs manually.

You can drop the CvUtil.pyPrint(...) line at the end of the function, too, since that's not part of your code.

Also, looking at the function above, I see you can delete this block:

Code:
		# Partisans!
		if city.getPopulation > 1 and iOwner != -1 and iPlayer != -1:
			owner = gc.getPlayer(iOwner)
			if not owner.isBarbarian() and owner.getNumCities() > 0:
				if gc.getTeam(owner.getTeam()).isAtWar(gc.getPlayer(iPlayer).getTeam()):
					if gc.getNumEventTriggerInfos() > 0: # prevents mods that don't have events from getting an error
						iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_PARTISANS')
						if iEvent != -1 and gc.getGame().isEventActive(iEvent) and owner.getEventTriggerWeight(iEvent) < 0:
							triggerData = owner.initTriggeredData(iEvent, true, -1, city.getX(), city.getY(), iPlayer, city.getID(), -1, -1, -1, -1)

Otherwise you could get multiple partisan events.

Finally, in reading the code I see one issue which may not be a problem. If the player captures the city containing the wonder, should their state religion spread to all of their cities? As it's written only the new city will get the state religion. If that's okay, leave it as-is.
 
Alright, I can fix the indentation (can't I just paste the proper indentation over it?) I think. Also I didn't even realize I could delete the Partisans damn it. And finally, I'm not really sure what the code says, but the basic idea is that, when you have the wonder it spreads your state religion to cities you conquer, and by that I mean as you conquer them. I didn't really think about what would (or should) happen when the city with KRC is conquered by a country with a different state religion.

What would happen if say you built KRC and had Christianity as a state religion, and it was the only religion in the city KRC was built in. Then say you get attacked by a Muslim civ and they take over the city that had KRC? With the code I have presently obviously.
 
Presently, the captured KRC city would obtain the conqueror's state religion if it didn't already have it.

There's one thing you may be missing, judging by your comment about the partisans code. All of the event handlers in BTS's CvEventManager continue to function when using BUG. Your new handlers will run in addition to the handlers in CvEventManager and BUG.

This is why you should remove code copied from CvEventManager, except the "def onXXX(self, argsList)" line, the comment (optional first line in quotes), and the line that pulls values from argsList. The "def" line is obviously needed as it defines the function. The comment isn't needed but doesn't hurt. And the argsList line is probably needed because you are typically using the arguments passed to the event handler in your new code.
 
Presently, the captured KRC city would obtain the conqueror's state religion if it didn't already have it.

There's one thing you may be missing, judging by your comment about the partisans code. All of the event handlers in BTS's CvEventManager continue to function when using BUG. Your new handlers will run in addition to the handlers in CvEventManager and BUG.

This is why you should remove code copied from CvEventManager, except the "def onXXX(self, argsList)" line, the comment (optional first line in quotes), and the line that pulls values from argsList. The "def" line is obviously needed as it defines the function. The comment isn't needed but doesn't hurt. And the argsList line is probably needed because you are typically using the arguments passed to the event handler in your new code.

No, I'm aware that basically what I'm doing is deleting things that are already presently coming out of of the CvEventManager (whether it be BUGs or the regular one or whatever) because if mine has them in too it will effectively happen "twice." So when three macemen partisans get popped from a lost city it would be six if I had the code doubled up. Is that right?

Anyway, here is the fixed code. I deleted the Partisans thing and I added some indentation, I hope with correct indentation:

Code:
## Sid Meier's Civilization 4
## Copyright Firaxis Games 2006
## 
## CvEventManager
## This class is passed an argsList from CvAppInterface.onEvent
## The argsList can contain anything from mouse location to key info
## The EVENTLIST that are being notified can be found 


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

import pickle

# BUG - Next War Merge - start
import SdToolkit
SD_MOD_ID = "NextWar"
SD_NUKES_ID = "NumNukes"
# BUG - Next War Merge - end

gc = CyGlobalContext()
localText = CyTranslator()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo


# globals
###################################################


g_iNumNukesWarningMessage = 7
g_iNumNukesGameOver = 20



class DiplomacyEventManager:
	def __init__(self, eventManager):
		eventManager.addEventHandler("GameStart", self.onGameStart)
		eventManager.addEventHandler("OnLoad", self.onLoadGame)
		eventManager.addEventHandler("GameStart", self.onGameStart)
		eventManager.addEventHandler("BeginGameTurn", self.onBeginGameTurn)
		eventManager.addEventHandler("cityRazed", self.onCityRazed)
		eventManager.addEventHandler("cityAcquiredAndKept", self.onCityAcquiredAndKept)        
		eventManager.addEventHandler("cityDoTurn", self.onCityDoTurn)

		###circus hagenbeck start part 1
                self.oldcity = [-1,-1]
                ###circus hagenbeck end part 1        
		
		# Next War tracks cities that have been razed
		self.iArcologyCityID = -1
		
	def onLoadGame(self, argsList):
		CvAdvisorUtils.resetNoLiberateCities()
# BUG - Next War Merge - start
		# convert old script data list to SdToolkit for old saves
		data = gc.getGame().getScriptData()
		if isinstance(data, list):
			CvUtil.pyPrint('converting script data: %s' % data)
			iNukes = list[0]
			gc.getGame().setScriptData("")
			SdToolkit.sdSetGlobal(SD_MOD_ID, SD_NUKES_ID, iNukes)
# BUG - Next War Merge - end
		return 0

	def onGameStart(self, argsList):
		'Called at the start of the game'

		self.initScriptData()
		
		### circus hagenbeck start part 2
	        if (gc.getGame().getGameTurnYear() <> gc.getDefineINT("START_YEAR")):
                        for iPlayer in range (gc.getMAX_PLAYERS()):
                                player = gc.getPlayer(iPlayer)
				if player.isAlive():
                                        numbuildings = player.countNumBuildings(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"))
                                        if numbuildings>0:
                                                for iCity in range(player.getNumCities()):
                                                        pCity = player.getCity(iCity)
                                                        if pCity.getNumBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"))>0:
                                                                self.oldcity = [iPlayer,iCity]
                                                                return
                ###circus hagenbeck end part 2          
		# Are we using the scenario file? If so, then show the backstory popup
		if (CyMap().plot(0,0).getScriptData() == "Scenario"):
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
					szTitle = u"<font=4b>" + localText.getText("TXT_KEY_NEXT_WAR_BACKSTORY_TITLE", ()) + u"</font>"
					szBody = u"<font=3>" + localText.getText("TXT_KEY_NEXT_WAR_BACKSTORY_TEXT", ()) + u"</font>"
					popupInfo.setText(szTitle + u"\n\n" + szBody)
					popupInfo.addPopup(iPlayer)

		if gc.getGame().isPbem():
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_DETAILS)
					popupInfo.setOption1(true)
					popupInfo.addPopup(iPlayer)
																	
		CvAdvisorUtils.resetNoLiberateCities()

	def onBeginGameTurn(self, argsList):
		'Called at the beginning of the end of each turn'
		iGameTurn = argsList[0]
###circus hagenbeck start part 3		
		if (CyGame().getTurnYear(iGameTurn)>=1890) and ( iGameTurn % 3 ==0 ):
                        counter = 0
                        while True:
                                counter = counter+1
                                if counter>=100:break
                                dice = gc.getGame().getMapRand()
                                iPlayer = dice.get(gc.getMAX_PLAYERS (), "Players")
                                pPlayer = gc.getPlayer(iPlayer)
                                if pPlayer.isNone():continue
                                if pPlayer.isAlive():
                                        iCity = dice.get(pPlayer.getNumCities () , "Cities" )
                                        pCity = pPlayer.getCity(iCity)
                                        if pCity.isNone():continue
                                        pCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"),1)
                                        CyInterface().addMessage(iPlayer,false,20,CyTranslator().getText("TXT_KEY_CIRCUS_MOVED",(pCity.getName (),pCity.getName ())),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pCity.getX(), pCity.getY(), True,True) 
                                        if self.oldcity <>[-1,-1]:
                                                otherplayer = gc.getPlayer(self.oldcity[0])
                                                othercity = otherplayer.getCity(self.oldcity[1])
                                                if not othercity.isNone():
                                                        othercity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"),0)
                                                        CyInterface().addMessage(self.oldcity[0],false,20,CyTranslator().getText("TXT_KEY_CIRCUS_LOST",(othercity.getName (),othercity.getName ())),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), othercity.getX(), othercity.getY(), True,True)
                                        self.oldcity = [iPlayer,iCity]                                 
                                        
                                        break
###circus hagenbeck end part 3         
		
	def onCityRazed(self, argsList):
		'City Razed'
		city, iPlayer = argsList
		iOwner = city.findHighestCulture()
			
		#Raze the Arcology
		owner = PyPlayer(city.getOwner())
		razor = PyPlayer(iPlayer)
		
		self.iArcologyCityID = -1
		
		if city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY")) or city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING")) or city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
			self.iArcologyCityID = city.getID()
	
	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
		iOwner,pCity = argsList
[COLOR="Blue"]		###from here 
		pPlayer = gc.getPlayer(iOwner) 
		if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_CRUSADE"))>0: 
			iStateReligion = pPlayer.getStateReligion () 
			if iStateReligion>=0: 
				if not pCity.isHasReligion(iStateReligion): 
					pCity.setHasReligion(iStateReligion,True,True,True)        [/COLOR]
		CvUtil.pyPrint('City Acquired and Kept Event: %s' %(pCity.getName()))    
		
	def onCityDoTurn(self, argsList):
		'City Production'
		pCity = argsList[0]
		iPlayer = argsList[1]
		
# no anger defying UN resolutions start #
		iGovernmentCivicOption = CvUtil.findInfoTypeNum(gc.getCivicOptionInfo,gc.getNumCivicOptionInfos(),'CIVICOPTION_GOVERNMENT')
		iPoliceState = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_POLICE_STATE')
		pPlayer = gc.getPlayer(iPlayer)
		iGovernmentCivic = pPlayer.getCivics(iGovernmentCivicOption)

		if (iGovernmentCivic == iPoliceState):
			pCity.changeDefyResolutionAngerTimer(pCity.getDefyResolutionAngerTimer())
# no anger defying UN resolutions end #        

####### Next War Functions ######
## Added Fort to doCheckDepletion -- otherwise bonuses worked via forts would never be subject to resource depletion.   JKP


	def doCheckDepletion(self):
		self.doCheckWorkedResource("BONUS_ALUMINUM", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_ALUMINUM", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_BANANA", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_BANANA", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_CLAM", "IMPROVEMENT_FISHING_BOATS", 880)
		self.doCheckWorkedResource("BONUS_COAL", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_COAL", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_COPPER", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_COPPER", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_CORN", "IMPROVEMENT_FARM", 1120)
		self.doCheckWorkedResource("BONUS_CORN", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_COW", "IMPROVEMENT_PASTURE", 1120)
		self.doCheckWorkedResource("BONUS_COW", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_CRAB", "IMPROVEMENT_FISHING_BOATS", 1120)
		self.doCheckWorkedResource("BONUS_DEER", "IMPROVEMENT_CAMP", 780)
		self.doCheckWorkedResource("BONUS_DEER", "IMPROVEMENT_FORT", 780)
		self.doCheckWorkedResource("BONUS_DYE", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_DYE", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_FISH", "IMPROVEMENT_FISHING_BOATS", 880)
		self.doCheckWorkedResource("BONUS_FUR", "IMPROVEMENT_CAMP", 560)
		self.doCheckWorkedResource("BONUS_FUR", "IMPROVEMENT_FORT", 560)
		self.doCheckWorkedResource("BONUS_GEMS", "IMPROVEMENT_MINE", 1120)
		self.doCheckWorkedResource("BONUS_GEMS", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_GOLD", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_GOLD", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_HORSE", "IMPROVEMENT_PASTURE", 1120)
		self.doCheckWorkedResource("BONUS_HORSE", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_IRON", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_IRON", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_IVORY", "IMPROVEMENT_CAMP", 560)
		self.doCheckWorkedResource("BONUS_IVORY", "IMPROVEMENT_FORT", 560)
		self.doCheckWorkedResource("BONUS_MARBLE", "IMPROVEMENT_QUARRY", 750)
		self.doCheckWorkedResource("BONUS_MARBLE", "IMPROVEMENT_FORT", 750)
		self.doCheckWorkedResource("BONUS_OIL", "IMPROVEMENT_WELL", 880)
		self.doCheckWorkedResource("BONUS_OIL", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_OIL", "IMPROVEMENT_OFFSHORE_PLATFORM", 880)
		self.doCheckWorkedResource("BONUS_PIG", "IMPROVEMENT_PASTURE", 1120)
		self.doCheckWorkedResource("BONUS_PIG", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_RICE", "IMPROVEMENT_FARM", 1120)
		self.doCheckWorkedResource("BONUS_RICE", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_SILK", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_SILK", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_SILVER", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_SILVER", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_SPICES", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_SPICES", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_STONE", "IMPROVEMENT_QUARRY", 750)
		self.doCheckWorkedResource("BONUS_STONE", "IMPROVEMENT_FORT", 750)
		self.doCheckWorkedResource("BONUS_SUGAR", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_SUGAR", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_URANIUM", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_URANIUM", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_WHALE", "IMPROVEMENT_WHALING_BOATS", 560)
		self.doCheckWorkedResource("BONUS_WHEAT", "IMPROVEMENT_FARM", 1120)
		self.doCheckWorkedResource("BONUS_WHEAT", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_WINE", "IMPROVEMENT_WINERY", 1120)
		self.doCheckWorkedResource("BONUS_WINE", "IMPROVEMENT_FORT", 1120)

	def doCheckWorkedResource(self, bonus, improvement, randomInt):
            
		iBonus = CvUtil.findInfoTypeNum(gc.getBonusInfo, gc.getNumBonusInfos(), bonus)
        
		if (iBonus == -1):
			return
        
		lValidPlots = self.getPlotListbyBonus(iBonus)
        
		if len(lValidPlots) == 0:
			return
                
##If you have the requisite improvement (incl. fort) or if the plot is being worked by a City, continue.
                        
			for plot in lValidPlots:
				P = False
                
				if plot.getImprovementType() == CvUtil.findInfoTypeNum(gc.getImprovementInfo, gc.getNumImprovementInfos(), improvement):
					P = True
				elif plot.isCity():
					P = True

				if P == True:
					if self.getRandomNumber(randomInt) == 0:
                    
						pBonusInfo = gc.getBonusInfo(iBonus)
                    
						plot.setBonusType(-1)
                    
						szTitle = localText.getText("TEXT_KEY_NEXT_WAR_RESOURCE_DEPLETED_TITLE", ())# (pBonusInfo.getDescription(), plotgetX(), plot.getY()))
                        #szText = localText.getText("TEXT_KEY_NEXT_WAR_RESOURCE_DEPLETED", (pBonusInfo.getDescription(), plot.getX(), plot.getY()))
                        #Not sure what the above commented out code for (debugging?) -- it was commented out in PM's original NextWar code.  JKP1187
                        
						CyInterface().addMessage(plot.getOwner(), False, gc.getEVENT_MESSAGE_TIME(), szTitle, "AS2D_DISCOVERBONUS", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT, pBonusInfo.getButton(), gc.getInfoTypeForString("COLOR_GREEN"), plot.getX(), plot.getY(), True, True)		
				else:
					return
				

### Below are additional functions necessary to the activity of the resource depl'n code:

	def getPlotListbyBonus(self, iBonus):
		lPlots = []
		totalPlots = gc.getMap().numPlots()
		
		for i in range(totalPlots):
			plot = gc.getMap().plotByIndex(i)
			iOwner = plot.getOwner()
			if (iOwner != -1):
				if plot.getBonusType(gc.getPlayer(iOwner).getTeam()) == iBonus:
					lPlots.append(plot)
		return lPlots

	def getRandomNumber(self, int):
		return gc.getGame().getSorenRandNum(int, "Next War")


# BUG - Next War Merge - start
	def initScriptData(self):
		
		# Set default script data manually since we need defaults for all values in the array before any functions can be called on them
		iDefaultNumNukesFired = 0
		SdToolkit.sdSetGlobal(SD_MOD_ID, SD_NUKES_ID, iDefaultNumNukesFired)
		
	def getGameNumNukes(self):
		return SdToolkit.sdGetGlobal(SD_MOD_ID, SD_NUKES_ID)

	def setGameNumNukes(self, iValue):
		SdToolkit.sdSetGlobal(SD_MOD_ID, SD_NUKES_ID, iValue)
		self.checkNukeStuff(iValue)
		
	def changeGameNumNukes(self, iChange):
		self.setGameNumNukes(self.getGameNumNukes() + iChange)
# BUG - Next War Merge - end

So, what do you think?
 
So, what do you think?

Does it work? That's the main thing that matters.

This still needs to go:

Code:
		if gc.getGame().isPbem():
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_DETAILS)
					popupInfo.setOption1(true)
					popupInfo.addPopup(iPlayer)
																	
		CvAdvisorUtils.resetNoLiberateCities()

Also, I see you're calling "self.checkNukeStuff(iValue)", but I don't see it defined in this class. Did you forget to copy it from NextWar's CvEventManager?
 
Does it work? That's the main thing that matters.

This still needs to go:

Code:
		if gc.getGame().isPbem():
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_DETAILS)
					popupInfo.setOption1(true)
					popupInfo.addPopup(iPlayer)
																	
		CvAdvisorUtils.resetNoLiberateCities()

Also, I see you're calling "self.checkNukeStuff(iValue)", but I don't see it defined in this class. Did you forget to copy it from NextWar's CvEventManager?

Well, I'm actually not the only person working on this mod (although sometimes I feel like I am), someone else did the majority of the merge So I'll look for it and copy it over.

Just to clarify though; you say I still have to delete that part of the code you specified, and then I have to define the self.checkNukeStuff(iValue)? How do I know what to add? This is what my file says:

Code:
# BUG - Next War Merge - start
	def initScriptData(self):
		
		# Set default script data manually since we need defaults for all values in the array before any functions can be called on them
		iDefaultNumNukesFired = 0
		SdToolkit.sdSetGlobal(SD_MOD_ID, SD_NUKES_ID, iDefaultNumNukesFired)
		
	def getGameNumNukes(self):
		return SdToolkit.sdGetGlobal(SD_MOD_ID, SD_NUKES_ID)

	def setGameNumNukes(self, iValue):
		SdToolkit.sdSetGlobal(SD_MOD_ID, SD_NUKES_ID, iValue)
		self.checkNukeStuff(iValue)
		
	def changeGameNumNukes(self, iChange):
		self.setGameNumNukes(self.getGameNumNukes() + iChange)
# BUG - Next War Merge - end

And this is what it says in the regular NextWar CvEventManager.py file:

Code:
	def initScriptData(self):
		
		# Set default script data manually since we need defaults for all values in the array before any functions can be called on them
		iDefaultNumNukesFired = 0
		
		aScriptData = [iDefaultNumNukesFired]
		gc.getGame().setScriptData(pickle.dumps(aScriptData))
		
	def getGameNumNukes(self):
		aszScriptData = pickle.loads(gc.getGame().getScriptData())
		iNumNukes = aszScriptData[0]		 # Num Nukes Fired is 0th element
		return iNumNukes
	def setGameNumNukes(self, iValue):
		aszScriptData = pickle.loads(gc.getGame().getScriptData())
		aszScriptData[0] = iValue
		gc.getGame().setScriptData(pickle.dumps(aszScriptData))
		
		self.checkNukeStuff(aszScriptData[0])
		
	def changeGameNumNukes(self, iChange):
		aszScriptData = pickle.loads(gc.getGame().getScriptData())
		aszScriptData[0] = aszScriptData[0] + iChange
		gc.getGame().setScriptData(pickle.dumps(aszScriptData))
		
		self.checkNukeStuff(aszScriptData[0])
		
	def checkNukeStuff(self, iNumNukes):
		
		print("iNumNukes")
		print(iNumNukes)
		print("g_iNumNukesGameOver")
		print(g_iNumNukesGameOver)
		
		# Amount of nukes matches Warning message
		if (CyMap().plot(0,0).getScriptData() == "Scenario"):
			if (iNumNukes == g_iNumNukesWarningMessage):
				self.addPopup("", localText.getText("TXT_KEY_ROUND_THREE_NUKE_WARNING", ()))
		
		# Amount of nukes matches Game over
			elif (iNumNukes == g_iNumNukesGameOver):
			
			# Show the screen that shows the world 'sploding
				CvScreensInterface.showNextWarScreen()
				gc.getGame().setWinner(18, 3)

So what from this last bit of code I just posted (Next War CvEventManager) do I have to merge into mine? I can't really tell.
 
So what from this last bit of code I just posted (Next War CvEventManager) do I have to merge into mine?

Everything from this line to the end of what you posted:

Code:
def checkNukeStuff(self, iNumNukes):
 
Everything from this line to the end of what you posted:

Code:
def checkNukeStuff(self, iNumNukes):

Okay, so this is what I have now, I have placed the parts I just changed in blue, although I'm sure with your expertise you could probably tell anyway:

Code:
## Sid Meier's Civilization 4
## Copyright Firaxis Games 2006
## 
## CvEventManager
## This class is passed an argsList from CvAppInterface.onEvent
## The argsList can contain anything from mouse location to key info
## The EVENTLIST that are being notified can be found 


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

import pickle

# BUG - Next War Merge - start
import SdToolkit
SD_MOD_ID = "NextWar"
SD_NUKES_ID = "NumNukes"
# BUG - Next War Merge - end

gc = CyGlobalContext()
localText = CyTranslator()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo


# globals
###################################################


g_iNumNukesWarningMessage = 7
g_iNumNukesGameOver = 20



class DiplomacyEventManager:
	def __init__(self, eventManager):
		eventManager.addEventHandler("GameStart", self.onGameStart)
		eventManager.addEventHandler("OnLoad", self.onLoadGame)
		eventManager.addEventHandler("GameStart", self.onGameStart)
		eventManager.addEventHandler("BeginGameTurn", self.onBeginGameTurn)
		eventManager.addEventHandler("cityRazed", self.onCityRazed)
		eventManager.addEventHandler("cityAcquiredAndKept", self.onCityAcquiredAndKept)        
		eventManager.addEventHandler("cityDoTurn", self.onCityDoTurn)

		###circus hagenbeck start part 1
                self.oldcity = [-1,-1]
                ###circus hagenbeck end part 1        
		
		# Next War tracks cities that have been razed
		self.iArcologyCityID = -1
		
	def onLoadGame(self, argsList):
		CvAdvisorUtils.resetNoLiberateCities()
# BUG - Next War Merge - start
		# convert old script data list to SdToolkit for old saves
		data = gc.getGame().getScriptData()
		if isinstance(data, list):
			CvUtil.pyPrint('converting script data: %s' % data)
			iNukes = list[0]
			gc.getGame().setScriptData("")
			SdToolkit.sdSetGlobal(SD_MOD_ID, SD_NUKES_ID, iNukes)
# BUG - Next War Merge - end
		return 0

	def onGameStart(self, argsList):
		'Called at the start of the game'

		self.initScriptData()
		
		### circus hagenbeck start part 2
	        if (gc.getGame().getGameTurnYear() <> gc.getDefineINT("START_YEAR")):
                        for iPlayer in range (gc.getMAX_PLAYERS()):
                                player = gc.getPlayer(iPlayer)
				if player.isAlive():
                                        numbuildings = player.countNumBuildings(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"))
                                        if numbuildings>0:
                                                for iCity in range(player.getNumCities()):
                                                        pCity = player.getCity(iCity)
                                                        if pCity.getNumBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"))>0:
                                                                self.oldcity = [iPlayer,iCity]
                                                                return
                ###circus hagenbeck end part 2          
		# Are we using the scenario file? If so, then show the backstory popup
		if (CyMap().plot(0,0).getScriptData() == "Scenario"):
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
					szTitle = u"<font=4b>" + localText.getText("TXT_KEY_NEXT_WAR_BACKSTORY_TITLE", ()) + u"</font>"
					szBody = u"<font=3>" + localText.getText("TXT_KEY_NEXT_WAR_BACKSTORY_TEXT", ()) + u"</font>"
					popupInfo.setText(szTitle + u"\n\n" + szBody)
					popupInfo.addPopup(iPlayer)

	def onBeginGameTurn(self, argsList):
		'Called at the beginning of the end of each turn'
		iGameTurn = argsList[0]
###circus hagenbeck start part 3		
		if (CyGame().getTurnYear(iGameTurn)>=1890) and ( iGameTurn % 3 ==0 ):
                        counter = 0
                        while True:
                                counter = counter+1
                                if counter>=100:break
                                dice = gc.getGame().getMapRand()
                                iPlayer = dice.get(gc.getMAX_PLAYERS (), "Players")
                                pPlayer = gc.getPlayer(iPlayer)
                                if pPlayer.isNone():continue
                                if pPlayer.isAlive():
                                        iCity = dice.get(pPlayer.getNumCities () , "Cities" )
                                        pCity = pPlayer.getCity(iCity)
                                        if pCity.isNone():continue
                                        pCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"),1)
                                        CyInterface().addMessage(iPlayer,false,20,CyTranslator().getText("TXT_KEY_CIRCUS_MOVED",(pCity.getName (),pCity.getName ())),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pCity.getX(), pCity.getY(), True,True) 
                                        if self.oldcity <>[-1,-1]:
                                                otherplayer = gc.getPlayer(self.oldcity[0])
                                                othercity = otherplayer.getCity(self.oldcity[1])
                                                if not othercity.isNone():
                                                        othercity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_CIRCUSHAGENBECK"),0)
                                                        CyInterface().addMessage(self.oldcity[0],false,20,CyTranslator().getText("TXT_KEY_CIRCUS_LOST",(othercity.getName (),othercity.getName ())),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), othercity.getX(), othercity.getY(), True,True)
                                        self.oldcity = [iPlayer,iCity]                                 
                                        
                                        break
###circus hagenbeck end part 3         
		
	def onCityRazed(self, argsList):
		'City Razed'
		city, iPlayer = argsList
		iOwner = city.findHighestCulture()
			
		#Raze the Arcology
		owner = PyPlayer(city.getOwner())
		razor = PyPlayer(iPlayer)
		
		self.iArcologyCityID = -1
		
		if city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY")) or city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING")) or city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
			self.iArcologyCityID = city.getID()
	
	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
		iOwner,pCity = argsList
		###from here 
		pPlayer = gc.getPlayer(iOwner) 
		if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_CRUSADE"))>0: 
			iStateReligion = pPlayer.getStateReligion () 
			if iStateReligion>=0: 
				if not pCity.isHasReligion(iStateReligion): 
					pCity.setHasReligion(iStateReligion,True,True,True)        
		CvUtil.pyPrint('City Acquired and Kept Event: %s' %(pCity.getName()))    
		
	def onCityDoTurn(self, argsList):
		'City Production'
		pCity = argsList[0]
		iPlayer = argsList[1]
		
# no anger defying UN resolutions start #
		iGovernmentCivicOption = CvUtil.findInfoTypeNum(gc.getCivicOptionInfo,gc.getNumCivicOptionInfos(),'CIVICOPTION_GOVERNMENT')
		iPoliceState = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_POLICE_STATE')
		pPlayer = gc.getPlayer(iPlayer)
		iGovernmentCivic = pPlayer.getCivics(iGovernmentCivicOption)

		if (iGovernmentCivic == iPoliceState):
			pCity.changeDefyResolutionAngerTimer(pCity.getDefyResolutionAngerTimer())
# no anger defying UN resolutions end #        

####### Next War Functions ######
## Added Fort to doCheckDepletion -- otherwise bonuses worked via forts would never be subject to resource depletion.   JKP


	def doCheckDepletion(self):
		self.doCheckWorkedResource("BONUS_ALUMINUM", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_ALUMINUM", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_BANANA", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_BANANA", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_CLAM", "IMPROVEMENT_FISHING_BOATS", 880)
		self.doCheckWorkedResource("BONUS_COAL", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_COAL", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_COPPER", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_COPPER", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_CORN", "IMPROVEMENT_FARM", 1120)
		self.doCheckWorkedResource("BONUS_CORN", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_COW", "IMPROVEMENT_PASTURE", 1120)
		self.doCheckWorkedResource("BONUS_COW", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_CRAB", "IMPROVEMENT_FISHING_BOATS", 1120)
		self.doCheckWorkedResource("BONUS_DEER", "IMPROVEMENT_CAMP", 780)
		self.doCheckWorkedResource("BONUS_DEER", "IMPROVEMENT_FORT", 780)
		self.doCheckWorkedResource("BONUS_DYE", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_DYE", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_FISH", "IMPROVEMENT_FISHING_BOATS", 880)
		self.doCheckWorkedResource("BONUS_FUR", "IMPROVEMENT_CAMP", 560)
		self.doCheckWorkedResource("BONUS_FUR", "IMPROVEMENT_FORT", 560)
		self.doCheckWorkedResource("BONUS_GEMS", "IMPROVEMENT_MINE", 1120)
		self.doCheckWorkedResource("BONUS_GEMS", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_GOLD", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_GOLD", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_HORSE", "IMPROVEMENT_PASTURE", 1120)
		self.doCheckWorkedResource("BONUS_HORSE", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_IRON", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_IRON", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_IVORY", "IMPROVEMENT_CAMP", 560)
		self.doCheckWorkedResource("BONUS_IVORY", "IMPROVEMENT_FORT", 560)
		self.doCheckWorkedResource("BONUS_MARBLE", "IMPROVEMENT_QUARRY", 750)
		self.doCheckWorkedResource("BONUS_MARBLE", "IMPROVEMENT_FORT", 750)
		self.doCheckWorkedResource("BONUS_OIL", "IMPROVEMENT_WELL", 880)
		self.doCheckWorkedResource("BONUS_OIL", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_OIL", "IMPROVEMENT_OFFSHORE_PLATFORM", 880)
		self.doCheckWorkedResource("BONUS_PIG", "IMPROVEMENT_PASTURE", 1120)
		self.doCheckWorkedResource("BONUS_PIG", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_RICE", "IMPROVEMENT_FARM", 1120)
		self.doCheckWorkedResource("BONUS_RICE", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_SILK", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_SILK", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_SILVER", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_SILVER", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_SPICES", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_SPICES", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_STONE", "IMPROVEMENT_QUARRY", 750)
		self.doCheckWorkedResource("BONUS_STONE", "IMPROVEMENT_FORT", 750)
		self.doCheckWorkedResource("BONUS_SUGAR", "IMPROVEMENT_PLANTATION", 1120)
		self.doCheckWorkedResource("BONUS_SUGAR", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_URANIUM", "IMPROVEMENT_MINE", 880)
		self.doCheckWorkedResource("BONUS_URANIUM", "IMPROVEMENT_FORT", 880)
		self.doCheckWorkedResource("BONUS_WHALE", "IMPROVEMENT_WHALING_BOATS", 560)
		self.doCheckWorkedResource("BONUS_WHEAT", "IMPROVEMENT_FARM", 1120)
		self.doCheckWorkedResource("BONUS_WHEAT", "IMPROVEMENT_FORT", 1120)
		self.doCheckWorkedResource("BONUS_WINE", "IMPROVEMENT_WINERY", 1120)
		self.doCheckWorkedResource("BONUS_WINE", "IMPROVEMENT_FORT", 1120)

	def doCheckWorkedResource(self, bonus, improvement, randomInt):
            
		iBonus = CvUtil.findInfoTypeNum(gc.getBonusInfo, gc.getNumBonusInfos(), bonus)
        
		if (iBonus == -1):
			return
        
		lValidPlots = self.getPlotListbyBonus(iBonus)
        
		if len(lValidPlots) == 0:
			return
                
##If you have the requisite improvement (incl. fort) or if the plot is being worked by a City, continue.
                        
			for plot in lValidPlots:
				P = False
                
				if plot.getImprovementType() == CvUtil.findInfoTypeNum(gc.getImprovementInfo, gc.getNumImprovementInfos(), improvement):
					P = True
				elif plot.isCity():
					P = True

				if P == True:
					if self.getRandomNumber(randomInt) == 0:
                    
						pBonusInfo = gc.getBonusInfo(iBonus)
                    
						plot.setBonusType(-1)
                    
						szTitle = localText.getText("TEXT_KEY_NEXT_WAR_RESOURCE_DEPLETED_TITLE", ())# (pBonusInfo.getDescription(), plotgetX(), plot.getY()))
                        #szText = localText.getText("TEXT_KEY_NEXT_WAR_RESOURCE_DEPLETED", (pBonusInfo.getDescription(), plot.getX(), plot.getY()))
                        #Not sure what the above commented out code for (debugging?) -- it was commented out in PM's original NextWar code.  JKP1187
                        
						CyInterface().addMessage(plot.getOwner(), False, gc.getEVENT_MESSAGE_TIME(), szTitle, "AS2D_DISCOVERBONUS", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT, pBonusInfo.getButton(), gc.getInfoTypeForString("COLOR_GREEN"), plot.getX(), plot.getY(), True, True)		
				else:
					return
				

### Below are additional functions necessary to the activity of the resource depl'n code:

	def getPlotListbyBonus(self, iBonus):
		lPlots = []
		totalPlots = gc.getMap().numPlots()
		
		for i in range(totalPlots):
			plot = gc.getMap().plotByIndex(i)
			iOwner = plot.getOwner()
			if (iOwner != -1):
				if plot.getBonusType(gc.getPlayer(iOwner).getTeam()) == iBonus:
					lPlots.append(plot)
		return lPlots

	def getRandomNumber(self, int):
		return gc.getGame().getSorenRandNum(int, "Next War")


# BUG - Next War Merge - start
	def initScriptData(self):
		
		# Set default script data manually since we need defaults for all values in the array before any functions can be called on them
		iDefaultNumNukesFired = 0
		SdToolkit.sdSetGlobal(SD_MOD_ID, SD_NUKES_ID, iDefaultNumNukesFired)
		
	def getGameNumNukes(self):
		return SdToolkit.sdGetGlobal(SD_MOD_ID, SD_NUKES_ID)

	def setGameNumNukes(self, iValue):
		SdToolkit.sdSetGlobal(SD_MOD_ID, SD_NUKES_ID, iValue)
		self.checkNukeStuff(iValue)
		
	def changeGameNumNukes(self, iChange):
		self.setGameNumNukes(self.getGameNumNukes() + iChange)
		
[COLOR="Blue"]	def checkNukeStuff(self, iNumNukes):
		
		print("iNumNukes")
		print(iNumNukes)
		print("g_iNumNukesGameOver")
		print(g_iNumNukesGameOver)
		
		# Amount of nukes matches Warning message
		if (CyMap().plot(0,0).getScriptData() == "Scenario"):
			if (iNumNukes == g_iNumNukesWarningMessage):
				self.addPopup("", localText.getText("TXT_KEY_ROUND_THREE_NUKE_WARNING", ()))
		
		# Amount of nukes matches Game over
			elif (iNumNukes == g_iNumNukesGameOver):
			
			# Show the screen that shows the world 'sploding
				CvScreensInterface.showNextWarScreen()
				gc.getGame().setWinner(18, 3)   [/COLOR]     
# BUG - Next War Merge - end

So, I'm going to go ahead and test out KRC now.
 
Thanks a lot, it looks like it works!

Spoiler :
attachment.php

Hopefully this means I can continue on without bothering you guys again, but I doubt that will actually happen. I truly appreciate the help you guys have given me and if you need anything at all please feel free to let me know. :goodjob:
 
Great I'm glad everything is working perfectly. Hope everything goes well for Diplomacy II! :)
 
Only a day and I'm already back! :lol:

This time it may not be my fault though, so I'm checking in here again to see if anyone wouldn't mind helping me out again.

I am adding a wonder to my mod (The Bamyan Buddha Statues, I made the buiding for it BTW) with some code that was originally written by Tsentom1, then amended by The_J to work this way (it was originally Tsentom1's Herc Factory). Basically the wonder is supposed to allow the builder to build more than the normal limit (in this case five, in my case six) on missionaries. Here is my amended DiplomacyGameUitls.py file, which is where it is supposed to go. I think Afforess mentioned that I didn't have to create event handlers in the DiplomacyGameUtils.py file, so I just added the code (which I colored blue here for convenience):

Code:
## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005
##
## Implementaion of miscellaneous game functions

import CvUtil
from CvPythonExtensions import *
import CvEventInterface

# globals
gc = CyGlobalContext()

class DiplomacyGameUtils:
	def canTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]
[COLOR="Blue"]## BAMYAN BUDDHA STATUES Start ##
		iMissionary = []
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_JEWISH_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CHRISTIAN_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ISLAMIC_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_HINDU_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_BUDDHIST_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CONFUCIAN_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_TAOIST_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_OLYMP_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ASEN_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_VOODOO_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_SHINTO_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ZORO_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_RA_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_TOLTEC_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_SHAMAN_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_LEVANT_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_DRUID_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ANUNNAKI_MISSIONARY'))        
		iMoreMissionariesWonder = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_BAMYAN')
		obsoleteTech = gc.getBuildingInfo(iMoreMissionariesWonder).getObsoleteTech()

		pPlayer = gc.getPlayer(pCity.getOwner())
		NumReligions = 18
		for i in range (NumReligions):
						if eUnit == iMissionary[i]:
								if pCity.isHasReligion(i):
										pUnit = gc.getUnitInfo (eUnit)
										Class = pUnit.getUnitClassType ()
										MissionaryCount = pPlayer.getUnitClassCount(Class)
										if MissionaryCount <6:
												if (gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
														for iCity in range(pPlayer.getNumCities()):
																ppCity = pPlayer.getCity(iCity)
																if ppCity.getNumActiveBuilding(iMoreMissionariesWonder) == true:
																		return True

## BAMYAN BUDDHA STATUES End ##[/COLOR]


		return False 
		
	def cannotConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		
		# player can't build an arcology if they have shielding or advanced shielding
		if eBuilding == gc.getInfoTypeForString("BUILDING_ARCOLOGY"):
			if pCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING")) or pCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
				return True
		
		# player can't build shielding if they have advanced
		if eBuilding == gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING"):
			if pCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
				return True

		return False

		
	def getUpgradePriceOverride(self, argsList):
		iPlayer, iUnitID, iUnitTypeUpgrade = argsList
		
## Leonardo's Workshop Start ##

		pPlayer = gc.getPlayer(iPlayer)
		pUnit = pPlayer.getUnit(iUnitID)

		iPrice = gc.getDefineINT("BASE_UNIT_UPGRADE_COST")
		iPrice += (max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION"))

		if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
			pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
			iPrice = iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100
			iPrice = iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100

		iPrice = iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100)

		b_Leonardo = gc.getInfoTypeForString("BUILDING_LEONARDO")
		obsoleteTech = gc.getBuildingInfo(b_Leonardo).getObsoleteTech()
		if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
			for iCity in range(pPlayer.getNumCities()):
				ppCity = pPlayer.getCity(iCity)
				if ppCity.getNumActiveBuilding(b_Leonardo) == true:
					iPrice = ((gc.getDefineINT("BASE_UNIT_UPGRADE_COST"))/2)
					iPrice += (((max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION")))/2)

					if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
						pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
						iPrice = ((iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100)/2)
						iPrice = ((iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100)/2)

						iPrice = ((iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100))/2)

		if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_LEADER')):

			iPrice = 0
		
		return iPrice

## Leonardo's Workshop End ##	

## Leonardo's Workshop Start ##	
#
## NOTE: You need to comment out (add a # before) the original return -1 (done below) ##
#
#		return -1	# Any value 0 or above will be used
#
## Leonardo's Workshop End ##

Now the first question I have is whether or not the code is just wrong or not? You will notice there are a lot more religions than there should be normally, this is because I have added them to the game, although they are only accessible with Choose Religions turned on.

After I posted that I saw something that could be a problem, could this be causing the issue?

Code:
									return True

## BAMYAN BUDDHA STATUES End ##


		return False

Anyway, thanks for taking a look at this, and if you see anything other than what is probably my mistake could you let me know so I could tell my buddy cybrxkhan?

:goodjob:

EDIT: I guess I should just mention that there were no assert failure or python failure pop-ups, the wonder just didn't work.
 
Other than being strangely over-indented, using the old findInfoTypeNum() function to find IDs instead of getInfoTypeForString(), and doing a lot of work for each call to canTrain() which could be done once when the mod loads . . . I see one problem:

Code:
if ppCity.getNumActiveBuilding(iMoreMissionariesWonder) [B][COLOR="Red"]== true[/COLOR][/B]:

CyCity.getNumActiveBuilding() returns the number of active buildings--not True or False as the old hasActiveBuilding() function it replaced did. Change this to

Code:
if ppCity.getNumActiveBuilding(iMoreMissionariesWonder) [B][COLOR="Red"]> 0[/COLOR][/B]:

However, true is defined as 1 which should make the wonder work when you have exactly one of them in one of your cities, so I don't know what's up.

Oh, I see another problem, but it won't be an issue if there is an obsoleting tech. You should still reverse the checks in this line:

Code:
if (gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):

to this

Code:
if (obsoleteTech == -1 or not gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech)):

You should add in some debugging print statements to the code to see if it's doing what you expect. For example:

Code:
if eUnit == iMissionary[i]:
	BugUtil.debug("Unit %d is a missionary for religion %d", eUnit, i)
	if pCity.isHasReligion(i):
		BugUtil.debug("City has correct religion")
		pUnit = gc.getUnitInfo (eUnit)
		...
		if MissionaryCount <6:
			BugUtil.debug("Player has less than 6 missionaries")
			...

That should be enough to demonstrate what to do. You'll need to import BugUtil at the top of the file:

Code:
import CvEventInterface
[B]import BugUtil[/B]

These messages will show up in Logs/PythonDbg.log as long as you turn on logging.
 
Thanks man, I'll try this out and let cyberxkhan know his code might be messed up. I didn't put in the debug part just yet (it seems a little complicated to me and I can't really tell where to put it by looking at that), but if it screws up again I'll try that out too. :goodjob:
 
Back
Top Bottom