View Full Version : Script modding guide?


baro
Jun 09, 2007, 02:55 PM
Does anyone know where I can find info on how to edit the map scripts? I'm wanting to change the terra map script so that it doesn't generate any peaks, as I hate this useless unrealistic terrain.

Seems like this should be an easy thing to do, but looking through the script I didn't see any mention of mountains or peaks. Surely there is a basic editing guide for this stuff? I searched the site but found none.

Sto
Jun 09, 2007, 04:06 PM
You have an option on the full of resources thread to replace peak and set a level of hills if you want . But i'm not on my pc right now so i can't give you the code to only do that . If you want to do that , just take a look at generatePlotTypes() and change plot type peak to mountain for an example :

for i in range(len(plotTypes)):
if plotTypes[i]==PlotTypes.PLOT_PEAK:
plotTypes[i]=PlotTypes.PLOT_HILLS
return plotTypes


Tcho !

Ps : there is no map script guide , all functions are explained in CvMapScriptInterface.py .

baro
Jun 09, 2007, 06:26 PM
So I'm a total scrub when it comes to editing this stuff. Where exactly in the terra map script do I stick this stuff? Can you give me an example?

the only area that matches what you said that I found was at the end


def generatePlotTypes():
NiTextOut("Setting Plot Types (Python Terra) ...")
# Call generatePlotsByRegion() function, from TerraMultilayeredFractal subclass.
global plotgen
plotgen = TerraMultilayeredFractal()
return plotgen.generatePlotsByRegion()

def generateTerrainTypes():
NiTextOut("Generating Terrain (Python Terra) ...")
terraingen = TerrainGenerator()
terrainTypes = terraingen.generateTerrain()
return terrainTypes

def addFeatures():
NiTextOut("Adding Features (Python Terra) ...")
featuregen = FeatureGenerator()
featuregen.addFeatures()
return 0


Where/how do I stick what you told me in? I just stuck it on the end and it gave me a 100 grasslands map covered with rivers. oops!

I'm just so sick of every terra map I generate having to go through and change every mountain to a hill.

Sto
Jun 10, 2007, 04:08 AM
at the end of def generatePlotTypes(): change that :

#return plotgen.generatePlotsByRegion()
plotTypes=plotgen.generatePlotsByRegion()
for i in range(len(plotTypes)):
if plotTypes[i]==PlotTypes.PLOT_PEAK:
plotTypes[i]=PlotTypes.PLOT_HILLS
return plotTypes

be carefull with the tabulation . But i'm not on my pc so i can't test that but that should work .

TCho !

EDIT : if you can't achieve that , just ask ... and try the terra script in the full of resources thread waiting for the answer .

baro
Jun 10, 2007, 07:13 PM
# All regions have been processed. Plot Type generation completed.
return self.wholeworldPlotTypes

'''
Regional Variables Key:

iWaterPercent,
iRegionWidth, iRegionHeight,
iRegionWestX, iRegionSouthY,
iRegionGrain, iRegionHillsGrain,
iRegionPlotFlags, iRegionTerrainFlags,
iRegionFracXExp, iRegionFracYExp,
bShift, iStrip,
rift_grain, has_center_rift,
invert_heights
'''

def generatePlotTypes():
NiTextOut("Setting Plot Types (Python Terra) ...")
# Call generatePlotsByRegion() function, from TerraMultilayeredFractal subclass.
global plotgen
plotgen = TerraMultilayeredFractal()
return plotgen.generatePlotsByRegion()
plotTypes=plotgen.generatePlotsByRegion()
for i in range(len(plotTypes)):
if plotTypes[i]==PlotTypes.PLOT_PEAK:
plotTypes[i]=PlotTypes.PLOT_HILLS
return plotTypes

def generateTerrainTypes():
NiTextOut("Generating Terrain (Python Terra) ...")
terraingen = TerrainGenerator()
terrainTypes = terraingen.generateTerrain()
return terrainTypes

def addFeatures():
NiTextOut("Adding Features (Python Terra) ...")
featuregen = FeatureGenerator()
featuregen.addFeatures()
return 0



This is what I changed the end of my terra file to look like. When I load the map script the game just crashes and I get to here ol Lenard go on and on. Maybe you gave me the wrong info or maybe I put in your info wrong or maybe both? I'd really love to get this simple "mod" done. Seems like it should be pretty easy to do, but I think I'm too stupid to figure it out.

ps I'm working with warlords if that makes any difference

Sto
Jun 11, 2007, 04:41 AM
You have forgotten the "#" before "return plotgen.generatePlotsByRegion()" and the tabulation like in the example i give , the best is to use python but this is doable with notepad ( you need 2 tabs = 8 spaces after the "for ..." and the "if ..." ) .

TCho !

Shizof
Jul 30, 2007, 10:34 AM
Hi! Is it possible for someone to explain how to write a script that replaces deserts(not flood plains) and ice to plains and grasslands(randomly). And jungles to forests?

Thedrin
Jul 30, 2007, 01:45 PM
Shizof:
Hi! Is it possible for someone to explain how to write a script that replaces deserts(not flood plains) and ice to plains and grasslands(randomly).

Take a look at the terrain generator 'class TerrainGenerator' found in CvMapGeneratorUtil.py at C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Warlords\Assets\Python. The first part of this generator is

def__init__(...):

Within the brackets are the default values of various variables which determine the type of terrain generated. The terrain options offered in LandMasses works by overriding these variables.

You can try simply replacing them with alternative values to see what you want. Alter iDesertPercent, fTundraLatitude, and fSnowLatitude for the three changes you specified so that less desert is produced and tundra and snow are generated further from the equator.

However, using this method, producing less deserts means producing less flood plains.

And jungles to forests?

Similar. Go to the features generator 'class FeatureGenerator' to alter the amount of forests and jungles.