HELP with merging my mod and BUG!!!

Okay, I guess I'm just going to do what I think you are telling me to do. So you are saying make a file like this:

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

## 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 *= pHandicapInfo.getAIUnitUpgradePercent() / 100
			iPrice *= max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100

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

		b_Leonardo = gc.getInfoTypeForString("BUILDING_LEONARDO")
		obsoleteTech = gc.getBuildingInfo(b_Leonardo).getObsoleteTech()
		if ( obsoleteTech == -1 or gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false ):
			for iCity in range(pPlayer.getNumCities()):
				ppCity = pPlayer.getCity(iCity)
				if ( ppCity.getNumActiveBuilding(b_Leonardo) > 0 ):
					iPrice /= 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 ##

## King Richard's Crusade START ##
	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()))
## King Richard's Crusade END ##

And then... uh... what?

But now I'm totally confused. First of all, not all of this code goes into the same file, some of it is supposed to be in CvEventManager and some of it is supposed to be in CvGameUtils, also the code you are telling me to put in the same line that Afforess said doesn't match the format, or at least doesn't look ilke it does to me (although admittedly I have no idea what I am doing). Then there is still the issue that I have no idea what the code I posted in my last post before this means at all. :crazyeye:

I think what might be confusing me about this is the jargon being used, try to act like you are explaining it to a total idiot, because that is basically what you are doing right now. :goodjob:
 
Okay let me see if I'm understand this correctly (I realize my last post was probably pretty wrong). First, my mod is called Diplomacy 2, so I created a file called Diplomacy2Stuff.py. This is the entirety of that file:

Code:
## CaposGameUtils

from CvPythonExtensions import *

class Diplomacy2Stuff:
## Leonardo's Workshop
	def getUpgradePriceOverride(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 *= pHandicapInfo.getAIUnitUpgradePercent() / 100
			iPrice *= max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100

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

		b_Leonardo = gc.getInfoTypeForString("BUILDING_LEONARDO")
		obsoleteTech = gc.getBuildingInfo(b_Leonardo).getObsoleteTech()
		if ( obsoleteTech == -1 or gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false ):
			for iCity in range(pPlayer.getNumCities()):
				ppCity = pPlayer.getCity(iCity)
				if ( ppCity.getNumActiveBuilding(b_Leonardo) > 0 ):
					iPrice /= 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 ##

Alright, so as far as I know that is what you were trying to tell me to make. I may have missed a couple things (and if I have please tell me) but I think that is what I needed to do so far right?

THEN you are saying that I have to add this line:

Code:
<gameutils module="Diplomacy2Stuff" class="Diplomacy2GameUtils"/>

Into that "TheCapoSettings.xml" file that Afforess told me to make, so it should look like this:

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

<mod id="TheCapoSettings"
    module="Diplomacy2Stuff" 
    name="NewMOD" 
    author="TheCapo" 
    version="1.0" 
    date="01/29/2010"
    url="">
    
    <events module="CvEventManager"/>
     
    <gameutils module="Diplomacy2Stuff" class="Diplomacy2GameUtils"/>[/
</mod>

And then it should work? Or am I totally wrong here?
 
Well, obviously that last part wasn't correct. I loaded up the mod with that in place and I got python errors while loading the save where I build Leonardo's Workshop. This time I managed to get all of the python pop-ups so you guys can see what they say.

They go from left to right, from the top to the bottom. The last one on the second attachment is what happens when I select a unit and hold the cursor over the button to upgrade.
 
Code:
## CaposGameUtils

from CvPythonExtensions import *

class Diplomacy2Stuff:
## Leonardo's Workshop
	def getUpgradePriceOverride([B][COLOR="Red"]self,[/COLOR][/B] argsList):
		iPlayer, iUnitID, iUnitTypeUpgrade = argsList

## Leonardo's Workshop Start ##

		pPlayer = gc.getPlayer(iPlayer)...

You could try adding that in red to your code. From the errors it seems that when it's called, it's given 2 arguments but in your code you have only one. Even the original one has two arguments.
 
Thanks, I'll give that a shot. :goodjob:

EDIT: Well that didn't work, but it did result in a different python error, if that means anything. I have attached it below. I'm wondering if maybe I'm missing something in the Diplomacy2Stuff.py and that might be causing this to happen. :confused:
 
Does anyone have an example I could use as a template for this? That might help me, because I just can't seem to get this done correctly.
 
Ugh, EF is a great programmer, but he can be too brief with his explanations. Either that, or everyone else isn't smart enough to understand him all the time. :p

Okay, I highly, highly recommend you download RoM 2.8 and use it's python as an example.

What EmperorFool is trying to tell you is to create a trimmed down version of the CvEventManager and CvGameUtils. Let's call them DiplomacyEventManager and DiplomacyGameUtils. Okay?

Now, since I haven't seen your python files, I can't give exact instructions here, so bear with me.

In your CvGameUtils, where is says "class CvGameUtils", change it to "class DiplomacyGameUtils". This name must match the name of the file. Do the same for the CvEventManager.

Note: You still should have TWO files. One file called "DiplomacyEventManager", which used to be the CvEventManager, and one file called "DiplomacyGameUtils", which used to be the "CvGameUtils".


Great, now we are half way there. Look at each function now. A function starts with the word "def" and stops at the next "def". If there is any custom code you added or took, keep the function. If it's generic BTS and you haven't modified it, delete all the code up till the next function that you have modified.

Hopefully you are still following me, cause we are almost done. Remember that config file you created, we need to tweak it to reflect the new changes for the file names. Make it look like this:

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

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

You should be done. If you get errors of any kind, post them here and I'll try to help you work them out. :)
</mod>
 
Okay before I start, and at the risk of you killing me right now, do you want me to COPY the CvGameUtils and CvEventManager files or just rename them altogether?

I ask because my mod is merged with NextWar. So if I were to simply copy them and delete the extra stuff I am worried that the NextWar stuff might get lost (although I'm relatively sure it is commented/noted in the code). So just to follow along, and put it in my own words so you know I am following. You want me to take the CvGameUtils file, when I see where it says "class CvGameUtils" and change that to "DiplomacyGameUtils," and that I should also change the name of the file CvGameUtils.py to DiplomacyGameUtils.py? Within that file I should delete anything that is not modified for my mod/NextWar?

Then do the exact same thing with CvEventManager (i.e. change instances of "class CvEventManager" to "class DiplomacyEventManager" and change the filename to DiplomacyEventManager.py)?

And just to make sure, I am not just copying and renaming, I am replacing these files with my new ones?
 
Yes. When you are done, you will no longer have a CvGameUtils or CvEventManager. BUG comes with it's own, so they are redundant. You should be RENAMING them, then trimming the content.


If you can't tell if the code is generic or not, post it here and I'll take a look.
 
This is the DiplomacyEventManager.py content:

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):
		#################### ON EVENT MAP ######################
		#print "EVENTMANAGER INIT"
				
		self.bCtrl = False
		self.bShift = False
		self.bAlt = False
		self.bAllowCheats = False
		
		# OnEvent Enums
		self.EventLButtonDown=1
		self.EventLcButtonDblClick=2
		self.EventRButtonDown=3
		self.EventBack=4
		self.EventForward=5
		self.EventKeyDown=6
		self.EventKeyUp=7
	
		self.__LOG_MOVEMENT = 0
		self.__LOG_BUILDING = 0
		self.__LOG_COMBAT = 0
		self.__LOG_CONTACT = 0
		self.__LOG_IMPROVEMENT =0
		self.__LOG_CITYLOST = 0
		self.__LOG_CITYBUILDING = 0
		self.__LOG_TECH = 0
		self.__LOG_UNITBUILD = 0
		self.__LOG_UNITKILLED = 1
		self.__LOG_UNITLOST = 0
		self.__LOG_UNITPROMOTED = 0
		self.__LOG_UNITSELECTED = 0
		self.__LOG_UNITPILLAGE = 0
		self.__LOG_GOODYRECEIVED = 0
		self.__LOG_GREATPERSON = 0
		self.__LOG_RELIGION = 0
		self.__LOG_RELIGIONSPREAD = 0
		self.__LOG_GOLDENAGE = 0
		self.__LOG_ENDGOLDENAGE = 0
		self.__LOG_WARPEACE = 0
		self.__LOG_PUSH_MISSION = 0
		###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
		
		## EVENTLIST
		self.EventHandlerMap = {
			'mouseEvent'			: self.onMouseEvent,
			'kbdEvent' 				: self.onKbdEvent,
			'ModNetMessage'					: self.onModNetMessage,
			'Init'					: self.onInit,
			'Update'				: self.onUpdate,
			'UnInit'				: self.onUnInit,
			'OnSave'				: self.onSaveGame,
			'OnPreSave'				: self.onPreSave,
			'OnLoad'				: self.onLoadGame,
			'GameStart'				: self.onGameStart,
			'GameEnd'				: self.onGameEnd,
			'plotRevealed' 			: self.onPlotRevealed,
			'plotFeatureRemoved' 	: self.onPlotFeatureRemoved,
			'plotPicked'			: self.onPlotPicked,
			'nukeExplosion'			: self.onNukeExplosion,
			'gotoPlotSet'			: self.onGotoPlotSet,
			'BeginGameTurn'			: self.onBeginGameTurn,
			'EndGameTurn'			: self.onEndGameTurn,
			'BeginPlayerTurn'		: self.onBeginPlayerTurn,
			'EndPlayerTurn'			: self.onEndPlayerTurn,
			'endTurnReady'			: self.onEndTurnReady,
			'combatResult' 			: self.onCombatResult,
		  'combatLogCalc'	 		: self.onCombatLogCalc,
		  'combatLogHit'				: self.onCombatLogHit,
			'improvementBuilt' 		: self.onImprovementBuilt,
			'improvementDestroyed' 		: self.onImprovementDestroyed,
			'routeBuilt' 		: self.onRouteBuilt,
			'firstContact' 			: self.onFirstContact,
			'cityBuilt' 			: self.onCityBuilt,
			'cityRazed'				: self.onCityRazed,
			'cityAcquired' 			: self.onCityAcquired,
			'cityAcquiredAndKept' 	: self.onCityAcquiredAndKept,
			'cityLost'				: self.onCityLost,
			'cultureExpansion' 		: self.onCultureExpansion,
			'cityGrowth' 			: self.onCityGrowth,
			'cityDoTurn' 			: self.onCityDoTurn,
			'cityBuildingUnit'	: self.onCityBuildingUnit,
			'cityBuildingBuilding'	: self.onCityBuildingBuilding,
			'cityRename'				: self.onCityRename,
			'cityHurry'				: self.onCityHurry,
			'selectionGroupPushMission'		: self.onSelectionGroupPushMission,
			'unitMove' 				: self.onUnitMove,
			'unitSetXY' 			: self.onUnitSetXY,
			'unitCreated' 			: self.onUnitCreated,
			'unitBuilt' 			: self.onUnitBuilt,
			'unitKilled'			: self.onUnitKilled,
			'unitLost'				: self.onUnitLost,
			'unitPromoted'			: self.onUnitPromoted,
			'unitSelected'			: self.onUnitSelected, 
			'UnitRename'				: self.onUnitRename,
			'unitPillage'				: self.onUnitPillage,
			'unitSpreadReligionAttempt'	: self.onUnitSpreadReligionAttempt,
			'unitGifted'				: self.onUnitGifted,
			'unitBuildImprovement'				: self.onUnitBuildImprovement,
			'goodyReceived'        	: self.onGoodyReceived,
			'greatPersonBorn'      	: self.onGreatPersonBorn,
			'buildingBuilt' 		: self.onBuildingBuilt,
			'projectBuilt' 			: self.onProjectBuilt,
			'techAcquired'			: self.onTechAcquired,
			'techSelected'			: self.onTechSelected,
			'religionFounded'		: self.onReligionFounded,
			'religionSpread'		: self.onReligionSpread, 
			'religionRemove'		: self.onReligionRemove, 
			'corporationFounded'	: self.onCorporationFounded,
			'corporationSpread'		: self.onCorporationSpread, 
			'corporationRemove'		: self.onCorporationRemove, 
			'goldenAge'				: self.onGoldenAge,
			'endGoldenAge'			: self.onEndGoldenAge,
			'chat' 					: self.onChat,
			'victory'				: self.onVictory,
			'vassalState'			: self.onVassalState,
			'changeWar'				: self.onChangeWar,
			'setPlayerAlive'		: self.onSetPlayerAlive,
			'playerChangeStateReligion'		: self.onPlayerChangeStateReligion,
			'playerGoldTrade'		: self.onPlayerGoldTrade,
			'windowActivation'		: self.onWindowActivation,
			'gameUpdate'			: self.onGameUpdate,		# sample generic event
		}

		################## Events List ###############################
		#
		# Dictionary of Events, indexed by EventID (also used at popup context id)
		#   entries have name, beginFunction, applyFunction [, randomization weight...]
		#
		# Normal events first, random events after
		#	
		################## Events List ###############################
		self.Events={
			CvUtil.EventEditCityName : ('EditCityName', self.__eventEditCityNameApply, self.__eventEditCityNameBegin),
			CvUtil.EventEditCity : ('EditCity', self.__eventEditCityApply, self.__eventEditCityBegin),
			CvUtil.EventPlaceObject : ('PlaceObject', self.__eventPlaceObjectApply, self.__eventPlaceObjectBegin),
			CvUtil.EventAwardTechsAndGold: ('AwardTechsAndGold', self.__eventAwardTechsAndGoldApply, self.__eventAwardTechsAndGoldBegin),
			CvUtil.EventEditUnitName : ('EditUnitName', self.__eventEditUnitNameApply, self.__eventEditUnitNameBegin),
			CvUtil.EventWBAllPlotsPopup : ('WBAllPlotsPopup', self.__eventWBAllPlotsPopupApply, self.__eventWBAllPlotsPopupBegin),
			CvUtil.EventWBLandmarkPopup : ('WBLandmarkPopup', self.__eventWBLandmarkPopupApply, self.__eventWBLandmarkPopupBegin),
			CvUtil.EventWBScriptPopup : ('WBScriptPopup', self.__eventWBScriptPopupApply, self.__eventWBScriptPopupBegin),
			CvUtil.EventWBStartYearPopup : ('WBStartYearPopup', self.__eventWBStartYearPopupApply, self.__eventWBStartYearPopupBegin),
			CvUtil.EventShowWonder: ('ShowWonder', self.__eventShowWonderApply, self.__eventShowWonderBegin),
		}	

	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_CIRCUS_HAGENBECK"))
                                        if numbuildings>0:
                                                for iCity in range(player.getNumCities()):
                                                        pCity = player.getCity(iCity)
                                                        if pCity.getNumBuilding(gc.getInfoTypeForString("BUILDING_CIRCUS_HAGENBECK"))>0:
                                                                self.oldcity = [iPlayer,iCity]
                                                                return
                ###circus hagenbeck end part 2          
		# Are we using the scenario file? If so, then show the backstory popup
		if (CyMap().plot(0,0).getScriptData() == "Scenario"):
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
					szTitle = u"<font=4b>" + localText.getText("TXT_KEY_NEXT_WAR_BACKSTORY_TITLE", ()) + u"</font>"
					szBody = u"<font=3>" + localText.getText("TXT_KEY_NEXT_WAR_BACKSTORY_TEXT", ()) + u"</font>"
					popupInfo.setText(szTitle + u"\n\n" + szBody)
					popupInfo.addPopup(iPlayer)
		if (gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR") and not gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_START)):
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setText(u"showDawnOfMan")
					popupInfo.addPopup(iPlayer)
		else:
			CyInterface().setSoundSelectionReady(true)

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

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

		# Partisans!
		if city.getPopulation > 1 and iOwner != -1 and iPlayer != -1:
			owner = gc.getPlayer(iOwner)
			if not owner.isBarbarian() and owner.getNumCities() > 0:
				if gc.getTeam(owner.getTeam()).isAtWar(gc.getPlayer(iPlayer).getTeam()):
					if gc.getNumEventTriggerInfos() > 0: # prevents mods that don't have events from getting an error
						iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_PARTISANS')
						if iEvent != -1 and gc.getGame().isEventActive(iEvent) and owner.getEventTriggerWeight(iEvent) < 0:
							triggerData = owner.initTriggeredData(iEvent, true, -1, city.getX(), city.getY(), iPlayer, city.getID(), -1, -1, -1, -1)
			
		#Raze the Arcology
		owner = PyPlayer(city.getOwner())
		razor = PyPlayer(iPlayer)
		
		self.iArcologyCityID = -1
		
		if city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY")) or city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING")) or city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
			self.iArcologyCityID = city.getID()
		
		CvUtil.pyPrint('Player %d Civilization %s City %s was razed by Player %d' 
			%(owner.getID(), owner.getCivilizationName(), city.getName(), razor.getID()))	
		CvUtil.pyPrint("City Razed Event: %s" %(city.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 #        

		CvAdvisorUtils.cityAdvise(pCity, iPlayer)
	
####### Next War Functions ######
## Added Fort to doCheckDepletion -- otherwise bonuses worked via forts would never be subject to resource depletion.   JKP


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

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

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

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

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

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


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

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

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

import CvUtil
from CvPythonExtensions import *
import CvEventInterface

# globals
gc = CyGlobalContext()

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

		return False

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

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

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

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

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

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

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

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

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

			iPrice = 0
		
		return iPrice

## Leonardo's Workshop End ##	

## Leonardo's Workshop Start ##	
#
## NOTE: You need to comment out (add a # before) the original return -1 (done below) ##
#
#		return -1	# Any value 0 or above will be used
#
## Leonardo's Workshop End ##
 
And then my TheCapoSettings.xml in the Config folder has this content:

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>

And yes, my mod is still called NewMOD until it is finished. Now I gotta test it...
 
Everything looks good, at least from what I can see.

(Famous last words, I know.)
 
Well, I think I'm going to label it "mixed results" for now. The mod loaded fine, but then I got that Traceback python pop-up again while loading the save (a few posts back with the hand in the background), there were no issues after the save loaded though and Leonardo's Workshop worked properly. So I loaded up the same save again, and on the second time there were no issues at all. I think what I should do is just play a new game and see if I encounter any issues and I'll let you know. For now I'm pretty happy about it though, and I'm hoping this works out for me.

Just a few follow up questions for now though; if I need to add more python to these files what I'd basically do is find the original code, edit it appropriately, and then copy then and paste it into the appropriate file, correct?

EDIT: Sorry, I wrote mod when I meant to write save (boldfaced)
 
Well, I think I'm going to label it "mixed results" for now. The mod loaded fine, but then I got that Traceback python pop-up again while loading the mod (a few posts back with the hand in the background), there were no issues after the save loaded though and Leonardo's Workshop worked properly. So I loaded up the same save again, and on the second time there were no issues at all. I think what I should do is just play a new game and see if I encounter any issues and I'll let you know. For now I'm pretty happy about it though, and I'm hoping this works out for me.

Just a few follow up questions for now though; if I need to add more python to these files what I'd basically do is find the original code, edit it appropriately, and then copy then and paste it into the appropriate file, correct?


Okay, I think I figured out why that traceback is appearing, I forgot one key step. In your DiplomacyEventManager delete the init line and replace it with this line:

Code:
def __init__(self, eventManager):

Okay, now this is going to be tedious and annoying, but if you don't do it, none of your changes in the EventManager will work.

For each function that you have in your DiplomacyEventManager, you need to add a line to activate it. For example, underneath the new "init" line you just changed, this will be the first new event handler you need to add.

Code:
class DiplomacyEventManager:
    def __init__(self, eventManager):
        eventManager.addEventHandler("OnLoad", self.onLoadGame)

Like that. You need to add one for each "def" you have. I did the first one. The rest of them should be fairly easy. Look up the name and self. call for each one in this big table:

Code:
            'mouseEvent'            : self.onMouseEvent,
            'kbdEvent'                 : self.onKbdEvent,
            'ModNetMessage'                    : self.onModNetMessage,
            'Init'                    : self.onInit,
            'Update'                : self.onUpdate,
            'UnInit'                : self.onUnInit,
            'OnSave'                : self.onSaveGame,
            'OnPreSave'                : self.onPreSave,
            'OnLoad'                : self.onLoadGame,
            'GameStart'                : self.onGameStart,
            'GameEnd'                : self.onGameEnd,
            'plotRevealed'             : self.onPlotRevealed,
            'plotFeatureRemoved'     : self.onPlotFeatureRemoved,
            'plotPicked'            : self.onPlotPicked,
            'nukeExplosion'            : self.onNukeExplosion,
            'gotoPlotSet'            : self.onGotoPlotSet,
            'BeginGameTurn'            : self.onBeginGameTurn,
            'EndGameTurn'            : self.onEndGameTurn,
            'BeginPlayerTurn'        : self.onBeginPlayerTurn,
            'EndPlayerTurn'            : self.onEndPlayerTurn,
            'endTurnReady'            : self.onEndTurnReady,
            'combatResult'             : self.onCombatResult,
          'combatLogCalc'             : self.onCombatLogCalc,
          'combatLogHit'                : self.onCombatLogHit,
            'improvementBuilt'         : self.onImprovementBuilt,
            'improvementDestroyed'         : self.onImprovementDestroyed,
            'routeBuilt'         : self.onRouteBuilt,
            'firstContact'             : self.onFirstContact,
            'cityBuilt'             : self.onCityBuilt,
            'cityRazed'                : self.onCityRazed,
            'cityAcquired'             : self.onCityAcquired,
            'cityAcquiredAndKept'     : self.onCityAcquiredAndKept,
            'cityLost'                : self.onCityLost,
            'cultureExpansion'         : self.onCultureExpansion,
            'cityGrowth'             : self.onCityGrowth,
            'cityDoTurn'             : self.onCityDoTurn,
            'cityBuildingUnit'    : self.onCityBuildingUnit,
            'cityBuildingBuilding'    : self.onCityBuildingBuilding,
            'cityRename'                : self.onCityRename,
            'cityHurry'                : self.onCityHurry,
            'selectionGroupPushMission'        : self.onSelectionGroupPushMission,
            'unitMove'                 : self.onUnitMove,
            'unitSetXY'             : self.onUnitSetXY,
            'unitCreated'             : self.onUnitCreated,
            'unitBuilt'             : self.onUnitBuilt,
            'unitKilled'            : self.onUnitKilled,
            'unitLost'                : self.onUnitLost,
            'unitPromoted'            : self.onUnitPromoted,
            'unitSelected'            : self.onUnitSelected, 
            'UnitRename'                : self.onUnitRename,
            'unitPillage'                : self.onUnitPillage,
            'unitSpreadReligionAttempt'    : self.onUnitSpreadReligionAttempt,
            'unitGifted'                : self.onUnitGifted,
            'unitBuildImprovement'                : self.onUnitBuildImprovement,
            'goodyReceived'            : self.onGoodyReceived,
            'greatPersonBorn'          : self.onGreatPersonBorn,
            'buildingBuilt'         : self.onBuildingBuilt,
            'projectBuilt'             : self.onProjectBuilt,
            'techAcquired'            : self.onTechAcquired,
            'techSelected'            : self.onTechSelected,
            'religionFounded'        : self.onReligionFounded,
            'religionSpread'        : self.onReligionSpread, 
            'religionRemove'        : self.onReligionRemove, 
            'corporationFounded'    : self.onCorporationFounded,
            'corporationSpread'        : self.onCorporationSpread, 
            'corporationRemove'        : self.onCorporationRemove, 
            'goldenAge'                : self.onGoldenAge,
            'endGoldenAge'            : self.onEndGoldenAge,
            'chat'                     : self.onChat,
            'victory'                : self.onVictory,
            'vassalState'            : self.onVassalState,
            'changeWar'                : self.onChangeWar,
            'setPlayerAlive'        : self.onSetPlayerAlive,
            'playerChangeStateReligion'        : self.onPlayerChangeStateReligion,
            'playerGoldTrade'        : self.onPlayerGoldTrade,
            'windowActivation'        : self.onWindowActivation,
            'gameUpdate'            : self.onGameUpdate

Once you have got that done, the python errors should go away.
 
Oh, and every time you add a new function in the event manager, you will need to add a new "event handler" like the GameOnLoad one.
 
I'm a little confused here.

So you want me to open my DiplomacyEventsManager.py and change this:

Code:
class DiplomacyEventManager:
	def __init__(self):
		#################### ON EVENT MAP ######################
		#print "EVENTMANAGER INIT"
				
		self.bCtrl = False
		self.bShift = False
		self.bAlt = False
		self.bAllowCheats = False

To this?

Code:
class DiplomacyEventManager:
	def __init__(self):
        eventManager.addEventHandler("OnLoad", self.onLoadGame)
		#################### ON EVENT MAP ######################
		#print "EVENTMANAGER INIT"
				
		self.bCtrl = False
		self.bShift = False
		self.bAlt = False
		self.bAllowCheats = False

I am also extremely confused about what to do for the rest of it. I just don't really know what you are telling me to do here.
 
Close.

This is your event manager, correct?
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, [COLOR=Red]eventmanager[/COLOR]):
        [COLOR="Green"]eventManager.addEventHandler("OnLoad", self.onLoadGame)[/COLOR]
        #################### ON EVENT MAP ######################
        #print "EVENTMANAGER INIT"
                
        self.bCtrl = False
        self.bShift = False
        self.bAlt = False
        self.bAllowCheats = False
        
        # OnEvent Enums
        self.EventLButtonDown=1
        self.EventLcButtonDblClick=2
        self.EventRButtonDown=3
        self.EventBack=4
        self.EventForward=5
        self.EventKeyDown=6
        self.EventKeyUp=7
    
        self.__LOG_MOVEMENT = 0
        self.__LOG_BUILDING = 0
        self.__LOG_COMBAT = 0
        self.__LOG_CONTACT = 0
        self.__LOG_IMPROVEMENT =0
        self.__LOG_CITYLOST = 0
        self.__LOG_CITYBUILDING = 0
        self.__LOG_TECH = 0
        self.__LOG_UNITBUILD = 0
        self.__LOG_UNITKILLED = 1
        self.__LOG_UNITLOST = 0
        self.__LOG_UNITPROMOTED = 0
        self.__LOG_UNITSELECTED = 0
        self.__LOG_UNITPILLAGE = 0
        self.__LOG_GOODYRECEIVED = 0
        self.__LOG_GREATPERSON = 0
        self.__LOG_RELIGION = 0
        self.__LOG_RELIGIONSPREAD = 0
        self.__LOG_GOLDENAGE = 0
        self.__LOG_ENDGOLDENAGE = 0
        self.__LOG_WARPEACE = 0
        self.__LOG_PUSH_MISSION = 0
        ###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
        
        ## EVENTLIST
        self.EventHandlerMap = {
            'mouseEvent'            : self.onMouseEvent,
            'kbdEvent'                 : self.onKbdEvent,
            'ModNetMessage'                    : self.onModNetMessage,
            'Init'                    : self.onInit,
            'Update'                : self.onUpdate,
            'UnInit'                : self.onUnInit,
            'OnSave'                : self.onSaveGame,
            'OnPreSave'                : self.onPreSave,
            'OnLoad'                : self.onLoadGame,
            'GameStart'                : self.onGameStart,
            'GameEnd'                : self.onGameEnd,
            'plotRevealed'             : self.onPlotRevealed,
            'plotFeatureRemoved'     : self.onPlotFeatureRemoved,
            'plotPicked'            : self.onPlotPicked,
            'nukeExplosion'            : self.onNukeExplosion,
            'gotoPlotSet'            : self.onGotoPlotSet,
            'BeginGameTurn'            : self.onBeginGameTurn,
            'EndGameTurn'            : self.onEndGameTurn,
            'BeginPlayerTurn'        : self.onBeginPlayerTurn,
            'EndPlayerTurn'            : self.onEndPlayerTurn,
            'endTurnReady'            : self.onEndTurnReady,
            'combatResult'             : self.onCombatResult,
          'combatLogCalc'             : self.onCombatLogCalc,
          'combatLogHit'                : self.onCombatLogHit,
            'improvementBuilt'         : self.onImprovementBuilt,
            'improvementDestroyed'         : self.onImprovementDestroyed,
            'routeBuilt'         : self.onRouteBuilt,
            'firstContact'             : self.onFirstContact,
            'cityBuilt'             : self.onCityBuilt,
            'cityRazed'                : self.onCityRazed,
            'cityAcquired'             : self.onCityAcquired,
            'cityAcquiredAndKept'     : self.onCityAcquiredAndKept,
            'cityLost'                : self.onCityLost,
            'cultureExpansion'         : self.onCultureExpansion,
            'cityGrowth'             : self.onCityGrowth,
            'cityDoTurn'             : self.onCityDoTurn,
            'cityBuildingUnit'    : self.onCityBuildingUnit,
            'cityBuildingBuilding'    : self.onCityBuildingBuilding,
            'cityRename'                : self.onCityRename,
            'cityHurry'                : self.onCityHurry,
            'selectionGroupPushMission'        : self.onSelectionGroupPushMission,
            'unitMove'                 : self.onUnitMove,
            'unitSetXY'             : self.onUnitSetXY,
            'unitCreated'             : self.onUnitCreated,
            'unitBuilt'             : self.onUnitBuilt,
            'unitKilled'            : self.onUnitKilled,
            'unitLost'                : self.onUnitLost,
            'unitPromoted'            : self.onUnitPromoted,
            'unitSelected'            : self.onUnitSelected, 
            'UnitRename'                : self.onUnitRename,
            'unitPillage'                : self.onUnitPillage,
            'unitSpreadReligionAttempt'    : self.onUnitSpreadReligionAttempt,
            'unitGifted'                : self.onUnitGifted,
            'unitBuildImprovement'                : self.onUnitBuildImprovement,
            'goodyReceived'            : self.onGoodyReceived,
            'greatPersonBorn'          : self.onGreatPersonBorn,
            'buildingBuilt'         : self.onBuildingBuilt,
            'projectBuilt'             : self.onProjectBuilt,
            'techAcquired'            : self.onTechAcquired,
            'techSelected'            : self.onTechSelected,
            'religionFounded'        : self.onReligionFounded,
            'religionSpread'        : self.onReligionSpread, 
            'religionRemove'        : self.onReligionRemove, 
            'corporationFounded'    : self.onCorporationFounded,
            'corporationSpread'        : self.onCorporationSpread, 
            'corporationRemove'        : self.onCorporationRemove, 
            'goldenAge'                : self.onGoldenAge,
            'endGoldenAge'            : self.onEndGoldenAge,
            'chat'                     : self.onChat,
            'victory'                : self.onVictory,
            'vassalState'            : self.onVassalState,
            'changeWar'                : self.onChangeWar,
            'setPlayerAlive'        : self.onSetPlayerAlive,
            'playerChangeStateReligion'        : self.onPlayerChangeStateReligion,
            'playerGoldTrade'        : self.onPlayerGoldTrade,
            'windowActivation'        : self.onWindowActivation,
            'gameUpdate'            : self.onGameUpdate,        # sample generic event
        }

        ################## Events List ###############################
        #
        # Dictionary of Events, indexed by EventID (also used at popup context id)
        #   entries have name, beginFunction, applyFunction [, randomization weight...]
        #
        # Normal events first, random events after
        #    
        ################## Events List ###############################
        self.Events={
            CvUtil.EventEditCityName : ('EditCityName', self.__eventEditCityNameApply, self.__eventEditCityNameBegin),
            CvUtil.EventEditCity : ('EditCity', self.__eventEditCityApply, self.__eventEditCityBegin),
            CvUtil.EventPlaceObject : ('PlaceObject', self.__eventPlaceObjectApply, self.__eventPlaceObjectBegin),
            CvUtil.EventAwardTechsAndGold: ('AwardTechsAndGold', self.__eventAwardTechsAndGoldApply, self.__eventAwardTechsAndGoldBegin),
            CvUtil.EventEditUnitName : ('EditUnitName', self.__eventEditUnitNameApply, self.__eventEditUnitNameBegin),
            CvUtil.EventWBAllPlotsPopup : ('WBAllPlotsPopup', self.__eventWBAllPlotsPopupApply, self.__eventWBAllPlotsPopupBegin),
            CvUtil.EventWBLandmarkPopup : ('WBLandmarkPopup', self.__eventWBLandmarkPopupApply, self.__eventWBLandmarkPopupBegin),
            CvUtil.EventWBScriptPopup : ('WBScriptPopup', self.__eventWBScriptPopupApply, self.__eventWBScriptPopupBegin),
            CvUtil.EventWBStartYearPopup : ('WBStartYearPopup', self.__eventWBStartYearPopupApply, self.__eventWBStartYearPopupBegin),
            CvUtil.EventShowWonder: ('ShowWonder', self.__eventShowWonderApply, self.__eventShowWonderBegin),
        }    
[COLOR=Blue]
    [/COLOR][COLOR=Blue]def onLoadGame(self, argsList):[/COLOR]
        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

   [COLOR=Blue] def onGameStart(self, argsList):[/COLOR]
        '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_CIRCUS_HAGENBECK"))
                                        if numbuildings>0:
                                                for iCity in range(player.getNumCities()):
                                                        pCity = player.getCity(iCity)
                                                        if pCity.getNumBuilding(gc.getInfoTypeForString("BUILDING_CIRCUS_HAGENBECK"))>0:
                                                                self.oldcity = [iPlayer,iCity]
                                                                return
                ###circus hagenbeck end part 2          
        # Are we using the scenario file? If so, then show the backstory popup
        if (CyMap().plot(0,0).getScriptData() == "Scenario"):
            for iPlayer in range(gc.getMAX_PLAYERS()):
                player = gc.getPlayer(iPlayer)
                if (player.isAlive() and player.isHuman()):
                    popupInfo = CyPopupInfo()
                    popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
                    szTitle = u"<font=4b>" + localText.getText("TXT_KEY_NEXT_WAR_BACKSTORY_TITLE", ()) + u"</font>"
                    szBody = u"<font=3>" + localText.getText("TXT_KEY_NEXT_WAR_BACKSTORY_TEXT", ()) + u"</font>"
                    popupInfo.setText(szTitle + u"\n\n" + szBody)
                    popupInfo.addPopup(iPlayer)
        if (gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR") and not gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_START)):
            for iPlayer in range(gc.getMAX_PLAYERS()):
                player = gc.getPlayer(iPlayer)
                if (player.isAlive() and player.isHuman()):
                    popupInfo = CyPopupInfo()
                    popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
                    popupInfo.setText(u"showDawnOfMan")
                    popupInfo.addPopup(iPlayer)
        else:
            CyInterface().setSoundSelectionReady(true)

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

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

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

        CvAdvisorUtils.cityAdvise(pCity, iPlayer)
    
####### Next War Functions ######
## Added Fort to doCheckDepletion -- otherwise bonuses worked via forts would never be subject to resource depletion.   JKP


  [COLOR=Blue]  def doCheckDepletion(self):[/COLOR]
        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:

  [COLOR=Blue]  def getPlotListbyBonus(self, iBonus):[/COLOR]
        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

    [COLOR=Blue]def getRandomNumber(self, int):[/COLOR]
        return gc.getGame().getSorenRandNum(int, "Next War")


# BUG - Next War Merge - start
   [COLOR=Blue] def initScriptData(self):[/COLOR]
        
        # 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)
        
   [COLOR=Blue] def getGameNumNukes(self):[/COLOR]
        return SdToolkit.sdGetGlobal(SD_MOD_ID, SD_NUKES_ID)

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

I put each function heading in blue. The change you need to add is in red. Now, look up each blue line in that big list of BTS functions.

If it is there, it needs a new "event handler", like the one I added, in green.

If it isn't in the list, do nothing. So, when you are done, you will have a couple of those, in a big list.

Just as an example (Your EventManager is different, don't copies these verbatim), RoM's Init looks like this:

Code:
class RoMEventManager:
    def __init__(self, eventManager):
        eventManager.addEventHandler("ModNetMessage", self.onModNetMessage)
        eventManager.addEventHandler("OnLoad", self.onLoadGame)
        eventManager.addEventHandler("GameStart", self.onGameStart)
        eventManager.addEventHandler("BeginPlayerTurn", self.onBeginPlayerTurn)
        eventManager.addEventHandler("buildingBuilt", self.onBuildingBuilt)
        eventManager.addEventHandler("projectBuilt", self.onProjectBuilt)
        eventManager.addEventHandler("unitBuilt", self.onUnitBuilt)
        eventManager.addEventHandler("cityBuilt", self.onCityBuilt)
        eventManager.addEventHandler("cityRazed", self.onCityRazed)
        eventManager.addEventHandler("cityLost", self.onCityLost)
        eventManager.addEventHandler("gameUpdate", self.onGameUpdate)
 
I don't see anything in green there. I also don't really understand how I know which event handler (whatever that is) to use. What am I looking for?

So if I get this:

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

I should "replace it" with this?

Code:
	def onGameStart(self, eventmanager):
        eventManager.addEventHandler("GameStart", self.onGameStart)
		'Called at the start of the game'

EDIT: put the wrong thing the first time.
 
Back
Top Bottom