HELP adding a python wonder to my mod!

The Capo

godless Heathen
Joined
Jan 29, 2001
Messages
9,302
Location
Washington, DC
Hey everyone, I have done this before but there seems to be some differences between what I am used to (well, sort of used to) and how GIR set up his mod. He has a pack of fifteen wonders to add to the game. I want to add the Machu Picchu wonder to my mod. To make this easier to follow I'll split this into two posts. The first will go over what GIR has in his code.

He appears to have the following python files that pertain to Machu Picchu.

First he has this in CvGameUtils:

Code:
	def cannotConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]

		### Petra Mod begins ###
		### Note: the code identifies the first building of a certain buildingclass in the CIV4BuildingInfos.xml file to be the default building
		###########################################################################################

		### find buildings with the same buildingClassType ###
		lgleicheBC = []
		buildingClassType = gc.getBuildingInfo(eBuilding).getBuildingClassType()
		for i in range(gc.getNumBuildingInfos()):
			if ( buildingClassType == gc.getBuildingInfo(i).getBuildingClassType() ):
				lgleicheBC.append(i)

		if ( len(lgleicheBC) >= 2 ):
			### is eBuilding the default building? ###
			if ( eBuilding == lgleicheBC[0] ):
				### do you have a "foreign" UB in the city? ###
				for i in range(len(lgleicheBC)-1):
					if ( pCity.getNumActiveBuilding(lgleicheBC[i +1])==true ):
						return True

		###########################################################################################
		### Petra Mod ends ###

[COLOR="Blue"]		### MachuPicchu Mod begins ###
		###########################################################################################

		if ( eBuilding == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU") ):

			### find peaks within the city radius controlled by your team ###
			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iPID = pPlayer.getID()
			iTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()
			for iXLoop in range(iX - 2, iX + 3, 1):
				for iYLoop in range(iY - 2, iY + 3, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					if ( pPlot.isPlayerCityRadius(iPID)==true ):
						if ( pPlot.getTeam()==iTID ):
							if ( pPlot.isPeak()==true  ):
								return False
			return True

		###########################################################################################
		### MachuPicchu Mod ends ###[/COLOR]

		return False

Then in his custom event manager file he has...

Code:
import CvEventManager
# --------- FlavianAmphitheatre -------------
import CvFlavianAmphitheatreEventManager
# --------- Petra -------------
import CvPetraEventManager
# --------- CircusMaximus -------------
import CvCircusMaximusEventManager
# --------- Partisan -------------
import CvPartisanEventManager
[COLOR="Blue"]# --------- MachuPicchu -------------
import CvMachuPicchuEventManager[/COLOR]
# --------- StackAid -------------
import CvStackAidEventManager
# --------- ViaAppia -------------
import CvViaAppiaEventManager
# --------- ForbiddenPalace -------------
import CvForbiddenPalaceEventManager
# --------- KGB Wonder -------------
import CvKGBEventManager
# --------- TemploMayor -------------
import CvTemploMayorEventManager
# --------- LeonardosWorkshop Wonder -------------
import CvLeonardosWorkshopEventManager

And

Code:
    def __init__(self, *args, **kwargs):
        super(CvCustomEventManager, self).__init__(*args, **kwargs)
        # map the initial EventHandlerMap values into the new data structure
        for eventType, eventHandler in self.EventHandlerMap.iteritems():
            self.setEventHandler(eventType, eventHandler)
        # --> INSERT EVENT HANDLER INITIALIZATION HERE <--

        # --------- FlavianAmphitheatre -------------
	CvFlavianAmphitheatreEventManager.CvFlavianAmphitheatreEventManager(self)
        # --------- Petra -------------
	CvPetraEventManager.CvPetraEventManager(self)
        # --------- CircusMaximus -------------
	CvCircusMaximusEventManager.CvCircusMaximusEventManager(self)
        # --------- Partisan -------------
	CvPartisanEventManager.CvPartisanEventManager(self)
[COLOR="Blue"]        # --------- MachuPicchu -------------
	CvMachuPicchuEventManager.CvMachuPicchuEventManager(self)[/COLOR]
        # --------- StackAid -------------
	CvStackAidEventManager.CvStackAidEventManager(self)
        # --------- ViaAppia -------------
	CvViaAppiaEventManager.CvViaAppiaEventManager(self)
        # --------- ForbiddenPalace -------------
	CvForbiddenPalaceEventManager.CvForbiddenPalaceEventManager(self)
        # --------- KGB Wonder -------------
	CvKGBEventManager.CvKGBEventManager(self)
        # --------- TemploMayor -------------
	CvTemploMayorEventManager.CvTemploMayorEventManager(self)
        # --------- LeonardosWorkshop Wonder -------------
	CvLeonardosWorkshopEventManager.CvLeonardosWorkshopEventManager(self)

Finally he has two different custom files for Machu Picchu, first he has CvMachuPicchuEventManager.py has this code in it:

Code:
# MachuPicchu
# CvMachuPicchuEventManager

from CvPythonExtensions import *
#import CvUtil
import CvEventManager
#import sys

# --------- MachuPicchu -------------
import MachuPicchu
gc = CyGlobalContext()	
MachuPicchu = MachuPicchu.MachuPicchu()

###################################################
class CvMachuPicchuEventManager(CvEventManager.CvEventManager):
	def __init__(self, eventManager):
		# initialize base class
		# --------- MachuPicchu -------------
		eventManager.addEventHandler("buildingBuilt", self.onBuildingBuilt)

	def onBuildingBuilt(self, argsList):
		MachuPicchu.onBuildingBuilt(argsList)

And then another file, MachuPicchu.py, has this in it:

Code:
############################
### MachuPicchu (by GIR) ###
############################

from CvPythonExtensions import *
import PyHelpers
gc = CyGlobalContext()

##################################################################################

class MachuPicchu:

	def onBuildingBuilt(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList

		if ( iBuildingType == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU") ):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iPID = pPlayer.getID()
			iTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()

			### check inner city radius for Peaks (MachuPicchu Wonder prefers to be in the inner city radius of the home city of this wonder) ###
			lPeakPlotX = []
			lPeakPlotY = []
			for iXLoop in range(iX - 1, iX + 2, 1):
				for iYLoop in range(iY - 1, iY + 2, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					if ( pPlot.isPlayerCityRadius(iPID)==true ):
						if ( pPlot.getTeam()==iTID ):
							if ( pPlot.isPeak()==true  ):
								lPeakPlotX.append(iXLoop)
								lPeakPlotY.append(iYLoop)

			if ( len(lPeakPlotX) < 1 ):

				### check all city radius plots for Peaks if no inner peak available ###
				lPeakPlotX = []
				lPeakPlotY = []
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if ( pPlot.isPeak()==true  ):
									lPeakPlotX.append(iXLoop)
									lPeakPlotY.append(iYLoop)

			if ( len(lPeakPlotX) > 0 ):
				it_machu_picchu = gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" )

				### set bonus for peaks in all city radius plots ###
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					iiX = ppCity.getX()
					iiY = ppCity.getY()
					### check all city radius plots for peak ###
					for iXLoop in range(iiX - 2, iiX + 3, 1):
						for iYLoop in range(iiY - 2, iiY + 3, 1):
							lPlot = CyMap().plot(iXLoop, iYLoop)
							if ( lPlot.isPlayerCityRadius(iPID)==true ):
								if ( lPlot.getTeam()==iTID ):
									if(lPlot.getTerrainType() != -1):
										if ( lPlot.isPeak()==true  ):
											lPlot.setImprovementType(it_machu_picchu)

				### now set bonus only with matchu picchu and remove matchu picchu (overlapping city radius) ###
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					iiX = ppCity.getX()
					iiY = ppCity.getY()
					### check all city radius plots for peak ###
					for iXLoop in range(iiX - 2, iiX + 3, 1):
						for iYLoop in range(iiY - 2, iiY + 3, 1):
							lPlot = CyMap().plot(iXLoop, iYLoop)
							if ( lPlot.isPlayerCityRadius(iPID)==true ):
								if ( lPlot.getTeam()==iTID ):
									if(lPlot.getTerrainType() != -1):
										if ( lPlot.isPeak()==true  ):
											if ( lPlot.getImprovementType() == it_machu_picchu ):
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_FOOD, 1)
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_PRODUCTION, 2)
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)
												lPlot.setImprovementType(-1)

												### ausgabe ###
												CyInterface().addMessage(iPID,True,0,' ','',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_211.dds',ColorTypes(5), iXLoop, iYLoop,True,True)


				### set machu picchu on hill ###
				### get random Peak from list ###
				iRand = CyGame().getSorenRandNum( len(lPeakPlotX), "Random Peak")
				iXPeak = lPeakPlotX[iRand]
				iYPeak = lPeakPlotY[iRand]
				pPeakPlot = CyMap().plot(iXPeak, iYPeak)
				#pPeakPlot.setFeatureType(gc.getInfoTypeForString( "FEATURE_FOREST" ), 1)
				pPeakPlot.setImprovementType(gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" ))
				CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_FOOD, 1)
				CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_COMMERCE, 6)
				plot_culture_1_10 = int(pPeakPlot.getCulture(iPID) * 0.10)
				pPeakPlot.changeCulture(iPID, plot_culture_1_10, true)

				### ausgabe ###
				CyInterface().addMessage(iPID,false,10,CyTranslator().getText("TXT_KEY_MACHU_PICCHU_GAMETXT1",(iXPeak,iXPeak)),'',0,gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_MACHU_PICCHU")).getButton(),ColorTypes(5), iXPeak, iYPeak,True,True)
				### message: The Machu Picchu provides some benefits from Peaks! ###

				### set additional bonus for peaks in the wonder city radius ###
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if(pPlot.getTerrainType() != -1):
									if ( pPlot.isPeak()==true  ):
											CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)

											### ausgabe ###
											if ( iXLoop != iXPeak or iYLoop != iYPeak ):
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_212.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
											else:
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_218.dds',ColorTypes(5), iXLoop, iYLoop,True,True)

So that is all the stuff GIR has going on in his pack of wonders. For now I only want to take Machu Picchu out and add it to my mod. This seems like more files than necessary, at least the way I have been taught to do it. My mod uses BUG by the way. I am not asking for anyone to do this for me, so much as I am asking if the next post is correct (i.e., if you read this before my next post, wait a second, I'm probably writing it right now).
 
Okay, so that was GIR's stuff. I have two customized files for my mod (which is called Diplomacy II). From what I can gather, what I should be adding the highlited (in red) parts like this to the DiplomacyEventManager.py file:

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)
[COLOR="Red"]		eventManager.addEventHandler("buildingBuilt", self.onBuildingBuilt)[/COLOR]
		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]                                 
                                        MaxPlayers = gc.getMAX_CIV_PLAYERS ()
                                        for iPlayerNum in xrange(MaxPlayers):
                                            CyInterface().addMessage(iPlayerNum,false,20,CyTranslator().getText("TXT_KEY_CIRCUS_ANNOUNCE",(pCity.getName (),pPlayer.getCivilizationAdjective () )),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pCity.getX(), pCity.getY(), True,True) 
                                        
                                        break
###circus hagenbeck end part 3

[COLOR="Red"]   	def onBuildingBuilt(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList

		if ( iBuildingType == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU") ):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iPID = pPlayer.getID()
			iTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()

			### check inner city radius for Peaks (MachuPicchu Wonder prefers to be in the inner city radius of the home city of this wonder) ###
			lPeakPlotX = []
			lPeakPlotY = []
			for iXLoop in range(iX - 1, iX + 2, 1):
				for iYLoop in range(iY - 1, iY + 2, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					if ( pPlot.isPlayerCityRadius(iPID)==true ):
						if ( pPlot.getTeam()==iTID ):
							if ( pPlot.isPeak()==true  ):
								lPeakPlotX.append(iXLoop)
								lPeakPlotY.append(iYLoop)

			if ( len(lPeakPlotX) < 1 ):

				### check all city radius plots for Peaks if no inner peak available ###
				lPeakPlotX = []
				lPeakPlotY = []
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if ( pPlot.isPeak()==true  ):
									lPeakPlotX.append(iXLoop)
									lPeakPlotY.append(iYLoop)

			if ( len(lPeakPlotX) > 0 ):
				it_machu_picchu = gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" )

				### set bonus for peaks in all city radius plots ###
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					iiX = ppCity.getX()
					iiY = ppCity.getY()
					### check all city radius plots for peak ###
					for iXLoop in range(iiX - 2, iiX + 3, 1):
						for iYLoop in range(iiY - 2, iiY + 3, 1):
							lPlot = CyMap().plot(iXLoop, iYLoop)
							if ( lPlot.isPlayerCityRadius(iPID)==true ):
								if ( lPlot.getTeam()==iTID ):
									if(lPlot.getTerrainType() != -1):
										if ( lPlot.isPeak()==true  ):
											lPlot.setImprovementType(it_machu_picchu)

				### now set bonus only with matchu picchu and remove matchu picchu (overlapping city radius) ###
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					iiX = ppCity.getX()
					iiY = ppCity.getY()
					### check all city radius plots for peak ###
					for iXLoop in range(iiX - 2, iiX + 3, 1):
						for iYLoop in range(iiY - 2, iiY + 3, 1):
							lPlot = CyMap().plot(iXLoop, iYLoop)
							if ( lPlot.isPlayerCityRadius(iPID)==true ):
								if ( lPlot.getTeam()==iTID ):
									if(lPlot.getTerrainType() != -1):
										if ( lPlot.isPeak()==true  ):
											if ( lPlot.getImprovementType() == it_machu_picchu ):
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_FOOD, 1)
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_PRODUCTION, 2)
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)
												lPlot.setImprovementType(-1)

												### ausgabe ###
												CyInterface().addMessage(iPID,True,0,' ','',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_211.dds',ColorTypes(5), iXLoop, iYLoop,True,True)


				### set machu picchu on hill ###
				### get random Peak from list ###
				iRand = CyGame().getSorenRandNum( len(lPeakPlotX), "Random Peak")
				iXPeak = lPeakPlotX[iRand]
				iYPeak = lPeakPlotY[iRand]
				pPeakPlot = CyMap().plot(iXPeak, iYPeak)
				#pPeakPlot.setFeatureType(gc.getInfoTypeForString( "FEATURE_FOREST" ), 1)
				pPeakPlot.setImprovementType(gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" ))
				CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_FOOD, 1)
				CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_COMMERCE, 6)
				plot_culture_1_10 = int(pPeakPlot.getCulture(iPID) * 0.10)
				pPeakPlot.changeCulture(iPID, plot_culture_1_10, true)

				### ausgabe ###
				CyInterface().addMessage(iPID,false,10,CyTranslator().getText("TXT_KEY_MACHU_PICCHU_GAMETXT1",(iXPeak,iXPeak)),'',0,gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_MACHU_PICCHU")).getButton(),ColorTypes(5), iXPeak, iYPeak,True,True)
				### message: The Machu Picchu provides some benefits from Peaks! ###

				### set additional bonus for peaks in the wonder city radius ###
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if(pPlot.getTerrainType() != -1):
									if ( pPlot.isPeak()==true  ):
											CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)

											### ausgabe ###
											if ( iXLoop != iXPeak or iYLoop != iYPeak ):
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_212.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
											else:
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_218.dds',ColorTypes(5), iXLoop, iYLoop,True,True)[/COLOR]
				      
		
	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)
		
	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)        
# BUG - Next War Merge - end

Alright, so I think that is correct so far, but then don't I also have to edit my DiplomacyGameUtils.py file to look like this?

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

import CvUtil
from CvPythonExtensions import *
import CvEventInterface
import BugUtil

# 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]
## 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]:
								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)
										Class = pUnit.getUnitClassType ()
										MissionaryCount = pPlayer.getUnitClassCount(Class)
										if MissionaryCount <6:
												BugUtil.debug("Player has less than 6 missionaries")
												if (obsoleteTech == -1 or not gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech)):
														for iCity in range(pPlayer.getNumCities()):
																ppCity = pPlayer.getCity(iCity)
																if ppCity.getNumActiveBuilding(iMoreMissionariesWonder) > 0:
																		return True

## BAMYAN BUDDHA STATUES End ##


		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
                
[COLOR="Red"]		### MachuPicchu Mod begins ###
		###########################################################################################

		if ( eBuilding == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU") ):

			### find peaks within the city radius controlled by your team ###
			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iPID = pPlayer.getID()
			iTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()
			for iXLoop in range(iX - 2, iX + 3, 1):
				for iYLoop in range(iY - 2, iY + 3, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					if ( pPlot.isPlayerCityRadius(iPID)==true ):
						if ( pPlot.getTeam()==iTID ):
							if ( pPlot.isPeak()==true  ):
								return False
			return True

		###########################################################################################
		### MachuPicchu Mod ends ###                [/COLOR]

		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 ##

Then I think I have to enable a callback in the python callback XML file? Is this all correct or am I missing a step?

Thanks in advance to anyone who can help me here.
 
Looks like you got it. Good job on folding the event manager into yours without using two classes like GIR did. Have you tried running it to see what happens? If it works, you will have spent a lot of time posting all that for nothing. ;)
 
Looks like you got it. Good job on folding the event manager into yours without using two classes like GIR did. Have you tried running it to see what happens? If it works, you will have spent a lot of time posting all that for nothing. ;)

I haven't checked it just yet, I still have two outstanding python things I'd rather handle first before moving (although I am aware it doesn't really matter, it's just easier for me to handle one thing at a time) but those are not really issues with the format or anything, the code just doesn't work properly. But thanks, and sometimes I post things around here so I can go back and reference them later. :goodjob:

I do sort of have a follow up question I guess, I have attached an image of the Machu Picchu building I made, obviously it doesn't need a peak to sit on (because the model already has a peak in it), plus I want to give it that green look it has. Anyway, I noticed this stuff...

Code:
   	[COLOR="Red"]def onBuildingBuilt(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList

		if ( iBuildingType == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU") ):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iPID = pPlayer.getID()
			iTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()

			### check inner city radius for Peaks (MachuPicchu Wonder prefers to be in the inner city radius of the home city of this wonder) ###
			lPeakPlotX = []
			lPeakPlotY = []
			for iXLoop in range(iX - 1, iX + 2, 1):
				for iYLoop in range(iY - 1, iY + 2, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					if ( pPlot.isPlayerCityRadius(iPID)==true ):
						if ( pPlot.getTeam()==iTID ):
							if ( pPlot.isPeak()==true  ):
								lPeakPlotX.append(iXLoop)
								lPeakPlotY.append(iYLoop)

			if ( len(lPeakPlotX) < 1 ):

				### check all city radius plots for Peaks if no inner peak available ###
				lPeakPlotX = []
				lPeakPlotY = []
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if ( pPlot.isPeak()==true  ):
									lPeakPlotX.append(iXLoop)
									lPeakPlotY.append(iYLoop)

			if ( len(lPeakPlotX) > 0 ):
				it_machu_picchu = gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" )[/COLOR]
				### set bonus for peaks in all city radius plots ###
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					iiX = ppCity.getX()
					iiY = ppCity.getY()
					### check all city radius plots for peak ###
					for iXLoop in range(iiX - 2, iiX + 3, 1):
						for iYLoop in range(iiY - 2, iiY + 3, 1):
							lPlot = CyMap().plot(iXLoop, iYLoop)
							if ( lPlot.isPlayerCityRadius(iPID)==true ):
								if ( lPlot.getTeam()==iTID ):
									if(lPlot.getTerrainType() != -1):
										if ( lPlot.isPeak()==true  ):
											lPlot.setImprovementType(it_machu_picchu)

				### now set bonus only with matchu picchu and remove matchu picchu (overlapping city radius) ###
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					iiX = ppCity.getX()
					iiY = ppCity.getY()
					### check all city radius plots for peak ###
					for iXLoop in range(iiX - 2, iiX + 3, 1):
						for iYLoop in range(iiY - 2, iiY + 3, 1):
							lPlot = CyMap().plot(iXLoop, iYLoop)
							if ( lPlot.isPlayerCityRadius(iPID)==true ):
								if ( lPlot.getTeam()==iTID ):
									if(lPlot.getTerrainType() != -1):
										if ( lPlot.isPeak()==true  ):
											if ( lPlot.getImprovementType() == it_machu_picchu ):
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_FOOD, 1)
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_PRODUCTION, 2)
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)
												lPlot.setImprovementType(-1)

												### ausgabe ###
												CyInterface().addMessage(iPID,True,0,' ','',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_211.dds',ColorTypes(5), iXLoop, iYLoop,True,True)


				### set machu picchu on hill ###
				### get random Peak from list ###
				iRand = CyGame().getSorenRandNum( len(lPeakPlotX), "Random Peak")
				iXPeak = lPeakPlotX[iRand]
				iYPeak = lPeakPlotY[iRand]
				pPeakPlot = CyMap().plot(iXPeak, iYPeak)
				#pPeakPlot.setFeatureType(gc.getInfoTypeForString( "FEATURE_FOREST" ), 1)
				pPeakPlot.setImprovementType(gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" ))
				CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_FOOD, 1)
				CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_COMMERCE, 6)
				plot_culture_1_10 = int(pPeakPlot.getCulture(iPID) * 0.10)
				pPeakPlot.changeCulture(iPID, plot_culture_1_10, true)

				### ausgabe ###
				CyInterface().addMessage(iPID,false,10,CyTranslator().getText("TXT_KEY_MACHU_PICCHU_GAMETXT1",(iXPeak,iXPeak)),'',0,gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_MACHU_PICCHU")).getButton(),ColorTypes(5), iXPeak, iYPeak,True,True)
				### message: The Machu Picchu provides some benefits from Peaks! ###

				### set additional bonus for peaks in the wonder city radius ###
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if(pPlot.getTerrainType() != -1):
									if ( pPlot.isPeak()==true  ):
											CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)

											### ausgabe ###
											if ( iXLoop != iXPeak or iYLoop != iYPeak ):
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_212.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
											else:
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_218.dds',ColorTypes(5), iXLoop, iYLoop,True,True)

Since this is like reading a bunch of Greek to me (and no I do not know how to read Greek) could you tell me which parts, or part, of this tells the game to put the building model itself on a peak tile?
 
The red code scans the first ring around the city for peaks. If it finds none, it next scans all tiles in the BFC (including the first ring again) for peaks.

The code that follows is a bit hard to parse at lunch, but it scans all cities twice. The first time it sets the improvement type to Machu Picchu. In the second loop it removes the improvement and sets the yield. The comment says it does this to avoid setting the yield twice. If setExtraYield() actually adds the yield, then this is needed (but could be done better). If not, this is not needed and the loops could be combined. I'm aware you aren't going to do that; just thought I'd be thorough. ;)
 
Since this is like reading a bunch of Greek to me (and no I do not know how to read Greek) could you tell me which parts, or part, of this tells the game to put the building model itself on a peak tile?

This part:
Code:
				### set machu picchu on hill ###
				### get random Peak from list ###
				iRand = CyGame().getSorenRandNum( len(lPeakPlotX), "Random Peak")
				iXPeak = lPeakPlotX[iRand]
				iYPeak = lPeakPlotY[iRand]
				pPeakPlot = CyMap().plot(iXPeak, iYPeak)
				#pPeakPlot.setFeatureType(gc.getInfoTypeForString( "FEATURE_FOREST" ), 1)
				pPeakPlot.setImprovementType(gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" ))
				CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_FOOD, 1)
				CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_COMMERCE, 6)
				plot_culture_1_10 = int(pPeakPlot.getCulture(iPID) * 0.10)
				pPeakPlot.changeCulture(iPID, plot_culture_1_10, true)

It picks a random plot from the list of peaks, adds the model to it (it has it as an improvement), and then adjusts that plot's food, commerce, and culture.
 
Well, what I want is for all the peaks in a city's radius to get the bonus effects from the wonder. So my questions are (a) does this do that as it is, and (b) how can I remove the building from being on a peak?

The reason I ask (b) is because this is the model I have made for it (attached) and I'd like to use this model rather than whatever came with GIR's modcomps.

EDIT: Hmm, according to the text in this what it does is give the bonus benefits to all of the peak tiles in the city's radius and then puts one improvement on one tile which gives it extra benefits. Are there two models then? Like the one I would use and then an improvement model that goes on the peak or is there just the one model? I'm obviously confused here, I can't read this stuff. Anyway, I'll go on a test run and see what happens. :goodjob:
 
Alright, I tried it out. Didn't work, can anyone tell what I did wrong?

Here is my DiplomacyEventManager.py file:

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)
[COLOR="Red"]		eventManager.addEventHandler("buildingBuilt", self.onBuildingBuilt)[/COLOR]
		eventManager.addEventHandler("cityRazed", self.onCityRazed)
		eventManager.addEventHandler("cityAcquiredAndKept", self.onCityAcquiredAndKept)        
		eventManager.addEventHandler("cityDoTurn", self.onCityDoTurn)
		eventManager.addEventHandler("buildingBuilt", self.onBuildingBuilt)        

		###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]                                 
                                        MaxPlayers = gc.getMAX_CIV_PLAYERS ()
                                        for iPlayerNum in xrange(MaxPlayers):
                                            CyInterface().addMessage(iPlayerNum,false,20,CyTranslator().getText("TXT_KEY_CIRCUS_ANNOUNCE",(pCity.getName (),pPlayer.getCivilizationAdjective () )),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pCity.getX(), pCity.getY(), True,True) 
                                        
                                        break
###circus hagenbeck end part 3
[COLOR="Red"]   	def onBuildingBuilt(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList

		if ( iBuildingType == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU") ):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iPID = pPlayer.getID()
			iTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()

			### check inner city radius for Peaks (MachuPicchu Wonder prefers to be in the inner city radius of the home city of this wonder) ###
			lPeakPlotX = []
			lPeakPlotY = []
			for iXLoop in range(iX - 1, iX + 2, 1):
				for iYLoop in range(iY - 1, iY + 2, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					if ( pPlot.isPlayerCityRadius(iPID)==true ):
						if ( pPlot.getTeam()==iTID ):
							if ( pPlot.isPeak()==true  ):
								lPeakPlotX.append(iXLoop)
								lPeakPlotY.append(iYLoop)

			if ( len(lPeakPlotX) < 1 ):

				### check all city radius plots for Peaks if no inner peak available ###
				lPeakPlotX = []
				lPeakPlotY = []
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if ( pPlot.isPeak()==true  ):
									lPeakPlotX.append(iXLoop)
									lPeakPlotY.append(iYLoop)

			if ( len(lPeakPlotX) > 0 ):
				it_machu_picchu = gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" )

				### set bonus for peaks in all city radius plots ###
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					iiX = ppCity.getX()
					iiY = ppCity.getY()
					### check all city radius plots for peak ###
					for iXLoop in range(iiX - 2, iiX + 3, 1):
						for iYLoop in range(iiY - 2, iiY + 3, 1):
							lPlot = CyMap().plot(iXLoop, iYLoop)
							if ( lPlot.isPlayerCityRadius(iPID)==true ):
								if ( lPlot.getTeam()==iTID ):
									if(lPlot.getTerrainType() != -1):
										if ( lPlot.isPeak()==true  ):
											lPlot.setImprovementType(it_machu_picchu)

				### now set bonus only with matchu picchu and remove matchu picchu (overlapping city radius) ###
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					iiX = ppCity.getX()
					iiY = ppCity.getY()
					### check all city radius plots for peak ###
					for iXLoop in range(iiX - 2, iiX + 3, 1):
						for iYLoop in range(iiY - 2, iiY + 3, 1):
							lPlot = CyMap().plot(iXLoop, iYLoop)
							if ( lPlot.isPlayerCityRadius(iPID)==true ):
								if ( lPlot.getTeam()==iTID ):
									if(lPlot.getTerrainType() != -1):
										if ( lPlot.isPeak()==true  ):
											if ( lPlot.getImprovementType() == it_machu_picchu ):
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_FOOD, 1)
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_PRODUCTION, 2)
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)
												lPlot.setImprovementType(-1)

												### ausgabe ###
												CyInterface().addMessage(iPID,True,0,' ','',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_211.dds',ColorTypes(5), iXLoop, iYLoop,True,True)


				### set machu picchu on hill ###
				### get random Peak from list ###
				iRand = CyGame().getSorenRandNum( len(lPeakPlotX), "Random Peak")
				iXPeak = lPeakPlotX[iRand]
				iYPeak = lPeakPlotY[iRand]
				pPeakPlot = CyMap().plot(iXPeak, iYPeak)
				#pPeakPlot.setFeatureType(gc.getInfoTypeForString( "FEATURE_FOREST" ), 1)
				pPeakPlot.setImprovementType(gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" ))
				CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_FOOD, 1)
				CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_COMMERCE, 6)
				plot_culture_1_10 = int(pPeakPlot.getCulture(iPID) * 0.10)
				pPeakPlot.changeCulture(iPID, plot_culture_1_10, true)

				### ausgabe ###
				CyInterface().addMessage(iPID,false,10,CyTranslator().getText("TXT_KEY_MACHU_PICCHU_GAMETXT1",(iXPeak,iXPeak)),'',0,gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_MACHU_PICCHU")).getButton(),ColorTypes(5), iXPeak, iYPeak,True,True)
				### message: The Machu Picchu provides some benefits from Peaks! ###

				### set additional bonus for peaks in the wonder city radius ###
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if(pPlot.getTerrainType() != -1):
									if ( pPlot.isPeak()==true  ):
											CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)

											### ausgabe ###
											if ( iXLoop != iXPeak or iYLoop != iYPeak ):
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_212.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
											else:
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_218.dds',ColorTypes(5), iXLoop, iYLoop,True,True)[/COLOR]
				      
		

		
	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 onBuildingBuilt(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList
		game = gc.getGame()
###from here
		if iBuildingType == gc.getInfoTypeForString("BUILDING_SYDNEY_OPERA_HOUSE"):
			pPlayer = gc.getPlayer(pCity.getOwner())
			pPlayer.initUnit(gc.getInfoTypeForString("UNIT_ARTIST"),pCity.getX(),pCity.getY(),UnitAITypes.UNITAI_ARTIST,DirectionTypes.NO_DIRECTION )  



	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)
		
	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)        
# BUG - Next War Merge - end

Then the rest of the code is in the DiplomacyGameUtils.py file:

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

import CvUtil
from CvPythonExtensions import *
import CvEventInterface
import BugUtil

# 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]
## 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]:
								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)
										Class = pUnit.getUnitClassType ()
										MissionaryCount = pPlayer.getUnitClassCount(Class)
										if MissionaryCount <6:
												BugUtil.debug("Player has less than 6 missionaries")
												if (obsoleteTech == -1 or not gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech)):
														for iCity in range(pPlayer.getNumCities()):
																ppCity = pPlayer.getCity(iCity)
																if ppCity.getNumActiveBuilding(iMoreMissionariesWonder) > 0:
																		return True

## BAMYAN BUDDHA STATUES End ##


		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
				
[COLOR="Red"]		### MachuPicchu Mod begins ###
		###########################################################################################

		if ( eBuilding == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU") ):

			### find peaks within the city radius controlled by your team ###
			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iPID = pPlayer.getID()
			iTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()
			for iXLoop in range(iX - 2, iX + 3, 1):
				for iYLoop in range(iY - 2, iY + 3, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					if ( pPlot.isPlayerCityRadius(iPID)==true ):
						if ( pPlot.getTeam()==iTID ):
							if ( pPlot.isPeak()==true  ):
								return False
			return True

		###########################################################################################
		### MachuPicchu Mod ends ### [/COLOR]                

		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 ##
 
Sorry, there were too many characters in my last post so I had to keep it short. All of the stuff I added to the python shown in the last post is highlited in RED. When I loaded the mod I got that first assert failure. I got no python errors when I built the wonder, so I'm assuming that the python wasn't read, although why would there be a python error? So now I'm assuming that a portion of the python wasn't read. Maybe I did something wrong with my PythonCallback file?

Code:
<?xml version="1.0"?>
<!-- Sid Meier's Civilization 4 -->
<!-- Copyright Firaxis Games 2005 -->
<!-- -->
<!-- Global Defines -->
<Civ4Defines xmlns="x-schema:CIV4GlobalDefinesSchema.xml">
	<Define>
		<DefineName>USE_CANNOT_FOUND_CITY_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_CAN_FOUND_CITIES_ON_WATER_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_IS_PLAYER_RESEARCH_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_CAN_RESEARCH_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_CANNOT_DO_CIVIC_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_CAN_DO_CIVIC_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_CANNOT_CONSTRUCT_CALLBACK</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_CAN_CONSTRUCT_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_CAN_DECLARE_WAR_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_CANNOT_RESEARCH_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_GET_UNIT_COST_MOD_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_GET_BUILDING_COST_MOD_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_GET_CITY_FOUND_VALUE_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_CANNOT_HANDLE_ACTION_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_CAN_BUILD_CALLBACK</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_CANNOT_TRAIN_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_CAN_TRAIN_CALLBACK</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_UNIT_CANNOT_MOVE_INTO_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_CANNOT_SPREAD_RELIGION_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_FINISH_TEXT_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_ON_UNIT_SET_XY_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_ON_UNIT_SELECTED_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_ON_UPDATE_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_ON_UNIT_CREATED_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_ON_UNIT_LOST_CALLBACK</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
</Civ4Defines>

Or perhaps my CapoSettings file isn't correct?

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>

<mod id="TheCapoSettings"
    module="DiplomacyEventManager" 
    name="NewMOD" 
    author="TheCapo" 
    version="1.0" 
    date="01/29/2010"
    url="">
    
    <events module="DiplomacyEventManager"/>
     
    <gameutils module="DiplomacyGameUtils" class="DiplomacyGameUtils" override="True"/>
</mod>

If anyone could help me identify what it is I did or did not do correctly here that would be fantastic. :goodjob:
 
You need to be more detailed about what's happening vs. what you expect to see. Posting a bunch of code and hoping someone can figure out the problem is unlikely to produce satisfactory results. Your configuration XML looks fine. Are your events/callbacks firing? Have you tried adding debug messages to figure out what's going wrong? Do you get Python errors in PythonErr.log?
 
You need to be more detailed about what's happening vs. what you expect to see. Posting a bunch of code and hoping someone can figure out the problem is unlikely to produce satisfactory results. Your configuration XML looks fine. Are your events/callbacks firing? Have you tried adding debug messages to figure out what's going wrong? Do you get Python errors in PythonErr.log?

I did explain all of that, its just over the course of a few posts becuase I couldn't fit all of the characters. But to answer your questions; nothing is happening, I build the wonder and that's it, there are no errors or pop-ups, the wonder just doesn't do what it is supposed to do. I don't know what you mean by events and callbacks firing, but I guess the answer to that would be no. I don't really know how to read the python log, but I have the debugging on right now, so I guess I'll play a game, build the wonder and see if I get anything.

I did start getting this assert failure after merging the wonder in. It appears when I am starting a new game during the loading process:


The only instance of the NO_IMPROVEMENT tag that I see anywhere is in the Civ4PlotLSystem.xml file, but that comes with Cultural Citystyles and I haven't had an issue with that, so I'm thinking that somwhere in that code there is something that references it and there is some type of problem with it.
 
I think I found the error, not sure about it though. But you got two onBuildingBuilts in your DiplomacyEventManager.py. I had to read your code parts three times before I noticed that. :lol:
You also got one tab too much between the lines in red. I'm not sure how much python cares about white space, but I don't think it would hurt to fix that.
Code:
				### set additional bonus for peaks in the wonder city radius ###
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if(pPlot.getTerrainType() != -1):
									[COLOR="Red"]if ( pPlot.isPeak()==true  ):
											CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)[/COLOR]

											### ausgabe ###
											if ( iXLoop != iXPeak or iYLoop != iYPeak ):
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_212.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
											else:
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_218.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
 
Good catch on the function name. The last function will hide the one defined before it.

As for indentation, Python is very picky that it match other lines indented to the same level in the same block, or that you indent after an if: or else:, etc. It doesn't care about how much you indent (one or two or 45 tabs), as long as it matches the other lines around it that are at the same level. That being said, I would highly recommend fixing it just the same. You can never be too careful where Python and indentation are concerned.
 
I just wonder why this kind of assert failures are always about EpisionageMissionInfos. Does it have something to do with the load order, because if I remember right they are loaded last.

Yes, Xienwolf has explained it like that. Every error, which occurrs after loading the XML files (which then are probably python errors) will be connected to the last XML file.
 
Okay guys, I got rid of the extra event handler and the extra function (i.e. combined the two into one function) and it still didn't work. Although there is a strong chance I screwed something up. I still got that NO_IMPROVEMENT assert failure when starting a game and on the dawn of man screen it said there was a failure to parse my TheCapoSettings.xml file (see attached screen-shot) at line 11.

I didn't change that file, but just in case this is what it says (line 11 is hilighted in red):

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>

<mod id="TheCapoSettings"
    module="DiplomacyEventManager" 
    name="NewMOD" 
    author="TheCapo" 
    version="1.0" 
    date="01/29/2010"
    url="">
    
[COLOR="Red"]    <events module="DiplomacyEventManager"/>[/COLOR]
     
    <gameutils module="DiplomacyGameUtils" class="DiplomacyGameUtils" override="True"/>
</mod>

So I'm assuming I must have put the python code in wrong. Here is what I did, it is the combination of the two functions I had before, I have hilighted all of the Machu Picchu parts in red:

Code:
	def onBuildingBuilt(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList
		game = gc.getGame()
###from here
		if iBuildingType == gc.getInfoTypeForString("BUILDING_SYDNEY_OPERA_HOUSE"):
			pPlayer = gc.getPlayer(pCity.getOwner())
			pPlayer.initUnit(gc.getInfoTypeForString("UNIT_ARTIST"),pCity.getX(),pCity.getY(),UnitAITypes.UNITAI_ARTIST,DirectionTypes.NO_DIRECTION )  
		if iBuildingType == gc.getInfoTypeForString("BUILDING_CERN"):
			pPlayer = gc.getPlayer(pCity.getOwner())
			pPlayer.initUnit(gc.getInfoTypeForString("UNIT_SCIENTIST"),pCity.getX(),pCity.getY(),UnitAITypes.UNITAI_SCIENTIST,DirectionTypes.NO_DIRECTION )            
		
[COLOR="Red"]		if ( iBuildingType == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU") ):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iPID = pPlayer.getID()
			iTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()

			### check inner city radius for Peaks (MachuPicchu Wonder prefers to be in the inner city radius of the home city of this wonder) ###
			lPeakPlotX = []
			lPeakPlotY = []
			for iXLoop in range(iX - 1, iX + 2, 1):
				for iYLoop in range(iY - 1, iY + 2, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					if ( pPlot.isPlayerCityRadius(iPID)==true ):
						if ( pPlot.getTeam()==iTID ):
							if ( pPlot.isPeak()==true  ):
								lPeakPlotX.append(iXLoop)
								lPeakPlotY.append(iYLoop)

			if ( len(lPeakPlotX) < 1 ):

				### check all city radius plots for Peaks if no inner peak available ###
				lPeakPlotX = []
				lPeakPlotY = []
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if ( pPlot.isPeak()==true  ):
									lPeakPlotX.append(iXLoop)
									lPeakPlotY.append(iYLoop)

			if ( len(lPeakPlotX) > 0 ):
				it_machu_picchu = gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" )

				### set bonus for peaks in all city radius plots ###
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					iiX = ppCity.getX()
					iiY = ppCity.getY()
					### check all city radius plots for peak ###
					for iXLoop in range(iiX - 2, iiX + 3, 1):
						for iYLoop in range(iiY - 2, iiY + 3, 1):
							lPlot = CyMap().plot(iXLoop, iYLoop)
							if ( lPlot.isPlayerCityRadius(iPID)==true ):
								if ( lPlot.getTeam()==iTID ):
									if(lPlot.getTerrainType() != -1):
										if ( lPlot.isPeak()==true  ):
											lPlot.setImprovementType(it_machu_picchu)

				### now set bonus only with matchu picchu and remove matchu picchu (overlapping city radius) ###
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					iiX = ppCity.getX()
					iiY = ppCity.getY()
					### check all city radius plots for peak ###
					for iXLoop in range(iiX - 2, iiX + 3, 1):
						for iYLoop in range(iiY - 2, iiY + 3, 1):
							lPlot = CyMap().plot(iXLoop, iYLoop)
							if ( lPlot.isPlayerCityRadius(iPID)==true ):
								if ( lPlot.getTeam()==iTID ):
									if(lPlot.getTerrainType() != -1):
										if ( lPlot.isPeak()==true  ):
											if ( lPlot.getImprovementType() == it_machu_picchu ):
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_FOOD, 1)
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_PRODUCTION, 2)
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)
												lPlot.setImprovementType(-1)

												### ausgabe ###
												CyInterface().addMessage(iPID,True,0,' ','',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_211.dds',ColorTypes(5), iXLoop, iYLoop,True,True)


				### set machu picchu on hill ###
				### get random Peak from list ###
				iRand = CyGame().getSorenRandNum( len(lPeakPlotX), "Random Peak")
				iXPeak = lPeakPlotX[iRand]
				iYPeak = lPeakPlotY[iRand]
				pPeakPlot = CyMap().plot(iXPeak, iYPeak)
				#pPeakPlot.setFeatureType(gc.getInfoTypeForString( "FEATURE_FOREST" ), 1)
				pPeakPlot.setImprovementType(gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" ))
				CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_FOOD, 1)
				CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_COMMERCE, 6)
				plot_culture_1_10 = int(pPeakPlot.getCulture(iPID) * 0.10)
				pPeakPlot.changeCulture(iPID, plot_culture_1_10, true)

				### ausgabe ###
				CyInterface().addMessage(iPID,false,10,CyTranslator().getText("TXT_KEY_MACHU_PICCHU_GAMETXT1",(iXPeak,iXPeak)),'',0,gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_MACHU_PICCHU")).getButton(),ColorTypes(5), iXPeak, iYPeak,True,True)
				### message: The Machu Picchu provides some benefits from Peaks! ###

				### set additional bonus for peaks in the wonder city radius ###
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if(pPlot.getTerrainType() != -1):
									if ( pPlot.isPeak()==true  ):
										CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)

											### ausgabe ###
											if ( iXLoop != iXPeak or iYLoop != iYPeak ):
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_212.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
											else:
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_218.dds',ColorTypes(5), iXLoop, iYLoop,True,True)[/COLOR]

Now, I am noticing that the last few lines there refers to a 'Art/Interface/Buttons/MachuPIcchu_Python/MachuPicchu_Python_218.dds. I don't have that at all, and looking at GIR's files he doesn't appear to have it either. Could that be what is causing this not to work?

Just to clarify what I mean by not working; I build the wonder, wonder splash comes up, the building model comes up. But it is also supposed to put an improvement/graphic on a peak and all the peaks in the city radius are supposed to have yields, and those two things aren't happening. So I guess my questions are, (1) is that python correct, (2) is that last bit about the MachuPicchu_Python_218.dds possibly causing this problem, and (3) if so what can I really do about it and what is that code telling the game to do?
 
The error is telling you that a Python exception was thrown while that <events> element was being processed. In this case the XML isn't the problem--the problem lies in what the XML causes to happen (your mod's event manager is initialized).

The Python exception should be in both PythonErr.log and PythonDbg.log in this case. Can you post the entire up-to-date Python module containing your event manager?
 
The Python exception should be in both PythonErr.log and PythonDbg.log in this case. Can you post the entire up-to-date Python module containing your event manager?

I'm not really sure what you meant there, I don't know exactly what constitutes the "python module" but here is my python folder. TheCapoSettings.xml file is posted above, and here is the DiplomacyEventsManager.py file in case you just wanted that:

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)
		eventManager.addEventHandler("buildingBuilt", self.onBuildingBuilt)        

		###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]                                 
                                        MaxPlayers = gc.getMAX_CIV_PLAYERS ()
                                        for iPlayerNum in xrange(MaxPlayers):
                                            CyInterface().addMessage(iPlayerNum,false,20,CyTranslator().getText("TXT_KEY_CIRCUS_ANNOUNCE",(pCity.getName (),pPlayer.getCivilizationAdjective () )),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pCity.getX(), pCity.getY(), True,True) 
                                        
                                        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 onBuildingBuilt(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList
		game = gc.getGame()
###from here
		if iBuildingType == gc.getInfoTypeForString("BUILDING_SYDNEY_OPERA_HOUSE"):
			pPlayer = gc.getPlayer(pCity.getOwner())
			pPlayer.initUnit(gc.getInfoTypeForString("UNIT_ARTIST"),pCity.getX(),pCity.getY(),UnitAITypes.UNITAI_ARTIST,DirectionTypes.NO_DIRECTION )  
		if iBuildingType == gc.getInfoTypeForString("BUILDING_CERN"):
			pPlayer = gc.getPlayer(pCity.getOwner())
			pPlayer.initUnit(gc.getInfoTypeForString("UNIT_SCIENTIST"),pCity.getX(),pCity.getY(),UnitAITypes.UNITAI_SCIENTIST,DirectionTypes.NO_DIRECTION )            
		
		if ( iBuildingType == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU") ):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iPID = pPlayer.getID()
			iTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()

			### check inner city radius for Peaks (MachuPicchu Wonder prefers to be in the inner city radius of the home city of this wonder) ###
			lPeakPlotX = []
			lPeakPlotY = []
			for iXLoop in range(iX - 1, iX + 2, 1):
				for iYLoop in range(iY - 1, iY + 2, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					if ( pPlot.isPlayerCityRadius(iPID)==true ):
						if ( pPlot.getTeam()==iTID ):
							if ( pPlot.isPeak()==true  ):
								lPeakPlotX.append(iXLoop)
								lPeakPlotY.append(iYLoop)

			if ( len(lPeakPlotX) < 1 ):

				### check all city radius plots for Peaks if no inner peak available ###
				lPeakPlotX = []
				lPeakPlotY = []
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if ( pPlot.isPeak()==true  ):
									lPeakPlotX.append(iXLoop)
									lPeakPlotY.append(iYLoop)

			if ( len(lPeakPlotX) > 0 ):
				it_machu_picchu = gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" )

				### set bonus for peaks in all city radius plots ###
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					iiX = ppCity.getX()
					iiY = ppCity.getY()
					### check all city radius plots for peak ###
					for iXLoop in range(iiX - 2, iiX + 3, 1):
						for iYLoop in range(iiY - 2, iiY + 3, 1):
							lPlot = CyMap().plot(iXLoop, iYLoop)
							if ( lPlot.isPlayerCityRadius(iPID)==true ):
								if ( lPlot.getTeam()==iTID ):
									if(lPlot.getTerrainType() != -1):
										if ( lPlot.isPeak()==true  ):
											lPlot.setImprovementType(it_machu_picchu)

				### now set bonus only with matchu picchu and remove matchu picchu (overlapping city radius) ###
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					iiX = ppCity.getX()
					iiY = ppCity.getY()
					### check all city radius plots for peak ###
					for iXLoop in range(iiX - 2, iiX + 3, 1):
						for iYLoop in range(iiY - 2, iiY + 3, 1):
							lPlot = CyMap().plot(iXLoop, iYLoop)
							if ( lPlot.isPlayerCityRadius(iPID)==true ):
								if ( lPlot.getTeam()==iTID ):
									if(lPlot.getTerrainType() != -1):
										if ( lPlot.isPeak()==true  ):
											if ( lPlot.getImprovementType() == it_machu_picchu ):
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_FOOD, 1)
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_PRODUCTION, 2)
												CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)
												lPlot.setImprovementType(-1)

												### ausgabe ###
												CyInterface().addMessage(iPID,True,0,' ','',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_211.dds',ColorTypes(5), iXLoop, iYLoop,True,True)


				### set machu picchu on hill ###
				### get random Peak from list ###
				iRand = CyGame().getSorenRandNum( len(lPeakPlotX), "Random Peak")
				iXPeak = lPeakPlotX[iRand]
				iYPeak = lPeakPlotY[iRand]
				pPeakPlot = CyMap().plot(iXPeak, iYPeak)
				#pPeakPlot.setFeatureType(gc.getInfoTypeForString( "FEATURE_FOREST" ), 1)
				pPeakPlot.setImprovementType(gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" ))
				CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_FOOD, 1)
				CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_COMMERCE, 6)
				plot_culture_1_10 = int(pPeakPlot.getCulture(iPID) * 0.10)
				pPeakPlot.changeCulture(iPID, plot_culture_1_10, true)

				### ausgabe ###
				CyInterface().addMessage(iPID,false,10,CyTranslator().getText("TXT_KEY_MACHU_PICCHU_GAMETXT1",(iXPeak,iXPeak)),'',0,gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_MACHU_PICCHU")).getButton(),ColorTypes(5), iXPeak, iYPeak,True,True)
				### message: The Machu Picchu provides some benefits from Peaks! ###

				### set additional bonus for peaks in the wonder city radius ###
				for iXLoop in range(iX - 2, iX + 3, 1):
					for iYLoop in range(iY - 2, iY + 3, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if ( pPlot.isPlayerCityRadius(iPID)==true ):
							if ( pPlot.getTeam()==iTID ):
								if(pPlot.getTerrainType() != -1):
									if ( pPlot.isPeak()==true  ):
										CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)

											### ausgabe ###
											if ( iXLoop != iXPeak or iYLoop != iYPeak ):
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_212.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
											else:
												CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_218.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
				      

	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)
		
	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)        
# BUG - Next War Merge - end

And I also did find those .dds files that the python was referring to, so I've plugged them into the proper location so hopefully that helps. :goodjob:
 

Attachments

  • Python.rar
    597.7 KB · Views: 64
Top Bottom