Lutefisk Mafia
Inscrutable Enforcer
Fiddling with the setGameturn function does not help, so the error must be based off of Elapsed game turns. And although there is a getElapsedGameTurns function, there is not a function to setElapsedGameTurns.
CvCity* pCity = getCapitalCity();
if (pCity->getPopulation() < 6 && pCity->angryPopulation(1) > 0 && pCity->foodDifference(false) > 1)
{
addGold+=getGold();
}
iGold += addGold;
if (bIncludeForcedGold)
{
if (getCivilizationType() == GC.getDefineINT("CIVILIZATION_KHAZAD"))
{
int addGold=0;
int iNumCities = getNumCities();
if (GC.getDefineINT("TECH_TAXATION") != NO_TECH)
{
if (isHasTech(GC.getDefineINT("TECH_TAXATION")))
{
addGold += iNumCities * 150;
}
}
if (GC.getDefineINT("TECH_TAXATION") != NO_TECH && GC.getDefineINT("TECH_FESTIVALS") != NO_TECH)
{
if (isHasTech(GC.getDefineINT("TECH_WAY_OF_THE_EARTHMOTHER")) || isHasTech(GC.getDefineINT("TECH_FESTIVALS")))
{
addGold += iNumCities * 150;
}
}
CvCity* pCity = getCapitalCity();
if (pCity->getPopulation() < 6 && pCity->angryPopulation(1) > 0 && pCity->foodDifference(false) > 1)
{
addGold+=getGold();
}
iGold += addGold;
}
}
if (bIncludeForcedGold)
{
if (getCivilizationType() == GC.getDefineINT("CIVILIZATION_KHAZAD"))
{
int addGold=0;
int iNumCities = getNumCities();
if (GC.getDefineINT("TECH_TAXATION") != NO_TECH)
{
if (isHasTech(GC.getDefineINT("TECH_TAXATION")))
{
addGold += iNumCities * 150;
}
}
if (GC.getDefineINT("TECH_TAXATION") != NO_TECH && GC.getDefineINT("TECH_FESTIVALS") != NO_TECH)
{
if (isHasTech(GC.getDefineINT("TECH_WAY_OF_THE_EARTHMOTHER")) || isHasTech(GC.getDefineINT("TECH_FESTIVALS")))
{
addGold += iNumCities * 150;
}
}
[COLOR="Red"]if (iNumCities > 0)[/COLOR]
{
CvCity* pCity = getCapitalCity();
if (pCity->getPopulation() < 6 && pCity->angryPopulation(1) > 0 && pCity->foodDifference(false) > 1)
{
addGold+=getGold();
}
iGold += addGold;
}
}
}
The question is: keep fleshing out this scenario, or change over to a stand-alone modmod?
What do you think, TC01?
The current scenario could be expanded, even with the existing constraints. It isn't a very clean or elegant coding job, so that makes it a little harder to add to, but it is still doable. If you have taken a close look at my coding you can probably tell that I was just making it all up as I went along!
I was intrigued by some of the stuff I noticed in the updated python for the core FfH2 build. If I am uderstanding it correctly, they are reading and writing information to some sort of data storage other than script data while still in the game? If that is true, it would be possible to acheive the holy grail of DA implementation which would be a persistent multi-map world!
TC01, did you notice the code to which I am referring and , if so, do you understand it? Alternatively, do you know your way around script data arrays and/or the pickle function? I could really benefit from collaborating with someone who has a more solid and reputable programming background than I do. Since I am self taught -- mostly by banging on things and seeing what happens -- I have some pretty big gaps in my understanding of python.
def goDeeperDungeon(self):
terrainList = []
for i in range (CyMap().numPlots()):
pPlot = CyMap().plotByIndex(i)
pTerrain = pPlot.getTerrainType()
terrainList.append(pTerrain)
elevationList = []
for i in range (CyMap().numPlots()):
pPlot = CyMap().plotByIndex(i)
pElevation = pPlot.getPlotType()
elevationList.append(pElevation)
featureList = []
for i in range (CyMap().numPlots()):
pPlot = CyMap().plotByIndex(i)
pFeature = pPlot.getFeatureType()
featureList.append(pFeature)
improvementList = []
for i in range (CyMap().numPlots()):
pPlot = CyMap().plotByIndex(i)
pImprovement = pPlot.getImprovementType()
improvementList.append(pImprovement)
scriptList = []
for i in range (CyMap().numPlots()):
pPlot = CyMap().plotByIndex(i)
pScript = pPlot.getScriptData()
scriptList.append(pScript)
levelMap = []
levelMap.append(terrainList)
levelMap.append(elevationList)
levelMap.append(featureList)
levelMap.append(improvementList)
levelMap.append(scriptList)
levelNumber = CyGame().getGlobalCounter()
CyMap().plot(levelNumber,19).setScriptData(levelMap)
def unpackfunction(self):
levelNumber = CyGame().getGlobalCounter()
levelMap = CyMap().plot(levelNumber,19).getScriptData()
terrainList = levelMap[0]
elevationList = levelMap[1]
featureList = levelMap[2]
improvementList = levelMap[3]
scriptList = levelMap[4]
for i in range (CyMap().numPlots()):
pPlot = CyMap().plotByIndex(i)
pPlot.setBonusType(-1)
pPlot.setFeatureType(-1, -1)
pPlot.setImprovementType(-1) #will also clear all warning posts. Replacement improvements are aded back in below
if i < 20:
pPlot.setScriptData('')
#pPlot.setPythonActive(False) #may need to add this back in later as a part of the flushing process
pPlot.setMoveDisabledHuman(False) #clears dungeon specific blocks
pPlot.setMoveDisabledAI(False)
CyEngine().removeLandmark(pPlot)
pTerrain = terrainList[i]
pPlot.setTerrainType(pTerrain,True,True)
pElevation = elevationList[i]
pPlot.setPlotType(pElevation, True, True)
pFeature = featureList[i]
pPlot.setFeatureType(pFeature, 0)
pImprovement = improvementList[i]
pPlot.setImprovementType(pImprovement)
[COLOR="Red"]import pickle[/COLOR]
def goDeeperDungeon(self):
terrainList = []
[COLOR="Green"]elevationList = []
featureList = []
improvementList = []
scriptList = [][/COLOR]
for i in range (CyMap().numPlots()):
pPlot = CyMap().plotByIndex(i)
pTerrain = pPlot.getTerrainType()
terrainList.append(pTerrain)
[COLOR="Green"]pElevation = pPlot.getPlotType()
elevationList.append(pElevation)
pFeature = pPlot.getFeatureType()
featureList.append(pFeature)
pImprovement = pPlot.getImprovementType()
improvementList.append(pImprovement)
pScript = pPlot.getScriptData()
scriptList.append(pScript)[/COLOR]
levelMap = []
levelMap.append(terrainList)
levelMap.append(elevationList)
levelMap.append(featureList)
levelMap.append(improvementList)
levelMap.append(scriptList)
levelNumber = CyGame().getGlobalCounter()
[COLOR="red"]szLevelMap = pickle.dumps(levelMap)
CyMap().plot(levelNumber,19).setScriptData(szLevelMap)[/COLOR]
def unpackfunction(self):
levelNumber = CyGame().getGlobalCounter()
[COLOR="red"]szLevelMap = CyMap().plot(levelNumber,19).getScriptData()
levelMap = pickle.loads(szLevelMap)[/COLOR]
terrainList = levelMap[0]
elevationList = levelMap[1]
featureList = levelMap[2]
improvementList = levelMap[3]
scriptList = levelMap[4]
for i in range (CyMap().numPlots()):
pPlot = CyMap().plotByIndex(i)
pPlot.setBonusType(-1)
pPlot.setFeatureType(-1, -1)
pPlot.setImprovementType(-1) #will also clear all warning posts. Replacement improvements are aded back in below
if i < 20:
pPlot.setScriptData('')
#pPlot.setPythonActive(False) #may need to add this back in later as a part of the flushing process
pPlot.setMoveDisabledHuman(False) #clears dungeon specific blocks
pPlot.setMoveDisabledAI(False)
CyEngine().removeLandmark(pPlot)
pTerrain = terrainList[i]
pPlot.setTerrainType(pTerrain,True,True)
pElevation = elevationList[i]
pPlot.setPlotType(pElevation, True, True)
pFeature = featureList[i]
pPlot.setFeatureType(pFeature, 0)
pImprovement = improvementList[i]
pPlot.setImprovementType(pImprovement)
import CvWBDesc
import os
WB = CvWBDesc.CvWBDesc()
def goDeeperDungeon(self, szCurrentMap, szNewMap):
fileCurrentMap = os.path.join(os.getcwd(), "Mods", "Fall from Heaven 2", "Assets", "XML", "Scenarios", szCurrentMap)
fileNewMap = os.path.join(os.getcwd(), "Mods", "Fall from Heaven 2", "Assets", "XML", "Scenarios", szNewMap)
WB.write(fileCurrentMap)
WB.read(fileNewMap)
WB.applyMap()
WB.applyInitialItems()