Maniac
Apolyton Sage
I have no idea why the object referred to (I assume pPlotSpawn) is considered an integer. Does anyone understand the problem? A python exception is caused by the last line of this:
The FindBestSpawnPlot function goes like this:
Does anyone see the light?
Code:
def onCityDoTurn(self, argsList):
'City Production'
pCity = argsList[0]
iPlayer = argsList[1]
pPlot = pCity.plot()
pPlayer = gc.getPlayer(iPlayer)
...
## Fungal Bloom
if pCity.getEcoDamage() > CyGame().getSorenRandNum(100, "Maniac"):
iX = pPlot.getX()
iY = pPlot.getY()
## Check if fungal growth happens - if not, just native life spawn
if pCity.getEcoDamage() < CyGame().getSorenRandNum(10, "Fungal Bloom"):
listbloomcandidates = []
for x in range(-2, 2):
for y in range(-2, 2):
pPlot2 = CyMap().plot(iX + x,iY + y)
if pPlot2.isNone(): continue
if pPlot2.isImpassable(): continue
if pPlot2.isCity(): continue
if (pPlot2.getTerrainType() == iFlatPolar or pPlot2.getTerrainType() == iRockyPolar): continue
if gc.getGame().getPlanetValue() < 60:
if pPlot2.isHills(): continue
if gc.getGame().getPlanetValue() < 80:
if pPlot2.getFeatureType() == iJungle: continue
listbloomcandidates.append(pPlot2)
if len(listbloomcandidates) > 0:
pPlotSpawn = cf.PlFFindBestSpawnPlot(listbloomcandidates, pCity)
CyInterface().addMessage(pCity.getOwner(),True,25,'Indigenous lifeforms detected near some base - pCity.getName()??.','AS2D_MINDWORMS',1,'Art/Interface/Buttons/Units/Mindworm.dds',ColorTypes(8),pPlotSpawn.getX(),pPlotSpawn.getY(),True,True)
The FindBestSpawnPlot function goes like this:
Code:
def PlFFindBestSpawnPlot(self, listbloomcandidates, pCity):
iHybridForest = gc.getInfoTypeForString('FEATURE_HYBRID_FOREST')
iJungle = gc.getInfoTypeForString('FEATURE_JUNGLE')
iXenofungus = gc.getInfoTypeForString('FEATURE_XENOFUNGUS')
iSeaFungus = gc.getInfoTypeForString('FEATURE_SEA_FUNGUS')
pBestPlot = -1
iBestPlot = 0
for pCurrentPlot in listbloomcandidates:
iCurrentPlot = 0
if pCurrentPlot.getNumUnits() == 0:
if pCurrentPlot.getOwner() == pCity.getOwner():
iCurrentPlot = iCurrentPlot + 22
if (pCurrentPlot.getFeatureType() == iXenofungus or pCurrentPlot.getFeatureType() == iSeaFungus):
iCurrentPlot = iCurrentPlot + 11
if (pCurrentPlot.getFeatureType() == iHybridForest):
iCurrentPlot = iCurrentPlot + 5
if pCurrentPlot.isBeingWorked():
iCurrentPlot = iCurrentPlot + 5
## Is it possible to know in python the combined defensive bonus of a plot's terrain, feature, bunker... together?
for i in range(pCurrentPlot.getNumUnits()):
if pCurrentPlot.getUnit(i).getOwner() == gc.getPlayer(gc.getBARBARIAN_PLAYER()):
if pCurrentPlot.getOwner() == pCity.getOwner():
iCurrentPlot = iCurrentPlot + 22
if (pCurrentPlot.getFeatureType() == iXenofungus or pCurrentPlot.getFeatureType() == iSeaFungus):
iCurrentPlot = iCurrentPlot + 11
if (pCurrentPlot.getFeatureType() == iHybridForest):
iCurrentPlot = iCurrentPlot + 5
if pCurrentPlot.isBeingWorked():
iCurrentPlot = iCurrentPlot + 5
## bonus for defensive bonus
if iCurrentPlot >= 1:
iCurrentPlot = iCurrentPlot + CyGame().getSorenRandNum(5, "Maniac")
if iCurrentPlot >= iBestPlot:
pBestPlot = pCurrentPlot
iBestPlot = iCurrentPlot
return pBestPlot
Does anyone see the light?
