Towns
评价数不足
Towns Map Creation: Part 5: Terrain: Variation in the Landscape
由 Varsh 制作
In this tutorial we will take our current terrain and add in some much needed variation to the grass.
   
奖励
收藏
已收藏
取消收藏
Notes
Grass comes in many forms, some is thin, some is thick, some is overgrown! To make things more varied we will need to make sure that grass is different from area to area but not too random that it looks odd.

Where we put the seeds for the grass in the code is very important, as the standard grass terrain will be changing in height as well. When the terrain is created the grass is placed everywhere, when the hills and mountains are created it pushes the available terrain upwards. If you create the other grass seeds after this process then you will only have the standard grass on the hills and mountains.
The grass seeds
To prevent this from happening the grass seeds must be placed before the use of any height seeds if it is required to be raised as well. As we want a variation of grass on top of hills and mountains then we will want to create the grass seed before the height seeds we have already created.
Directly after initialising the map have a new seed called “seedGrassNoFlower”, the type is “grassnoflower” (remember that the type is the id referenced in the graphics.ini file) and it will be on level 24. This will replace some of the original grass terrain with a different type of grass.

The map is pretty large so we want to be able to cover quite a large area but at the same time not too much or too sparse. Having a number of 15 seeds will make things sparse but will give enough variation, having 25 seeds will fill the map but not too much so having 15 is the absolute minimum and we want to be able to have at least 10 more so for the number of seeds we will have a 1d10+15.

To make sure that the grass seed doesn't look like the diamond shaped lakes or be too large in size we will have the north, south, east and west percentages set to 25 and give a higher turn amount to compensate for the low percentage chance. I have set this to 30 turns.

With the following settings you should now have the following:
<seed id="seedGrassNoFlower"> <type>grassnoflower</type> <num>1d10+15</num> <level>24</level> <turns>30</turns> <northPCT>25</northPCT> <southPCT>25</southPCT> <eastPCT>25</eastPCT> <westPCT>25</westPCT> </seed>
For a bit more variation on the initial grass seeds I will add another seed called “seedGrassNoFlower1” with a type of “grassnoflower1” using the same values as above.
Testing the changes
If you load the map now you should see that you have large patches of two new types of grass. Even though there's variation it still looks a little strange at time so we can change that by adding a new type of tag called “change”.
Varying the new grass seeds
For the “change” tags it's always best to have these done at the end of the map creation process otherwise having things change too many times during the map creation process will create many undesirable effects.

So just before closing the map generation “</gen_map>” we are going to have two changes for two different types of grass. For the first change we will have the id of “changeGrassNoFlower1”. Now this is where things can get a little confusing. I'll show you the values I've used for this change first:
<change id="changeGrassNoFlower1"> <source>grassnoflower</source> <destination>grassnoflower1</destination> <terrain>grassnoflower</terrain> <PCT>50</PCT> <radius>20</radius> </change>
The “source” means that those are the terrain tiles that you want to change, the “destination” is the terrain tile you want to change the tile into, the “terrain” is the terrain tile that needs to be next to the terrain tile that is changing otherwise if that terrain tile is not adjacent then it will not change.

Phew that was a mouthful though I hope it makes sense. You might want to read over that paragraph a few times before it sinks in and you go “aha!”.

The percentage as you probably would have guessed is the amount of terrain tiles that would be changing and the radius is the area that will be affected.

There was another change that was added afterwards called “changeGrassNoFlower2” which is almost the same as above except with the following:
<change id="changeGrassNoFlower2"> <source>grassnoflower1</source> <destination>grassnoflower2</destination> <terrain>grass</terrain> <PCT>50</PCT> <radius>10</radius> </change>
I am now taking the newly made “grassnoflower1” and changing them to “grassnoflower2” but only if they are adjacent to any “grass” terrain tiles present otherwise they will not change. I want half of them to change and they can change up to 10 terrain tiles away.

The second seed also had the same “grassnoflower1” terrain so this will be its first change meaning that now you will have two types of grass seeds, one that has 3 different types of grass and another with a couple variations.
Testing the final changes
Load the map and see how it looks, you should now see a lot more variation to the map than before. Experiment by adding more seeds and changes but for the rest of the tutorials these settings will be kept.
Tips
Remember that the source, destination, terrain and the type refers to the graphic id in the graphics.ini file.
Code
Here's the code for the gen_map.xml file with the new additions:
<?xml version="1.0" encoding="UTF-8"?> <gen_map> <init id="init"> <numLevelsOutside>24</numLevelsOutside> <numLevelsUnderground>40</numLevelsUnderground> <mainTerrain>grass,dirt,stone</mainTerrain> <numCitizens>100</numCitizens> <startingLevel>23</startingLevel> </init> <seed id="seedGrassNoFlower"> <type>grassnoflower</type> <num>1d10+15</num> <level>24</level> <turns>30</turns> <northPCT>25</northPCT> <southPCT>25</southPCT> <eastPCT>25</eastPCT> <westPCT>25</westPCT> </seed> <seed id="seedGrassNoFlower1"> <type>grassnoflower1</type> <num>1d10+15</num> <level>24</level> <turns>30</turns> <northPCT>25</northPCT> <southPCT>25</southPCT> <eastPCT>25</eastPCT> <westPCT>25</westPCT> </seed> <seed id="seedLake"> <type>_WATER_</type> <num>1d3</num> <level>24</level> <pointx>1d160+20</pointx> <pointy>1d160+20</pointy> <turns>10</turns> <northPCT>100</northPCT> <southPCT>100</southPCT> <eastPCT>100</eastPCT> <westPCT>100</westPCT> <downPCT>100</downPCT> </seed> <bezier id="bezierRiver1"> <type>_WATER_INF_</type> <level>24</level> <depth>5</depth> <wide>5</wide> <point1_x_min>25</point1_x_min> <point1_x_max>175</point1_x_max> <point1_y_min>-50</point1_y_min> <point1_y_max>-50</point1_y_max> <point2_x_min>25</point2_x_min> <point2_x_max>175</point2_x_max> <point2_y_min>250</point2_y_min> <point2_y_max>250</point2_y_max> <controlpoint1_x_min>-50</controlpoint1_x_min> <controlpoint1_x_max>250</controlpoint1_x_max> <controlpoint1_y_min>25</controlpoint1_y_min> <controlpoint1_y_max>75</controlpoint1_y_max> <controlpoint2_x_min>-50</controlpoint2_x_min> <controlpoint2_x_max>250</controlpoint2_x_max> <controlpoint2_y_min>125</controlpoint2_y_min> <controlpoint2_y_max>175</controlpoint2_y_max> </bezier> <heightSeed id="seedHeight1"> <num>2d3+2</num> <turns>20</turns> <flatsBetweenLevels>1d3</flatsBetweenLevels> <northPCT>50</northPCT> <southPCT>50</southPCT> <eastPCT>50</eastPCT> <westPCT>50</westPCT> </heightSeed> <heightSeed id="seedHeight2"> <num>2d10+5</num> <turns>10</turns> <flatsBetweenLevels>1d5</flatsBetweenLevels> <northPCT>50</northPCT> <southPCT>50</southPCT> <eastPCT>50</eastPCT> <westPCT>50</westPCT> </heightSeed> <change id="changeGrassNoFlower1"> <source>grassnoflower</source> <destination>grassnoflower1</destination> <terrain>grassnoflower</terrain> <PCT>50</PCT> <radius>20</radius> </change> <change id="changeGrassNoFlower2"> <source>grassnoflower1</source> <destination>grassnoflower2</destination> <terrain>grass</terrain> <PCT>50</PCT> <radius>10</radius> </change> </gen_map>