First of all, how are you defining x and z?
Half the code needed for that so see the full code further below.
And second: coherence and smoothness should be floats to ints. use 1.0 instead of 1. I had the same problem before.
I'll do that but it works for now...
pathWidth is not technically correct. Size parameter defines the area of placer not it's width.
var pathWidth = 5; // This is not really the path's sickness in tiles but the number of tiles in the clumbs of the path
But your overall code should work.
It does, but the uncommented stuff is the thing in question. So in this code it's the 'avoidClasses' and I have no idea why. I fixed this by painting the hills after the path, so don't tell me that it will not work because no tiles are added to 'clHill' at this point
. I just wanted to tell that 'avoidClasses' sometimes fails (maybe because of the centered placer with given coordinated, I don't have a clue)
What do you want to do exactly?
For the dark forest map I want the forest to be placed differently from the other maps to really make it dark (well, at least in theory possible). So I add it on every tile if a random check vs the 'actual density' succeeds. This 'actual density' is mainly the 'maxTreeDensity' (constant for a single map dependent on map size to avoid out of memory errors) scaled by other density modifiers (Dependent on distance to next start location or the center eye candy and the radius to have room to place additional resources at the given radius). This works fine and as I want it.
However, to enable the players to reach the center and each other on more than 1 path I added paths that should cut through the woods (I think that would just be possible by adding the paths after the woods, but I wanted to get used to the painter/placer/constraint/area usage that is in most cases the perfect thing).
I noticed that the paths sometimes run in the non-starting-resource-hills and that looked bad so I added an TileClassPainter(clHill) to the resource area and the avoidClasses(clHill) constraint to the paths. But it didn't avoid the hills. So I placed the hills after the paths.
That was most likely a bug in my code that I didn't find because for the woods (that avoids paths) it works and it's a centered placer, too.
Besides: As it is now only the center of the paths and the resource terrain clumbs are in the corresponding classes not all terrain clumb's tiles.
I should see your complete code this time. Could you show it to me in PM?
Here it is though not in a PM, someone might find it useful (like your suggestion to use float, not int):
And a download:
By the way, NONE of the existing maps use 'TileClassPainter' so I'm quite sure it doesn't work properly.
For SmoothElevationPainter: I can't reproduce this on a simple map (why ever) but just replace line 223 with:
var painter = [new TerrainPainter(terrainWoodBorder), new SmoothElevationPainter(ELEVATION_MODIFY, 0.0, 10.0)];
And play around with the 'ClumpPlacer' and 'SmoothElevationPainter' arguments. Then generate the map and watch the terrain elevation below bushes/wild animals/apple trees (all in 'terrainWoodBorder')
I recommend to generate it with 3 players on a small map. It generates relatively fast then and has enough wood/wood border to play around with the variables and see the results.
Writing a test map...
Edited by FeXoR, 22 March 2012 - 12:18 PM.