[to_xp]Gekko
QCT junkie
Guys, I need help with this bit of python...
ok so what this code does is clear bad terrain around starting positions in a square shape.
However, it leaves a big + shape unchanged directly above, below, left and right of the starting tile. it looks horrible O.o
How could I change the code to also include those tiles? the starting tile should be considered cityRing == 0 , adjacent ones cityRing == 1 etc.
also it would be awesome if the range for this clearing could be tied to map size: 3 for duel/tiny, 4 for small/standard, 5 for large/huge .
Many, many thanks in advance to anyone that can help
Code:
x = plot.getX()
y = plot.getY()
# cycle through the surrounding plots
for xx in range(x - 3, x + 3):
for yy in range(y - 3, y + 3):
if yy == y or xx == x:
continue
nPlot = gameMap.plot(xx,yy)
featureType = nPlot.getFeatureType()
terrainType = nPlot.getTerrainType()
cityRing = float(max(abs(x-xx),abs(y-yy)))
cityRingMod = 0
if nPlot.isRiver():
cityRingMod = -1
# With FfH we need to make sure we don't break the unique
# features, which are really improvements.
if nPlot.getImprovementType() == ImprovementTypes.NO_IMPROVEMENT and nPlot.getBonusType(TeamTypes.NO_TEAM) == BonusTypes.NO_BONUS:
if terrainType == tundra:
if tv < 2:
if PRand.random() > 0.1 * (cityRing + cityRingMod):
nPlot.setTerrainType(grass,True,True)
elif PRand.random() > 0.1 * (cityRing + cityRingMod):
nPlot.setTerrainType(snow,True,True)
if nPlot.getPlotType() == PlotTypes.PLOT_HILLS:
if PRand.random() > 0.3 * (cityRing + cityRingMod):
nPlot.setPlotType(PlotTypes.PLOT_LAND,True,True)
if nPlot.isRiver() and terrainType == desert:
nPlot.setFeatureType(mc.itFeatureFloodPlains,0)
elif nPlot.isPeak():
if PRand.random() > 0.15 * (cityRing + cityRingMod) or cityRing == 1:
nPlot.setPlotType(PlotTypes.PLOT_HILLS,True,True)
if featureType == mc.itFeatureJungle and jv < 2:
if PRand.random() > 0.15 * (cityRing + cityRingMod):
nPlot.setFeatureType(mc.itFeatureForest,0)
elif featureType == mc.itFeatureForest and tv > 1:
if PRand.random() > 0.25 * (cityRing + cityRingMod):
nPlot.setFeatureType(mc.itNoFeature,0)
if PRand.random() > 0.2 * (cityRing + cityRingMod):
nPlot.setTerrainType(grass,True,True)
elif terrainType == snow and tv < 2:
if PRand.random() > 0.1 * (cityRing + cityRingMod):
nPlot.setTerrainType(tundra,True,True)
return
ok so what this code does is clear bad terrain around starting positions in a square shape.
However, it leaves a big + shape unchanged directly above, below, left and right of the starting tile. it looks horrible O.o
How could I change the code to also include those tiles? the starting tile should be considered cityRing == 0 , adjacent ones cityRing == 1 etc.
also it would be awesome if the range for this clearing could be tied to map size: 3 for duel/tiny, 4 for small/standard, 5 for large/huge .
Many, many thanks in advance to anyone that can help