Creatures in War [CIW] [Mod in the making] [Need some support and ideas]

Codes from ANM 2.1
CvEventManager.py:
Spoiler :
PHP:
## 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
# Rise of Mankind start
import GodsOfOld
# import pickle
import cPickle as pickle
import CvGameUtils
import BugOptions
import BugCore
import BugUtil
import OOSLogger
RevDCMOpt = BugCore.game.RevDCM
# Rise of Mankind end

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

# globals
###################################################
class CvEventManager:
	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
		
		# RoM start Next War tracks cities that have been razed
		self.iArcologyCityID = -1
		
		#Net Messages
		self.m_iNetMessage_Inquisitor = 0
		
# Rise of Mankind 2.7
		# def onBuildingBuilt / Initializing of building upgrade line
		self.asBuildingUpgradeLine_Upgrade_Name = [
		["BUILDING_KNIGHT_STABLE"],
		["BUILDING_ARCOLOGY_SHIELDING"],
		["BUILDING_ADVANCED_SHIELDING","BUILDING_NATIONAL_SHIELD"],
		["BUILDING_HARBOR","BUILDING_CARTHAGE_COTHON"],
		["BUILDING_PORT"],
		["BUILDING_COMMERCIAL_PORT"],
		["BUILDING_INTERNATIONAL_PORT"],
		["BUILDING_COMMERCIAL_AIRPORT"],
		["BUILDING_HIGH_WALLS"],
		["BUILDING_CUSTOM_HOUSE","BUILDING_PORTUGAL_FEITORIA"],
		["BUILDING_DRYDOCK"],
		["BUILDING_NAVAL_YARD"],
		["BUILDING_STEEL_MILL"],
		["BUILDING_FOOD_PROCESSING_PLANT"],
		["BUILDING_ARCOLOGY"],
		["BUILDING_MODERN_GRANARY"],
		["BUILDING_GARRISON"],
		["BUILDING_NUCLEAR_PLANT","BUILDING_HYDRO_PLANT","BUILDING_FUSION_PLANT"],
		["BUILDING_AEROSPACE_COMPLEX"],
		["BUILDING_COMMUNICATION_TOWER"],
		["BUILDING_NETWORK_NODE"]]
		self.asBuildingUpgradeLine_Obsolete_Name = [
		["BUILDING_STABLE","BUILDING_MONGOL_GER"],
		["BUILDING_ANTI_MISSILE_BATTERIES","BUILDING_ARCOLOGY"],
		["BUILDING_ANTI_MISSILE_BATTERIES","BUILDING_ARCOLOGY","BUILDING_ARCOLOGY_SHIELDING"],
		["BUILDING_RIVER_PORT"],
		["BUILDING_RIVER_PORT","BUILDING_HARBOR","BUILDING_CARTHAGE_COTHON"],
		["BUILDING_RIVER_PORT","BUILDING_HARBOR","BUILDING_CARTHAGE_COTHON","BUILDING_PORT"],
		["BUILDING_RIVER_PORT","BUILDING_HARBOR","BUILDING_CARTHAGE_COTHON","BUILDING_PORT","BUILDING_COMMERCIAL_PORT"],
		["BUILDING_AIRPORT"],
		["BUILDING_WALLS","BUILDING_CELTIC_DUN"],
		["BUILDING_TOLL_HOUSE"],
		["BUILDING_SHIPYARD"],
		["BUILDING_SHIPYARD","BUILDING_DRYDOCK"],
		["BUILDING_FORGE","BUILDING_MALI_MINT","BUILDING_IRON_FORGE"],
		["BUILDING_BAKERY"],
		["BUILDING_ANTI_MISSILE_BATTERIES"],
		["BUILDING_GRANARY","BUILDING_INCAN_TERRACE"],
		["BUILDING_BARRACKS","BUILDING_ZULU_IKHANDA","BUILDING_ASSYRIA_EKAL"],
		["BUILDING_COAL_PLANT","BUILDING_JAPANESE_SHALE_PLANT","BUILDING_OIL_PLANT"],
		["BUILDING_MILITARY_AIRBASE"],
		["BUILDING_BROADCAST_TOWER"],
		["BUILDING_BROADCAST_TOWER","BUILDING_COMMUNICATION_TOWER"]]
		self.aiBuildingUpgradeLine_Upgrade_InfoTypeNum = []
		self.aiBuildingUpgradeLine_Obsolete_InfoTypeNum = []
# Rise of Mankind 2.7		
# Rise of Mankind 2.71
		self.iBUILDING_CRUSADE = 0
		self.iBUILDING_DJENNE = 0
		self.iBUILDING_WORLD_BANK = 0
		self.iTECH_KNOWLEDGE_MANAGEMENT = 0
		self.m_iNetMessage_Colonist = 410
		self.m_iNetMessage_Pioneer = 411
# Rise of Mankind 2.71
# Rise of Mankind 2.8
		self.iPROJECT_EDEN = 0
# Rise of Mankind 2.8
		
		## 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),
		}

#################### EVENT STARTERS ######################
	def handleEvent(self, argsList):
		'EventMgr entry point'
		# extract the last 6 args in the list, the first arg has already been consumed
		self.origArgsList = argsList	# point to original
		tag = argsList[0]				# event type string
		idx = len(argsList)-6
		bDummy = false
		self.bDbg, bDummy, self.bAlt, self.bCtrl, self.bShift, self.bAllowCheats = argsList[idx:]
		ret = 0
		if self.EventHandlerMap.has_key(tag):
			fxn = self.EventHandlerMap[tag]
			ret = fxn(argsList[1:idx])
		return ret
		
#################### EVENT APPLY ######################	
	def beginEvent( self, context, argsList=-1 ):
		'Begin Event'
		entry = self.Events[context]
		return entry[2]( argsList )
	
	def applyEvent( self, argsList ):
		'Apply the effects of an event '
		context, playerID, netUserData, popupReturn = argsList
		
		if context == CvUtil.PopupTypeEffectViewer:
			return CvDebugTools.g_CvDebugTools.applyEffectViewer( playerID, netUserData, popupReturn )
		
		entry = self.Events[context]
				
		if ( context not in CvUtil.SilentEvents ):
			self.reportEvent(entry, context, (playerID, netUserData, popupReturn) )
		return entry[1]( playerID, netUserData, popupReturn )   # the apply function

	def reportEvent(self, entry, context, argsList):
		'Report an Event to Events.log '
		if (gc.getGame().getActivePlayer() != -1):
			message = "DEBUG Event: %s (%s)" %(entry[0], gc.getActivePlayer().getName())
			CyInterface().addImmediateMessage(message,"")
			CvUtil.pyPrint(message)
		return 0
		
#################### ON EVENTS ######################
	def onKbdEvent(self, argsList):
		'keypress handler - return 1 if the event was consumed'

		eventType,key,mx,my,px,py = argsList
		game = gc.getGame()
		
		if (self.bAllowCheats):
			# notify debug tools of input to allow it to override the control
			argsList = (eventType,key,self.bCtrl,self.bShift,self.bAlt,mx,my,px,py,gc.getGame().isNetworkMultiPlayer())
			if ( CvDebugTools.g_CvDebugTools.notifyInput(argsList) ):
				return 0
		
		if ( eventType == self.EventKeyDown ):
			theKey=int(key)
			
			CvCameraControls.g_CameraControls.handleInput( theKey )

			if (self.bAllowCheats):
				# Shift - T (Debug - No MP)
				if (theKey == int(InputTypes.KB_T)):
					if ( self.bShift ):
						self.beginEvent(CvUtil.EventAwardTechsAndGold)
						#self.beginEvent(CvUtil.EventCameraControlPopup)
						return 1
							
				elif (theKey == int(InputTypes.KB_W)):
					if ( self.bShift and self.bCtrl):
						self.beginEvent(CvUtil.EventShowWonder)
						return 1
							
				# Shift - ] (Debug - currently mouse-overd unit, health += 10
				elif (theKey == int(InputTypes.KB_LBRACKET) and self.bShift ):
					unit = CyMap().plot(px, py).getUnit(0)
					if ( not unit.isNone() ):
						d = min( unit.maxHitPoints()-1, unit.getDamage() + 10 )
						unit.setDamage( d, PlayerTypes.NO_PLAYER )
					
				# Shift - [ (Debug - currently mouse-overd unit, health -= 10
				elif (theKey == int(InputTypes.KB_RBRACKET) and self.bShift ):
					unit = CyMap().plot(px, py).getUnit(0)
					if ( not unit.isNone() ):
						d = max( 0, unit.getDamage() - 10 )
						unit.setDamage( d, PlayerTypes.NO_PLAYER )
					
				elif (theKey == int(InputTypes.KB_F1)):
					if ( self.bShift ):
						CvScreensInterface.replayScreen.showScreen(False)
						return 1
					# don't return 1 unless you want the input consumed
				
				elif (theKey == int(InputTypes.KB_F2)):
					if ( self.bShift ):
						import CvDebugInfoScreen
						CvScreensInterface.showDebugInfoScreen()
						return 1
				
				elif (theKey == int(InputTypes.KB_F3)):
					if ( self.bShift ):
						CvScreensInterface.showDanQuayleScreen(())
						return 1
						
				elif (theKey == int(InputTypes.KB_F4)):
					if ( self.bShift ):
						CvScreensInterface.showUnVictoryScreen(())
						return 1
											
		return 0

	def onModNetMessage(self, argsList):
		'Called whenever CyMessageControl().sendModNetMessage() is called - this is all for you modders!'
		
		iData1, iData2, iData3, iData4, iData5 = argsList
		
		print("Modder's net message!")
		
		CvUtil.pyPrint( 'onModNetMessage' )
		
		# Rise of Mankind start
		iMessageID = iData1
		
		#Inquisitor's Effect on a City
		if ( iMessageID == self.m_iNetMessage_Inquisitor ):
			
			iPlotX = iData2
			iPlotY = iData3
			iOwner = iData4
			iUnitID = iData5
			
			pPlot = CyMap( ).plot( iPlotX, iPlotY )
			pCity = pPlot.getPlotCity( )
			pPlayer = gc.getPlayer( iOwner )
			pUnit = pPlayer.getUnit( iUnitID )
			
			self.doInquisitorPersecution( pCity, pUnit )
# Rise of Mankind 2.71
		# NetModMessage 410
		# SettlersEventManager.py / Colonist
		# Add additional buildings and change city size
		if ( gc.getDefineINT("ROM_MULTIPLAYER_FIX") <= 0 ):
			if ( iMessageID == self.m_iNetMessage_Colonist ):
				iPlotX = iData2
				iPlotY = iData3
				iOwner = iData4
				iUnitID = iData5
			
				pPlot = CyMap( ).plot( iPlotX, iPlotY )
				pCity = pPlot.getPlotCity( )
				pPlayer = gc.getPlayer( iOwner )
				
				pCity.setPopulation(3)
				self.addCityBuildings(pCity, "BUILDINGCLASS_BARRACKS")
				self.addCityBuildings(pCity, "BUILDINGCLASS_GRANARY")
				self.addCityBuildings(pCity, "BUILDINGCLASS_FORGE")
				self.addCityBuildings(pCity, "BUILDINGCLASS_MARKET")
				if pCity.plot().isCoastalLand():
					self.addCityBuildings(pCity, "BUILDINGCLASS_HARBOR")
					self.addCityBuildings(pCity, "BUILDINGCLASS_LIGHTHOUSE")
					self.addCityBuildings(pCity, "BUILDINGCLASS_FISHERMAN_HUT")
			
			# NetModMessage 411
			# SettlersEventManager.py / Pioneer
			# Add additional buildings and change city size
			if ( iMessageID == self.m_iNetMessage_Pioneer ):
				iPlotX = iData2
				iPlotY = iData3
				iOwner = iData4
				iUnitID = iData5
			
				pPlot = CyMap( ).plot( iPlotX, iPlotY )
				pCity = pPlot.getPlotCity( )
				pPlayer = gc.getPlayer( iOwner )
				
				pCity.setPopulation(4)
				self.addCityBuildings(pCity, "BUILDINGCLASS_GARRISON")
				self.addCityBuildings(pCity, "BUILDINGCLASS_GRANARY")
				self.addCityBuildings(pCity, "BUILDINGCLASS_FORGE")
				self.addCityBuildings(pCity, "BUILDINGCLASS_COURTHOUSE")
				self.addCityBuildings(pCity, "BUILDINGCLASS_MARKET")
				self.addCityBuildings(pCity, "BUILDINGCLASS_STABLE")
				self.addCityBuildings(pCity, "BUILDINGCLASS_GROCER")
				self.addCityBuildings(pCity, "BUILDINGCLASS_DOCTOR")
				self.addCityBuildings(pCity, "BUILDINGCLASS_BANK")
				self.addCityBuildings(pCity, "BUILDINGCLASS_LIBRARY")
				if pCity.plot().isCoastalLand():
					self.addCityBuildings(pCity, "BUILDINGCLASS_PORT")
					self.addCityBuildings(pCity, "BUILDINGCLASS_LIGHTHOUSE")
					self.addCityBuildings(pCity, "BUILDINGCLASS_FISHERMAN_HUT")
						
	def addCityBuildings(self, pCity, szBuilding):
		iBuilding = gc.getInfoTypeForString(szBuilding)
		iUniqueBuilding = gc.getCivilizationInfo(gc.getPlayer(pCity.getOwner()).getCivilizationType()).getCivilizationBuildings(iBuilding)
		if iUniqueBuilding > -1:
			if pCity.canConstruct(iUniqueBuilding, False, True, False):
				pCity.setNumRealBuilding(iUniqueBuilding, 1)
# Rise of Mankind 2.71
				
	def onInit(self, argsList):
		'Called when Civ starts up'
		CvUtil.pyPrint( 'OnInit' )
		
	def onUpdate(self, argsList):
		'Called every frame'
		fDeltaTime = argsList[0]
		
		# allow camera to be updated
		CvCameraControls.g_CameraControls.onUpdate( fDeltaTime )
		
	def onWindowActivation(self, argsList):
		'Called when the game window activates or deactivates'
		bActive = argsList[0]
		
	def onUnInit(self, argsList):
		'Called when Civ shuts down'
		CvUtil.pyPrint('OnUnInit')
	
	def onPreSave(self, argsList):
		"called before a game is actually saved"
		CvUtil.pyPrint('OnPreSave')
	
	def onSaveGame(self, argsList):
		"return the string to be saved - Must be a string"
		return ""

	def onLoadGame(self, argsList):
		CvAdvisorUtils.resetNoLiberateCities()
# Rise of Mankind 2.7
		for iBuildingUpgradeLine_OuterItem in range(self.asBuildingUpgradeLine_Upgrade_Name.__len__()):
			for iBuildingUpgradeLine_InnerItem_Upgrade in range(self.asBuildingUpgradeLine_Upgrade_Name[iBuildingUpgradeLine_OuterItem].__len__()):
				for iBuildingUpgradeLine_InnerItem_Obsolete in range(self.asBuildingUpgradeLine_Obsolete_Name[iBuildingUpgradeLine_OuterItem].__len__()):
					self.aiBuildingUpgradeLine_Upgrade_InfoTypeNum.append(CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), self.asBuildingUpgradeLine_Upgrade_Name[iBuildingUpgradeLine_OuterItem][iBuildingUpgradeLine_InnerItem_Upgrade]))
					self.aiBuildingUpgradeLine_Obsolete_InfoTypeNum.append(CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), self.asBuildingUpgradeLine_Obsolete_Name[iBuildingUpgradeLine_OuterItem][iBuildingUpgradeLine_InnerItem_Obsolete]))

		self.iBUILDING_CRUSADE = gc.getInfoTypeForString("BUILDING_CRUSADE")
# Rise of Mankind 2.7
# Rise of Mankind 2.71
		self.iBUILDING_DJENNE = gc.getInfoTypeForString("BUILDING_DJENNE")
		self.iBUILDING_WORLD_BANK = gc.getInfoTypeForString("BUILDING_WORLD_BANK")
		self.iTECH_KNOWLEDGE_MANAGEMENT = gc.getInfoTypeForString("TECH_KNOWLEDGE_MANAGEMENT")
		self.iPROJECT_EDEN = gc.getInfoTypeForString("PROJECT_EDEN")
# Rise of Mankind 2.71

		return 0

	def onGameStart(self, argsList):
		'Called at the start of the game'
		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()
# Rise of Mankind 2.63 - init building upgrade lines, can not be done earlier as the game inits python before it inits xml...
		for iBuildingUpgradeLine_OuterItem in range(self.asBuildingUpgradeLine_Upgrade_Name.__len__()):
			for iBuildingUpgradeLine_InnerItem_Upgrade in range(self.asBuildingUpgradeLine_Upgrade_Name[iBuildingUpgradeLine_OuterItem].__len__()):
				for iBuildingUpgradeLine_InnerItem_Obsolete in range(self.asBuildingUpgradeLine_Obsolete_Name[iBuildingUpgradeLine_OuterItem].__len__()):
					self.aiBuildingUpgradeLine_Upgrade_InfoTypeNum.append(CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), self.asBuildingUpgradeLine_Upgrade_Name[iBuildingUpgradeLine_OuterItem][iBuildingUpgradeLine_InnerItem_Upgrade]))
					self.aiBuildingUpgradeLine_Obsolete_InfoTypeNum.append(CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), self.asBuildingUpgradeLine_Obsolete_Name[iBuildingUpgradeLine_OuterItem][iBuildingUpgradeLine_InnerItem_Obsolete]))
		# def onBuildingBuilt / Additional tests variable
		self.iBUILDING_CRUSADE = gc.getInfoTypeForString("BUILDING_CRUSADE")
# Rise of Mankind
# Rise of Mankind 2.71
		self.iBUILDING_DJENNE = gc.getInfoTypeForString("BUILDING_DJENNE")
		self.iBUILDING_WORLD_BANK = gc.getInfoTypeForString("BUILDING_WORLD_BANK")
		self.iTECH_KNOWLEDGE_MANAGEMENT = gc.getInfoTypeForString("TECH_KNOWLEDGE_MANAGEMENT")
# Rise of Mankind 2.71
# Rise of Mankind 2.8
		self.iPROJECT_EDEN = gc.getInfoTypeForString('PROJECT_EDEN')
# Rise of Mankind 2.8

	def onGameEnd(self, argsList):
		'Called at the End of the game'
		print("Game is ending")
		return

	def onBeginGameTurn(self, argsList):
		'Called at the beginning of the end of each turn'
		iGameTurn = argsList[0]
		CvTopCivs.CvTopCivs().turnChecker(iGameTurn)

	def onEndGameTurn(self, argsList):
		'Called at the end of the end of each turn'
		iGameTurn = argsList[0]
		
	def onBeginPlayerTurn(self, argsList):
		'Called at the beginning of a players turn'
		iGameTurn, iPlayer = argsList	
		pPlayer = gc.getPlayer(iPlayer)
		
		pPlayer = gc.getPlayer(iPlayer)
# Rise of Mankind 2.7 start - world bank national wonder
		if gc.getTeam(pPlayer.getTeam()).isHasTech(gc.getInfoTypeForString("TECH_APPLIED_ECONOMICS")):
			b_WorldBank = gc.getInfoTypeForString("BUILDING_WORLD_BANK")
			obsoleteTech = gc.getBuildingInfo(b_WorldBank).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_WorldBank) == true:
						#pPID = pPlayer.getID()
						iGold = pPlayer.getGold( )
						pPlayer.changeGold( iGold//50 )
# Rise of Mankind 2.7 end
		
		#Inquisition Mod
		
#		BugUtil.info("RoM - Begin Player turn, do religious victory checks")
		# Code to determine if all cities have 6 "Religious Unity" Prerequisites by Orion Veteran
		# Special thanks to STO for providing the code strategy - Great Job! 
		# 1. A player must have an official State Religion
		# 2. A player must have the Holy City for the official State Religion	
		# 3. A player must have built the Shrine for the official State Religion			
		# 4. 80% a player's cities must have the official state religion established.
		# 5. All of a player's cities must not have any non-state religions established.
		# 6. Religious influence must be at least 80%
		
		#Is the "Religious" victory game option set to True?
		if CyGame().isVictoryValid(gc.getInfoTypeForString("VICTORY_RELIGIOUS")) :
			if (pPlayer.getNumCities() > 0) and (CyGame().getNumCivCities() > 2 * CyGame().countCivPlayersAlive()): # be sure the game is advanced enough to test a religious victory
				bUnity = True
				iStateReligion = pPlayer.getStateReligion()
			
				if iStateReligion == -1 :
					# No State Religion was Found - Prerequisite 1
					#CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'No State Religion!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),0,0,False,False)
					bUnity = False
				
				if bUnity :				
					if not pPlayer.hasHolyCity(iStateReligion) :
						# No Holy City was Found for the official state religion - Prerequisite 2
						#CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Holy City Not Found!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),0,0,False,False)
						bUnity = False
			
				if bUnity :
					bHasShrine = False
					MyShrine = CvUtil.CvGetStateReligionShrine(iPlayer)
					#CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Test','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),0,0,False,False)

					for iCity in range(pPlayer.getNumCities()):
						CVpCity = pPlayer.getCity(iCity)
						if CVpCity.isHasBuilding(gc.getInfoTypeForString(MyShrine)):
							# No official State Religion Shrine was found for the official state religion - Prerequisite 3
							bHasShrine = True
							break
							
					if not bHasShrine :
						#CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'No State Shrine was Found!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),0,0,False,False)
						bUnity = False
						
				if bUnity :
					#RevolutionDCM - relaxation of prerequisite 4 because of the practical difficulty in spreading state religion to every satellite settlement
					maxNonStatePercentThreshold = 20
					nonStateReligionCount = 0	
					numCities = len(PyHelpers.PyPlayer(iPlayer).getCityList())

					for pyCity in PyHelpers.PyPlayer(iPlayer).getCityList() :
						if not bUnity :
							break
				
						for iReligionLoop in range(gc.getNumReligionInfos()):
							if iReligionLoop == iStateReligion :
								if not pyCity.hasReligion(iReligionLoop) :
									# City does not have the official state religion - Prerequisite 4
									#CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'No State Religion founded in City!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),0,0,False,False)
									nonStateReligionCount += 1
								nonStateReligionPercent = 100 * nonStateReligionCount / numCities
								if nonStateReligionPercent > maxNonStatePercentThreshold:
									bUnity = False
									break
							elif pyCity.hasReligion(iReligionLoop) :
								# City has a non-State religion - Prerequisite 5
								if not CvUtil.isOC_INQISITOR_CAN_REMOVE_HOLY_CITY():
									if not CvUtil.isHoly(pyCity):
										bUnity = False
										break
								else:	
									#CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Found non-State Religion!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),0,0,False,False)
									bUnity = False
									break
								
				if bUnity :
					if CyGame().calculateReligionPercent(iStateReligion) < 75 :
						# Religeous influence is less than 75% - Prerequisite 6
						#CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'No Religion influence!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),0,0,False,False)
						bUnity = False							

				if bUnity :
					# The player has met all 5 prerequsites to achieve a valid religeous victory
					#CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Victory!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),0,0,False,False)
					CyGame().setWinner(pPlayer.getTeam(), gc.getInfoTypeForString("VICTORY_RELIGIOUS"))
# End Inquisition Mod
# Rise of Mankind 2.8 start - Scientific Victory when Ascension Gate is found from player city ie. it has been built
		if CyGame().isVictoryValid(gc.getInfoTypeForString("VICTORY_SCIENTIFIC")) :
			if gc.getTeam(pPlayer.getTeam()).isHasTech(gc.getInfoTypeForString("TECH_SENTIENT_EARTH")):
				b_AscensionGate = gc.getInfoTypeForString("BUILDING_ASCENSION_GATE")
				for iCity in range(pPlayer.getNumCities()):
					ppCity = pPlayer.getCity(iCity)
					if ppCity.getNumActiveBuilding(b_AscensionGate) == true:
						CyGame().setWinner(pPlayer.getTeam(), gc.getInfoTypeForString("VICTORY_SCIENTIFIC"))
 
Codes from ANM 2.1 continuing from 670th line, in last post codes end in 669th line.
CvEventManager.py:
Spoiler :
PHP:
# Rise of Mankind 2.8 end Scientific victory
# Rise of Mankind 2.6 - Crusade Start ##
#		test = ( iGameTurn % 14 )
#		BugUtil.info ( "crusade test: %d", test) 
		b_Crusade = self.iBUILDING_CRUSADE
		obsoleteTech = gc.getBuildingInfo(b_Crusade).getObsoleteTech()

		if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
#			BugUtil.info("RoM - crusader spawn, tech check passed")
			for iCity in range(pPlayer.getNumCities()):
				ppCity = pPlayer.getCity(iCity)
				if ppCity.getNumActiveBuilding(b_Crusade) == true:

					iX = ppCity.getX()
					iY = ppCity.getY()
					u_crusader = gc.getInfoTypeForString( "UNIT_CRUSADER" )

					estiEnd = CyGame().getEstimateEndTurn()
					if ( estiEnd >= 1800 ):
						if ( iGameTurn % 16 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					elif ( estiEnd >= 1400 ):
						if ( iGameTurn % 14 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					elif ( estiEnd >= 1000 ):
						if ( iGameTurn % 12 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					elif ( estiEnd >= 700 ):
						if ( iGameTurn % 8 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					elif ( estiEnd >= 500 ):
						if ( iGameTurn % 6 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					elif ( estiEnd >= 300 ):
						if ( iGameTurn % 4 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					else:
						if ( iGameTurn % 4 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )

# Rise of Mankind 2.6 - Crusade End #

		
	def onEndPlayerTurn(self, argsList):
		'Called at the end of a players turn'
		iGameTurn, iPlayer = argsList
		
		if (gc.getGame().getElapsedGameTurns() == 1):
			if (gc.getPlayer(iPlayer).isHuman()):
				if (gc.getPlayer(iPlayer).canRevolution(0)):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_CHANGECIVIC)
					popupInfo.addPopup(iPlayer)
		
		CvAdvisorUtils.resetAdvisorNags()
		CvAdvisorUtils.endTurnFeats(iPlayer)

	def onEndTurnReady(self, argsList):
		iGameTurn = argsList[0]

	def onFirstContact(self, argsList):
		'Contact'
		iTeamX,iHasMetTeamY = argsList
		if (not self.__LOG_CONTACT):
			return
		CvUtil.pyPrint('Team %d has met Team %d' %(iTeamX, iHasMetTeamY))
	
	def onCombatResult(self, argsList):
		'Combat Result'
		pWinner,pLoser = argsList
		playerX = PyPlayer(pWinner.getOwner())
		unitX = PyInfo.UnitInfo(pWinner.getUnitType())
		playerY = PyPlayer(pLoser.getOwner())
		unitY = PyInfo.UnitInfo(pLoser.getUnitType())
		if (not self.__LOG_COMBAT):
			return
		if playerX and playerX and unitX and playerY:
			CvUtil.pyPrint('Player %d Civilization %s Unit %s has defeated Player %d Civilization %s Unit %s' 
				%(playerX.getID(), playerX.getCivilizationName(), unitX.getDescription(), 
				playerY.getID(), playerY.getCivilizationName(), unitY.getDescription()))

	def onCombatLogCalc(self, argsList):
		'Combat Result'	
		genericArgs = argsList[0][0]
		cdAttacker = genericArgs[0]
		cdDefender = genericArgs[1]
		iCombatOdds = genericArgs[2]
		CvUtil.combatMessageBuilder(cdAttacker, cdDefender, iCombatOdds)
		
	def onCombatLogHit(self, argsList):
		'Combat Message'
		global gCombatMessages, gCombatLog
		genericArgs = argsList[0][0]
		cdAttacker = genericArgs[0]
		cdDefender = genericArgs[1]
		iIsAttacker = genericArgs[2]
		iDamage = genericArgs[3]
		
		if cdDefender.eOwner == cdDefender.eVisualOwner:
			szDefenderName = gc.getPlayer(cdDefender.eOwner).getNameKey()
		else:
			szDefenderName = localText.getText("TXT_KEY_TRAIT_PLAYER_UNKNOWN", ())
		if cdAttacker.eOwner == cdAttacker.eVisualOwner:
			szAttackerName = gc.getPlayer(cdAttacker.eOwner).getNameKey()
		else:
			szAttackerName = localText.getText("TXT_KEY_TRAIT_PLAYER_UNKNOWN", ())

		if (iIsAttacker == 0):
			combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_HIT", (szDefenderName, cdDefender.sUnitName, iDamage, cdDefender.iCurrHitPoints, cdDefender.iMaxHitPoints))
			CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
			CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)
			if (cdDefender.iCurrHitPoints <= 0):
				combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_DEFEATED", (szAttackerName, cdAttacker.sUnitName, szDefenderName, cdDefender.sUnitName))
				CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
				CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)
		elif (iIsAttacker == 1):
			combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_HIT", (szAttackerName, cdAttacker.sUnitName, iDamage, cdAttacker.iCurrHitPoints, cdAttacker.iMaxHitPoints))
			CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
			CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)
			if (cdAttacker.iCurrHitPoints <= 0):
				combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_DEFEATED", (szDefenderName, cdDefender.sUnitName, szAttackerName, cdAttacker.sUnitName))
				CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
				CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)

	def onImprovementBuilt(self, argsList):
		'Improvement Built'
		iImprovement, iX, iY = argsList
###AdvancedNukesbegin###
		pPlot = CyMap().plot(iX,iY)
		if(iImprovement==gc.getInfoTypeForString('IMPROVEMENT_SANITIZE_WATER')):
			pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_COAST" ), 1, 1)
			pPlot.setImprovementType(-1)
###AdvancedNukesend###
		if (not self.__LOG_IMPROVEMENT):
			return
		CvUtil.pyPrint('Improvement %s was built at %d, %d'
			%(PyInfo.ImprovementInfo(iImprovement).getDescription(), iX, iY))

	def onImprovementDestroyed(self, argsList):
		'Improvement Destroyed'
		iImprovement, iOwner, iX, iY = argsList
		if (not self.__LOG_IMPROVEMENT):
			return
		CvUtil.pyPrint('Improvement %s was Destroyed at %d, %d'
			%(PyInfo.ImprovementInfo(iImprovement).getDescription(), iX, iY))

	def onRouteBuilt(self, argsList):
		'Route Built'
		iRoute, iX, iY = argsList
		if (not self.__LOG_IMPROVEMENT):
			return
		CvUtil.pyPrint('Route %s was built at %d, %d'
			%(gc.getRouteInfo(iRoute).getDescription(), iX, iY))

	def onPlotRevealed(self, argsList):
		'Plot Revealed'
		pPlot = argsList[0]
		iTeam = argsList[1]

	def onPlotFeatureRemoved(self, argsList):
		'Plot Revealed'
		pPlot = argsList[0]
		iFeatureType = argsList[1]
		pCity = argsList[2] # This can be null

	def onPlotPicked(self, argsList):
		'Plot Picked'
		pPlot = argsList[0]
		CvUtil.pyPrint('Plot was picked at %d, %d'
			%(pPlot.getX(), pPlot.getY()))

	def onNukeExplosion(self, argsList):
		'Nuke Explosion'
		pPlot, pNukeUnit = argsList
###AdvancedNukesbegin###
		if (pNukeUnit is not None and pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_TURN')):
			if (pPlot.isCity()==true):
				iPlayer = pNukeUnit.getOwner()
				pPlayer = gc.getPlayer(iPlayer)
				pCity = pPlot.getPlotCity()
				pPlayer.acquireCity(pCity,false,false)
				iX = pPlot.getX()
				iY = pPlot.getY()
				for iiX in range(iX-1, iX+2, 1):
					for iiY in range(iY-1, iY+2, 1):
						numUnits = pPlot.getNumUnits()
						for e in xrange(numUnits,0,-1):
        						pUnit = pPlot.getUnit(e)
        						pUnit.kill(false, -1)  
						pNukedPlot = CyMap().plot(iiX,iiY)
						if (pNukedPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FALLOUT')):
							pNukedPlot.setFeatureType(-1, -1)
###AdvancedNukesend###
		CvUtil.pyPrint('Nuke detonated at %d, %d'
			%(pPlot.getX(), pPlot.getY()))
###AdvancedNukesbegin###		
		if (pNukeUnit is not None and pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_FUSION_NUKE')):

                        
                        iX = pPlot.getX()
                        iY = pPlot.getY()

			for iXLoop in range(iX - 0, iX + 1, 1):
				for iYLoop in range(iY - 0, iY + 1, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if (( pPlot.isPeak()==true  ) or (pPlot.isHills()==true)):
							pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
 						pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_COAST" ), 1, 1)

		if (pNukeUnit is not None and pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_FUSION_NOVA')):

                        
                        iX = pPlot.getX()
                        iY = pPlot.getY()

			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.isPeak()==true  ) or (pPlot.isHills()==true)):
							pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
 						pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_COAST" ), 1, 1)

		if (pNukeUnit is not None and pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_POISON_NUKE')):

                        
                        iX = pPlot.getX()
                        iY = pPlot.getY()

			for iXLoop in range(iX - 1, iX + 2, 1):
				for iYLoop in range(iY - 1, iY + 2, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						pPlot.setFeatureType(gc.getInfoTypeForString( "FEATURE_BIOGAS" ), 1)
						if ( pPlot.isWater()==true  ):
 							pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_SLIMY_COAST" ), 1, 1)

		if (pNukeUnit is not None and pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_POISON_NOVA')):

                        
                        iX = pPlot.getX()
                        iY = pPlot.getY()

			for iXLoop in range(iX - 5, iX + 6, 1):
				for iYLoop in range(iY - 5, iY + 6, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						pPlot.setFeatureType(gc.getInfoTypeForString( "FEATURE_PLAGUEGAS" ), 1)
						if ( pPlot.isWater()==true  ):
							pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_SLIMY_OCEAN" ), 1, 1)

###AdvancedNukesend###

	def onGotoPlotSet(self, argsList):
		'Nuke Explosion'
		pPlot, iPlayer = argsList

	def onBuildingBuilt(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList
		game = gc.getGame()
# Rise of Mankind 2.7 - Djenne Start

		if (iBuildingType == self.iBUILDING_DJENNE):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			pPID = pPlayer.getID()
			pTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()
			tt_desert = gc.getInfoTypeForString( 'TERRAIN_DESERT' )

			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(pPID)==true ):
						if ( pPlot.getTeam()==pTID ):
							if ( pPlot.getTerrainType()==tt_desert ):
								CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 2)
			
			
			CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_DJENNE_PYTHON",()),'',0,'Art/Interface/Buttons/Buildings/Djenne.dds',ColorTypes(44), iX, iY, True,True)
# Rise of Mankind 2.7 - Djenne end

		
# Rise of Mankind 2.7 start - world bank national wonder
		if iBuildingType == self.iBUILDING_WORLD_BANK:

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			pPID = pPlayer.getID()
			iGold = pPlayer.getGold( )
			pPlayer.changeGold( iGold//2 )
# Rise of Mankind 2.7 end
# Rise of Mankind 2.8 start - allow movies for national wonders
		#if ((not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer()) and isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType())):
		if ((not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer()) and (isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType()) or isNationalWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType()) )):
# Rise of Mankind 2.8 end
			# If this is a wonder...
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())

		CvAdvisorUtils.buildingBuiltFeats(pCity, iBuildingType)

# Rise of Mankind 2.63 start - building upgrade optimization
		# Building upgrade line check
		if self.aiBuildingUpgradeLine_Upgrade_InfoTypeNum.count(iBuildingType) > 0:	
			aiBuildingUpgradeLine_Upgrade_InfoTypeNum_Temp = self.aiBuildingUpgradeLine_Upgrade_InfoTypeNum[:]
			aiBuildingUpgradeLine_Obsolete_InfoTypeNum_Temp = self.aiBuildingUpgradeLine_Obsolete_InfoTypeNum[:]
			while aiBuildingUpgradeLine_Upgrade_InfoTypeNum_Temp.count(iBuildingType) > 0:
				iBuildingUpgradeLine_Item_Index = aiBuildingUpgradeLine_Upgrade_InfoTypeNum_Temp.index(iBuildingType)
				aiBuildingUpgradeLine_Upgrade_InfoTypeNum_Temp.remove(iBuildingType)
				pCity.setNumRealBuilding(aiBuildingUpgradeLine_Obsolete_InfoTypeNum_Temp.pop(iBuildingUpgradeLine_Item_Index), False)

# Rise of Mankind 2.63 end
		
# Rise of Mankind 2.6 - Crusade Start #

		# Crusade check
		if iBuildingType == self.iBUILDING_CRUSADE:
			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iPID = pPlayer.getID()
			iTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()
			u_crusader = gc.getInfoTypeForString("UNIT_CRUSADER")

			for i in range(1):
				pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )

# Rise of Mankind 2.6 - Crusade End ###

		if (not self.__LOG_BUILDING):
			return
		CvUtil.pyPrint('%s was finished by Player %d Civilization %s' 
			%(PyInfo.BuildingInfo(iBuildingType).getDescription(), pCity.getOwner(), gc.getPlayer(pCity.getOwner()).getCivilizationDescription(0)))
	
	def onProjectBuilt(self, argsList):
		'Project Completed'
		pCity, iProjectType = argsList
		game = gc.getGame()
		
# Rise of Mankind 2.8 - Eden project

		if iProjectType == self.iPROJECT_EDEN:

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			pPID = pPlayer.getID()
			pTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()
			tt_desert = gc.getInfoTypeForString( 'TERRAIN_DESERT' )
			tt_plain = gc.getInfoTypeForString( 'TERRAIN_PLAINS' )
			tt_grass = gc.getInfoTypeForString( 'TERRAIN_GRASS' )
			tt_tundra = gc.getInfoTypeForString( 'TERRAIN_TUNDRA' )
			tt_snow = gc.getInfoTypeForString( 'TERRAIN_SNOW' )
			tt_ocean = gc.getInfoTypeForString( 'TERRAIN_OCEAN' )
			tt_marsh = gc.getInfoTypeForString( 'TERRAIN_MARSH' )

			for iXLoop in range(iX - 50, iX + 50, 1):
				for iYLoop in range(iY - 50, iY + 50, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					#if ( pPlot.isPlayerCityRadius(pPID)==true ):
					if ( pPlot.getTeam()==pTID ):
						if ( pPlot.getTerrainType()==tt_grass ):
							if ( pPlot.getImprovementType()!=gc.getInfoTypeForString( 'IMPROVEMENT_FARM' )) and ( pPlot.getImprovementType()!=gc.getInfoTypeForString( 'IMPROVEMENT_VERTICAL_FARM' )) and ( pPlot.getImprovementType()!=gc.getInfoTypeForString( 'IMPROVEMENT_WINDMILL' )) and ( pPlot.getImprovementType()!=gc.getInfoTypeForString( 'IMPROVEMENT_PLANTATION' )) and ( pPlot.getImprovementType()!=gc.getInfoTypeForString( 'IMPROVEMENT_OLIVE_FARM' )) and ( pPlot.getImprovementType()!=gc.getInfoTypeForString( 'IMPROVEMENT_APPLE_FARM' )) and ( pPlot.getImprovementType()!=gc.getInfoTypeForString( 'IMPROVEMENT_WINERY' )) and ( pPlot.getImprovementType()!=gc.getInfoTypeForString( 'IMPROVEMENT_COTTAGE' )) and ( pPlot.getImprovementType()!=gc.getInfoTypeForString( 'IMPROVEMENT_HAMLET' )) and ( pPlot.getImprovementType()!=gc.getInfoTypeForString( 'IMPROVEMENT_VILLAGE' )) and ( pPlot.getImprovementType()!=gc.getInfoTypeForString( 'IMPROVEMENT_TOWN' )) and ( pPlot.getImprovementType()!=gc.getInfoTypeForString( 'IMPROVEMENT_FOREST_PRESERVE' )):
								if ( pPlot.getFeatureType()!=gc.getInfoTypeForString( 'FEATURE_JUNGLE' )):
									pPlot.setFeatureType(gc.getInfoTypeForString( "FEATURE_FOREST" ), 1)
						elif ( pPlot.getTerrainType()==tt_plain ):
							pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_GRASS" ), 1, 1)
						elif ( pPlot.getTerrainType()==tt_marsh ):
							pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_GRASS" ), 1, 1)
						elif ( pPlot.getTerrainType()==tt_tundra ):
							pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_PLAINS" ), 1, 1)
						elif ( pPlot.getTerrainType()==tt_snow ):
							pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_TUNDRA" ), 1, 1)
						elif ( pPlot.getTerrainType()==tt_ocean ):
							pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_COAST" ), 1, 1)
						elif ( pPlot.getTerrainType()==tt_desert ):
							pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_PLAINS" ), 1, 1)
			
			CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_EDEN_PYTHON",()),'',0,'Art/Interface/Buttons/Buildings/Eden.dds',ColorTypes(44), iX, iY, True,True)

# Rise of Mankind 2.8 # Eden End #

		if ((not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer())):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iProjectType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(2)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())
				
	def onSelectionGroupPushMission(self, argsList):
		'selection group mission'
		eOwner = argsList[0]
		eMission = argsList[1]
		iNumUnits = argsList[2]
		listUnitIds = argsList[3]
		
		if (not self.__LOG_PUSH_MISSION):
			return
		if pHeadUnit:
			CvUtil.pyPrint("Selection Group pushed mission %d" %(eMission))
	
	def onUnitMove(self, argsList):
		'unit move'
		pPlot,pUnit,pOldPlot = argsList
		player = PyPlayer(pUnit.getOwner())
		unitInfo = PyInfo.UnitInfo(pUnit.getUnitType())
		if (not self.__LOG_MOVEMENT):
			return
		if player and unitInfo:
			CvUtil.pyPrint('Player %d Civilization %s unit %s is moving to %d, %d' 
				%(player.getID(), player.getCivilizationName(), unitInfo.getDescription(), 
				pUnit.getX(), pUnit.getY()))

	def onUnitSetXY(self, argsList):
		'units xy coords set manually'
		pPlot,pUnit = argsList
		player = PyPlayer(pUnit.getOwner())
		unitInfo = PyInfo.UnitInfo(pUnit.getUnitType())
		if (not self.__LOG_MOVEMENT):
			return
		
	def onUnitCreated(self, argsList):
		'Unit Completed'
		unit = argsList[0]
		player = PyPlayer(unit.getOwner())
		if (not self.__LOG_UNITBUILD):
			return

	def onUnitBuilt(self, argsList):
		'Unit Completed'
		city = argsList[0]
		unit = argsList[1]
		player = PyPlayer(city.getOwner())

		CvAdvisorUtils.unitBuiltFeats(city, unit)
# Rise of Mankind 2.5
		# if player has Technocracy civic active, give free promotion to unit
		iPlayer = gc.getPlayer(city.getOwner())
		if gc.getTeam(iPlayer.getTeam()).isHasTech(self.iTECH_KNOWLEDGE_MANAGEMENT):
			iFutureCivicOption = CvUtil.findInfoTypeNum(gc.getCivicOptionInfo,gc.getNumCivicOptionInfos(),"CIVICOPTION_FUTURE")
			iTechnocracy = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),"CIVIC_TECHNOCRACY")

			iFutureCivic = iPlayer.getCivics(iFutureCivicOption)

			if (iFutureCivic == iTechnocracy):
				iSensors =  CvUtil.findInfoTypeNum(gc.getPromotionInfo, gc.getNumPromotionInfos(),'PROMOTION_SENSORS')
				if ( gc.getTeam(iPlayer.getTeam()).isHasTech(gc.getInfoTypeForString("TECH_SMART_DUST")) == true ):
					if (unit.isPromotionValid(iSensors)):
						unit.setHasPromotion(iSensors, True)
# Rise of Mankind 2.5

		
		if (not self.__LOG_UNITBUILD):
			return
		CvUtil.pyPrint('%s was finished by Player %d Civilization %s' 
			%(PyInfo.UnitInfo(unit.getUnitType()).getDescription(), player.getID(), player.getCivilizationName()))
	
	def onUnitKilled(self, argsList):
		'Unit Killed'
		unit, iAttacker = argsList
		player = PyPlayer(unit.getOwner())
		attacker = PyPlayer(iAttacker)
		if (not self.__LOG_UNITKILLED):
			return
		CvUtil.pyPrint('Player %d Civilization %s Unit %s was killed by Player %d' 
			%(player.getID(), player.getCivilizationName(), PyInfo.UnitInfo(unit.getUnitType()).getDescription(), attacker.getID()))

	def onUnitLost(self, argsList):
		'Unit Lost'
		unit = argsList[0]
		player = PyPlayer(unit.getOwner())
		if (not self.__LOG_UNITLOST):
			return
		CvUtil.pyPrint('%s was lost by Player %d Civilization %s' 
			%(PyInfo.UnitInfo(unit.getUnitType()).getDescription(), player.getID(), player.getCivilizationName()))
	
	def onUnitPromoted(self, argsList):
		'Unit Promoted'
		pUnit, iPromotion = argsList
		player = PyPlayer(pUnit.getOwner())
		if (not self.__LOG_UNITPROMOTED):
			return
		CvUtil.pyPrint('Unit Promotion Event: %s - %s' %(player.getCivilizationName(), pUnit.getName(),))
	
	def onUnitSelected(self, argsList):
		'Unit Selected'
		unit = argsList[0]
		player = PyPlayer(unit.getOwner())
		if (not self.__LOG_UNITSELECTED):
			return
		CvUtil.pyPrint('%s was selected by Player %d Civilization %s' 
			%(PyInfo.UnitInfo(unit.getUnitType()).getDescription(), player.getID(), player.getCivilizationName()))
	
	def onUnitRename(self, argsList):
		'Unit is renamed'
		pUnit = argsList[0]
		if (pUnit.getOwner() == gc.getGame().getActivePlayer()):
			self.__eventEditUnitNameBegin(pUnit)
	
	def onUnitPillage(self, argsList):
		'Unit pillages a plot'
		pUnit, iImprovement, iRoute, iOwner = argsList
		iPlotX = pUnit.getX()
		iPlotY = pUnit.getY()
		pPlot = CyMap().plot(iPlotX, iPlotY)
		
		if (not self.__LOG_UNITPILLAGE):
			return
		CvUtil.pyPrint("Player %d's %s pillaged improvement %d and route %d at plot at (%d, %d)" 
			%(iOwner, PyInfo.UnitInfo(pUnit.getUnitType()).getDescription(), iImprovement, iRoute, iPlotX, iPlotY))
	
	def onUnitSpreadReligionAttempt(self, argsList):
		'Unit tries to spread religion to a city'
		pUnit, iReligion, bSuccess = argsList
		
		iX = pUnit.getX()
		iY = pUnit.getY()
		pPlot = CyMap().plot(iX, iY)
		pCity = pPlot.getPlotCity()
	
	def onUnitGifted(self, argsList):
		'Unit is gifted from one player to another'
		pUnit, iGiftingPlayer, pPlotLocation = argsList
	
	def onUnitBuildImprovement(self, argsList):
		'Unit begins enacting a Build (building an Improvement or Route)'
		pUnit, iBuild, bFinished = argsList

	def onGoodyReceived(self, argsList):
		'Goody received'
		iPlayer, pPlot, pUnit, iGoodyType = argsList
		if (not self.__LOG_GOODYRECEIVED):
			return
		CvUtil.pyPrint('%s received a goody' %(gc.getPlayer(iPlayer).getCivilizationDescription(0)),)
	
	def onGreatPersonBorn(self, argsList):
		'Unit Promoted'
		pUnit, iPlayer, pCity = argsList
		player = PyPlayer(iPlayer)
		if pUnit.isNone() or pCity.isNone():
			return
		if (not self.__LOG_GREATPERSON):
			return
		CvUtil.pyPrint('A %s was born for %s in %s' %(pUnit.getName(), player.getCivilizationName(), pCity.getName()))
	
	def onTechAcquired(self, argsList):
		'Tech Acquired'
		iTechType, iTeam, iPlayer, bAnnounce = argsList
		# Note that iPlayer may be NULL (-1) and not a refer to a player object
		# Inquisition Mod
		rSlotAvailable = False
		xChooseReligion = False
		iRCount = 0
		
	
		#pHolyCity = False
		# End Inquisition Mod
		# Show tech splash when applicable
		if (iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash()):
			if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
				if ((not gc.getGame().isNetworkMultiPlayer()) and (iPlayer == gc.getGame().getActivePlayer())):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setData1(iTechType)
					popupInfo.setText(u"showTechSplash")
					popupInfo.addPopup(iPlayer)
					
		# Inquisition Mod
		CvPlayer = gc.getPlayer(iPlayer)
		
		# Is Tech a Religious Tech?
		if CvUtil.CvIsReligiousTech(iTechType):
#			BugUtil.info("Inquisition, religious tech acquired")
			# If game option is Limited Religions
			if RevDCMOpt.isOC_LIMITED_RELIGIONS():
				if not CvPlayer.isBarbarian() and CvPlayer.isAlive():
					#if iPlayer > -1 and not CvPlayer.isNone() and not CvPlayer.isBarbarian() and CvPlayer.isAlive():
					#CvGameUtils.LR_iPlayer = iPlayer
					# Does the player have a Holy City?
					if not CvUtil.OwnsHolyCity(iPlayer):
						# Loop through Religions
						for iReligion in range(gc.getNumReligionInfos()):
							# If the religion has not been founded
							if not gc.getGame().isReligionFounded(iReligion):
								# If game option is not set to choose religions
								if not CyGame().isOption(GameOptionTypes.GAMEOPTION_PICK_RELIGION):
									if gc.getReligionInfo(iReligion).getTechPrereq() == iTechType:
										gc.getPlayer(iPlayer).foundReligion(iReligion,iReligion,True)
										#CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Message 1','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),0,0,False,False)
										break
								# If game option is set to choose religions
								elif CyGame().isOption(GameOptionTypes.GAMEOPTION_PICK_RELIGION):
									rSlotAvailable = True
									break
						
						#  There is one or more unfounded Religions
						if rSlotAvailable:
							if CvUtil.CvGetTotalReligionsFounded() < 3:
								if iTechType == gc.getInfoTypeForString("TECH_CEREMONIAL_BURIAL") or iTechType == gc.getInfoTypeForString("TECH_POLYTHEISM") or iTechType == gc.getInfoTypeForString("TECH_DUALISM"):	
									xChooseReligion = True
							elif CvUtil.CvGetTotalReligionsFounded() < 5:
								if iTechType == gc.getInfoTypeForString("TECH_AESTHETICS") or iTechType == gc.getInfoTypeForString("TECH_MONOTHEISM"):
									xChooseReligion = True
							elif CvUtil.CvGetTotalReligionsFounded() < 7:
								if iTechType == gc.getInfoTypeForString("TECH_CODE_OF_LAWS") or iTechType == gc.getInfoTypeForString("TECH_MEDITATION"):
									xChooseReligion = True
							elif CvUtil.CvGetTotalReligionsFounded() < 9:
								if iTechType == gc.getInfoTypeForString("TECH_THEOLOGY") or iTechType == gc.getInfoTypeForString("TECH_CALENDAR"):	
									xChooseReligion = True
							elif CvUtil.CvGetTotalReligionsFounded() < 11:
								if iTechType == gc.getInfoTypeForString("TECH_EDUCATION") or iTechType == gc.getInfoTypeForString("TECH_PHILOSOPHY"):	
									xChooseReligion = True
						
						
						if xChooseReligion:
							if not CvPlayer.isHuman():
								if not CvUtil.OwnsHolyCity(iPlayer):
# rise of mankind 2.6 start - AI player chooses favorite religion rather than random one
									eFavorite = gc.getLeaderHeadInfo(CvPlayer.getLeaderType()).getFavoriteReligion()
									if eFavorite > -1 and not CyGame().isReligionFounded(eFavorite):
										gc.getPlayer(iPlayer).foundReligion(eFavorite,eFavorite,True)
									else:	
										gc.getPlayer(iPlayer).foundReligion(iReligion,iReligion,True)
# rise of mankind 2.6 end
							else:
								# Create Religion Selection Popup
								popupInfo = CyPopupInfo()
								popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
								popupInfo.setData1(iPlayer)
								popupInfo.setText(CyTranslator().getText(("TXT_KEY_FOUNDED_RELIGION"),()))
								
								# Find all unfounded religions
								for iNewReligion in range(gc.getNumReligionInfos()):
									if not gc.getGame().isReligionFounded(iNewReligion):
										popupInfo.addPythonButton(gc.getReligionInfo(iNewReligion).getDescription(), gc.getReligionInfo(iNewReligion).getButton())
										iRCount = iRCount + 1
										if iRCount == gc.getNumReligionInfos() - CvUtil.CvGetTotalReligionsFounded():
											# Display popup for human player to selected Religion
											popupInfo.addPopup(1)
											#CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Message C','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),0,0,False,False)
											break
											# End Inquisition Mod
 
Codes from ANM 2.1 continuing from 1325th line, in last post codes end in 1324th line.
CvEventManager.py:
Spoiler :
PHP:
		if (not self.__LOG_TECH):
			return
		CvUtil.pyPrint('%s was finished by Team %d'
			%(PyInfo.TechnologyInfo(iTechType).getDescription(), iTeam))
	
	def onTechSelected(self, argsList):
		'Tech Selected'
		iTechType, iPlayer = argsList
		if (not self.__LOG_TECH):
			return
		CvUtil.pyPrint('%s was selected by Player %d' %(PyInfo.TechnologyInfo(iTechType).getDescription(), iPlayer))
	
	def onReligionFounded(self, argsList):
		'Religion Founded'
		iReligion, iFounder = argsList
		player = PyPlayer(iFounder)
		
		iCityId = gc.getGame().getHolyCity(iReligion).getID()
		if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
			if ((not gc.getGame().isNetworkMultiPlayer()) and (iFounder == gc.getGame().getActivePlayer())):
				popupInfo = CyPopupInfo()
				popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
				popupInfo.setData1(iReligion)
				popupInfo.setData2(iCityId)
				popupInfo.setData3(1)
				popupInfo.setText(u"showWonderMovie")
				popupInfo.addPopup(iFounder)
		
		if (not self.__LOG_RELIGION):
			return
		CvUtil.pyPrint('Player %d Civilization %s has founded %s'
			%(iFounder, player.getCivilizationName(), gc.getReligionInfo(iReligion).getDescription()))

	def onReligionSpread(self, argsList):
		'Religion Has Spread to a City'
		iReligion, iOwner, pSpreadCity = argsList
		player = PyPlayer(iOwner)
		if (not self.__LOG_RELIGIONSPREAD):
			return
		CvUtil.pyPrint('%s has spread to Player %d Civilization %s city of %s'
			%(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pSpreadCity.getName()))

	def onReligionRemove(self, argsList):
		'Religion Has been removed from a City'
		iReligion, iOwner, pRemoveCity = argsList
		player = PyPlayer(iOwner)
		if (not self.__LOG_RELIGIONSPREAD):
			return
		CvUtil.pyPrint('%s has been removed from Player %d Civilization %s city of %s'
			%(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pRemoveCity.getName()))
				
	def onCorporationFounded(self, argsList):
		'Corporation Founded'
		iCorporation, iFounder = argsList
		player = PyPlayer(iFounder)
		
		if (not self.__LOG_RELIGION):
			return
		CvUtil.pyPrint('Player %d Civilization %s has founded %s'
			%(iFounder, player.getCivilizationName(), gc.getCorporationInfo(iCorporation).getDescription()))

	def onCorporationSpread(self, argsList):
		'Corporation Has Spread to a City'
		iCorporation, iOwner, pSpreadCity = argsList
		player = PyPlayer(iOwner)
		if (not self.__LOG_RELIGIONSPREAD):
			return
		CvUtil.pyPrint('%s has spread to Player %d Civilization %s city of %s'
			%(gc.getCorporationInfo(iCorporation).getDescription(), iOwner, player.getCivilizationName(), pSpreadCity.getName()))

	def onCorporationRemove(self, argsList):
		'Corporation Has been removed from a City'
		iCorporation, iOwner, pRemoveCity = argsList
		player = PyPlayer(iOwner)
		if (not self.__LOG_RELIGIONSPREAD):
			return
		CvUtil.pyPrint('%s has been removed from Player %d Civilization %s city of %s'
			%(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pRemoveCity.getName()))
				
	def onGoldenAge(self, argsList):
		'Golden Age'
		iPlayer = argsList[0]
		player = PyPlayer(iPlayer)
		if (not self.__LOG_GOLDENAGE):
			return
		CvUtil.pyPrint('Player %d Civilization %s has begun a golden age'
			%(iPlayer, player.getCivilizationName()))

	def onEndGoldenAge(self, argsList):
		'End Golden Age'
		iPlayer = argsList[0]
		player = PyPlayer(iPlayer)
		if (not self.__LOG_ENDGOLDENAGE):
			return
		CvUtil.pyPrint('Player %d Civilization %s golden age has ended'
			%(iPlayer, player.getCivilizationName()))

	def onChangeWar(self, argsList):
		'War Status Changes'
		bIsWar = argsList[0]
		iTeam = argsList[1]
		iRivalTeam = argsList[2]
		if (not self.__LOG_WARPEACE):
			return
		if (bIsWar):
			strStatus = "declared war"
		else:
			strStatus = "declared peace"
		CvUtil.pyPrint('Team %d has %s on Team %d'
			%(iTeam, strStatus, iRivalTeam))
	
	def onChat(self, argsList):
		'Chat Message Event'
		chatMessage = "%s" %(argsList[0],)
		
	def onSetPlayerAlive(self, argsList):
		'Set Player Alive Event'
		iPlayerID = argsList[0]
		bNewValue = argsList[1]
		CvUtil.pyPrint("Player %d's alive status set to: %d" %(iPlayerID, int(bNewValue)))
		
	def onPlayerChangeStateReligion(self, argsList):
		'Player changes his state religion'
		iPlayer, iNewReligion, iOldReligion = argsList
		
	def onPlayerGoldTrade(self, argsList):
		'Player Trades gold to another player'
		iFromPlayer, iToPlayer, iGoldAmount = argsList
		
	def onCityBuilt(self, argsList):
		'City Built'
		city = argsList[0]
		if (city.getOwner() == gc.getGame().getActivePlayer()):
			self.__eventEditCityNameBegin(city, False)	
		CvUtil.pyPrint('City Built Event: %s' %(city.getName()))
		
	def onCityRazed(self, argsList):
		'City Razed'
		city, iPlayer = argsList
		iOwner = city.findHighestCulture()
		iGoldTotal = 0
		Respawn = False
		pPlayer = gc.getPlayer(iPlayer)
		iStateReligion = pPlayer.getStateReligion()
		
# Rise of Mankind 2.6 Start 
		self.iArcologyCityID = -1
		
		if city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY")) or city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING")) or city.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ADVANCED_SHIELDING")):
			self.iArcologyCityID = city.getID()
		
		# Removes all non-state Religious Buildings from the City
		for iBuildingLoop in range(gc.getNumBuildingInfos( )):
			if city.isHasBuilding( iBuildingLoop ):
				pBuilding = gc.getBuildingInfo( iBuildingLoop )
				iRequiredReligion = pBuilding.getReligionType( )
				for iReligionLoop in range(gc.getNumReligionInfos()):
					if iReligionLoop != pPlayer.getStateReligion( ):
						if iRequiredReligion == iReligionLoop:
							if CvUtil.OCHasNonStateShrine(pPlayer, iBuildingLoop):
								# Greatly increases Anger for all AIs who share the religion of the destroyed Shrine
								CvUtil.AIAttitudeAdjustment(iPlayer, iRequiredReligion, -3 )
								# Add gold to treasury for pillaging the non-state Shrine
# Rise of Mankind 2.7 - adjustments to how much gold you get from purging non-state religions, 20% from Orion's Inquisition defaults
								iGoldTotal = iGoldTotal + 100 # Orion's Inquisition default 500
								CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Destruction of a non-state Holy Shrine has angered AI Civs!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(7),0,0,False,False)
							else:
								# Increases Anger for all AIs who share the religion of a destroyed Temple, Monastery or Cathedral
								CvUtil.AIAttitudeAdjustment(iPlayer, iRequiredReligion, -1 )
								# Add gold to treasury for pillaging the non-state Religious Building									
								iGoldTotal = iGoldTotal + 50 # Orion's Inquisition default 250
							
		# Check default -- Does game option allow removal of a Holy City?
		if RevDCMOpt.isOC_RESPAWN_HOLY_CITIES():
			for iReligionLoop in range(gc.getNumReligionInfos()):
				# Make sure only non-state religions are selected
				if iReligionLoop != iStateReligion:
					# Is this a non-state Holy City?
					if city.isHolyCityByType( iReligionLoop ):
						# Increases Anger for all AIs who share the purged Holy City
						CvUtil.AIAttitudeAdjustment(iPlayer, iReligionLoop, -3 )
						# Remove non-state Holy City identifier
						gc.getGame( ).clearHolyCity( iReligionLoop )
						# Add gold to treasury for pillaging the non-state Holy City							
						iGoldTotal = iGoldTotal + 100 # Orion's Inquisition default 500
						# Increases Anger for all AIs who share the purged religion						
						CvUtil.AIAttitudeAdjustment(iPlayer, iReligionLoop, -1 )
						# Remove non-state religion
						city.setHasReligion(iReligionLoop, 0, 0, 0)						
						# Add gold to treasury to compensate for inquisition costs
						iGoldTotal = iGoldTotal + 20 # Orion's Inquisition default 100
						CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Destruction of a non-state Holy City has angered AI Civs!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(7),0,0,False,False)
						# Is there at least 1 non Holy City remaining with HC Religion?  
						if CvUtil.findCityWithXReligion(iReligionLoop):
							# Set Minimum of Two Cities required for Respawning a Holy City
							minCitiesForInfluence = 2
							# Find player with the greatest Religious Influence for Religion 
							eBestPlayer = CvUtil.getPlayerWithMaxInfluenceForReligion(iReligionLoop, minCitiesForInfluence)	
							# If there is a player with enough Religious Influence for Religion
							if eBestPlayer >= 0:
								XpPlayer = gc.getPlayer(eBestPlayer)
								# Respawn the Holy City 
								CvUtil.ReSpawnHolyCity(XpPlayer, iReligionLoop)
					
					elif city.isHasReligion( iReligionLoop ):
						# Increases Anger for all AIs who share the purged religion						
						CvUtil.AIAttitudeAdjustment(iPlayer, iReligionLoop, -1 )
						# Add gold to treasury for pillaging 						
						iGoldTotal = iGoldTotal + 20 # Orion's Inquisition default 100
# Rise of Mankind 2.7 end
			# Total Pillage Reward
			pPlayer.changeGold(iGoldTotal)
# Rise of Mankind 2.6 end
			
		# 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)
			
		CvUtil.pyPrint("City Razed Event: %s" %(city.getName(),))
			
	def onCityAcquired(self, argsList):
		'City Acquired'
		iPreviousOwner,iNewOwner,pCity,bConquest,bTrade = argsList
		CvUtil.pyPrint('City Acquired Event: %s' %(pCity.getName()))
	
	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
		iOwner,pCity = argsList
		CvUtil.pyPrint('City Acquired and Kept Event: %s' %(pCity.getName()))
	
	def onCityLost(self, argsList):
		'City Lost'
		city = argsList[0]
		player = PyPlayer(city.getOwner())
		
		# RoM Start
		if city.getID() == self.iArcologyCityID:
			city.plot().setImprovementType(gc.getInfoTypeForString("IMPROVEMENT_CITY_RUINS_ARCOLOGY"))
		# RoM end
		
		if (not self.__LOG_CITYLOST):
			return
		CvUtil.pyPrint('City %s was lost by Player %d Civilization %s' 
			%(city.getName(), player.getID(), player.getCivilizationName()))
	
	def onCultureExpansion(self, argsList):
		'City Culture Expansion'
		pCity = argsList[0]
		iPlayer = argsList[1]
		CvUtil.pyPrint("City %s's culture has expanded" %(pCity.getName(),))
	
	def onCityGrowth(self, argsList):
		'City Population Growth'
		pCity = argsList[0]
		iPlayer = argsList[1]
		CvUtil.pyPrint("%s has grown" %(pCity.getName(),))
	
	def onCityDoTurn(self, argsList):
		'City Production'
		pCity = argsList[0]
		iPlayer = argsList[1]

		CvAdvisorUtils.cityAdvise(pCity, iPlayer)
	
	def onCityBuildingUnit(self, argsList):
		'City begins building a unit'
		pCity = argsList[0]
		iUnitType = argsList[1]
		if (not self.__LOG_CITYBUILDING):
			return
		CvUtil.pyPrint("%s has begun building a %s" %(pCity.getName(),gc.getUnitInfo(iUnitType).getDescription()))
	
	def onCityBuildingBuilding(self, argsList):
		'City begins building a Building'
		pCity = argsList[0]
		iBuildingType = argsList[1]
		if (not self.__LOG_CITYBUILDING):
			return
		CvUtil.pyPrint("%s has begun building a %s" %(pCity.getName(),gc.getBuildingInfo(iBuildingType).getDescription()))
	
	def onCityRename(self, argsList):
		'City is renamed'
		pCity = argsList[0]
		if (pCity.getOwner() == gc.getGame().getActivePlayer()):
			self.__eventEditCityNameBegin(pCity, True)	
	
	def onCityHurry(self, argsList):
		'City is renamed'
		pCity = argsList[0]
		iHurryType = argsList[1]

	def onVictory(self, argsList):
		'Victory'
		iTeam, iVictory = argsList
		if (iVictory >= 0 and iVictory < gc.getNumVictoryInfos()):
			victoryInfo = gc.getVictoryInfo(int(iVictory))
			CvUtil.pyPrint("Victory!  Team %d achieves a %s victory"
				%(iTeam, victoryInfo.getDescription()))
	
	def onVassalState(self, argsList):
		'Vassal State'
		iMaster, iVassal, bVassal = argsList
		
		if (bVassal):
			CvUtil.pyPrint("Team %d becomes a Vassal State of Team %d"
				%(iVassal, iMaster))
		else:
			CvUtil.pyPrint("Team %d revolts and is no longer a Vassal State of Team %d"
				%(iVassal, iMaster))
	
	def onGameUpdate(self, argsList):
		'sample generic event, called on each game turn slice'
		genericArgs = argsList[0][0]	# tuple of tuple of my args
		turnSlice = genericArgs[0]
# Rise of Mankind 2.7
		OOSLogger.doGameUpdate()
# Rise of Mankind 2.7
		
	def onMouseEvent(self, argsList):
		'mouse handler - returns 1 if the event was consumed'
		eventType,mx,my,px,py,interfaceConsumed,screens = argsList
		if ( px!=-1 and py!=-1 ):
			if ( eventType == self.EventLButtonDown ):
				if (self.bAllowCheats and self.bCtrl and self.bAlt and CyMap().plot(px,py).isCity() and not interfaceConsumed):
					# Launch Edit City Event
					self.beginEvent( CvUtil.EventEditCity, (px,py) )
					return 1
				
				elif (self.bAllowCheats and self.bCtrl and self.bShift and not interfaceConsumed):
					# Launch Place Object Event
					self.beginEvent( CvUtil.EventPlaceObject, (px, py) )
					return 1
			
		if ( eventType == self.EventBack ):
			return CvScreensInterface.handleBack(screens)
		elif ( eventType == self.EventForward ):
			return CvScreensInterface.handleForward(screens)
		
		return 0

#################### TRIGGERED EVENTS ##################	
				
	def __eventEditCityNameBegin(self, city, bRename):
		popup = PyPopup.PyPopup(CvUtil.EventEditCityName, EventContextTypes.EVENTCONTEXT_ALL)
		popup.setUserData((city.getID(), bRename))
		popup.setHeaderString(localText.getText("TXT_KEY_NAME_CITY", ()))
		popup.setBodyString(localText.getText("TXT_KEY_SETTLE_NEW_CITY_NAME", ()))
		popup.createEditBox(city.getName())
		popup.setEditBoxMaxCharCount( 15 )
		popup.launch()
	
	def __eventEditCityNameApply(self, playerID, userData, popupReturn):	
		'Edit City Name Event'
		iCityID = userData[0]
		bRename = userData[1]
		player = gc.getPlayer(playerID)
		city = player.getCity(iCityID)
		cityName = popupReturn.getEditBoxString(0)
		if (len(cityName) > 30):
			cityName = cityName[:30]
		city.setName(cityName, not bRename)

	def __eventEditCityBegin(self, argsList):
		'Edit City Event'
		px,py = argsList
		CvWBPopups.CvWBPopups().initEditCity(argsList)
	
	def __eventEditCityApply(self, playerID, userData, popupReturn):
		'Edit City Event Apply'
		if (getChtLvl() > 0):
			CvWBPopups.CvWBPopups().applyEditCity( (popupReturn, userData) )

	def __eventPlaceObjectBegin(self, argsList):
		'Place Object Event'
		CvDebugTools.CvDebugTools().initUnitPicker(argsList)
	
	def __eventPlaceObjectApply(self, playerID, userData, popupReturn):
		'Place Object Event Apply'
		if (getChtLvl() > 0):
			CvDebugTools.CvDebugTools().applyUnitPicker( (popupReturn, userData) )

	def __eventAwardTechsAndGoldBegin(self, argsList):
		'Award Techs & Gold Event'
		CvDebugTools.CvDebugTools().cheatTechs()
	
	def __eventAwardTechsAndGoldApply(self, playerID, netUserData, popupReturn):
		'Award Techs & Gold Event Apply'
		if (getChtLvl() > 0):
			CvDebugTools.CvDebugTools().applyTechCheat( (popupReturn) )
	
	def __eventShowWonderBegin(self, argsList):
		'Show Wonder Event'
		CvDebugTools.CvDebugTools().wonderMovie()
	
	def __eventShowWonderApply(self, playerID, netUserData, popupReturn):
		'Wonder Movie Apply'
		if (getChtLvl() > 0):
			CvDebugTools.CvDebugTools().applyWonderMovie( (popupReturn) )
	
	def __eventEditUnitNameBegin(self, argsList):
		pUnit = argsList
		popup = PyPopup.PyPopup(CvUtil.EventEditUnitName, EventContextTypes.EVENTCONTEXT_ALL)
		popup.setUserData((pUnit.getID(),))
		popup.setBodyString(localText.getText("TXT_KEY_RENAME_UNIT", ()))
		popup.createEditBox(pUnit.getNameNoDesc())
		popup.launch()

	def __eventEditUnitNameApply(self, playerID, userData, popupReturn):	
		'Edit Unit Name Event'
		iUnitID = userData[0]
		unit = gc.getPlayer(playerID).getUnit(iUnitID)
		newName = popupReturn.getEditBoxString(0)
		if (len(newName) > 25):
			newName = newName[:25]			
		unit.setName(newName)

	def __eventWBAllPlotsPopupBegin(self, argsList):
		CvScreensInterface.getWorldBuilderScreen().allPlotsCB()
		return
	def __eventWBAllPlotsPopupApply(self, playerID, userData, popupReturn):
		if (popupReturn.getButtonClicked() >= 0):
			CvScreensInterface.getWorldBuilderScreen().handleAllPlotsCB(popupReturn)
		return

	def __eventWBLandmarkPopupBegin(self, argsList):
		CvScreensInterface.getWorldBuilderScreen().setLandmarkCB("")
		#popup = PyPopup.PyPopup(CvUtil.EventWBLandmarkPopup, EventContextTypes.EVENTCONTEXT_ALL)
		#popup.createEditBox(localText.getText("TXT_KEY_WB_LANDMARK_START", ()))
		#popup.launch()
		return

	def __eventWBLandmarkPopupApply(self, playerID, userData, popupReturn):
		if (popupReturn.getEditBoxString(0)):
			szLandmark = popupReturn.getEditBoxString(0)
			if (len(szLandmark)):
				CvScreensInterface.getWorldBuilderScreen().setLandmarkCB(szLandmark)
		return

	def __eventWBScriptPopupBegin(self, argsList):
		popup = PyPopup.PyPopup(CvUtil.EventWBScriptPopup, EventContextTypes.EVENTCONTEXT_ALL)
		popup.setHeaderString(localText.getText("TXT_KEY_WB_SCRIPT", ()))
		popup.createEditBox(CvScreensInterface.getWorldBuilderScreen().getCurrentScript())
		popup.launch()
		return

	def __eventWBScriptPopupApply(self, playerID, userData, popupReturn):
		if (popupReturn.getEditBoxString(0)):
			szScriptName = popupReturn.getEditBoxString(0)
			CvScreensInterface.getWorldBuilderScreen().setScriptCB(szScriptName)
		return

	def __eventWBStartYearPopupBegin(self, argsList):
		popup = PyPopup.PyPopup(CvUtil.EventWBStartYearPopup, EventContextTypes.EVENTCONTEXT_ALL)
		popup.createSpinBox(0, "", gc.getGame().getStartYear(), 1, 5000, -5000)
		popup.launch()
		return

	def __eventWBStartYearPopupApply(self, playerID, userData, popupReturn):
		iStartYear = popupReturn.getSpinnerWidgetValue(int(0))
		CvScreensInterface.getWorldBuilderScreen().setStartYearCB(iStartYear)
		return
		
# Rise of Mankind 2.7 Start
	def doInquisitorPersecution( self, pCity, pUnit ):
		revModEnabled = gc.getGame().isOption(GameOptionTypes.GAMEOPTION_REVOLUTION)
		pPlayer = gc.getPlayer( pCity.getOwner( ) )
		iPlayer = pPlayer.getID( )
		iGoldTotal = 0
		
		# gets a list of all religions in the city except state religion
		CyInterface().playGeneralSound("AS3D_UN_CHRIST_MISSIONARY_ACTIVATE")
		lCityReligions = [ ]
		for iReligionLoop in range(gc.getNumReligionInfos( )):
			if pCity.isHasReligion( iReligionLoop ):
				if pPlayer.getStateReligion( ) != iReligionLoop:
					lCityReligions.append( iReligionLoop )
					iHC = 0
					if pCity.isHolyCityByType(iReligionLoop):
						iHC = -50
				else:
					if pCity.isHolyCityByType(iReligionLoop):
						iHC = 10

		# Does Persecution succeed
		irandom = gc.getGame().getSorenRandNum(100,"")
		if irandom < 95 - ((len( lCityReligions ))*5) + iHC:
			
			# increases Anger for all AIs in City Religion List
			if len( lCityReligions ) > 0:
				lPlayers =PyGame().getCivPlayerList()
				for iAI_PlayersLoop in range( len(lPlayers) ):
					pSecondPlayer = lPlayers[iAI_PlayersLoop]
					iSecondPlayer = pSecondPlayer.getID( )
					for iAIAngerLoop in range( len( lCityReligions ) ):
						pReligion = gc.getReligionInfo( lCityReligions[iAIAngerLoop] )
						if pSecondPlayer.getStateReligion( ) == lCityReligions[iAIAngerLoop]:
							pSecondPlayer.AI_changeAttitude( pPlayer.getID( ), -1 )
							CyInterface().addMessage(iSecondPlayer,False,25,CyTranslator().getText("TXT_KEY_MESSAGE_INQUISITION_GLOBAL",(pCity.getName(),pReligion.getText())),"AS2D_PLAGUE",InterfaceMessageTypes.MESSAGE_TYPE_INFO,pUnit.getButton(),ColorTypes(7),pCity.getX(),pCity.getY(),True,True)
						else:
							if iSecondPlayer != iPlayer:
								lCities = PyPlayer( iSecondPlayer ).getCityList( )
								for iCityloop in range( pSecondPlayer.getNumCities() ):
									pPlayerCity = lCities[ iCityloop ]
									if pPlayerCity.isHolyCityByType(lCityReligions[iAIAngerLoop]):
										CyInterface().addMessage(iSecondPlayer,False,25,CyTranslator().getText("TXT_KEY_MESSAGE_INQUISITION_GLOBAL",(pCity.getName(),pReligion.getText())),"AS2D_PLAGUE",InterfaceMessageTypes.MESSAGE_TYPE_INFO,pUnit.getButton(),ColorTypes(7),pCity.getX(),pCity.getY(),True,True)

			# removes buildings
			for iBuildingLoop in range(gc.getNumBuildingInfos( )):
				if pCity.isHasBuilding( iBuildingLoop ):
					pBuilding = gc.getBuildingInfo( iBuildingLoop )
					#Shrines are excluded from consideration here
					iRequiredReligion = pBuilding.getPrereqReligion( )
					#Next line would also include shrines
					#iRequiredReligion = pBuilding.getReligionType( )
					for iReligionLoop in range(gc.getNumReligionInfos()):
						if iReligionLoop != pPlayer.getStateReligion( ):
							if iRequiredReligion == iReligionLoop:
								pCity.setNumRealBuilding ( iBuildingLoop,0 )

			# remove religions
			iStateReligion = gc.getPlayer( pUnit.getOwner( ) ).getStateReligion( )
			for iReligionLoop in range(gc.getNumReligionInfos()):
				if iReligionLoop != iStateReligion:
					if RevDCMOpt.isOC_RESPAWN_HOLY_CITIES():
						if pCity.isHolyCityByType(iReligionLoop):
							gc.getGame().clearHolyCity(iReligionLoop)
							pCity.setHasReligion(iReligionLoop, 0, 0, 0)
							minCitiesForInfluence = 2
							eBestPlayer = CvUtil.getPlayerWithMaxInfluenceForReligion(iReligionLoop, minCitiesForInfluence)
							if eBestPlayer >= 0:
								XpPlayer = gc.getPlayer(eBestPlayer)
								CvUtil.ReSpawnHolyCity(XpPlayer, iReligionLoop)
					if not pCity.isHolyCityByType(iReligionLoop):
						pCity.setHasReligion(iReligionLoop, 0, 0, 0)
						# Add gold to treasury to compensate for inquisition costs
# Rise of Mankind 2.7 adjustment how much gold you get from successful Inquisitor usage, gives now 20% of default setting
						iGoldTotal = iGoldTotal + 20 # default was 100

			# Persecution succeeds
			CyInterface().addMessage(CyGame().getActivePlayer(),False,25,CyTranslator().getText("TXT_KEY_MESSAGE_INQUISITION",(pCity.getName(),)),"AS2D_PLAGUE",InterfaceMessageTypes.MESSAGE_TYPE_INFO,pUnit.getButton(),ColorTypes(8),pCity.getX(),pCity.getY(),True,True)
			if revModEnabled:
				# Unhappiness from persecution
				pCity.changeHurryAngerTimer(pCity.flatHurryAngerLength())
				# RevolutionDCM - inquisitions
				pCity.changeRevolutionIndex(-100)
			else:
				pPlayer.changeGold(iGoldTotal)
		else:
			# Persecution fails
			CyInterface().addMessage(CyGame().getActivePlayer(),False,25,CyTranslator().getText("TXT_KEY_MESSAGE_INQUISITION_FAIL",(pCity.getName(),)),"AS2D_SABOTAGE",InterfaceMessageTypes.MESSAGE_TYPE_INFO,pUnit.getButton(),ColorTypes(7),pCity.getX(),pCity.getY(),True,True)
			if revModEnabled:
				# Unhappiness from attempted persecution
				pCity.changeRevolutionIndex(200)
				pCity.changeHurryAngerTimer(pCity.flatHurryAngerLength())
			else:
				pCity.changeHurryAngerTimer(pCity.flatHurryAngerLength())
				
		# Unit expended
		pUnit.kill( 0, -1 )

This is end of codes in CvEventManager.py
 
I plan to use this part of codes from CvEventManager.py:

804th-809th lines:
Spoiler :
PHP:
###AdvancedNukesbegin###
		pPlot = CyMap().plot(iX,iY)
		if(iImprovement==gc.getInfoTypeForString('IMPROVEMENT_SANITIZE_WATER')):
			pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_COAST" ), 1, 1)
			pPlot.setImprovementType(-1)
###AdvancedNukesend###

851st-869th lines:

Spoiler :
PHP:
###AdvancedNukesbegin###
		if (pNukeUnit is not None and pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_TURN')):
			if (pPlot.isCity()==true):
				iPlayer = pNukeUnit.getOwner()
				pPlayer = gc.getPlayer(iPlayer)
				pCity = pPlot.getPlotCity()
				pPlayer.acquireCity(pCity,false,false)
				iX = pPlot.getX()
				iY = pPlot.getY()
				for iiX in range(iX-1, iX+2, 1):
					for iiY in range(iY-1, iY+2, 1):
						numUnits = pPlot.getNumUnits()
						for e in xrange(numUnits,0,-1):
        						pUnit = pPlot.getUnit(e)
        						pUnit.kill(false, -1)  
						pNukedPlot = CyMap().plot(iiX,iiY)
						if (pNukedPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FALLOUT')):
							pNukedPlot.setFeatureType(-1, -1)
###AdvancedNukesend###

872nd-925th lines:

Spoiler :
PHP:
###AdvancedNukesbegin###		
		if (pNukeUnit is not None and pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_FUSION_NUKE')):

                        
                        iX = pPlot.getX()
                        iY = pPlot.getY()

			for iXLoop in range(iX - 0, iX + 1, 1):
				for iYLoop in range(iY - 0, iY + 1, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if (( pPlot.isPeak()==true  ) or (pPlot.isHills()==true)):
							pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
 						pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_COAST" ), 1, 1)

		if (pNukeUnit is not None and pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_FUSION_NOVA')):

                        
                        iX = pPlot.getX()
                        iY = pPlot.getY()

			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.isPeak()==true  ) or (pPlot.isHills()==true)):
							pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
 						pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_COAST" ), 1, 1)

		if (pNukeUnit is not None and pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_POISON_NUKE')):

                        
                        iX = pPlot.getX()
                        iY = pPlot.getY()

			for iXLoop in range(iX - 1, iX + 2, 1):
				for iYLoop in range(iY - 1, iY + 2, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						pPlot.setFeatureType(gc.getInfoTypeForString( "FEATURE_BIOGAS" ), 1)
						if ( pPlot.isWater()==true  ):
 							pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_SLIMY_COAST" ), 1, 1)

		if (pNukeUnit is not None and pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_POISON_NOVA')):

                        
                        iX = pPlot.getX()
                        iY = pPlot.getY()

			for iXLoop in range(iX - 5, iX + 6, 1):
				for iYLoop in range(iY - 5, iY + 6, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						pPlot.setFeatureType(gc.getInfoTypeForString( "FEATURE_PLAGUEGAS" ), 1)
						if ( pPlot.isWater()==true  ):
							pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_SLIMY_OCEAN" ), 1, 1)

###AdvancedNukesend###

I will copy this codes in my CvEventManager.py.

Is this okay?
 
I do what i say and i get this (ALL IMAGES ARE IN SPOILERS):

BBM
Ok, this work good without errors.
Spoiler :
BBM.png


Fusion Nova (similar like The_J Planet Buster) when explode its destroy (destroyed range in City radius 1) everything and convert it in water terrain.
I get errors, look.
Spoiler :
fusion_nova.png


Plague Bringer, its work without errors:
Spoiler :
plague_bring.png


Tactical Fusi (similar like Fusion Nova, just destroy one terrain plot on which is launched)
i get errors for this too.
Spoiler :
tactical_fusi.png


Y.A.M. (this nuke take over enemy city, if you launch it, and if Y.A.M. explode, this nuke automatically capture city for you, like as mind control)
And for this i get errors.
Spoiler :
YAM.png


All nukes do what they real do, but some nukes show errors. - this is problem.
 
A couple of points on python that I have not seen mentioned.

1) leading white space is part of the code - I have found that sometimes when I compare code the software I am using will say that they are the same but one will have an extra tab or space in it and so the result falls over with an error.

2) tabs and spaces are not equivalent - just because you have tabs set to 5 spaces on your machine does not mean that I have it set the same on my machine. Mixing spaces and tabs may work on your machine when you run civ but will fail on my machine.


iArcologyCityID is defined in the onCityRazed function. It is set if the city has any of the Arcology buildings in it. If you do not have those buildings but may in the future you will need to add the bit setting this value otherwise the values is -1. Since it is only used to determine the type of city ruins that will be placed on the plot you can probably remove that if segment completely.
 
A couple of points on python that I have not seen mentioned.

1) leading white space is part of the code - I have found that sometimes when I compare code the software I am using will say that they are the same but one will have an extra tab or space in it and so the result falls over with an error.

2) tabs and spaces are not equivalent - just because you have tabs set to 5 spaces on your machine does not mean that I have it set the same on my machine. Mixing spaces and tabs may work on your machine when you run civ but will fail on my machine.


iArcologyCityID is defined in the onCityRazed function. It is set if the city has any of the Arcology buildings in it. If you do not have those buildings but may in the future you will need to add the bit setting this value otherwise the values is -1. Since it is only used to determine the type of city ruins that will be placed on the plot you can probably remove that if segment completely.

I will tell what i am do.

First i am copy all XML and Python files from BTS in my mod (when i create mod) and i am modify that files.

After i am import Arcologies from NEXT WAR in my mod. After that i am import nukes. After that i get errors when nukes explode.

Now, about one hour ago i am create new mod (NUKES mod) in which i am test this crazy nukes (again copy all BTS files - XML and Python), i am add all which is necessary and this is work in this new created mod (NUKES mod). Nukes explode without errors and with their abilities all works nice! And i came to the conclusion that is problem - arcology in python.

In this (NUKE mod) i am only add nukes.

What to do? And one question, which program used for .py edit/merge?
 
All you need is just the section in def onNukeExplosion(self, argsList):

Code:
        if (gc.getInfoTypeForStringWithHiddenAssert("UNIT_TURN") > 0): 
            if (pNukeUnit is not None and pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_TURN')): 
                if (pPlot.isCity()==true): 
                    iPlayer = pNukeUnit.getOwner() 
                    pPlayer = gc.getPlayer(iPlayer) 
                    pCity = pPlot.getPlotCity() 
                    pPlayer.acquireCity(pCity,false,false) 
                    iX = pPlot.getX() 
                    iY = pPlot.getY() 
                    for iiX in range(iX-1, iX+2, 1): 
                        for iiY in range(iY-1, iY+2, 1): 
                            numUnits = pPlot.getNumUnits() 
                            for e in xrange(numUnits,0,-1): 
                                    pUnit = pPlot.getUnit(e) 
                                    pUnit.kill(false, -1)   
                            pNukedPlot = CyMap().plot(iiX,iiY) 
                            if (pNukedPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FALLOUT')): 
                                pNukedPlot.setFeatureType(-1, -1)

Effects:
If nuked plot is a city:
1) Take over the city
2) Attempts to kill units within 1 radius
3) Remove fallout if any within 1 radius

Things to Fix
1) It does NOT check ownership of city.
You can actually nuke your own teammate city you know... and take over it as a result.
2) numUnits refer to number of units in the nuke plot, yet it is trying to kill same amount of units in surrounding plots.
It is highly possible that there isn't that many units in surrounding, resulting in pUnit is None giving all sorts of errors.
3) Both radius of 1 are hard coded in python but you may want to change it to be based on the Nuke Radius as defined in XML
4) Codes only triggered when the nuked plot itself is the city plot. A.I. definitely wont understand and probably just nuke surrounding plot if that was a better location.

Code:
       if (gc.getInfoTypeForStringWithHiddenAssert("UNIT_FUSION_NUKE") > 0): 
            if (pNukeUnit is not None and pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_FUSION_NUKE')): 

                             
                iX = pPlot.getX() 
                iY = pPlot.getY() 

                for iXLoop in range(iX - 0, iX + 1, 1): 
                    for iYLoop in range(iY - 0, iY + 1, 1): 
                            pPlot = CyMap().plot(iXLoop, iYLoop) 
                            if (( pPlot.isPeak()==true  ) or (pPlot.isHills()==true)): 
                                pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True) 
                            pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_COAST" ), 1, 1
Effects:
1) Change all plots within 0 radius from peaks/hills to land
2) Change all plots within 0 radius to coastal terrain

Things to Fix
1) Similar to above, change radius to XML nuke radius is better unless intended, although for this case the radius is actually... 0, then why bother to use a loop
2) Totally redundant to change peaks/hills to land when eventually they are all turning to coast
3) It should be changing plot type to ocean rather than changing terrain to coast.
The latter means that if you nuke a plot in the middle of pacific ocean, you suddenly get a patch of coast there.
4) Again, this is bad idea for A.I. Sometimes it may be good to nuke your own plot when there is a huge SOD on it, but if the end result is that it will turn my only uranium mine there or my capital into ocean plot, I will think twice about it.

As for the other 2 nukes, unless you have those poison gas features, no doubt they will create problems for you.
 
I am fix it!!!

I am make mistake. I am forget to copy this part of code from NEXT WAR mod:

PHP:
		# Next War tracks cities that have been razed
		self.iArcologyCityID = -1

and this make errors.

Yes, i am agree with you platy. This nukes sounds good, but everything which you are write in Things to Fix (BOTH), you are right. AI nuked my capital and destroy my source of Aluminum (only which i had), and it's very unreal if i send nuke in ocean which is far away from land, this make ocean in coast (it's crazy and stupid).

"Totally redundant to change peaks/hills to land when eventually they are all turning to coast" - Absolutely, this part of code is the excess:
PHP:
 if (( pPlot.isPeak()==true  ) or (pPlot.isHills()==true)): 
                                pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
if i am understand you.

This now work, i am try everything. Send nuke on cities, ocean, etc etc. I am not get any errors :)

But one more thing is stupid. I think that i send Fusion Nova or Tactical Fusi on FEATURE_ICE (and nuke don't destroy this feature). This is one more thing for fix, but that is not very important now.

I will start to import your promotions in my mod.

THANK YOU EVERYONE FOR HELP, BECAUSE YOU ARE SEPARATE YOUR TIME FOR ME!
 
Can someone tell me, where i can found some futuristic NAVAL units (not EE2 units pack [EE2 pack will be used as far away futuristic naval units, me need near futuristic naval units]; not Final Frontier space ships because i am import real space ships in game ;DDD ) ?
 
NEWS:

- Tech tree finished
- Units finished (not UU, not wild Units)
- Building finished (without Wonders, not UB)
- All Eras finished
- Platy promotions imported in game
- Platy traits imported in game (not all, i am import some old Platy traits)
- Mad nukes imported in game
- All Civilizations have their unique trait
- Gods of Old religions imported in game
 
DECISION:

- I am put space ships in mod, idea is fantastic, but with that idea comes problems.
- Spaceships can move all terrain + impossible terrain, but AI more like to load spaceships in transport and to unload spaceships on my island, continent whatever, AI only use spaceships for crossing seas and ocean if they want to pillage my land (if i am in War or AI vs AI war).
- If Land units which intercept enemies plains have more than 1 range AI don't want to build AIR units! It's mean for all mods, because all AI's land are covered with land units, because don't use more than 1 range in your mods.
- If settler can move all terrain AI don't want to use them. I don't know why it's some AI think.

QUESTION FOR READERS:

- Is normal if you have spaceships, to load them in transport, transported over sea and invade enemy land on this way? More real is if you have spaceship you can move every tile on map which you want.

- I will maybe remove spaceships from game, but i will not cut off some eras.
 
I have one map script, i am converted for my mod and script works fine, but script have lots of forests almost on every tile. How i can reduce forest?

Here is map script:
Spoiler :
PHP:
#
#	FILE:	 Solar System.py
#	AUTHOR:  Based on Highlands.py by Bob Thomas (Sirian)
#	PURPOSE: Solar System Map
#-----------------------------------------------------------------------------
#	Copyright (c) Firaxis Games, Inc. All rights reserved.
#-----------------------------------------------------------------------------
#

from CvPythonExtensions import *
import CvUtil
import CvMapGeneratorUtil
import random
import sys
from math import sqrt
from CvMapGeneratorUtil import FractalWorld
from CvMapGeneratorUtil import TerrainGenerator
from CvMapGeneratorUtil import FeatureGenerator





def getDescription():
	return "Two planets, one Earthlike and the other like Titan.  This script puts some start positions on Titan, so at least a Modern era start is recommended."

def getNumCustomMapOptions():
	return 3
	
def getCustomMapOptionName(argsList):
	[iOption] = argsList
	option_names = {
		0:	"TXT_KEY_MAP_SCRIPT_MOUNTAIN_PATTERN",
		1:	"TXT_KEY_MAP_SCRIPT_MOUNTAIN_DENSITY",
		2:	"TXT_KEY_MAP_SCRIPT_WATER_SETTING"
		}
	translated_text = unicode(CyTranslator().getText(option_names[iOption], ()))
	return translated_text
	
def getNumCustomMapOptionValues(argsList):
	[iOption] = argsList
	option_values = {
		0:	3,
		1:	3,
		2:	3
		}
	return option_values[iOption]
	
def getCustomMapOptionDescAt(argsList):
	[iOption, iSelection] = argsList
	selection_names = {
		0:	{
			0: "TXT_KEY_MAP_SCRIPT_SCATTERED",
			1: "TXT_KEY_MAP_SCRIPT_RIDGELINES",
			2: "TXT_KEY_MAP_SCRIPT_CLUSTERED"
			},
		1:	{
			0: "TXT_KEY_MAP_SCRIPT_DENSE_PEAKS",
			1: "TXT_KEY_MAP_SCRIPT_NORMAL_PEAKS",
			2: "TXT_KEY_MAP_SCRIPT_THIN_PEAKS"
			},
		2:	{
			0: "TXT_KEY_MAP_SCRIPT_SMALL_LAKES",
			1: "TXT_KEY_MAP_SCRIPT_LARGE_LAKES",
			2: "TXT_KEY_MAP_SCRIPT_SEAS"
			}
		}
	translated_text = unicode(CyTranslator().getText(selection_names[iOption][iSelection], ()))
	return translated_text
	
def getCustomMapOptionDefault(argsList):
	[iOption] = argsList
	option_defaults = {
		0:	1,
		1:	1,
		2:	0
		}
	return option_defaults[iOption]

def isAdvancedMap():
	"This map should show up in simple mode"
	return 0
	
def isClimateMap():
	return 1

def isSeaLevelMap():
	return 0

def beforeInit():
	# Roll a dice to determine if the cold region will be in north or south.
	gc = CyGlobalContext()
	dice = gc.getGame().getMapRand()
	global shiftMultiplier
	shiftRoll = dice.get(2, "North or South climate shift - Highlands PYTHON")
	if shiftRoll == 0: # Cold in north
		shiftMultiplier = 0.0
	else: # Cold in south
		shiftMultiplier = 1.0
	return 0

def getWrapX():
	return true
	
def getWrapY():
	return true

def addLakes():
	iPass=1

def addRivers():
	iPass=1

def getTopLatitude():
		return 90
	
def getBottomLatitude():
		return -90

def getGridSize(argsList):
	"Reduce grid sizes by one level."
	grid_sizes = {
		WorldSizeTypes.WORLDSIZE_DUEL:		(24,15),
		WorldSizeTypes.WORLDSIZE_TINY:		(24,15),
		WorldSizeTypes.WORLDSIZE_SMALL:		(24,15),
		WorldSizeTypes.WORLDSIZE_STANDARD:	(24,15),
		WorldSizeTypes.WORLDSIZE_LARGE:		(24,15),
		WorldSizeTypes.WORLDSIZE_HUGE:		(24,15)
	}

	if (argsList[0] == -1): # (-1,) is passed to function on loads
		return []
	[eWorldSize] = argsList
	return grid_sizes[eWorldSize]

def minStartingDistanceModifier():
	return -100

def findStartingPlot(argsList):
	[playerID] = argsList

	def isValid(playerID, x, y):

		if x <3:
			return False		

		if x>28:
			if x<45: 
				return False
  
		if x >81:
			return False

		return True
	
	return CvMapGeneratorUtil.findStartingPlot(playerID, isValid)

def generatePlotTypes():
	NiTextOut("Setting Plot Types (Python Highlands) ...")
	gc = CyGlobalContext()
	map = CyMap()
	dice = gc.getGame().getMapRand()
	iFlags = 0  # Disallow FRAC_POLAR flag, to prevent "zero row" problems.
	iW = map.getGridWidth()
	iH = map.getGridHeight()
	plotTypes = [PlotTypes.PLOT_LAND] * (iW*iH)
	terrainFrac = CyFractal()
	lakesFrac = CyFractal()
	
	# Get custom map user inputs.
	userInputGrain = map.getCustomMapOption(0)
	userInputPeaks = map.getCustomMapOption(1)
	userInputLakes = map.getCustomMapOption(2)

	# Varying grains for hills/peaks per map size and Mountain Ranges setting.
	# [clustered_grain, ridgelines_grain, scattered_grain]
	worldsizes = {
		WorldSizeTypes.WORLDSIZE_DUEL:      [3,4,5],
		WorldSizeTypes.WORLDSIZE_TINY:      [3,4,5],
		WorldSizeTypes.WORLDSIZE_SMALL:     [4,5,6],
		WorldSizeTypes.WORLDSIZE_STANDARD:  [4,5,6],
		WorldSizeTypes.WORLDSIZE_LARGE:     [4,5,6],
		WorldSizeTypes.WORLDSIZE_HUGE:      [4,5,6]
		}
	grain_list = worldsizes[map.getWorldSize()]
	grain_list.reverse()
	grain = grain_list[userInputGrain]
	
	# Peak density
	peak_list = [70, 77, 83]
	hill_list = [40, 45, 50]
	peaks = peak_list[userInputPeaks]
	hills = hill_list[userInputPeaks]

	terrainFrac.fracInit(iW, iH, grain, dice, 0, -1, -1)

	iHillsThreshold = terrainFrac.getHeightFromPercent(hills)
	iPeaksThreshold = terrainFrac.getHeightFromPercent(peaks)

	# Now the main loop, which will assign the plot types.
	for x in range(iW):
		for y in range(iH):
			i = y*iW + x
			val = terrainFrac.getHeight(x,y)
			if val >= iPeaksThreshold:
				plotTypes[i] = PlotTypes.PLOT_PEAK
			elif val >= iHillsThreshold and val < iPeaksThreshold:
				plotTypes[i] = PlotTypes.PLOT_HILLS
			else:
				plotTypes[i] = PlotTypes.PLOT_LAND 

	return plotTypes

# subclass TerrainGenerator to redefine everything. This is a regional map.
class HighlandsTerrainGenerator(CvMapGeneratorUtil.TerrainGenerator):
	def __init__(self, fracXExp=-1, fracYExp=-1):
		# Note: If you change longitude values here, then you will...
		# ...need to change them elsewhere in the script, as well.
		self.gc = CyGlobalContext()
		self.map = CyMap()

		self.grain_amount = 4 + self.gc.getWorldInfo(self.map.getWorldSize()).getTerrainGrainChange()

		self.iWidth = self.map.getGridWidth()
		self.iHeight = self.map.getGridHeight()

		self.mapRand = self.gc.getGame().getMapRand()

		self.iFlags = 0  # Disallow FRAC_POLAR flag, to prevent "zero row" problems.

		self.cold=CyFractal()
		self.cool=CyFractal()
		self.temp=CyFractal()
		self.hot=CyFractal()
		self.variation=CyFractal()

		self.iColdIBottomPercent = 75
		self.iColdTBottomPercent = 20
		self.iCoolTBottomPercent = 85
		self.iCoolPBottomPercent = 45
		self.iTempDBottomPercent = 90
		self.iTempPBottomPercent = 65
		self.iHotDBottomPercent = 70
		self.iHotPBottomPercent = 60

		self.fColdLatitude = 0.8
		self.fCoolLatitude = 0.6
		self.fHotLatitude = 0.2

		self.fracXExp = fracXExp
		self.fracYExp = fracYExp

		self.initFractals()
		
	def initFractals(self):
		self.cold.fracInit(self.iWidth, self.iHeight, self.grain_amount, self.mapRand, self.iFlags, self.fracXExp, self.fracYExp)
		self.iColdIBottom = self.cold.getHeightFromPercent(self.iColdIBottomPercent)
		self.iColdTBottom = self.cold.getHeightFromPercent(self.iColdTBottomPercent)

		self.cool.fracInit(self.iWidth, self.iHeight, self.grain_amount, self.mapRand, self.iFlags, self.fracXExp, self.fracYExp)
		self.iCoolTBottom = self.cool.getHeightFromPercent(self.iCoolTBottomPercent)
		self.iCoolPBottom = self.cool.getHeightFromPercent(self.iCoolPBottomPercent)

		self.temp.fracInit(self.iWidth, self.iHeight, self.grain_amount, self.mapRand, self.iFlags, self.fracXExp, self.fracYExp)
		self.iTempDBottom = self.temp.getHeightFromPercent(self.iTempDBottomPercent)
		self.iTempPBottom = self.temp.getHeightFromPercent(self.iTempPBottomPercent)

		self.hot.fracInit(self.iWidth, self.iHeight, self.grain_amount, self.mapRand, self.iFlags, self.fracXExp, self.fracYExp)
		self.iHotDBottom = self.hot.getHeightFromPercent(self.iHotDBottomPercent)
		self.iHotPBottom = self.hot.getHeightFromPercent(self.iHotPBottomPercent)

		self.variation.fracInit(self.iWidth, self.iHeight, self.grain_amount, self.mapRand, self.iFlags, self.fracXExp, self.fracYExp)

		self.terrainDesert = self.gc.getInfoTypeForString("TERRAIN_COAST")
		self.terrainPlains = self.gc.getInfoTypeForString("TERRAIN_COAST")
		self.terrainGrass = self.gc.getInfoTypeForString("TERRAIN_GRASS")
		self.terrainIce = self.gc.getInfoTypeForString("TERRAIN_COAST")
		self.terrainTundra = self.gc.getInfoTypeForString("TERRAIN_COAST")
		self.terrainCoast = self.gc.getInfoTypeForString("TERRAIN_ORBIT")
		self.terrainOcean = self.gc.getInfoTypeForString("TERRAIN_SPACE")
		self.terrainSpacerock = self.gc.getInfoTypeForString("TERRAIN_SPACEROCK")
		self.terrainMars = self.gc.getInfoTypeForString("TERRAIN_MARS")
		self.terrainVenus = self.gc.getInfoTypeForString("TERRAIN_VENUS")
		self.terrainIcemoon = self.gc.getInfoTypeForString("TERRAIN_ICEMOON")
		self.terrainTitan = self.gc.getInfoTypeForString("TERRAIN_TITAN")
		self.terrainPermafrost = self.gc.getInfoTypeForString("TERRAIN_TUNDRA")
		self.terrainPolar = self.gc.getInfoTypeForString("TERRAIN_POLARSEA")

	def getLatitudeAtPlot(self, iX, iY):
		# Latitudes run vertically for a world with a tilted axis.
		lat = iY/float(self.iWidth) # 0.0 = south

		# Adjust latitude using self.variation fractal, to mix things up:
		lat += (128 - self.variation.getHeight(iX, iY))/(255.0 * 5.0)

		# Limit to the range [0, 1]:
		if lat < 0:
			lat = 0.0
		if lat > 1:
			lat = 1.0

		return lat

	def generateTerrainAtPlot(self,iX,iY):
		lat = self.getLatitudeAtPlot(iX,iY)

		if (self.map.plot(iX, iY).isWater()):
			return self.map.plot(iX, iY).getTerrainType()

		if lat >= self.fColdLatitude:
			val = self.cold.getHeight(iX, iY)
			if val >= self.iColdIBottom:
				terrainVal = self.terrainIce
			elif val >= self.iColdTBottom and val < self.iColdIBottom:
				terrainVal = self.terrainTundra
			else:
				terrainVal = self.terrainPlains
		elif lat < self.fColdLatitude and lat >= self.fCoolLatitude:
			val = self.cool.getHeight(iX, iY)
			if val >= self.iCoolTBottom:
				terrainVal = self.terrainTundra
			elif val >= self.iCoolPBottom and val < self.iCoolTBottom:
				terrainVal = self.terrainPlains
			else:
				terrainVal = self.terrainGrass
		elif lat < self.fHotLatitude:
			val = self.hot.getHeight(iX, iY)
			if val >= self.iHotDBottom:
				terrainVal = self.terrainDesert
			elif val >= self.iHotPBottom and val < self.iHotDBottom:
				terrainVal = self.terrainPlains
			else:
				terrainVal = self.terrainGrass
		else:
			val = self.temp.getHeight(iX, iY)
			if val >= self.iTempDBottom:
				terrainVal = self.terrainDesert
			elif val < self.iTempDBottom and val >= self.iTempPBottom:
				terrainVal = self.terrainPlains
			else:
				terrainVal = self.terrainGrass

		if (terrainVal == TerrainTypes.NO_TERRAIN):
			return self.map.plot(iX, iY).getTerrainType()

		if iX==0:
			     terrainVal =self.terrainCoast

		if iX==1:
			     terrainVal =self.terrainCoast
		if iX==2:
			terrainVal =self.terrainPolar

		if iX>2:
		     if iX<28:
				terrainVal =self.terrainTitan

		if iX==28:
                 terrainVal =self.terrainPolar

		if iX==29:
			terrainVal =self.terrainCoast

		if iX==30:
			terrainVal =self.terrainCoast

		if iX>30:
		     if iX<43:
                      terrainVal =self.terrainOcean

		if iX==43:
			terrainVal =self.terrainCoast
                   
		if iX==44:
			terrainVal =self.terrainCoast

		if iX==45:
			terrainVal =self.terrainPolar

		if iX==46:
		      if terrainVal == self.terrainGrass:
 			     terrainVal =self.terrainPermafrost  

		if iX==80:
		      if terrainVal == self.terrainGrass:
 			     terrainVal =self.terrainPermafrost  

		if iX==81:
                 terrainVal =self.terrainPolar


		if iX==82:
			terrainVal =self.terrainCoast

		if iX==83:
			terrainVal =self.terrainCoast

		if iX>83:
                 	terrainVal =self.terrainOcean

		return terrainVal


def generateTerrainTypes():
	NiTextOut("Generating Terrain (Python Highlands) ...")
	terraingen = HighlandsTerrainGenerator()
	terrainTypes = terraingen.generateTerrain()
	return terrainTypes

class HighlandsFeatureGenerator(CvMapGeneratorUtil.FeatureGenerator):
	def __init__(self, iJunglePercent=60, iForestPercent=45, iHotForestPercent = 25,
	             forest_grain=6, fracXExp=-1, fracYExp=-1):
		self.gc = CyGlobalContext()
		self.map = CyMap()
		self.mapRand = self.gc.getGame().getMapRand()
		self.forests = CyFractal()
		
		self.iFlags = 0  # Disallow FRAC_POLAR flag, to prevent "zero row" problems.

		self.iGridW = self.map.getGridWidth()
		self.iGridH = self.map.getGridHeight()
		
		self.iJunglePercent = iJunglePercent
		self.iForestPercent = iForestPercent
		self.iHotForestPercent = iHotForestPercent
		
		self.forest_grain = forest_grain + self.gc.getWorldInfo(self.map.getWorldSize()).getFeatureGrainChange()

		self.fracXExp = fracXExp
		self.fracYExp = fracYExp

		self.__initFractals()
		self.__initFeatureTypes()
	
	def __initFractals(self):
		self.forests.fracInit(self.iGridW, self.iGridH, self.forest_grain, self.mapRand, self.iFlags, self.fracXExp, self.fracYExp)
		
		self.iJungleLevel = self.forests.getHeightFromPercent(100 - self.iJunglePercent)
		self.iForestLevel = self.forests.getHeightFromPercent(self.iForestPercent)
		self.iHotForestLevel = self.forests.getHeightFromPercent(self.iHotForestPercent)
		
	def __initFeatureTypes(self):
		self.featureJungle = self.gc.getInfoTypeForString("FEATURE_CARBONICE")
		self.featureForest = self.gc.getInfoTypeForString("FEATURE_REGOLITH")
		self.featureOasis = self.gc.getInfoTypeForString("FEATURE_SCORCH")
		self.featureFlood = self.gc.getInfoTypeForString("FEATURE_REGOLITH")
		self.featureIce = self.gc.getInfoTypeForString("FEATURE_CLOUDS")
		self.featureAsteroids = self.gc.getInfoTypeForString("FEATURE_ASTEROIDS")
		self.featureWoods = self.gc.getInfoTypeForString("FEATURE_FOREST")
		self.featureGlacier = self.gc.getInfoTypeForString("FEATURE_GLACIER")

	def getLatitudeAtPlot(self, iX, iY):
		lat = iY/float(self.iGridH) # 0.0 = south
		# Flip terrain if southward shift was rolled.
		global shiftMultiplier
		return abs(lat - shiftMultiplier)

	def addFeaturesAtPlot(self, iX, iY):
		lat = self.getLatitudeAtPlot(iX, iY)
		pPlot = self.map.sPlot(iX, iY)

		for iI in range(self.gc.getNumFeatureInfos()):
			if pPlot.canHaveFeature(iI):
				if self.mapRand.get(10000, "Add Feature PYTHON") < self.gc.getFeatureInfo(iI).getAppearanceProbability():
					pPlot.setFeatureType(iI, -1)

		if (pPlot.getFeatureType() == FeatureTypes.NO_FEATURE):
			self.addJunglesAtPlot(pPlot, iX, iY, lat)
			
		if (pPlot.getFeatureType() == FeatureTypes.NO_FEATURE):
			self.addForestsAtPlot(pPlot, iX, iY, lat)

		if (pPlot.getFeatureType() == FeatureTypes.NO_FEATURE):
			self.addAsteroidsAtPlot(pPlot, iX, iY, lat)

		if (pPlot.getFeatureType() == FeatureTypes.NO_FEATURE):
			self.addWoodsAtPlot(pPlot, iX, iY, lat)

		if iX==2:
			if pPlot.isHills() or pPlot.isPeak(): 
				pPlot.setPlotType(PlotTypes.PLOT_LAND, true, true)

		if iX>44:
		     if iX<82:
				if iY>55:
					 if pPlot.isPeak(): 
					       pPlot.setPlotType(PlotTypes.PLOT_OCEAN, true, true)

		if iX>44:
		     if iX<82:
				if iY<5:
					 if pPlot.isPeak(): 
					       pPlot.setPlotType(PlotTypes.PLOT_OCEAN, true, true)

		if iX>44:
		     if iX<82:
				if iY>25:
		     			if iY<35:
						if pPlot.isHills() or pPlot.isPeak(): 
							pPlot.setPlotType(PlotTypes.PLOT_OCEAN, true, true)
		if iX>28:
		     if iX<46:
				if pPlot.isHills() or pPlot.isPeak(): 
					pPlot.setPlotType(PlotTypes.PLOT_LAND, true, true)

		if iX>80:
			if pPlot.isHills() or pPlot.isPeak(): 
				pPlot.setPlotType(PlotTypes.PLOT_LAND, true, true)

		if iX==2:
			self.addGlacierAtPlot(pPlot, iX, iY, lat)

		if iX==28:
			self.addGlacierAtPlot(pPlot, iX, iY, lat)

		if iX==45:
			self.addGlacierAtPlot(pPlot, iX, iY, lat)

		if iX==81:
			self.addGlacierAtPlot(pPlot, iX, iY, lat)

	def addGlacierAtPlot(self, pPlot, iX, iY, lat):
		pPlot.setFeatureType(self.featureGlacier, -1)

	def addAsteroidsAtPlot(self, pPlot, iX, iY, lat):
		if pPlot.canHaveFeature(self.featureAsteroids):
			pPlot.setFeatureType(self.featureAsteroids, -1)

	def addWoodsAtPlot(self, pPlot, iX, iY, lat):
		if pPlot.canHaveFeature(self.featureWoods):
			pPlot.setFeatureType(self.featureWoods, -1)
	
	def addJunglesAtPlot(self, pPlot, iX, iY, lat):
		# Warning: this version of JunglesAtPlot is using the forest fractal!
		if lat > 0.50:
			if lat < 0.60 and pPlot.canHaveFeature(self.featureJungle):
				if (self.forests.getHeight(iX, iY) >= self.iJungleLevel):
					pPlot.setFeatureType(self.featureJungle, -1)

		if lat < 0.10 and pPlot.canHaveFeature(self.featureJungle):
			if (self.forests.getHeight(iX, iY) >= self.iJungleLevel):
				pPlot.setFeatureType(self.featureJungle, -1)

	def addForestsAtPlot(self, pPlot, iX, iY, lat):
		if lat > 0.2:
			if pPlot.canHaveFeature(self.featureForest):
				if self.forests.getHeight(iX, iY) <= self.iForestLevel:
					pPlot.setFeatureType(self.featureForest, -1)
		else:
			if pPlot.canHaveFeature(self.featureForest):
				if self.forests.getHeight(iX, iY) <= self.iHotForestLevel:
					pPlot.setFeatureType(self.featureForest, -1)

def addFeatures():
	global featuregen
	NiTextOut("Adding Features (Python Highlands) ...")
	featuregen = HighlandsFeatureGenerator()
	featuregen.addFeatures()
	return 0



def normalizeRemovePeaks():
	iPass=1



def normalizeRemoveBadFeatures():
	iPass=1

def normalizeRemoveBadTerrain():
	iPass=1

def normalizeAddFoodBonuses()	:
	iPass=1

def normalizeAddGoodTerrain():
	iPass=1

def normalizeAddExtras():
	iPass=1

def startHumansOnSameTile():
	return True

Can this part of code reduce forest? Maybe iJunglePercent, iForestPercent, iHotForestPercent to set on lower value?
Spoiler :
PHP:
class HighlandsFeatureGenerator(CvMapGeneratorUtil.FeatureGenerator):
	def __init__(self, iJunglePercent=60, iForestPercent=45, iHotForestPercent = 25,
	             forest_grain=6, fracXExp=-1, fracYExp=-1):
		self.gc = CyGlobalContext()
		self.map = CyMap()
		self.mapRand = self.gc.getGame().getMapRand()
		self.forests = CyFractal()
		
		self.iFlags = 0  # Disallow FRAC_POLAR flag, to prevent "zero row" problems.

		self.iGridW = self.map.getGridWidth()
		self.iGridH = self.map.getGridHeight()
		
		self.iJunglePercent = iJunglePercent
		self.iForestPercent = iForestPercent
		self.iHotForestPercent = iHotForestPercent
		
		self.forest_grain = forest_grain + self.gc.getWorldInfo(self.map.getWorldSize()).getFeatureGrainChange()

		self.fracXExp = fracXExp
		self.fracYExp = fracYExp

		self.__initFractals()
		self.__initFeatureTypes()
 
iForestPercent=45 - i think if you lower this number - something like 10,
you will have lower forest.

Thank you keldath, but that is not solve the problem.

I am solve the problem, i was looking and searching in file.

self.featureWoods = self.gc.getInfoTypeForString("FEATURE_FOREST")

I am search for this. And i am found this:

PHP:
	def addWoodsAtPlot(self, pPlot, iX, iY, lat):
		if pPlot.canHaveFeature(self.featureWoods):
			pPlot.setFeatureType(self.featureWoods, -1)

i am replace this with this:

PHP:
	def addWoodsAtPlot(self, pPlot, iX, iY, lat):
		if lat > 0.2:
			if pPlot.canHaveFeature(self.featureWoods):
				if self.forests.getHeight(iX, iY) <= self.iForestLevel:
					pPlot.setFeatureType(self.featureWoods, -1)
		else:
			if pPlot.canHaveFeature(self.featureWoods):
				if self.forests.getHeight(iX, iY) <= self.iHotForestLevel:
					pPlot.setFeatureType(self.featureWoods, -1)

and i am get what i am want :D i am found this in Highland mapscript i am just copy from that of course i am replace self.featureForest with self.featureWoods.

I am not experience programmer, i just have "C" knowledge + "Maybe luck".

I am not test map script yet i will test soon as possible, if i get some errors it's will be bad for me.
 
Can someone explain me something about mods versions. Alpha, Beta, Final Release, version 1.0, version 1.3, version 2.0 etc.

How I can determine?
 
hehe thats a funny question.

alpha beta final :)

well :
beta - a pre release version - mainly for tests and stability
alpha one step before you release - after you finished what you wanted to fix in the beta.
final release - when you end your work on a mod and your not planing on getting out more updates.

v 1. ...1.3 - names for you to keep track of your work.
when i mod - i create a "version" to save my latest work - and i number it 0.1..0.2 ... so on,
when i release a mod - i call it version 1.0.

when i later add a patch to fix things - i name the patch with a version.

when i make a big update that changes and adds a lot of stuff - i call it - version 2 pr version 1.1.

good luck :)
 
Back
Top Bottom