The Capo
godless Heathen
Hey everyone, I have done this before but there seems to be some differences between what I am used to (well, sort of used to) and how GIR set up his mod. He has a pack of fifteen wonders to add to the game. I want to add the Machu Picchu wonder to my mod. To make this easier to follow I'll split this into two posts. The first will go over what GIR has in his code.
He appears to have the following python files that pertain to Machu Picchu.
First he has this in CvGameUtils:
Then in his custom event manager file he has...
And
Finally he has two different custom files for Machu Picchu, first he has CvMachuPicchuEventManager.py has this code in it:
And then another file, MachuPicchu.py, has this in it:
So that is all the stuff GIR has going on in his pack of wonders. For now I only want to take Machu Picchu out and add it to my mod. This seems like more files than necessary, at least the way I have been taught to do it. My mod uses BUG by the way. I am not asking for anyone to do this for me, so much as I am asking if the next post is correct (i.e., if you read this before my next post, wait a second, I'm probably writing it right now).
He appears to have the following python files that pertain to Machu Picchu.
First he has this in CvGameUtils:
Code:
def cannotConstruct(self,argsList):
pCity = argsList[0]
eBuilding = argsList[1]
bContinue = argsList[2]
bTestVisible = argsList[3]
bIgnoreCost = argsList[4]
### Petra Mod begins ###
### Note: the code identifies the first building of a certain buildingclass in the CIV4BuildingInfos.xml file to be the default building
###########################################################################################
### find buildings with the same buildingClassType ###
lgleicheBC = []
buildingClassType = gc.getBuildingInfo(eBuilding).getBuildingClassType()
for i in range(gc.getNumBuildingInfos()):
if ( buildingClassType == gc.getBuildingInfo(i).getBuildingClassType() ):
lgleicheBC.append(i)
if ( len(lgleicheBC) >= 2 ):
### is eBuilding the default building? ###
if ( eBuilding == lgleicheBC[0] ):
### do you have a "foreign" UB in the city? ###
for i in range(len(lgleicheBC)-1):
if ( pCity.getNumActiveBuilding(lgleicheBC[i +1])==true ):
return True
###########################################################################################
### Petra Mod ends ###
[COLOR="Blue"] ### MachuPicchu Mod begins ###
###########################################################################################
if ( eBuilding == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU") ):
### find peaks within the city radius controlled by your team ###
pPlayer = gc.getPlayer(pCity.plot().getOwner())
iPID = pPlayer.getID()
iTID = pPlayer.getTeam()
iX = pCity.getX()
iY = pCity.getY()
for iXLoop in range(iX - 2, iX + 3, 1):
for iYLoop in range(iY - 2, iY + 3, 1):
pPlot = CyMap().plot(iXLoop, iYLoop)
if ( pPlot.isPlayerCityRadius(iPID)==true ):
if ( pPlot.getTeam()==iTID ):
if ( pPlot.isPeak()==true ):
return False
return True
###########################################################################################
### MachuPicchu Mod ends ###[/COLOR]
return False
Then in his custom event manager file he has...
Code:
import CvEventManager
# --------- FlavianAmphitheatre -------------
import CvFlavianAmphitheatreEventManager
# --------- Petra -------------
import CvPetraEventManager
# --------- CircusMaximus -------------
import CvCircusMaximusEventManager
# --------- Partisan -------------
import CvPartisanEventManager
[COLOR="Blue"]# --------- MachuPicchu -------------
import CvMachuPicchuEventManager[/COLOR]
# --------- StackAid -------------
import CvStackAidEventManager
# --------- ViaAppia -------------
import CvViaAppiaEventManager
# --------- ForbiddenPalace -------------
import CvForbiddenPalaceEventManager
# --------- KGB Wonder -------------
import CvKGBEventManager
# --------- TemploMayor -------------
import CvTemploMayorEventManager
# --------- LeonardosWorkshop Wonder -------------
import CvLeonardosWorkshopEventManager
And
Code:
def __init__(self, *args, **kwargs):
super(CvCustomEventManager, self).__init__(*args, **kwargs)
# map the initial EventHandlerMap values into the new data structure
for eventType, eventHandler in self.EventHandlerMap.iteritems():
self.setEventHandler(eventType, eventHandler)
# --> INSERT EVENT HANDLER INITIALIZATION HERE <--
# --------- FlavianAmphitheatre -------------
CvFlavianAmphitheatreEventManager.CvFlavianAmphitheatreEventManager(self)
# --------- Petra -------------
CvPetraEventManager.CvPetraEventManager(self)
# --------- CircusMaximus -------------
CvCircusMaximusEventManager.CvCircusMaximusEventManager(self)
# --------- Partisan -------------
CvPartisanEventManager.CvPartisanEventManager(self)
[COLOR="Blue"] # --------- MachuPicchu -------------
CvMachuPicchuEventManager.CvMachuPicchuEventManager(self)[/COLOR]
# --------- StackAid -------------
CvStackAidEventManager.CvStackAidEventManager(self)
# --------- ViaAppia -------------
CvViaAppiaEventManager.CvViaAppiaEventManager(self)
# --------- ForbiddenPalace -------------
CvForbiddenPalaceEventManager.CvForbiddenPalaceEventManager(self)
# --------- KGB Wonder -------------
CvKGBEventManager.CvKGBEventManager(self)
# --------- TemploMayor -------------
CvTemploMayorEventManager.CvTemploMayorEventManager(self)
# --------- LeonardosWorkshop Wonder -------------
CvLeonardosWorkshopEventManager.CvLeonardosWorkshopEventManager(self)
Finally he has two different custom files for Machu Picchu, first he has CvMachuPicchuEventManager.py has this code in it:
Code:
# MachuPicchu
# CvMachuPicchuEventManager
from CvPythonExtensions import *
#import CvUtil
import CvEventManager
#import sys
# --------- MachuPicchu -------------
import MachuPicchu
gc = CyGlobalContext()
MachuPicchu = MachuPicchu.MachuPicchu()
###################################################
class CvMachuPicchuEventManager(CvEventManager.CvEventManager):
def __init__(self, eventManager):
# initialize base class
# --------- MachuPicchu -------------
eventManager.addEventHandler("buildingBuilt", self.onBuildingBuilt)
def onBuildingBuilt(self, argsList):
MachuPicchu.onBuildingBuilt(argsList)
And then another file, MachuPicchu.py, has this in it:
Code:
############################
### MachuPicchu (by GIR) ###
############################
from CvPythonExtensions import *
import PyHelpers
gc = CyGlobalContext()
##################################################################################
class MachuPicchu:
def onBuildingBuilt(self, argsList):
'Building Completed'
pCity, iBuildingType = argsList
if ( iBuildingType == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU") ):
pPlayer = gc.getPlayer(pCity.plot().getOwner())
iPID = pPlayer.getID()
iTID = pPlayer.getTeam()
iX = pCity.getX()
iY = pCity.getY()
### check inner city radius for Peaks (MachuPicchu Wonder prefers to be in the inner city radius of the home city of this wonder) ###
lPeakPlotX = []
lPeakPlotY = []
for iXLoop in range(iX - 1, iX + 2, 1):
for iYLoop in range(iY - 1, iY + 2, 1):
pPlot = CyMap().plot(iXLoop, iYLoop)
if ( pPlot.isPlayerCityRadius(iPID)==true ):
if ( pPlot.getTeam()==iTID ):
if ( pPlot.isPeak()==true ):
lPeakPlotX.append(iXLoop)
lPeakPlotY.append(iYLoop)
if ( len(lPeakPlotX) < 1 ):
### check all city radius plots for Peaks if no inner peak available ###
lPeakPlotX = []
lPeakPlotY = []
for iXLoop in range(iX - 2, iX + 3, 1):
for iYLoop in range(iY - 2, iY + 3, 1):
pPlot = CyMap().plot(iXLoop, iYLoop)
if ( pPlot.isPlayerCityRadius(iPID)==true ):
if ( pPlot.getTeam()==iTID ):
if ( pPlot.isPeak()==true ):
lPeakPlotX.append(iXLoop)
lPeakPlotY.append(iYLoop)
if ( len(lPeakPlotX) > 0 ):
it_machu_picchu = gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" )
### set bonus for peaks in all city radius plots ###
for iCity in range(pPlayer.getNumCities()):
ppCity = pPlayer.getCity(iCity)
iiX = ppCity.getX()
iiY = ppCity.getY()
### check all city radius plots for peak ###
for iXLoop in range(iiX - 2, iiX + 3, 1):
for iYLoop in range(iiY - 2, iiY + 3, 1):
lPlot = CyMap().plot(iXLoop, iYLoop)
if ( lPlot.isPlayerCityRadius(iPID)==true ):
if ( lPlot.getTeam()==iTID ):
if(lPlot.getTerrainType() != -1):
if ( lPlot.isPeak()==true ):
lPlot.setImprovementType(it_machu_picchu)
### now set bonus only with matchu picchu and remove matchu picchu (overlapping city radius) ###
for iCity in range(pPlayer.getNumCities()):
ppCity = pPlayer.getCity(iCity)
iiX = ppCity.getX()
iiY = ppCity.getY()
### check all city radius plots for peak ###
for iXLoop in range(iiX - 2, iiX + 3, 1):
for iYLoop in range(iiY - 2, iiY + 3, 1):
lPlot = CyMap().plot(iXLoop, iYLoop)
if ( lPlot.isPlayerCityRadius(iPID)==true ):
if ( lPlot.getTeam()==iTID ):
if(lPlot.getTerrainType() != -1):
if ( lPlot.isPeak()==true ):
if ( lPlot.getImprovementType() == it_machu_picchu ):
CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_FOOD, 1)
CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_PRODUCTION, 2)
CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)
lPlot.setImprovementType(-1)
### ausgabe ###
CyInterface().addMessage(iPID,True,0,' ','',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_211.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
### set machu picchu on hill ###
### get random Peak from list ###
iRand = CyGame().getSorenRandNum( len(lPeakPlotX), "Random Peak")
iXPeak = lPeakPlotX[iRand]
iYPeak = lPeakPlotY[iRand]
pPeakPlot = CyMap().plot(iXPeak, iYPeak)
#pPeakPlot.setFeatureType(gc.getInfoTypeForString( "FEATURE_FOREST" ), 1)
pPeakPlot.setImprovementType(gc.getInfoTypeForString( "IMPROVEMENT_MACHU_PICCHU" ))
CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_FOOD, 1)
CyGame().setPlotExtraYield(iXPeak, iYPeak, YieldTypes.YIELD_COMMERCE, 6)
plot_culture_1_10 = int(pPeakPlot.getCulture(iPID) * 0.10)
pPeakPlot.changeCulture(iPID, plot_culture_1_10, true)
### ausgabe ###
CyInterface().addMessage(iPID,false,10,CyTranslator().getText("TXT_KEY_MACHU_PICCHU_GAMETXT1",(iXPeak,iXPeak)),'',0,gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_MACHU_PICCHU")).getButton(),ColorTypes(5), iXPeak, iYPeak,True,True)
### message: The Machu Picchu provides some benefits from Peaks! ###
### set additional bonus for peaks in the wonder city radius ###
for iXLoop in range(iX - 2, iX + 3, 1):
for iYLoop in range(iY - 2, iY + 3, 1):
pPlot = CyMap().plot(iXLoop, iYLoop)
if ( pPlot.isPlayerCityRadius(iPID)==true ):
if ( pPlot.getTeam()==iTID ):
if(pPlot.getTerrainType() != -1):
if ( pPlot.isPeak()==true ):
CyGame().setPlotExtraYield(iXLoop, iYLoop, YieldTypes.YIELD_COMMERCE, 1)
### ausgabe ###
if ( iXLoop != iXPeak or iYLoop != iYPeak ):
CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_212.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
else:
CyInterface().addMessage(iPID,True,0," ",'0',1,'Art/Interface/Buttons/MachuPicchu_Python/MachuPicchu_Python_218.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
So that is all the stuff GIR has going on in his pack of wonders. For now I only want to take Machu Picchu out and add it to my mod. This seems like more files than necessary, at least the way I have been taught to do it. My mod uses BUG by the way. I am not asking for anyone to do this for me, so much as I am asking if the next post is correct (i.e., if you read this before my next post, wait a second, I'm probably writing it right now).