Asking for help in making a specific typ of map script.

Before The Dawn

Chieftain
Joined
Nov 15, 2008
Messages
26
Location
Lat=63° 50' 10"N Long=20° 10' 36"O
First: I'm totaly unable to learn python but I can change stuf If I know what to change and what to chage it to, the same goes for adding and removing stuff in .py scripts.
Second: Is there maby some freindly person that please could tell me what I need to change and/or add in this example of a Map Script:
Code:
from CvPythonExtensions import *
import CvUtil
import CvMapGeneratorUtil
from CvMapGeneratorUtil import FractalWorld
from CvMapGeneratorUtil import TerrainGenerator
from CvMapGeneratorUtil import FeatureGenerator
def getDescription():
 return "TXT_KEY_MAP_SCRIPT_FRACTAL_DESCR"
 
def isAdvancedMap():
 "This map should show up in simple mode"
 return 0
def generatePlotTypes():
 NiTextOut("Setting Plot Types (Python Fractal) ...")
 fractal_world = FractalWorld()
 fractal_world.initFractal(rift_grain = -1, has_center_rift = False, polar = False)
 return fractal_world.generatePlotTypes()
def generateTerrainTypes():
 NiTextOut("Generating Terrain (Python Fractal) ...")
 terraingen = TerrainGenerator()
 terrainTypes = terraingen.generateTerrain()
 return terrainTypes
def addFeatures():
 NiTextOut("Adding Features (Python Fractal) ...")
 featuregen = FeatureGenerator()
 featuregen.addFeatures()
 return 0
To get a Map script that:
1) Doesn't contains any Ice, Snow, Tundra, Desert, Jungle and Peaks
or lets you choose what terrain types you wishes.
2) That allows bonuses even if the required terrain/feature type is missing
and an option to add bonuses on XX numbers of plots(ie. add bonuses on every single plot, on no plots at all, at half of the plots and so on).
3) That allows you to travel around the map(world) in every direction(is it called tel*something*????)

So what do you say? Know what I should change or add??
Using one of the existing scripts isn't an option since they contains alot of stuff I don't need.
 
Concerning snow, here's how you can do:
Code:
def addFeatures():
	featuregen = NoIceFeatureGenerator()
	featuregen.addFeatures()
	return 0

class NoIceFeatureGenerator(FeatureGenerator):
	def addIceAtPlot(self, pPlot, iX, iY, lat):
		return
This is what I use in tectonics.
To remove tundra and desert you'd probably do something similar.
Ice in the sea is managed differently, there's a variable somewhere, I can't remember which, that shuts it off. Another option is to do something like this:
Code:
	def getLatitudeAtPlot(self, iX, iY):
		"returns 0.0 for tropical, up to 1.0 for polar"
		# 25/90 to 65/90:
		lat = 5/float(18) + 4*(self.iGridH - iY)/float(9*self.iGridH)
		return lat
Beware the 'like'. This example is for a Mediterranean map (desert in the south, temperate north).

For jungle, you must be able to do it by changing hte xml files rather than the python code.

For the peaks, I think it's something liek def normalizeRemovePeaks(): and remove the plots. It depends on what you want instead of peaks and still have something good looking.
Try something like this to get hills instead:
Code:
def normalizeRemovePeaks():
	map = CyMap()
	mapWidth = map.getGridWidth()
	mapHeight = map.getGridHeight()
	width = map.getGridWidth()
	height = map.getGridHeight()
	for x in range(width):
		for y in range(height):
			if (map.plot(x,y).getPlotType() == PlotTypes.PLOT_PEAK):
				map.plot(x,y).setPlotType( PlotTypes.PLOT_HILLS, true, true)

That allows bonuses even if the required terrain/feature type is missing
Better to change the xml.

That allows you to travel around the map(world) in every direction(is it called tel*something*????)
What do you mean? Travel east-west and north-south? That's a torus:
Code:
def getWrapX():
	return True

def getWrapY():
	return True
 
Thanks!:)
I'm Not sure I understood everything but maby someone else also has some tips and togheter with your tips It might make sens to me. As I stated before I am unable(atleast it seems so) to learn python. I have a Learnig disabillity.

I was hoping for a way to do everything in python so I only have to change 1 file instead of several so if there is a way to do question 2 and 3 without changing in xml files it would be great.
What do you mean? Travel east-west and north-south? That's a torus:

Code:
def getWrapX():
return True

def getWrapY():
return True

Thats exeactly what I meant. Atleast I think so, haven,t tried it yet.

After a bit of cutting and pasting and som changes I made this map script.
Code:
def generatePlotTypes():
    NiTextOut("Setting Plot Types (Python Fractal) ...")
    fractal_world = FractalWorld()
    fractal_world.initFractal(rift_grain = -1, has_center_rift = False, polar = False)        
    gc = CyGlobalContext()
    mmap = gc.getMap()
    iNumPlotsX = mmap.getGridWidth()
    iNumPlotsY = mmap.getGridHeight()
    mc.initialize()
    mc.initInGameOptions()
    PWRand.seed()
    hm.GenerateMap(iNumPlotsX,iNumPlotsY,mc.LandPercent)
    plotTypes = [PlotTypes.PLOT_OCEAN] * (iNumPlotsX*iNumPlotsY)

    for i in range(iNumPlotsX*iNumPlotsY):
        mapLoc = hm.plotMap[i]
        if mapLoc == hm.HILLS:
            plotTypes[i] = PlotTypes.PLOT_HILLS
        elif mapLoc == hm.LAND:
            plotTypes[i] = PlotTypes.PLOT_LAND
        else:
            plotTypes[i] = PlotTypes.PLOT_OCEAN
    print "Finished generating plot types."         
    return fractal_world.generatePlotTypes(water_percent=20)

def generateTerrainTypes():
    NiTextOut("Generating Terrain  ...")
    print "Adding Terrain"
    gc = CyGlobalContext()
    terrainPlains = gc.getInfoTypeForString("TERRAIN_PLAINS")
    terrainGrass = gc.getInfoTypeForString("TERRAIN_GRASS")
    terrainHill = gc.getInfoTypeForString("TERRAIN_HILL")
    terrainCoast = gc.getInfoTypeForString("TERRAIN_COAST")
    terrainOcean = gc.getInfoTypeForString("TERRAIN_OCEAN")
    
    tm.GenerateTempMap(80,-80)
    rm.GenerateRainMap(80,-80)
    terr.GenerateTerrainMap()
    terr.generateContinentMap()   
    terrainTypes = [0]*(hm.mapWidth*hm.mapHeight)
    for i in range(hm.mapWidth*hm.mapHeight):
        if terr.terrainMap[i] == terr.OCEAN:
            terrainTypes[i] = terrainOcean
        elif terr.terrainMap[i] == terr.COAST:
            terrainTypes[i] = terrainCoast
        elif terr.terrainMap[i] == terr.PLAINS:
            terrainTypes[i] = terrainPlains
        elif terr.terrainMap[i] == terr.GRASS:
            terrainTypes[i] = terrainGrass
        elif terr.terrainMap[i] == terr.HILL:
            terrainTypes[i] = terrainHill            
    print "Finished generating terrain types."
    return terrainTypes

def addFeatures():
	NiTextOut("Adding Features (Python Fractal) ...")
	featuregen = FeatureGenerator()
	featuregen.addFeatures()
	return 0
It's Almost only land masses and only a few lakes with Ice in them and almost no hills. If you look at this one and compare it with the questions I had maby some one can tell me what went wrong since I got almost no Hills. I know Why there is almost no water and what to change to get more water.
But why is ther Ice?
Is ther maby somethin I can change in CvMapGeneratorUtil.py to remove Ice all together?

And Finaly Can any one tell me wher and what to change to get the starting units(workers, settlers and so on) to not start in the same plot. Ie if you hav 18 units I want them to start in 18 diffrent plots like this:
Code:
		XXXXXX
		XXXXXX
		XXXXXX

And sorry for my english.
 
Back
Top Bottom