deanej
Deity
I'm attempting to make a mod that allows terrain to change with the seasons. However, the game doesn't even use the methods I made to allow this! Here's the code:
and in the very end of the file:
Code:
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)
#Seasons Mod Start
#Terrain Types
iSnow = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_SNOW')
iSnowPermenant = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_SNOW_PERMENANT')
iPlains = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_PLAINS')
iPlainsPermenant = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_PLAINS_PERMENANT')
iTundra = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_TUNDRA')
iTundraSeasons = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_TUNDRA_SEASONS')
iGrassland = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_GRASS')
iGrasslandSeasons = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_GRASS_SEASONS')
#Change terrain from base to seasons
for iPlotLoop in range(CyMap().numPlots()):
pPlot = CyMap().plotByIndex(iPlotLoop)
if(pPlot.getTerrainType() == iSnow):
pPlot.setTerrainType(iSnowPermenant,True,True)
if(pPlot.getTerrainType() == iPlains):
pPlot.setTerrainType(iPlainsPermenant,True,True)
if(pPlot.getTerrainType() == iTundra):
pPlot.setTerrainType(iTundraSeasons,True,True)
if(pPlot.getTerrainType() == iGrassland):
pPlot.setTerrainType(iGrasslandSeasons,True,True)
#Change to correct season
if(iGameTurn % 4 == 0):
self.setSeasonFall()
self.setSeasonWinter()
elif(iGameTurn % 4 == 3):
self.setSeasonFall()
elif(iGameTurn % 4 == 1):
self.setSeasonFall()
self.setSeasonWinter()
self.setSeasonSpring()
#Seasons Mod End
Code:
def onBeginGameTurn(self, argsList):
'Called at the beginning of the end of each turn'
iGameTurn = argsList[0]
CvTopCivs.CvTopCivs().turnChecker(iGameTurn)
#Seasons Mod Start
#Changing of the seasons
if(iGameTurn % 4 == 0):
self.setSeasonWinter()
elif(iGameTurn % 4 == 3):
self.setSeasonFall()
elif(iGameTurn % 4 == 2):
self.setSeasonSummer()
elif(iGameTurn % 4 == 1):
self.setSeasonSpring()
#Seasons Mod End
and in the very end of the file:
Code:
#Seasons Mod Start
def setSeasonWinter(self):
iGrasslandSeasons = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_GRASS_SEASONS')
iPlainsSeasons = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_PLAINS_SEASONS')
print "Changing to winter..."
for iPlotLoop in range(CyMap().numPlots()):
pPlot = CyMap().plotByIndex(iPlotLoop)
if(pPlot.getTerrainType() == iGrasslandSeasons):
pPlot.setTerrainType(iPlainsSeasons,True,True)
def setSeasonFall(self):
iTundraSeasons = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_TUNDRA_SEASONS')
iSnowSeasons = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_SNOW_SEASONS')
print "Chaging to fall..."
for iPlotLoop in range(CyMap().numPlots()):
pPlot = CyMap().plotByIndex(iPlotLoop)
if(pPlot.getTerrainType() == iTundraSeasons):
pPlot.setTerrainType(iSnowSeasons,True,True)
def setSeasonSummer(self):
iTundraSeasons = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_TUNDRA_SEASONS')
iSnowSeasons = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_SNOW_SEASONS')
print "Changing to summer..."
for iPlotLoop in range(CyMap().numPlots()):
pPlot = CyMap().plotByIndex(iPlotLoop)
if(pPlot.getTerrainType() == iSnowSeasons):
pPlot.setTerrainType(iTundraSeasons,True,True)
def setSeasonSpring(self):
iGrasslandSeasons = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_GRASS_SEASONS')
iPlainsSeasons = CvUtil.findInfoTypeNum(gc.getTerrainInfo,gc.getNumTerrainInfos(),'TERRAIN_PLAINS_SEASONS')
print "Changing to spring..."
for iPlotLoop in range(CyMap().numPlots()):
pPlot = CyMap().plotByIndex(iPlotLoop)
if(pPlot.getTerrainType() == iPlainsSeasons):
pPlot.setTerrainType(iGrasslandSeasons,True,True)
#Seasons Mod End