diff --git a/binaries/data/mods/public/maps/random/archipelago.js b/binaries/data/mods/public/maps/random/archipelago.js index fe46e89f46..4cdb44d808 100644 --- a/binaries/data/mods/public/maps/random/archipelago.js +++ b/binaries/data/mods/public/maps/random/archipelago.js @@ -233,6 +233,21 @@ createAreas( scaleByMapSize(1, 5)*randInt(9,15) ); +// create shore jaggedness +log("Creating shore jaggedness..."); +placer = new ClumpPlacer(scaleByMapSize(15, 80), 0.2, 0.1, 1); +terrainPainter = new LayeredPainter( + [tCliff, tHill], // terrains + [2] // widths +); +elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 4); +createAreas( + placer, + [terrainPainter, elevationPainter, paintClass(clLand)], + borderClasses(clLand, 6, 3), + scaleByMapSize(12, 130) * 2, 150 +); + //painting the terrain paintTerrainBasedOnHeight(1, 3, 0, tShore); paintTerrainBasedOnHeight(-8, 1, 2, tWater); diff --git a/binaries/data/mods/public/maps/random/english_channel.js b/binaries/data/mods/public/maps/random/english_channel.js index 3827d7251c..dd99c46757 100644 --- a/binaries/data/mods/public/maps/random/english_channel.js +++ b/binaries/data/mods/public/maps/random/english_channel.js @@ -537,6 +537,16 @@ createObjectGroups(group, 0, 2 * numPlayers, 50 ); +// create berry bush +log("Creating berry bush..."); +group = new SimpleGroup( + [new SimpleObject(oBerryBush, 5,7, 0,4)], + true, clFood +); +createObjectGroups(group, 0, + avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10), + randInt(1, 4) * numPlayers + 2, 50 +); // create straggler trees log("Creating straggler trees..."); diff --git a/binaries/data/mods/public/maps/random/islands.js b/binaries/data/mods/public/maps/random/islands.js index 7b9514757c..16cc09d722 100644 --- a/binaries/data/mods/public/maps/random/islands.js +++ b/binaries/data/mods/public/maps/random/islands.js @@ -100,7 +100,7 @@ for (var i = 0; i < numPlayers; i++) log("Creating base for player " + id + "..."); // some constants - var radius = scaleByMapSize(17,29); + var radius = scaleByMapSize(20,29); var shoreRadius = 6; var elevation = 3; diff --git a/binaries/data/mods/public/maps/random/lake.js b/binaries/data/mods/public/maps/random/lake.js index 7f98f43887..2623bb9473 100644 --- a/binaries/data/mods/public/maps/random/lake.js +++ b/binaries/data/mods/public/maps/random/lake.js @@ -235,6 +235,19 @@ createArea(placer, [terrainPainter, elevationPainter, paintClass(clWater)], avoi // create shore jaggedness log("Creating shore jaggedness..."); +placer = new ClumpPlacer(scaleByMapSize(20, 150), 0.2, 0.1, 1); +terrainPainter = new LayeredPainter( + [tCliff, tHill], // terrains + [2] // widths +); +elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -5, 4); +createAreas( + placer, + [terrainPainter, elevationPainter, paintClass(clWater)], + [avoidClasses(clPlayer, 20), borderClasses(clWater, 6, 4)], + scaleByMapSize(7, 130) * 2, 150 +); + placer = new ClumpPlacer(scaleByMapSize(15, 80), 0.2, 0.1, 1); terrainPainter = new LayeredPainter( [tCliff, tHill], // terrains diff --git a/binaries/data/mods/public/maps/random/lorraine_plain.js b/binaries/data/mods/public/maps/random/lorraine_plain.js index 5e552ac08e..00e33602b6 100644 --- a/binaries/data/mods/public/maps/random/lorraine_plain.js +++ b/binaries/data/mods/public/maps/random/lorraine_plain.js @@ -1,49 +1,46 @@ RMS.LoadLibrary("rmgen"); -var tGrass = ["temp_grass", "temp_grass", "temp_grass_d"]; -var tGrassPForest = "temp_plants_bog"; -var tGrassDForest = "temp_plants_bog"; -var tGrassA = "temp_grass_plants"; -var tGrassB = "temp_plants_bog"; -var tGrassC = ["temp_grass_b", "temp_grass_c"]; -var tDirt = ["temp_plants_bog", "temp_mud_a"]; -var tHill = ["temp_highlands", "temp_grass_long_b"]; -var tCliff = ["temp_cliff_a", "temp_cliff_b"]; -var tRoad = "temp_road"; -var tRoadWild = "temp_road_overgrown"; -var tGrassPatch = "temp_grass_plants"; -var tShoreBlend = "temp_grass_plants"; -var tShore = "temp_plants_bog"; -var tWater = "temp_mud_a"; +const tGrass = ["temp_grass", "temp_grass", "temp_grass_d"]; +const tGrassPForest = "temp_plants_bog"; +const tGrassDForest = "temp_plants_bog"; +const tGrassA = "temp_grass_plants"; +const tGrassB = "temp_plants_bog"; +const tGrassC = "temp_mud_a"; +const tDirt = ["temp_plants_bog", "temp_mud_a"]; +const tHill = ["temp_highlands", "temp_grass_long_b"]; +const tCliff = ["temp_cliff_a", "temp_cliff_b"]; +const tRoad = "temp_road"; +const tRoadWild = "temp_road_overgrown"; +const tGrassPatchBlend = "temp_grass_long_b"; +const tGrassPatch = ["temp_grass_d", "temp_grass_clovers"]; +const tShoreBlend = "temp_grass_plants"; +const tShore = "temp_plants_bog"; +const tWater = "temp_mud_a"; // gaia entities -var oBeech = "gaia/flora_tree_euro_beech"; -var oOak = "gaia/flora_tree_oak"; -var oBerryBush = "gaia/flora_bush_berry"; -var oChicken = "gaia/fauna_chicken"; -var oDeer = "gaia/fauna_deer"; -var oFish = "gaia/fauna_fish"; -var oSheep = "gaia/fauna_rabbit"; -var oStoneLarge = "gaia/geology_stonemine_temperate_quarry"; -var oStoneSmall = "gaia/geology_stone_temperate"; -var oMetalLarge = "gaia/geology_metal_temperate_slabs"; -var oWood = "gaia/special_treasure_wood"; -var oFood = "gaia/special_treasure_food_bin"; -var oMetal = "gaia/special_treasure_metal"; -var oStone = "gaia/special_treasure_stone"; +const oBeech = "gaia/flora_tree_euro_beech"; +const oOak = "gaia/flora_tree_oak"; +const oBerryBush = "gaia/flora_bush_berry"; +const oChicken = "gaia/fauna_chicken"; +const oDeer = "gaia/fauna_deer"; +const oFish = "gaia/fauna_fish"; +const oRabbit = "gaia/fauna_rabbit"; +const oStoneLarge = "gaia/geology_stonemine_temperate_quarry"; +const oStoneSmall = "gaia/geology_stone_temperate"; +const oMetalLarge = "gaia/geology_metal_temperate_slabs"; // decorative props -var aGrass = "actor|props/flora/grass_soft_small_tall.xml"; -var aGrassShort = "actor|props/flora/grass_soft_large.xml"; -var aRockLarge = "actor|geology/stone_granite_med.xml"; -var aRockMedium = "actor|geology/stone_granite_med.xml"; -var aReeds = "actor|props/flora/reeds_pond_lush_a.xml"; -var aLillies = "actor|props/flora/water_lillies.xml"; -var aBushMedium = "actor|props/flora/bush_medit_me.xml"; -var aBushSmall = "actor|props/flora/bush_medit_sm.xml"; +const aGrass = "actor|props/flora/grass_soft_small_tall.xml"; +const aGrassShort = "actor|props/flora/grass_soft_large.xml"; +const aRockLarge = "actor|geology/stone_granite_med.xml"; +const aRockMedium = "actor|geology/stone_granite_med.xml"; +const aReeds = "actor|props/flora/reeds_pond_lush_a.xml"; +const aLillies = "actor|props/flora/water_lillies.xml"; +const aBushMedium = "actor|props/flora/bush_medit_me.xml"; +const aBushSmall = "actor|props/flora/bush_medit_sm.xml"; -var pForestD = [tGrassDForest + TERRAIN_SEPARATOR + oBeech, tGrassDForest]; -var pForestP = [tGrassPForest + TERRAIN_SEPARATOR + oOak, tGrassPForest]; +const pForestB = [tGrassDForest + TERRAIN_SEPARATOR + oBeech, tGrassDForest]; +const pForestO = [tGrassPForest + TERRAIN_SEPARATOR + oOak, tGrassPForest]; const BUILDING_ANGlE = -PI/4; // initialize map @@ -52,9 +49,9 @@ log("Initializing map..."); InitMap(); -var numPlayers = getNumPlayers(); -var mapSize = getMapSize(); -var mapArea = mapSize*mapSize; +const numPlayers = getNumPlayers(); +const mapSize = getMapSize(); +const mapArea = mapSize*mapSize; // create tile classes @@ -135,7 +132,7 @@ for (var i = 0; i < numPlayers; i++) createArea(placer, painter, null); // create starting units - placeCivDefaultEntities(fx, fz, id, BUILDING_ANGlE); + placeCivDefaultEntities(fx, fz, id, BUILDING_ANGlE, {'iberWall' : 'towers'}); // create animals for (var j = 0; j < 2; ++j) @@ -231,7 +228,7 @@ log("Creating the shallows of the main river"); for (var i = 0; i <= randInt(3, scaleByMapSize(4,6)); i++) { var cLocation = randFloat(0.15,0.85); - passageMaker(fractionToTiles(cLocation), fractionToTiles(0.35), fractionToTiles(cLocation), fractionToTiles(0.65), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4); + passageMaker(floor(fractionToTiles(cLocation)), floor(fractionToTiles(0.35)), floor(fractionToTiles(cLocation)), floor(fractionToTiles(0.65)), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4); } // create tributaries @@ -249,7 +246,7 @@ for (var i = 0; i <= randInt(8, (scaleByMapSize(12,20))); i++) { var cDistance = -0.05; } - var point = getTIPIADBON([fractionToTiles(cLocation), fractionToTiles(0.5 + cDistance)], [fractionToTiles(cLocation), fractionToTiles(0.5 - cDistance)], [-6, -1.5], 0.5, 4, 0.01); + var point = getTIPIADBON([fractionToTiles(cLocation), fractionToTiles(0.5 + cDistance)], [fractionToTiles(cLocation), fractionToTiles(0.5 - cDistance)], [-6, -1.5], 0.5, 5, 0.01); if (point !== undefined) { var placer = new PathPlacer(floor(point[0]), floor(point[1]), floor(fractionToTiles(0.5 + 0.49*cos(tang))), floor(fractionToTiles(0.5 + 0.49*sin(tang))), scaleByMapSize(10,20), 0.4, 3*(scaleByMapSize(1,4)), 0.1, 0.05); @@ -273,12 +270,14 @@ for (var i = 0; i <= randInt(8, (scaleByMapSize(12,20))); i++) } } -passageMaker(fractionToTiles(0.2), fractionToTiles(0.25), fractionToTiles(0.8), fractionToTiles(0.25), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4); -passageMaker(fractionToTiles(0.2), fractionToTiles(0.75), fractionToTiles(0.8), fractionToTiles(0.75), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4); +passageMaker(floor(fractionToTiles(0.2)), floor(fractionToTiles(0.25)), floor(fractionToTiles(0.8)), floor(fractionToTiles(0.25)), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4); +passageMaker(floor(fractionToTiles(0.2)), floor(fractionToTiles(0.75)), floor(fractionToTiles(0.8)), floor(fractionToTiles(0.75)), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4); -paintTerrainBasedOnHeight(-5, 2, 1, tWater); +paintTerrainBasedOnHeight(-5, 1, 1, tWater); +paintTerrainBasedOnHeight(1, 2, 1, tShore) paintTileClassBasedOnHeight(-6, 0.5, 1, clWater) + RMS.SetProgress(50); // create bumps @@ -288,7 +287,7 @@ painter = new SmoothElevationPainter(ELEVATION_MODIFY, 2, 2); createAreas( placer, painter, - avoidClasses(clWater, 2, clPlayer, 7), + avoidClasses(clWater, 2, clPlayer, 15), scaleByMapSize(100, 200) ); @@ -306,8 +305,8 @@ var numStragglers = totalTrees * (1.0 - P_FOREST); // create forests log("Creating forests..."); var types = [ - [[tGrassDForest, tGrass, pForestD], [tGrassDForest, pForestD]], - [[tGrassPForest, tGrass, pForestP], [tGrassPForest, pForestP]] + [[tGrassDForest, tGrass, pForestB], [tGrassDForest, pForestB]], + [[tGrassPForest, tGrass, pForestO], [tGrassPForest, pForestO]] ]; // some variation var size = numForest / (scaleByMapSize(2,8) * numPlayers); var num = floor(size / types.length); @@ -321,7 +320,7 @@ for (var i = 0; i < types.length; ++i) createAreas( placer, [painter, paintClass(clForest)], - avoidClasses(clPlayer, 6, clWater, 3, clForest, 8, clHill, 1), + avoidClasses(clPlayer, 15, clWater, 3, clForest, 8, clHill, 1), num ); } @@ -335,30 +334,31 @@ for (var i = 0; i < sizes.length; i++) { placer = new ClumpPlacer(sizes[i], 0.3, 0.06, 0.5); painter = new LayeredPainter( - [[tGrass,tGrassA],[tGrassA,tGrassB], [tGrassB,tGrassC]], // terrains + [[tGrass,tGrassA], tGrassB, [tGrassB,tGrassC]], // terrains [1,1] // widths ); createAreas( placer, [painter, paintClass(clDirt)], - avoidClasses(clWater, 1, clForest, 0, clHill, 0, clPlayer, 6), + avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 6), scaleByMapSize(15, 45) ); } -RMS.SetProgress(75); - // create grass patches log("Creating grass patches..."); var sizes = [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]; for (var i = 0; i < sizes.length; i++) { placer = new ClumpPlacer(sizes[i], 0.3, 0.06, 0.5); - painter = new TerrainPainter(tGrassPatch); + painter = new LayeredPainter( + [tGrassPatchBlend, tGrassPatch], // terrains + [1] // widths + ); createAreas( placer, painter, - avoidClasses(clWater, 1, clForest, 0, clHill, 0, clPlayer, 6), + avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 6), scaleByMapSize(15, 45) ); } @@ -369,14 +369,14 @@ log("Creating stone mines..."); // create large stone quarries group = new SimpleGroup([new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)], true, clRock); createObjectGroups(group, 0, - [avoidClasses(clWater, 0, clForest, 1, clPlayer, 8, clRock, 10, clHill, 1)], + [avoidClasses(clWater, 0, clForest, 1, clPlayer, 15, clRock, 10, clHill, 1)], scaleByMapSize(4,16), 100 ); // create small stone quarries group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock); createObjectGroups(group, 0, - [avoidClasses(clWater, 0, clForest, 1, clPlayer, 8, clRock, 10, clHill, 1)], + [avoidClasses(clWater, 0, clForest, 1, clPlayer, 15, clRock, 10, clHill, 1)], scaleByMapSize(4,16), 100 ); @@ -384,7 +384,7 @@ log("Creating metal mines..."); // create large metal quarries group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal); createObjectGroups(group, 0, - [avoidClasses(clWater, 0, clForest, 1, clPlayer, 8, clMetal, 10, clRock, 5, clHill, 1)], + [avoidClasses(clWater, 0, clForest, 1, clPlayer, 15, clMetal, 10, clRock, 5, clHill, 1)], scaleByMapSize(4,16), 100 ); @@ -423,22 +423,33 @@ group = new SimpleGroup( true, clFood ); createObjectGroups(group, 0, - avoidClasses(clWater, 0, clForest, 0, clPlayer, 1, clHill, 1, clFood, 20), + avoidClasses(clWater, 0, clForest, 0, clPlayer, 15, clHill, 1, clFood, 20), 3 * numPlayers, 50 ); -// create sheep -log("Creating sheep..."); +// create rabbid +log("Creating rabbid..."); group = new SimpleGroup( - [new SimpleObject(oSheep, 2,3, 0,2)], + [new SimpleObject(oRabbit, 2,3, 0,2)], true, clFood ); createObjectGroups(group, 0, - avoidClasses(clWater, 0, clForest, 0, clPlayer, 6, clHill, 1, clFood, 20), + avoidClasses(clWater, 0, clForest, 0, clPlayer, 15, clHill, 1, clFood, 20), 3 * numPlayers, 50 ); +// create berry bush +log("Creating berry bush..."); +group = new SimpleGroup( + [new SimpleObject(oBerryBush, 5,7, 0,4)], + true, clFood +); +createObjectGroups(group, 0, + avoidClasses(clWater, 3, clForest, 0, clPlayer, 15, clHill, 1, clFood, 10), + randInt(1, 4) * numPlayers + 2, 50 +); + // create straggler trees log("Creating straggler trees..."); var types = [oOak, oBeech]; // some variation @@ -503,7 +514,7 @@ setWaterColour(0.443,0.412,0.322); setWaterTint(0.647,0.82,0.949); setWaterReflectionTint(0.286,0.58,0.855); setWaterWaviness(2.5); -setWaterMurkiness(1.00); +setWaterMurkiness(0.80); setWaterReflectionTintStrength(0.25); // Export map data diff --git a/binaries/data/mods/public/maps/random/migration.js b/binaries/data/mods/public/maps/random/migration.js index 013aa5855c..12a36e825f 100644 --- a/binaries/data/mods/public/maps/random/migration.js +++ b/binaries/data/mods/public/maps/random/migration.js @@ -1,53 +1,52 @@ RMS.LoadLibrary("rmgen"); - //random terrain textures -var rt = randomizeBiome(); +var random_terrain = randomizeBiome(); -var tGrass = rBiomeT1(); -var tGrassPForest = rBiomeT2(); -var tGrassDForest = rBiomeT3(); -var tCliff = rBiomeT4(); -var tGrassA = rBiomeT5(); -var tGrassB = rBiomeT6(); -var tGrassC = rBiomeT7(); -var tHill = rBiomeT8(); -var tDirt = rBiomeT9(); -var tRoad = rBiomeT10(); -var tRoadWild = rBiomeT11(); -var tGrassPatch = rBiomeT12(); -var tShoreBlend = rBiomeT13(); -var tShore = rBiomeT14(); -var tWater = rBiomeT15(); +const tMainTerrain = rBiomeT1(); +const tForestFloor1 = rBiomeT2(); +const tForestFloor2 = rBiomeT3(); +const tCliff = rBiomeT4(); +const tTier1Terrain = rBiomeT5(); +const tTier2Terrain = rBiomeT6(); +const tTier3Terrain = rBiomeT7(); +const tHill = rBiomeT8(); +const tDirt = rBiomeT9(); +const tRoad = rBiomeT10(); +const tRoadWild = rBiomeT11(); +const tTier4Terrain = rBiomeT12(); +const tShoreBlend = rBiomeT13(); +const tShore = rBiomeT14(); +const tWater = rBiomeT15(); // gaia entities -var oOak = rBiomeE1(); -var oOakLarge = rBiomeE2(); -var oApple = rBiomeE3(); -var oPine = rBiomeE4(); -var oAleppoPine = rBiomeE5(); -var oBerryBush = rBiomeE6(); -var oChicken = rBiomeE7(); -var oDeer = rBiomeE8(); -var oFish = rBiomeE9(); -var oSheep = rBiomeE10(); -var oStoneLarge = rBiomeE11(); -var oStoneSmall = rBiomeE12(); -var oMetalLarge = rBiomeE13(); -var oWood = "gaia/special_treasure_wood"; +const oTree1 = rBiomeE1(); +const oTree2 = rBiomeE2(); +const oTree3 = rBiomeE3(); +const oTree4 = rBiomeE4(); +const oTree5 = rBiomeE5(); +const oFruitBush = rBiomeE6(); +const oChicken = rBiomeE7(); +const oMainHuntableAnimal = rBiomeE8(); +const oFish = rBiomeE9(); +const oSecondaryHuntableAnimal = rBiomeE10(); +const oStoneLarge = rBiomeE11(); +const oStoneSmall = rBiomeE12(); +const oMetalLarge = rBiomeE13(); +const oWood = "gaia/special_treasure_wood"; // decorative props -var aGrass = rBiomeA1(); -var aGrassShort = rBiomeA2(); -var aReeds = rBiomeA3(); -var aLillies = rBiomeA4(); -var aRockLarge = rBiomeA5(); -var aRockMedium = rBiomeA6(); -var aBushMedium = rBiomeA7(); -var aBushSmall = rBiomeA8(); +const aGrass = rBiomeA1(); +const aGrassShort = rBiomeA2(); +const aReeds = rBiomeA3(); +const aLillies = rBiomeA4(); +const aRockLarge = rBiomeA5(); +const aRockMedium = rBiomeA6(); +const aBushMedium = rBiomeA7(); +const aBushSmall = rBiomeA8(); -var pForestD = [tGrassDForest + TERRAIN_SEPARATOR + oOak, tGrassDForest + TERRAIN_SEPARATOR + oOakLarge, tGrassDForest]; -var pForestP = [tGrassPForest + TERRAIN_SEPARATOR + oPine, tGrassPForest + TERRAIN_SEPARATOR + oAleppoPine, tGrassPForest]; +const pForest1 = [tForestFloor2 + TERRAIN_SEPARATOR + oTree1, tForestFloor2 + TERRAIN_SEPARATOR + oTree2, tForestFloor2]; +const pForest2 = [tForestFloor1 + TERRAIN_SEPARATOR + oTree4, tForestFloor1 + TERRAIN_SEPARATOR + oTree5, tForestFloor1]; const BUILDING_ANGlE = -PI/4; // initialize map @@ -56,9 +55,9 @@ log("Initializing map..."); InitMap(); -var numPlayers = getNumPlayers(); -var mapSize = getMapSize(); -var mapArea = mapSize*mapSize; +const numPlayers = getNumPlayers(); +const mapSize = getMapSize(); +const mapArea = mapSize*mapSize; // create tile classes @@ -74,26 +73,6 @@ var clBaseResource = createTileClass(); var clSettlement = createTileClass(); var clLand = createTileClass(); var clRiver = createTileClass(); -//Create the continent body - - - -var fx = fractionToTiles(0.12); -var fz = fractionToTiles(0.5); -var ix = round(fx); -var iz = round(fz); - -var placer = new ClumpPlacer(mapArea * 0.50, 0.80, 0.08, 10, ix, iz); -var terrainPainter = new LayeredPainter( - [tWater, tShore, tGrass], // terrains - [4, 2] // widths -); -var elevationPainter = new SmoothElevationPainter( - ELEVATION_SET, // type - 3, // elevation - 4 // blend radius -); -createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null); // randomize player order var playerIDs = []; @@ -124,7 +103,7 @@ for (var i = 0; i < numPlayers; i++) // some constants var radius = scaleByMapSize(15,25); - var shoreRadius = 2; + var shoreRadius = 4; var elevation = 3; var hillSize = PI * radius * radius; @@ -136,7 +115,7 @@ for (var i = 0; i < numPlayers; i++) // create the hill var placer = new ClumpPlacer(hillSize, 0.80, 0.1, 10, ix, iz); var terrainPainter = new LayeredPainter( - [tWater , tShore, tGrass], // terrains + [tWater , tShore, tMainTerrain], // terrains [1, shoreRadius] // widths ); var elevationPainter = new SmoothElevationPainter( @@ -153,7 +132,7 @@ for (var i = 0; i < numPlayers; i++) createArea(placer, painter, null); // create starting units - placeCivDefaultEntities(fx, fz, id, BUILDING_ANGlE, {'iberWall' : 'towers'}); + placeCivDefaultEntities(fx, fz, id, BUILDING_ANGlE, {'iberWall' : false}); // create animals for (var j = 0; j < 2; ++j) @@ -175,7 +154,7 @@ for (var i = 0; i < numPlayers; i++) var bbX = round(fx + bbDist * cos(bbAngle)); var bbZ = round(fz + bbDist * sin(bbAngle)); group = new SimpleGroup( - [new SimpleObject(oBerryBush, 5,5, 0,3)], + [new SimpleObject(oFruitBush, 5,5, 0,3)], true, clBaseResource, bbX, bbZ ); createObjectGroup(group, 0); @@ -223,7 +202,7 @@ for (var i = 0; i < numPlayers; i++) var tX = round(fx + tDist * cos(tAngle)); var tZ = round(fz + tDist * sin(tAngle)); group = new SimpleGroup( - [new SimpleObject(oOak, num, num, 0,4)], + [new SimpleObject(oTree1, num, num, 0,4)], false, clBaseResource, tX, tZ ); createObjectGroup(group, 0, avoidClasses(clBaseResource,2)); @@ -242,8 +221,51 @@ for (var i = 0; i < numPlayers; i++) ); createObjectGroup(group, 0); } + + //create docks + var dockLocation = getTIPIADBON([ix, iz], [mapSize / 2, mapSize / 2], [-3 , 2.6], 0.5, 3); + if (dockLocation !== undefined) + placeObject(dockLocation[0], dockLocation[1], "structures/" + g_MapSettings.PlayerData[id-1].Civ + "_dock", id, playerAngle[i] + PI); } + +//Create the continent body +var fx = fractionToTiles(0.12); +var fz = fractionToTiles(0.5); +var ix = round(fx); +var iz = round(fz); + +var placer = new ClumpPlacer(mapArea * 0.50, 0.80, 0.08, 10, ix, iz); +var terrainPainter = new LayeredPainter( + [tWater, tShore, tMainTerrain], // terrains + [4, 2] // widths +); +var elevationPainter = new SmoothElevationPainter( + ELEVATION_SET, // type + 3, // elevation + 4 // blend radius +); +createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], avoidClasses(clPlayer, 8)); + +// create shore jaggedness +log("Creating shore jaggedness..."); +placer = new ClumpPlacer(scaleByMapSize(15, 80), 0.2, 0.1, 1); +terrainPainter = new LayeredPainter( + [tMainTerrain, tMainTerrain], // terrains + [2] // widths +); +elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 4); +createAreas( + placer, + [terrainPainter, elevationPainter, paintClass(clLand)], + [borderClasses(clLand, 6, 3), avoidClasses(clPlayer, 8)], + scaleByMapSize(20, 150) * 2, 150 +); + +//painting the terrain +paintTerrainBasedOnHeight(1, 3, 0, tShore); +paintTerrainBasedOnHeight(-8, 1, 2, tWater); + RMS.SetProgress(20); // create bumps @@ -273,23 +295,23 @@ createAreas( ); // calculate desired number of trees for map (based on size) -if (rt == 6) +if (random_terrain == 6) { -var MIN_TREES = 200; -var MAX_TREES = 1250; -var P_FOREST = 0.02; + var MIN_TREES = 200; + var MAX_TREES = 1250; + var P_FOREST = 0.02; } -else if (rt == 7) +else if (random_terrain == 7) { -var MIN_TREES = 1000; -var MAX_TREES = 6000; -var P_FOREST = 0.6; + var MIN_TREES = 1000; + var MAX_TREES = 6000; + var P_FOREST = 0.6; } else { -var MIN_TREES = 500; -var MAX_TREES = 3000; -var P_FOREST = 0.7; + var MIN_TREES = 500; + var MAX_TREES = 3000; + var P_FOREST = 0.7; } var totalTrees = scaleByMapSize(MIN_TREES, MAX_TREES); @@ -299,11 +321,11 @@ var numStragglers = totalTrees * (1.0 - P_FOREST); // create forests log("Creating forests..."); var types = [ - [[tGrassDForest, tGrass, pForestD], [tGrassDForest, pForestD]], - [[tGrassPForest, tGrass, pForestP], [tGrassPForest, pForestP]] + [[tForestFloor2, tMainTerrain, pForest1], [tForestFloor2, pForest1]], + [[tForestFloor1, tMainTerrain, pForest2], [tForestFloor1, pForest2]] ]; // some variation -if (rt == 6) +if (random_terrain == 6) { var size = numForest / (0.5 * scaleByMapSize(2,8) * numPlayers); } @@ -335,7 +357,7 @@ for (var i = 0; i < sizes.length; i++) { placer = new ClumpPlacer(sizes[i], 0.3, 0.06, 0.5); painter = new LayeredPainter( - [[tGrass,tGrassA],[tGrassA,tGrassB], [tGrassB,tGrassC]], // terrains + [[tMainTerrain,tTier1Terrain],[tTier1Terrain,tTier2Terrain], [tTier2Terrain,tTier3Terrain]], // terrains [1,1] // widths ); createAreas( @@ -352,7 +374,7 @@ var sizes = [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80) for (var i = 0; i < sizes.length; i++) { placer = new ClumpPlacer(sizes[i], 0.3, 0.06, 0.5); - painter = new TerrainPainter(tGrassPatch); + painter = new TerrainPainter(tTier4Terrain); createAreas( placer, painter, @@ -367,14 +389,14 @@ log("Creating stone mines..."); // create large stone quarries group = new SimpleGroup([new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)], true, clRock); createObjectGroups(group, 0, - [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1, clRiver, 1), stayClasses(clLand, 5)], + [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1, clRiver, 1), stayClasses(clLand, 7)], scaleByMapSize(4,16), 100 ); // create small stone quarries group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock); createObjectGroups(group, 0, - [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1, clRiver, 1), stayClasses(clLand, 5)], + [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1, clRiver, 1), stayClasses(clLand, 7)], scaleByMapSize(4,16), 100 ); @@ -382,7 +404,7 @@ log("Creating metal mines..."); // create large metal quarries group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal); createObjectGroups(group, 0, - [avoidClasses(clForest, 1, clPlayer, 10, clMetal, 10, clRock, 5, clHill, 1, clRiver, 1), stayClasses(clLand, 5)], + [avoidClasses(clForest, 1, clPlayer, 10, clMetal, 10, clRock, 5, clHill, 1, clRiver, 1), stayClasses(clLand, 7)], scaleByMapSize(4,16), 100 ); @@ -396,7 +418,7 @@ group = new SimpleGroup( ); createObjectGroups( group, 0, - [avoidClasses(clWater, 0, clForest, 0, clPlayer, 0, clHill, 0, clRiver, 1), stayClasses(clLand, 5)], + [avoidClasses(clWater, 0, clForest, 0, clPlayer, 0, clHill, 0, clRiver, 1), stayClasses(clLand, 6)], scaleByMapSize(16, 262), 50 ); @@ -409,7 +431,7 @@ group = new SimpleGroup( ); createObjectGroups( group, 0, - [avoidClasses(clWater, 0, clForest, 0, clPlayer, 0, clHill, 0, clRiver, 1), stayClasses(clLand, 5)], + [avoidClasses(clWater, 0, clForest, 0, clPlayer, 0, clHill, 0, clRiver, 1), stayClasses(clLand, 6)], scaleByMapSize(8, 131), 50 ); @@ -418,11 +440,11 @@ RMS.SetProgress(70); // create deer log("Creating deer..."); group = new SimpleGroup( - [new SimpleObject(oDeer, 5,7, 0,4)], + [new SimpleObject(oMainHuntableAnimal, 5,7, 0,4)], true, clFood ); createObjectGroups(group, 0, - [avoidClasses(clWater, 0, clForest, 0, clPlayer, 10, clHill, 1, clFood, 20, clRiver, 1), stayClasses(clLand, 3)], + [avoidClasses(clWater, 0, clForest, 0, clPlayer, 10, clHill, 1, clFood, 20, clRiver, 1), stayClasses(clLand, 7)], 3 * numPlayers, 50 ); @@ -431,14 +453,25 @@ RMS.SetProgress(75); // create sheep log("Creating sheep..."); group = new SimpleGroup( - [new SimpleObject(oSheep, 2,3, 0,2)], + [new SimpleObject(oSecondaryHuntableAnimal, 2,3, 0,2)], true, clFood ); createObjectGroups(group, 0, - [avoidClasses(clWater, 0, clForest, 0, clPlayer, 10, clHill, 1, clFood, 20, clRiver, 1), stayClasses(clLand, 3)], + [avoidClasses(clWater, 0, clForest, 0, clPlayer, 10, clHill, 1, clFood, 20, clRiver, 1), stayClasses(clLand, 7)], 3 * numPlayers, 50 ); +// create fruit bush +log("Creating fruit bush..."); +group = new SimpleGroup( + [new SimpleObject(oFruitBush, 5,7, 0,4)], + true, clFood +); +createObjectGroups(group, 0, + [avoidClasses(clWater, 0, clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 7)], + randInt(1, 4) * numPlayers + 2, 50 +); + // create fish log("Creating fish..."); group = new SimpleGroup( @@ -455,7 +488,7 @@ RMS.SetProgress(85); // create straggler trees log("Creating straggler trees..."); -var types = [oOak, oOakLarge, oPine, oApple]; // some variation +var types = [oTree1, oTree2, oTree4, oTree3]; // some variation var num = floor(numStragglers / types.length); for (var i = 0; i < types.length; ++i) { @@ -464,13 +497,13 @@ for (var i = 0; i < types.length; ++i) true, clForest ); createObjectGroups(group, 0, - [avoidClasses(clWater, 1, clForest, 1, clHill, 1, clPlayer, 9, clMetal, 1, clRock, 1, clRiver, 1), stayClasses(clLand, 7)], + [avoidClasses(clWater, 1, clForest, 1, clHill, 1, clPlayer, 9, clMetal, 1, clRock, 1, clRiver, 1), stayClasses(clLand, 9)], num ); } var planetm = 1; -if (rt==7) +if (random_terrain==7) { planetm = 8; } @@ -508,15 +541,15 @@ createObjectGroups(group, 0, planetm * scaleByMapSize(13, 200), 50 ); -rt = randInt(1,3) -if (rt==1){ -setSkySet("cirrus"); +random_terrain = randInt(1,3) +if (random_terrain==1){ + setSkySet("cirrus"); } -else if (rt ==2){ -setSkySet("cumulus"); +else if (random_terrain ==2){ + setSkySet("cumulus"); } -else if (rt ==3){ -setSkySet("sunny"); +else if (random_terrain ==3){ + setSkySet("sunny"); } setSunRotation(randFloat(0, TWO_PI)); setSunElevation(randFloat(PI/ 5, PI / 3)); diff --git a/binaries/data/mods/public/maps/random/neareastern_badlands.js b/binaries/data/mods/public/maps/random/neareastern_badlands.js index 3ade4beb39..03a72c8091 100644 --- a/binaries/data/mods/public/maps/random/neareastern_badlands.js +++ b/binaries/data/mods/public/maps/random/neareastern_badlands.js @@ -17,7 +17,7 @@ const tShore = "desert_shore_stones"; const tWaterDeep = "desert_shore_stones_wet"; // gaia entities -const oBerryBush = "gaia/flora_bush_berry"; +const oBerryBush = "gaia/flora_bush_grapes"; const oChicken = "gaia/fauna_chicken"; const oCamel = "gaia/fauna_camel"; const oFish = "gaia/fauna_fish"; @@ -40,8 +40,8 @@ const aBushes = [aBush1, aBush2, aBush3, aBush4]; const aDecorativeRock = "actor|geology/stone_desert_med.xml"; // terrain + entity (for painting) -var pForest = [tForestFloor + TERRAIN_SEPARATOR + oDatePalm, tForestFloor + TERRAIN_SEPARATOR + oSDatePalm, tForestFloor]; -var pForestOasis = [tGrass + TERRAIN_SEPARATOR + oDatePalm, tGrass + TERRAIN_SEPARATOR + oSDatePalm, tGrass]; +const pForest = [tForestFloor + TERRAIN_SEPARATOR + oDatePalm, tForestFloor + TERRAIN_SEPARATOR + oSDatePalm, tForestFloor]; +const pForestOasis = [tGrass + TERRAIN_SEPARATOR + oDatePalm, tGrass + TERRAIN_SEPARATOR + oSDatePalm, tGrass]; const BUILDING_ANGlE = -PI/4; @@ -51,9 +51,9 @@ log("Initializing map..."); InitMap(); -var numPlayers = getNumPlayers(); -var mapSize = getMapSize(); -var mapArea = mapSize*mapSize; +const numPlayers = getNumPlayers(); +const mapSize = getMapSize(); +const mapArea = mapSize*mapSize; // create tile classes diff --git a/binaries/data/mods/public/maps/random/northern_lights.js b/binaries/data/mods/public/maps/random/northern_lights.js index 38efd80a43..3cdb69c5ca 100644 --- a/binaries/data/mods/public/maps/random/northern_lights.js +++ b/binaries/data/mods/public/maps/random/northern_lights.js @@ -1,34 +1,34 @@ RMS.LoadLibrary("rmgen"); -var tGrass = ["polar_snow_b"]; -var tGrassA = "polar_ice_snow"; -var tGrassB = "polar_ice"; -var tGrassC = "polar_snow_a"; -var tForestFloor = "polar_tundra_snow"; -var tCliff = "polar_snow_rocks"; -var tDirt = ["polar_snow_glacial"]; -var tRoad = "new_alpine_citytile"; -var tRoadWild = "new_alpine_citytile"; -var tShoreBlend = "alpine_shore_rocks_icy"; -var tShore = "alpine_shore_rocks"; -var tWater = "alpine_shore_rocks"; +const tSnowA = ["polar_snow_b"]; +const tSnowB = "polar_ice_snow"; +const tSnowC = "polar_ice"; +const tSnowD = "polar_snow_a"; +const tForestFloor = "polar_tundra_snow"; +const tCliff = "polar_snow_rocks"; +const tSnowE = ["polar_snow_glacial"]; +const tRoad = "new_alpine_citytile"; +const tRoadWild = "new_alpine_citytile"; +const tShoreBlend = "alpine_shore_rocks_icy"; +const tShore = "alpine_shore_rocks"; +const tWater = "alpine_shore_rocks"; // gaia entities -var oTree = "gaia/flora_tree_pine_w"; -var oStoneLarge = "gaia/geology_stonemine_alpine_quarry"; -var oStoneSmall = "gaia/geology_stone_alpine_a"; -var oMetalLarge = "gaia/geology_metal_alpine_slabs"; -var oFish = "gaia/fauna_fish"; -var oDeer = "gaia/fauna_walrus"; -var oSheep = "gaia/fauna_wolf_snow"; +const oPine = "gaia/flora_tree_pine_w"; +const oStoneLarge = "gaia/geology_stonemine_alpine_quarry"; +const oStoneSmall = "gaia/geology_stone_alpine_a"; +const oMetalLarge = "gaia/geology_metal_alpine_slabs"; +const oFish = "gaia/fauna_fish"; +const oWalrus = "gaia/fauna_walrus"; +const oWolf = "gaia/fauna_wolf_snow"; // decorative props -var aRockLarge = "actor|geology/stone_granite_med.xml"; -var aRockMedium = "actor|geology/stone_granite_med.xml"; -var aIceberg = "actor|props/special/eyecandy/iceberg.xml"; +const aRockLarge = "actor|geology/stone_granite_med.xml"; +const aRockMedium = "actor|geology/stone_granite_med.xml"; +const aIceberg = "actor|props/special/eyecandy/iceberg.xml"; -var pForestD = [tForestFloor + TERRAIN_SEPARATOR + oTree, tForestFloor, tForestFloor]; -var pForestP = [tForestFloor + TERRAIN_SEPARATOR + oTree, tForestFloor, tForestFloor, tForestFloor]; +const pForestD = [tForestFloor + TERRAIN_SEPARATOR + oPine, tForestFloor, tForestFloor]; +const pForestS = [tForestFloor + TERRAIN_SEPARATOR + oPine, tForestFloor, tForestFloor, tForestFloor]; const BUILDING_ANGlE = -PI/4; // initialize map @@ -37,9 +37,9 @@ log("Initializing map..."); InitMap(); -var numPlayers = getNumPlayers(); -var mapSize = getMapSize(); -var mapArea = mapSize*mapSize; +const numPlayers = getNumPlayers(); +const mapSize = getMapSize(); +const mapArea = mapSize*mapSize; // create tile classes @@ -145,7 +145,7 @@ for (var i = 0; i < numPlayers; i++) var tX = round(fx + tDist * cos(tAngle)); var tZ = round(fz + tDist * sin(tAngle)); group = new SimpleGroup( - [new SimpleObject(oTree, num, num, 0,3)], + [new SimpleObject(oPine, num, num, 0,3)], false, clBaseResource, tX, tZ ); createObjectGroup(group, 0, avoidClasses(clBaseResource,2)); @@ -185,7 +185,7 @@ for (var i = 0; i < scaleByMapSize(20,120); i++) { placer = new ClumpPlacer(scaleByMapSize(50, 70), 0.2, 0.1, 10, randFloat(0.1,0.9)*mapSize, randFloat(0.67,0.74)*mapSize); var terrainPainter = new LayeredPainter( - [tGrass, tGrass], // terrains + [tSnowA, tSnowA], // terrains [2] // widths ); var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 3); @@ -200,7 +200,7 @@ for (var i = 0; i < scaleByMapSize(20,120); i++) log("Creating islands..."); placer = new ClumpPlacer(scaleByMapSize(40, 180), 0.2, 0.1, 1); var terrainPainter = new LayeredPainter( - [tGrass, tGrass], // terrains + [tSnowA, tSnowA], // terrains [3] // widths ); var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 3); @@ -225,7 +225,7 @@ var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -4, 3); var waterAreas = createAreas( placer, [terrainPainter, elevationPainter, paintClass(clWater)], - avoidClasses(clPlayer, 15, clWater, 20), + avoidClasses(clPlayer, 20, clWater, 20), numLakes ); @@ -238,14 +238,14 @@ RMS.SetProgress(45); log("Creating hills..."); placer = new ClumpPlacer(scaleByMapSize(20, 150), 0.2, 0.1, 1); var terrainPainter = new LayeredPainter( - [tCliff, tGrass], // terrains + [tCliff, tSnowA], // terrains [3] // widths ); var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 25, 3); createAreas( placer, [terrainPainter, elevationPainter, paintClass(clHill)], - avoidClasses(clPlayer, 12, clHill, 15, clWater, 2, clBaseResource, 2), + avoidClasses(clPlayer, 20, clHill, 15, clWater, 2, clBaseResource, 2), scaleByMapSize(2, 8) * numPlayers ); @@ -263,8 +263,8 @@ var numStragglers = totalTrees * (1.0 - P_FOREST); // create forests log("Creating forests..."); var types = [ - [[tGrass, tGrass, tGrass, tGrass, pForestD], [tGrass, tGrass, tGrass, pForestD]], - [[tGrass, tGrass, tGrass, tGrass, pForestP], [tGrass, tGrass, tGrass, pForestP]] + [[tSnowA, tSnowA, tSnowA, tSnowA, pForestD], [tSnowA, tSnowA, tSnowA, pForestD]], + [[tSnowA, tSnowA, tSnowA, tSnowA, pForestS], [tSnowA, tSnowA, tSnowA, pForestS]] ]; // some variation @@ -281,7 +281,7 @@ for (var i = 0; i < types.length; ++i) createAreas( placer, [painter, paintClass(clForest)], - avoidClasses(clPlayer, 12, clForest, 20, clHill, 0, clWater, 8), + avoidClasses(clPlayer, 20, clForest, 20, clHill, 0, clWater, 8), num ); } @@ -303,13 +303,13 @@ for (var i = 0; i < sizes.length; i++) { placer = new ClumpPlacer(sizes[i], 0.3, 0.06, 0.5); painter = new LayeredPainter( - [tGrassC,tGrassA,tGrassB], // terrains + [tSnowD,tSnowB,tSnowC], // terrains [2,1] // widths ); createAreas( placer, [painter, paintClass(clDirt)], - avoidClasses(clWater, 8, clForest, 0, clHill, 0, clPlayer, 12, clDirt, 16), + avoidClasses(clWater, 8, clForest, 0, clHill, 0, clPlayer, 20, clDirt, 16), scaleByMapSize(20, 80) ); } @@ -318,13 +318,13 @@ for (var i = 0; i < sizes.length; i++) { placer = new ClumpPlacer(sizes[i], 0.3, 0.06, 0.5); painter = new LayeredPainter( - [tDirt,tDirt], // terrains + [tSnowE,tSnowE], // terrains [1] // widths ); createAreas( placer, [painter, paintClass(clDirt)], - avoidClasses(clWater, 8, clForest, 0, clHill, 0, clPlayer, 12, clDirt, 16), + avoidClasses(clWater, 8, clForest, 0, clHill, 0, clPlayer, 20, clDirt, 16), scaleByMapSize(20, 80) ); } @@ -333,14 +333,14 @@ log("Creating stone mines..."); // create large stone quarries group = new SimpleGroup([new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)], true, clRock); createObjectGroups(group, 0, - avoidClasses(clWater, 3, clForest, 1, clPlayer, 10, clRock, 10, clHill, 1), + avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), scaleByMapSize(4,16), 100 ); // create small stone quarries group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock); createObjectGroups(group, 0, - avoidClasses(clWater, 3, clForest, 1, clPlayer, 10, clRock, 10, clHill, 1), + avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), scaleByMapSize(4,16), 100 ); @@ -348,7 +348,7 @@ log("Creating metal mines..."); // create large metal quarries group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal); createObjectGroups(group, 0, - avoidClasses(clWater, 3, clForest, 1, clPlayer, 10, clMetal, 10, clRock, 5, clHill, 1), + avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 1), scaleByMapSize(4,16), 100 ); @@ -357,7 +357,7 @@ RMS.SetProgress(95); // create straggler trees log("Creating straggler trees..."); -var types = [oTree]; // some variation +var types = [oPine]; // some variation var num = floor(numStragglers / types.length); for (var i = 0; i < types.length; ++i) { @@ -374,11 +374,11 @@ for (var i = 0; i < types.length; ++i) // create deer log("Creating deer..."); group = new SimpleGroup( - [new SimpleObject(oDeer, 5,7, 0,4)], + [new SimpleObject(oWalrus, 5,7, 0,4)], true, clFood ); createObjectGroups(group, 0, - avoidClasses(clWater, 3, clForest, 0, clPlayer, 10, clHill, 1, clFood, 20), + avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 20), 3 * numPlayers, 50 ); @@ -387,11 +387,11 @@ RMS.SetProgress(75); // create sheep log("Creating sheep..."); group = new SimpleGroup( - [new SimpleObject(oSheep, 2,3, 0,2)], + [new SimpleObject(oWolf, 2,3, 0,2)], true, clFood ); createObjectGroups(group, 0, - avoidClasses(clWater, 3, clForest, 0, clPlayer, 10, clHill, 1, clFood, 20), + avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 20), 3 * numPlayers, 50 ); diff --git a/binaries/data/mods/public/maps/random/oasis.js b/binaries/data/mods/public/maps/random/oasis.js index 07ffa994ea..c154fe7852 100644 --- a/binaries/data/mods/public/maps/random/oasis.js +++ b/binaries/data/mods/public/maps/random/oasis.js @@ -1,49 +1,43 @@ RMS.LoadLibrary("rmgen"); //random terrain textures -var tGrass = ["desert_sand_dunes_100", "desert_dirt_cracks","desert_sand_smooth", "desert_dirt_rough", "desert_dirt_rough_2", "desert_sand_smooth"]; -var tDune = ["desert_sand_dunes_50"]; -var tBigDune = ["desert_sand_dunes_50"]; -var tGrassPForest = "forestfloor_dirty"; -var tForestFloor = "desert_forestfloor_palms"; -var tGrassA = ["desert_dirt_persia_1", "desert_dirt_persia_2"]; -var tGrassB = "dirta"; -var tGrassC = "medit_dirt_dry"; -var tHill = ["desert_dirt_rocks_1", "desert_dirt_rocks_2", "desert_dirt_rocks_3"]; -var tDirt = ["desert_dirt_rough","desert_dirt_rough","desert_dirt_rough", "desert_dirt_rough_2", "desert_dirt_rocks_2"]; -var tRoad = "desert_city_tile";; -var tRoadWild = "desert_city_tile";; -var tGrassPatch = "desert_dirt_rough";; -var tShoreBlend = "desert_sand_wet"; -var tShore = "dirta"; -var tWater = "desert_sand_wet"; +const tSand = ["desert_sand_dunes_100", "desert_dirt_cracks","desert_sand_smooth", "desert_dirt_rough", "desert_dirt_rough_2", "desert_sand_smooth"]; +const tDune = ["desert_sand_dunes_50"]; +const tBigDune = ["desert_sand_dunes_50"]; +const tForestFloor = "desert_forestfloor_palms"; +const tHill = ["desert_dirt_rocks_1", "desert_dirt_rocks_2", "desert_dirt_rocks_3"]; +const tDirt = ["desert_dirt_rough","desert_dirt_rough","desert_dirt_rough", "desert_dirt_rough_2", "desert_dirt_rocks_2"]; +const tRoad = "desert_city_tile";; +const tRoadWild = "desert_city_tile";; +const tShoreBlend = "desert_sand_wet"; +const tShore = "dirta"; +const tWater = "desert_sand_wet"; // gaia entities -var ePalmShort = "gaia/flora_tree_cretan_date_palm_short"; -var ePalmTall = "gaia/flora_tree_cretan_date_palm_tall"; -var eBush = "gaia/flora_bush_berry"; -var eChicken = "gaia/fauna_chicken"; -var eCamel = "gaia/fauna_camel"; -var eGazelle = "gaia/fauna_gazelle"; -var eLion = "gaia/fauna_lion"; -var eLioness = "gaia/fauna_lioness"; -var eStoneMine = "gaia/geology_stonemine_desert_quarry"; -var eStoneMineSmall = "gaia/geology_stone_desert_small"; -var eMetalMine = "gaia/geology_metal_desert_slabs"; +const ePalmShort = "gaia/flora_tree_cretan_date_palm_short"; +const ePalmTall = "gaia/flora_tree_cretan_date_palm_tall"; +const eBush = "gaia/flora_bush_grapes"; +const eChicken = "gaia/fauna_chicken"; +const eCamel = "gaia/fauna_camel"; +const eGazelle = "gaia/fauna_gazelle"; +const eLion = "gaia/fauna_lion"; +const eLioness = "gaia/fauna_lioness"; +const eStoneMine = "gaia/geology_stonemine_desert_quarry"; +const eStoneMineSmall = "gaia/geology_stone_desert_small"; +const eMetalMine = "gaia/geology_metal_desert_slabs"; // decorative props -var aFlower1 = "actor|props/flora/decals_flowers_daisies.xml"; -var aWaterFlower = "actor|props/flora/water_lillies.xml"; -var aReedsA = "actor|props/flora/reeds_pond_lush_a.xml"; -var aReedsB = "actor|props/flora/reeds_pond_lush_b.xml"; -var aRock = "actor|geology/stone_desert_med.xml"; -var rba6 = "actor|geology/stone_desert_med"; -var aBushA = "actor|props/flora/bush_desert_dry_a.xml"; -var aBushB = "actor|props/flora/bush_desert_dry_a.xml"; -var aSand = "actor|particle/blowing_sand.xml"; +const aFlower1 = "actor|props/flora/decals_flowers_daisies.xml"; +const aWaterFlower = "actor|props/flora/water_lillies.xml"; +const aReedsA = "actor|props/flora/reeds_pond_lush_a.xml"; +const aReedsB = "actor|props/flora/reeds_pond_lush_b.xml"; +const aRock = "actor|geology/stone_desert_med.xml"; +const aBushA = "actor|props/flora/bush_desert_dry_a.xml"; +const aBushB = "actor|props/flora/bush_desert_dry_a.xml"; +const aSand = "actor|particle/blowing_sand.xml"; -var pForestD = [tForestFloor + TERRAIN_SEPARATOR + ePalmShort, tForestFloor + TERRAIN_SEPARATOR + ePalmTall, tForestFloor]; -var pOasisForestLight = [tForestFloor + TERRAIN_SEPARATOR + ePalmShort, tForestFloor + TERRAIN_SEPARATOR + ePalmTall, tForestFloor,tForestFloor,tForestFloor +const pForestMain = [tForestFloor + TERRAIN_SEPARATOR + ePalmShort, tForestFloor + TERRAIN_SEPARATOR + ePalmTall, tForestFloor]; +const pOasisForestLight = [tForestFloor + TERRAIN_SEPARATOR + ePalmShort, tForestFloor + TERRAIN_SEPARATOR + ePalmTall, tForestFloor,tForestFloor,tForestFloor ,tForestFloor,tForestFloor,tForestFloor,tForestFloor]; const BUILDING_ANGlE = -PI/4; @@ -53,9 +47,9 @@ log("Initializing map..."); InitMap(); -var numPlayers = getNumPlayers(); -var mapSize = getMapSize(); -var mapArea = mapSize*mapSize; +const numPlayers = getNumPlayers(); +const mapSize = getMapSize(); +const mapArea = mapSize*mapSize; // create tile classes @@ -77,7 +71,7 @@ for (var ix = 0; ix < mapSize; ix++) { var x = ix / (mapSize + 1.0); var z = iz / (mapSize + 1.0); - placeTerrain(ix, iz, tGrass); + placeTerrain(ix, iz, tSand); } } @@ -198,7 +192,7 @@ for (var i = 0; i < numPlayers; i++) ); createObjectGroup(group, 0); // Create starting batches of wood - var types = [tForestFloor, pForestD]; // some variation + var types = [tForestFloor, pForestMain]; // some variation var forestX = 0; var forestY = 0; var forestAngle = 0; @@ -273,7 +267,7 @@ if(mapSize > 150 && randInt(0,1)) { var pex = round(fx) + round(fractionToTiles(0.13 * -cos(pAngle))); var pey = round(fz) + round(fractionToTiles(0.13 * sin(pAngle + PI))); var path = new PathPlacer(px,py,pex,pey,scaleByMapSize(7,18), 0.4,1,0.2,0) - terrainPainter = new TerrainPainter(tGrass); + terrainPainter = new TerrainPainter(tSand); elevationPainter = new SmoothElevationPainter(ELEVATION_MODIFY, 4, 5 ); createArea(path, [terrainPainter, elevationPainter, paintClass(clPassage)], null); } diff --git a/binaries/data/mods/public/maps/random/persian_highlands.js b/binaries/data/mods/public/maps/random/persian_highlands.js index 0a930c3fe8..dc2c6b6150 100644 --- a/binaries/data/mods/public/maps/random/persian_highlands.js +++ b/binaries/data/mods/public/maps/random/persian_highlands.js @@ -1,19 +1,19 @@ RMS.LoadLibrary("rmgen"); const tCity = "desert_city_tile_plaza"; -const tSand = ["desert_dirt_persia_1", "desert_dirt_persia_2", "grass_field_dry"]; -const tDunes = ["desert_lakebed_dry_b", "desert_dirt_persia_1", "desert_dirt_persia_2", "desert_lakebed_dry"]; -const tDunes2 = ["desert_lakebed_dry_b", "desert_dirt_persia_1", "desert_dirt_persia_2", "desert_lakebed_dry", "desert_dirt_persia_2", "desert_dirt_persia_1"]; -const tFineSand = "desert_pebbles_rough"; +const tDirtMain = ["desert_dirt_persia_1", "desert_dirt_persia_2", "grass_field_dry"]; +const tLakebed1 = ["desert_lakebed_dry_b", "desert_lakebed_dry"]; +const tLakebed2 = ["desert_lakebed_dry_b", "desert_lakebed_dry", "desert_shore_stones", "desert_shore_stones"]; +const tPebbles = "desert_pebbles_rough"; const tCliff = ["desert_cliff_persia_1", "desert_cliff_persia_2"]; const tForestFloor = "medit_grass_field_dry"; const tRocky = "desert_dirt_persia_rocky"; const tRocks = "desert_dirt_persia_rocks"; -const tDirt = ["desert_pebbles_rough", "grass_field_brown"]; +const tGrass = "grass_field_dry"; const tHill = "desert_cliff_persia_base"; // gaia entities -const oBerryBush = "gaia/flora_bush_grapes"; +const oGrapesBush = "gaia/flora_bush_grapes"; const oChicken = "gaia/fauna_chicken"; const oCamel = "gaia/fauna_camel"; const oFish = "gaia/fauna_fish"; @@ -23,7 +23,7 @@ const oLion = "gaia/fauna_lioness"; const oStoneLarge = "gaia/geology_stonemine_desert_badlands_quarry"; const oStoneSmall = "gaia/geology_stone_desert_small"; const oMetalLarge = "gaia/geology_metal_desert_slabs"; -const oDead = "gaia/flora_tree_tamarix"; +const oTamarix = "gaia/flora_tree_tamarix"; const oOak = "gaia/flora_tree_oak"; // decorative props @@ -35,8 +35,7 @@ const aBushes = [aBush1, aBush2, aBush3, aBush4]; const aDecorativeRock = "actor|geology/stone_desert_med.xml"; // terrain + entity (for painting) -const pForestO = [tForestFloor + TERRAIN_SEPARATOR + oOak, tForestFloor + TERRAIN_SEPARATOR + oOak, tForestFloor, tSand, tSand]; -const pForestD = [tForestFloor + TERRAIN_SEPARATOR + oDead, tForestFloor + TERRAIN_SEPARATOR + oDead, tForestFloor, tSand, tSand]; +const pForestO = [tForestFloor + TERRAIN_SEPARATOR + oOak, tForestFloor + TERRAIN_SEPARATOR + oOak, tForestFloor, tDirtMain, tDirtMain]; const BUILDING_ANGlE = -PI/4; @@ -44,9 +43,9 @@ log("Initializing map..."); InitMap(); -var numPlayers = getNumPlayers(); -var mapSize = getMapSize(); -var mapArea = mapSize*mapSize; +const numPlayers = getNumPlayers(); +const mapSize = getMapSize(); +const mapArea = mapSize*mapSize; // create tile classes @@ -133,7 +132,7 @@ for (var i = 0; i < numPlayers; i++) var bbX = round(fx + bbDist * cos(bbAngle)); var bbZ = round(fz + bbDist * sin(bbAngle)); group = new SimpleGroup( - [new SimpleObject(oBerryBush, 5,5, 0,3)], + [new SimpleObject(oGrapesBush, 5,5, 0,3)], true, clBaseResource, bbX, bbZ ); createObjectGroup(group, 0); @@ -192,7 +191,7 @@ RMS.SetProgress(15); var placer = new ClumpPlacer(scaleByMapSize(25, 100), 0.2, 0.1, 0); var painter = new TerrainPainter([tRocky, tRocks]); createAreas(placer, [painter, paintClass(clPatch)], - avoidClasses(clPatch, 2, clPlayer, 0), + avoidClasses(clPatch, 2, clPlayer, 4), scaleByMapSize(15, 50) ); @@ -200,9 +199,9 @@ RMS.SetProgress(20); log("Creating dirt patches..."); placer = new ClumpPlacer(scaleByMapSize(25, 100), 0.2, 0.1, 0); -painter = new TerrainPainter([tDirt]); +painter = new TerrainPainter([tGrass]); createAreas(placer, [painter, paintClass(clPatch)], - avoidClasses(clPatch, 2, clPlayer, 0), + avoidClasses(clPatch, 2, clPlayer, 4), scaleByMapSize(15, 50) ); @@ -212,7 +211,7 @@ RMS.SetProgress(25); log("Creating centeral plateau..."); var oRadius = scaleByMapSize(18, 68); placer = new ClumpPlacer(PI*oRadius*oRadius, 0.6, 0.15, 0, mapSize/2, mapSize/2); -painter = new LayeredPainter([tDunes2, tDunes], [8]); +painter = new LayeredPainter([tLakebed2, tLakebed1], [8]); var elevationPainter = new SmoothElevationPainter(ELEVATION_MODIFY, -10, 8); createArea(placer, [painter, elevationPainter, paintClass(clCP)], null); @@ -231,7 +230,7 @@ var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 22, 2); createAreas( placer, [terrainPainter, elevationPainter, paintClass(clHill)], - avoidClasses(clPlayer, 3, clCP, 5, clHill, 10), + avoidClasses(clPlayer, 7, clCP, 5, clHill, 10), scaleByMapSize(1, 4) * numPlayers * 3 ); @@ -249,8 +248,8 @@ var numStragglers = totalTrees * (1.0 - P_FOREST); // create forests log("Creating forests..."); var types = [ - [[tSand, tForestFloor, pForestO], [tForestFloor, pForestO]], - [[tSand, tForestFloor, pForestO], [tForestFloor, pForestO]] + [[tDirtMain, tForestFloor, pForestO], [tForestFloor, pForestO]], + [[tDirtMain, tForestFloor, pForestO], [tForestFloor, pForestO]] ]; // some variation var size = numForest / (scaleByMapSize(2,8) * numPlayers); var num = floor(size / types.length); @@ -264,7 +263,7 @@ for (var i = 0; i < types.length; ++i) createAreas( placer, [painter, paintClass(clForest)], - avoidClasses(clPlayer, 1, clWater, 3, clForest, 10, clHill, 1, clCP, 1), + avoidClasses(clPlayer, 6, clWater, 3, clForest, 10, clHill, 1, clCP, 1), num ); } @@ -371,6 +370,17 @@ createObjectGroups(group, 0, 3 * numPlayers, 50 ); +// create grape bush +log("Creating grape bush..."); +group = new SimpleGroup( + [new SimpleObject(oGrapesBush, 5,7, 0,4)], + true, clFood +); +createObjectGroups(group, 0, + avoidClasses(clForest, 0, clPlayer, 20, clHill, 1, clFood, 10, clCP, 2), + randInt(1, 4) * numPlayers + 2, 50 +); + // create camels log("Creating camels..."); group = new SimpleGroup( @@ -386,7 +396,7 @@ RMS.SetProgress(85); // create dead trees log("Creating dead trees..."); -var types = [oDead]; // some variation +var types = [oTamarix]; // some variation var num = floor(numStragglers / types.length); for (var i = 0; i < types.length; ++i) { diff --git a/binaries/data/mods/public/maps/random/rmgen/misc.js b/binaries/data/mods/public/maps/random/rmgen/misc.js index 586a054ec6..be36e8a53a 100644 --- a/binaries/data/mods/public/maps/random/rmgen/misc.js +++ b/binaries/data/mods/public/maps/random/rmgen/misc.js @@ -1 +1 @@ -///////////////////////////////////////////////////////////////////////////////////////// // passageMaker // // Function for creating shallow water between two given points by changing the heiight of all tiles in // the path with height less than or equal to "maxheight" to "height" // // x1,z1: Starting point of path // x2,z2: Ending point of path // width: Width of the shallow // maxheight: Maximum height that it changes // height: Height of the shallow // smooth: smooth elevation in borders // tileclass: (Optianal) - Adds those tiles to the class given // terrain: (Optional) - Changes the texture of the elevated land // ///////////////////////////////////////////////////////////////////////////////////////// function passageMaker(x1, z1, x2, z2, width, maxheight, height, smooth, tileclass, terrain, riverheight) { var tchm = TILE_CENTERED_HEIGHT_MAP; TILE_CENTERED_HEIGHT_MAP = true; var mapSize = g_Map.size; for (var ix = 0; ix < mapSize; ix++) { for (var iz = 0; iz < mapSize; iz++) { var a = z1-z2; var b = x2-x1; var c = (z1*(x1-x2))-(x1*(z1-z2)); var dis = abs(a*ix + b*iz + c)/sqrt(a*a + b*b); var k = (a*ix + b*iz + c)/(a*a + b*b); var my = iz-(b*k); var inline = 0; if (b == 0) { dis = abs(ix-x1); if ((iz <= Math.max(z1,z2))&&(iz >= Math.min(z1,z2))) { inline = 1; } } else { if ((my <= Math.max(z1,z2))&&(my >= Math.min(z1,z2))) { inline = 1; } } if ((dis <= width)&&(inline)) { if(g_Map.getHeight(ix, iz) <= maxheight) { if (dis > width - smooth) { g_Map.setHeight(ix, iz, ((width - dis)*(height)+(riverheight)*(smooth - width + dis))/(smooth)); } else if (dis <= width - smooth) { g_Map.setHeight(ix, iz, height); } if (tileclass !== undefined) { addToClass(ix, iz, tileclass); } if (terrain !== undefined) { placeTerrain(ix, iz, terrain); } } } } } TILE_CENTERED_HEIGHT_MAP = tchm; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //rndRiver is a fuction that creates random values useful for making a jagged river. // //it works the same as sin or cos function. the only difference is that it's period is 1 instead of 2*pi //it needs the "seed" parameter to use it to make random curves that don't get broken. //seed must be created using randFloat(). or else it won't work // // f: Input: Same as angle in a sine function // seed: Random Seed: Best to implement is to use randFloat() // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function rndRiver(f, seed) { var rndRq = seed; var rndRw = rndRq; var rndRe = 0; var rndRr = f-floor(f); var rndRa = 0; for (var rndRx=0; rndRx<=floor(f); rndRx++) { rndRw = 10*(rndRw-floor(rndRw)); } if (rndRx%2==0) { var rndRs = -1; } else { var rndRs = 1; } rndRe = (floor(rndRw))%5; if (rndRe==0) { rndRa = (rndRs)*2.3*(rndRr)*(rndRr-1)*(rndRr-0.5)*(rndRr-0.5); } else if (rndRe==1) { rndRa = (rndRs)*2.6*(rndRr)*(rndRr-1)*(rndRr-0.3)*(rndRr-0.7); } else if (rndRe==2) { rndRa = (rndRs)*22*(rndRr)*(rndRr-1)*(rndRr-0.2)*(rndRr-0.3)*(rndRr-0.3)*(rndRr-0.8); } else if (rndRe==3) { rndRa = (rndRs)*180*(rndRr)*(rndRr-1)*(rndRr-0.2)*(rndRr-0.2)*(rndRr-0.4)*(rndRr-0.6)*(rndRr-0.6)*(rndRr-0.8); } else if (rndRe==4) { rndRa = (rndRs)*2.6*(rndRr)*(rndRr-1)*(rndRr-0.5)*(rndRr-0.7); } return rndRa; } ///////////////////////////////////////////////////////////////////////////////////////// // createStartingPlayerEntities // // Creates the starting player entities // fx&fz: position of player base // playerid: id of player // civEntities: use getStartingEntities(id-1) fo this one // BUILDING_ANGlE: angle of main base building // /////////////////////////////////////////////////////////////////////////////////////////// function createStartingPlayerEntities(fx, fz, playerid, civEntities, BUILDING_ANGlE) { var uDist = 6; var uSpace = 2; placeObject(fx, fz, civEntities[0].Template, playerid, BUILDING_ANGlE); for (var j = 1; j < civEntities.length; ++j) { var uAngle = BUILDING_ANGlE - PI * (2-j) / 2; var count = (civEntities[j].Count !== undefined ? civEntities[j].Count : 1); for (var numberofentities = 0; numberofentities < count; numberofentities++) { var ux = fx + uDist * cos(uAngle) + numberofentities * uSpace * cos(uAngle + PI/2) - (0.75 * uSpace * floor(count / 2) * cos(uAngle + PI/2)); var uz = fz + uDist * sin(uAngle) + numberofentities * uSpace * sin(uAngle + PI/2) - (0.75 * uSpace * floor(count / 2) * sin(uAngle + PI/2)); placeObject(ux, uz, civEntities[j].Template, playerid, uAngle); } } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // placeCivDefaultEntities // // Creates the default starting player entities depending on the players civ // fx&fy: position of player base // playerid: id of player // angle: angle of main base building, optional, default is BUILDING_ANGlE // kwargs: Takes some optional keyword arguments to tweek things // 'iberWall': may be false, 'walls' (default) or 'towers'. Determines the defensive structures Iberians get as civ bonus // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function placeCivDefaultEntities(fx, fz, playerid, angle, kwargs) { // Unpack kwargs kwargs = (kwargs || {}); var iberWall = 'walls'; if (getMapSize() <= 128) iberWall = false; if ('iberWall' in kwargs) iberWall = kwargs['iberWall']; // Place default civ starting entities var civ = g_MapSettings.PlayerData[playerid-1].Civ; var civEntities = getStartingEntities(playerid-1); var uDist = 6; var uSpace = 2; placeObject(fx, fz, civEntities[0].Template, playerid, angle); for (var j = 1; j < civEntities.length; ++j) { var uAngle = angle - PI * (2-j) / 2; var count = (civEntities[j].Count !== undefined ? civEntities[j].Count : 1); for (var numberofentities = 0; numberofentities < count; numberofentities++) { var ux = fx + uDist * cos(uAngle) + numberofentities * uSpace * cos(uAngle + PI/2) - (0.75 * uSpace * floor(count / 2) * cos(uAngle + PI/2)); var uz = fz + uDist * sin(uAngle) + numberofentities * uSpace * sin(uAngle + PI/2) - (0.75 * uSpace * floor(count / 2) * sin(uAngle + PI/2)); placeObject(ux, uz, civEntities[j].Template, playerid, uAngle); } } // Add defensive structiures for Iberians as their civ bonus if (civ == 'iber' && iberWall != false) { if (iberWall == 'towers') placePolygonalWall(fx, fz, 15, ['entry'], 'tower', civ, playerid, angle, 7); else placeGenericFortress(fx, fz, 20/*radius*/, playerid); } } ///////////////////////////////////////////////////////////////////////////////////////// // paintTerrainBasedOnHeight // // paints the tiles which have a height between minheight and maxheight with the given terrain // minheight: minimum height of the tile // maxheight: maximum height of the tile // mode: accepts 4 values. 0 means the it will select tiles with height more than minheight and less than maxheight. // 1 means it selects tiles with height more than or equal to minheight and less than max height. 2 means more than // minheight and less than or equal to maxheight. 3 means more than or equal to minheight and less than or equal to maxheight // terrain: intended terrain texture // /////////////////////////////////////////////////////////////////////////////////////////// function paintTerrainBasedOnHeight(minheight, maxheight, mode, terrain) { var mSize = g_Map.size; for (var qx = 0; qx < mSize; qx++) { for (var qz = 0; qz < mSize; qz++) { if (mode == 0) { if ((g_Map.getHeight(qx, qz) > minheight)&&(g_Map.getHeight(qx, qz) < maxheight)) { placeTerrain(qx, qz, terrain); } } else if (mode == 1) { if ((g_Map.getHeight(qx, qz) >= minheight)&&(g_Map.getHeight(qx, qz) < maxheight)) { placeTerrain(qx, qz, terrain); } } else if (mode == 2) { if ((g_Map.getHeight(qx, qz) > minheight)&&(g_Map.getHeight(qx, qz) <= maxheight)) { placeTerrain(qx, qz, terrain); } } else if (mode == 3) { if ((g_Map.getHeight(qx, qz) >= minheight)&&(g_Map.getHeight(qx, qz) <= maxheight)) { placeTerrain(qx, qz, terrain); } } } } } ///////////////////////////////////////////////////////////////////////////////////////// // paintTileClassBasedOnHeight and unPaintTileClassBasedOnHeight // // paints or unpaints the tiles which have a height between minheight and maxheight with the given tile class // minheight: minimum height of the tile // maxheight: maximum height of the tile // mode: accepts 4 values. 0 means the it will select tiles with height more than minheight and less than maxheight. // 1 means it selects tiles with height more than or equal to minheight and less than max height. 2 means more than // minheight and less than or equal to maxheight. 3 means more than or equal to minheight and less than or equal to maxheight // tileclass: intended tile class // /////////////////////////////////////////////////////////////////////////////////////////// function paintTileClassBasedOnHeight(minheight, maxheight, mode, tileclass) { var mSize = g_Map.size; for (var qx = 0; qx < mSize; qx++) { for (var qz = 0; qz < mSize; qz++) { if (mode == 0) { if ((g_Map.getHeight(qx, qz) > minheight)&&(g_Map.getHeight(qx, qz) < maxheight)) { addToClass(qx, qz, tileclass); } } else if (mode == 1) { if ((g_Map.getHeight(qx, qz) >= minheight)&&(g_Map.getHeight(qx, qz) < maxheight)) { addToClass(qx, qz, tileclass); } } else if (mode == 2) { if ((g_Map.getHeight(qx, qz) > minheight)&&(g_Map.getHeight(qx, qz) <= maxheight)) { addToClass(qx, qz, tileclass); } } else if (mode == 3) { if ((g_Map.getHeight(qx, qz) >= minheight)&&(g_Map.getHeight(qx, qz) <= maxheight)) { addToClass(qx, qz, tileclass); } } } } } function unPaintTileClassBasedOnHeight(minheight, maxheight, mode, tileclass) { var mSize = g_Map.size; for (var qx = 0; qx < mSize; qx++) { for (var qz = 0; qz < mSize; qz++) { if (mode == 0) { if ((g_Map.getHeight(qx, qz) > minheight)&&(g_Map.getHeight(qx, qz) < maxheight)) { removeFromClass(qx, qz, tileclass); } } else if (mode == 1) { if ((g_Map.getHeight(qx, qz) >= minheight)&&(g_Map.getHeight(qx, qz) < maxheight)) { removeFromClass(qx, qz, tileclass); } } else if (mode == 2) { if ((g_Map.getHeight(qx, qz) > minheight)&&(g_Map.getHeight(qx, qz) <= maxheight)) { removeFromClass(qx, qz, tileclass); } } else if (mode == 3) { if ((g_Map.getHeight(qx, qz) >= minheight)&&(g_Map.getHeight(qx, qz) <= maxheight)) { removeFromClass(qx, qz, tileclass); } } } } } ///////////////////////////////////////////////////////////////////////////////////////// // getTIPIADBON // // "get The Intended Point In A Direction Based On Height" // gets the N'th point with a specific height in a line and returns it as a [x, y] array // startPoint: [x, y] array defining the start point // endPoint: [x, y] array defining the ending point // heightRange: [min, max] array defining the range which the height of the intended point can be. includes both "min" and "max" // step: how much tile units per turn should the search go. more value means faster but less accurate // n: how many points to skip before ending the search. skips """n-1 points""". // /////////////////////////////////////////////////////////////////////////////////////////// function getTIPIADBON(startPoint, endPoint, heightRange, step, n) { var stepX = step*(endPoint[0]-startPoint[0])/(sqrt((endPoint[0]-startPoint[0])*(endPoint[0]-startPoint[0]) + (endPoint[1]-startPoint[1])*(endPoint[1]-startPoint[1]))); var stepY = step*(endPoint[1]-startPoint[1])/(sqrt((endPoint[0]-startPoint[0])*(endPoint[0]-startPoint[0]) + (endPoint[1]-startPoint[1])*(endPoint[1]-startPoint[1]))); var y = startPoint[1]; var checked = 0; for (var x = startPoint[0]; true; x += n*stepX) { if ((floor(x) < g_Map.size)||(floor(y) < g_Map.size)) { if ((g_Map.getHeight(floor(x), floor(y)) <= heightRange[1])&&(g_Map.getHeight(floor(x), floor(y)) >= heightRange[0])) { ++checked; } if (checked >= n) { return [x, y]; } } y += stepY; if ((y > endPoint[1])&&(stepY>0)) break; if ((y < endPoint[1])&&(stepY<0)) break; if ((x > endPoint[1])&&(stepX>0)) break; if ((x < endPoint[1])&&(stepX<0)) break; } return undefined; } ///////////////////////////////////////////////////////////////////////////////////////// // doIntersect // // determines if two lines with the width "width" intersect or collide with each other // x1, y1, x2, y2: determine the position of the first line // x3, y3, x4, y4: determine the position of the second line // width: determines the width of the lines // /////////////////////////////////////////////////////////////////////////////////////////// function checkIfIntersect (x1, y1, x2, y2, x3, y3, x4, y4, width) { if (x1 == x2) { if (((x3 - x1) < width) || ((x4 - x2) < width)) return true; } else { var m = (y1 - y2) / (x1 - x2); var b = y1 - m * x1; var m2 = sqrt(m * m + 1) if ((Math.abs((y3 - x3 * m - b)/m2) < width) || (Math.abs((y4 - x4 * m - b)/m2) < width)) return true; //neccessary for some situations. if (x3 == x4) { if (((x1 - x3) < width) || ((x2 - x4) < width)) return true; } else { var m = (y3 - y4) / (x3 - x4); var b = y3 - m * x3; var m2 = sqrt(m * m + 1) if ((Math.abs((y1 - x1 * m - b)/m2) < width) || (Math.abs((y2 - x2 * m - b)/m2) < width)) return true; } } var s = ((x1 - x2) * (y3 - y1) - (y1 - y2) * (x3 - x1)), p = ((x1 - x2) * (y4 - y1) - (y1 - y2) * (x4 - x1)); if ((s * p) <= 0) { s = ((x3 - x4) * (y1 - y3) - (y3 - y4) * (x1 - x3)); p = ((x3 - x4) * (y2 - y3) - (y3 - y4) * (x2 - x3)); if ((s * p) <= 0) return true; } return false; } ///////////////////////////////////////////////////////////////////////////////////////// // distanceOfPointFromLine // // returns the distance of a point from a line // x1, y1, x2, y2: determine the position of the line // x3, y3: determine the position of the point // /////////////////////////////////////////////////////////////////////////////////////////// function distanceOfPointFromLine (x1, y1, x2, y2, x3, y3) { if (x1 == x2) { return x3 - x1; } else { var m = (y1 - y2) / (x1 - x2); var b = y1 - m * x1; var m2 = sqrt(m * m + 1) return Math.abs((y3 - x3 * m - b)/m2); } } ///////////////////////////////////////////////////////////////////////////////////////// // createRamp // // creates a ramp from point (x1, y1) to (x2, y2). // x1, y1, x2, y2: determine the position of the start and end of the ramp // minHeight, maxHeight: determine the height levels of the start and end point // width: determines the width of the ramp // smoothLevel: determines the smooth level around the edges of the ramp // mainTerrain: (Optional) determines the terrain texture for the ramp // edgeTerrain: (Optional) determines the terrain texture for the edges // tileclass: (Optional) adds the ramp to this tile class // /////////////////////////////////////////////////////////////////////////////////////////// function createRamp (x1, y1, x2, y2, minHeight, maxHeight, width, smoothLevel, mainTerrain, edgeTerrain, tileclass) { var halfWidth = width / 2; var mapSize = g_Map.size; if (y1 == y2) { var x3 = x2; var y3 = y2 + halfWidth; } else { var m = (x1 - x2) / (y1 - y2); var b = y2 + m * x2; var x3 = x2 + halfWidth; var y3 = - m * x3 + b; } var minBoundX = (x1 <= x2 ? (x1 > halfWidth ? x1 - halfWidth : 0) : (x2 > halfWidth ? x2 - halfWidth : 0)); var maxBoundX = (x1 >= x2 ? (x1 < mapSize - halfWidth ? x1 + halfWidth : mapSize) : (x2 < mapSize - halfWidth ? x2 + halfWidth : mapSize)); var minBoundY = (y1 <= y2 ? (y1 > halfWidth ? y1 - halfWidth : 0) : (y2 > halfWidth ? y2 - halfWidth : 0)); var maxBoundY = (y1 >= y2 ? (x1 < mapSize - halfWidth ? y1 + halfWidth : mapSize) : (y2 < mapSize - halfWidth ? y2 + halfWidth : mapSize)); for (var x = minBoundX; x < maxBoundX; ++x) { for (var y = minBoundY; y < maxBoundY; ++y) { var lDist = distanceOfPointFromLine(x3, y3, x2, y2, x, y); var sDist = distanceOfPointFromLine(x1, y1, x2, y2, x, y); var rampLength = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); if (lDist <= rampLength && sDist <= halfWidth) { var h = ((rampLength - lDist) * maxHeight + lDist * minHeight) / rampLength; if (sDist >= halfWidth - smoothLevel) { h = (h - minHeight) * (halfWidth - sDist) / smoothLevel + minHeight; if (edgeTerrain !== undefined) placeTerrain(x, y, edgeTerrain); } else { if (mainTerrain !== undefined) placeTerrain(x, y, mainTerrain); } if (tileclass !== undefined) addToClass(x, y, tileclass); if(g_Map.getHeight(floor(x), floor(y)) < h) g_Map.setHeight(x, y, h); } } } } \ No newline at end of file +///////////////////////////////////////////////////////////////////////////////////////// // passageMaker // // Function for creating shallow water between two given points by changing the heiight of all tiles in // the path with height less than or equal to "maxheight" to "height" // // x1,z1: Starting point of path // x2,z2: Ending point of path // width: Width of the shallow // maxheight: Maximum height that it changes // height: Height of the shallow // smooth: smooth elevation in borders // tileclass: (Optianal) - Adds those tiles to the class given // terrain: (Optional) - Changes the texture of the elevated land // ///////////////////////////////////////////////////////////////////////////////////////// function passageMaker(x1, z1, x2, z2, width, maxheight, height, smooth, tileclass, terrain, riverheight) { var tchm = TILE_CENTERED_HEIGHT_MAP; TILE_CENTERED_HEIGHT_MAP = true; var mapSize = g_Map.size; for (var ix = 0; ix < mapSize; ix++) { for (var iz = 0; iz < mapSize; iz++) { var a = z1-z2; var b = x2-x1; var c = (z1*(x1-x2))-(x1*(z1-z2)); var dis = abs(a*ix + b*iz + c)/sqrt(a*a + b*b); var k = (a*ix + b*iz + c)/(a*a + b*b); var my = iz-(b*k); var inline = 0; if (b == 0) { dis = abs(ix-x1); if ((iz <= Math.max(z1,z2))&&(iz >= Math.min(z1,z2))) { inline = 1; } } else { if ((my <= Math.max(z1,z2))&&(my >= Math.min(z1,z2))) { inline = 1; } } if ((dis <= width)&&(inline)) { if(g_Map.getHeight(ix, iz) <= maxheight) { if (dis > width - smooth) { g_Map.setHeight(ix, iz, ((width - dis)*(height)+(riverheight)*(smooth - width + dis))/(smooth)); } else if (dis <= width - smooth) { g_Map.setHeight(ix, iz, height); } if (tileclass !== undefined) { addToClass(ix, iz, tileclass); } if (terrain !== undefined) { placeTerrain(ix, iz, terrain); } } } } } TILE_CENTERED_HEIGHT_MAP = tchm; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //rndRiver is a fuction that creates random values useful for making a jagged river. // //it works the same as sin or cos function. the only difference is that it's period is 1 instead of 2*pi //it needs the "seed" parameter to use it to make random curves that don't get broken. //seed must be created using randFloat(). or else it won't work // // f: Input: Same as angle in a sine function // seed: Random Seed: Best to implement is to use randFloat() // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function rndRiver(f, seed) { var rndRq = seed; var rndRw = rndRq; var rndRe = 0; var rndRr = f-floor(f); var rndRa = 0; for (var rndRx=0; rndRx<=floor(f); rndRx++) { rndRw = 10*(rndRw-floor(rndRw)); } if (rndRx%2==0) { var rndRs = -1; } else { var rndRs = 1; } rndRe = (floor(rndRw))%5; if (rndRe==0) { rndRa = (rndRs)*2.3*(rndRr)*(rndRr-1)*(rndRr-0.5)*(rndRr-0.5); } else if (rndRe==1) { rndRa = (rndRs)*2.6*(rndRr)*(rndRr-1)*(rndRr-0.3)*(rndRr-0.7); } else if (rndRe==2) { rndRa = (rndRs)*22*(rndRr)*(rndRr-1)*(rndRr-0.2)*(rndRr-0.3)*(rndRr-0.3)*(rndRr-0.8); } else if (rndRe==3) { rndRa = (rndRs)*180*(rndRr)*(rndRr-1)*(rndRr-0.2)*(rndRr-0.2)*(rndRr-0.4)*(rndRr-0.6)*(rndRr-0.6)*(rndRr-0.8); } else if (rndRe==4) { rndRa = (rndRs)*2.6*(rndRr)*(rndRr-1)*(rndRr-0.5)*(rndRr-0.7); } return rndRa; } ///////////////////////////////////////////////////////////////////////////////////////// // createStartingPlayerEntities // // Creates the starting player entities // fx&fz: position of player base // playerid: id of player // civEntities: use getStartingEntities(id-1) fo this one // BUILDING_ANGlE: angle of main base building // /////////////////////////////////////////////////////////////////////////////////////////// function createStartingPlayerEntities(fx, fz, playerid, civEntities, BUILDING_ANGlE) { var uDist = 6; var uSpace = 2; placeObject(fx, fz, civEntities[0].Template, playerid, BUILDING_ANGlE); for (var j = 1; j < civEntities.length; ++j) { var uAngle = BUILDING_ANGlE - PI * (2-j) / 2; var count = (civEntities[j].Count !== undefined ? civEntities[j].Count : 1); for (var numberofentities = 0; numberofentities < count; numberofentities++) { var ux = fx + uDist * cos(uAngle) + numberofentities * uSpace * cos(uAngle + PI/2) - (0.75 * uSpace * floor(count / 2) * cos(uAngle + PI/2)); var uz = fz + uDist * sin(uAngle) + numberofentities * uSpace * sin(uAngle + PI/2) - (0.75 * uSpace * floor(count / 2) * sin(uAngle + PI/2)); placeObject(ux, uz, civEntities[j].Template, playerid, uAngle); } } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // placeCivDefaultEntities // // Creates the default starting player entities depending on the players civ // fx&fy: position of player base // playerid: id of player // angle: angle of main base building, optional, default is BUILDING_ANGlE // kwargs: Takes some optional keyword arguments to tweek things // 'iberWall': may be false, 'walls' (default) or 'towers'. Determines the defensive structures Iberians get as civ bonus // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function placeCivDefaultEntities(fx, fz, playerid, angle, kwargs) { // Unpack kwargs kwargs = (kwargs || {}); var iberWall = 'walls'; if (getMapSize() <= 128) iberWall = false; if ('iberWall' in kwargs) iberWall = kwargs['iberWall']; // Place default civ starting entities var civ = g_MapSettings.PlayerData[playerid-1].Civ; var civEntities = getStartingEntities(playerid-1); var uDist = 6; var uSpace = 2; placeObject(fx, fz, civEntities[0].Template, playerid, angle); for (var j = 1; j < civEntities.length; ++j) { var uAngle = angle - PI * (2-j) / 2; var count = (civEntities[j].Count !== undefined ? civEntities[j].Count : 1); for (var numberofentities = 0; numberofentities < count; numberofentities++) { var ux = fx + uDist * cos(uAngle) + numberofentities * uSpace * cos(uAngle + PI/2) - (0.75 * uSpace * floor(count / 2) * cos(uAngle + PI/2)); var uz = fz + uDist * sin(uAngle) + numberofentities * uSpace * sin(uAngle + PI/2) - (0.75 * uSpace * floor(count / 2) * sin(uAngle + PI/2)); placeObject(ux, uz, civEntities[j].Template, playerid, uAngle); } } // Add defensive structiures for Iberians as their civ bonus if (civ == 'iber' && iberWall != false) { if (iberWall == 'towers') placePolygonalWall(fx, fz, 15, ['entry'], 'tower', civ, playerid, angle, 7); else placeGenericFortress(fx, fz, 20/*radius*/, playerid); } } ///////////////////////////////////////////////////////////////////////////////////////// // paintTerrainBasedOnHeight // // paints the tiles which have a height between minheight and maxheight with the given terrain // minheight: minimum height of the tile // maxheight: maximum height of the tile // mode: accepts 4 values. 0 means the it will select tiles with height more than minheight and less than maxheight. // 1 means it selects tiles with height more than or equal to minheight and less than max height. 2 means more than // minheight and less than or equal to maxheight. 3 means more than or equal to minheight and less than or equal to maxheight // terrain: intended terrain texture // /////////////////////////////////////////////////////////////////////////////////////////// function paintTerrainBasedOnHeight(minheight, maxheight, mode, terrain) { var mSize = g_Map.size; for (var qx = 0; qx < mSize; qx++) { for (var qz = 0; qz < mSize; qz++) { if (mode == 0) { if ((g_Map.getHeight(qx, qz) > minheight)&&(g_Map.getHeight(qx, qz) < maxheight)) { placeTerrain(qx, qz, terrain); } } else if (mode == 1) { if ((g_Map.getHeight(qx, qz) >= minheight)&&(g_Map.getHeight(qx, qz) < maxheight)) { placeTerrain(qx, qz, terrain); } } else if (mode == 2) { if ((g_Map.getHeight(qx, qz) > minheight)&&(g_Map.getHeight(qx, qz) <= maxheight)) { placeTerrain(qx, qz, terrain); } } else if (mode == 3) { if ((g_Map.getHeight(qx, qz) >= minheight)&&(g_Map.getHeight(qx, qz) <= maxheight)) { placeTerrain(qx, qz, terrain); } } } } } ///////////////////////////////////////////////////////////////////////////////////////// // paintTileClassBasedOnHeight and unPaintTileClassBasedOnHeight // // paints or unpaints the tiles which have a height between minheight and maxheight with the given tile class // minheight: minimum height of the tile // maxheight: maximum height of the tile // mode: accepts 4 values. 0 means the it will select tiles with height more than minheight and less than maxheight. // 1 means it selects tiles with height more than or equal to minheight and less than max height. 2 means more than // minheight and less than or equal to maxheight. 3 means more than or equal to minheight and less than or equal to maxheight // tileclass: intended tile class // /////////////////////////////////////////////////////////////////////////////////////////// function paintTileClassBasedOnHeight(minheight, maxheight, mode, tileclass) { var mSize = g_Map.size; for (var qx = 0; qx < mSize; qx++) { for (var qz = 0; qz < mSize; qz++) { if (mode == 0) { if ((g_Map.getHeight(qx, qz) > minheight)&&(g_Map.getHeight(qx, qz) < maxheight)) { addToClass(qx, qz, tileclass); } } else if (mode == 1) { if ((g_Map.getHeight(qx, qz) >= minheight)&&(g_Map.getHeight(qx, qz) < maxheight)) { addToClass(qx, qz, tileclass); } } else if (mode == 2) { if ((g_Map.getHeight(qx, qz) > minheight)&&(g_Map.getHeight(qx, qz) <= maxheight)) { addToClass(qx, qz, tileclass); } } else if (mode == 3) { if ((g_Map.getHeight(qx, qz) >= minheight)&&(g_Map.getHeight(qx, qz) <= maxheight)) { addToClass(qx, qz, tileclass); } } } } } function unPaintTileClassBasedOnHeight(minheight, maxheight, mode, tileclass) { var mSize = g_Map.size; for (var qx = 0; qx < mSize; qx++) { for (var qz = 0; qz < mSize; qz++) { if (mode == 0) { if ((g_Map.getHeight(qx, qz) > minheight)&&(g_Map.getHeight(qx, qz) < maxheight)) { removeFromClass(qx, qz, tileclass); } } else if (mode == 1) { if ((g_Map.getHeight(qx, qz) >= minheight)&&(g_Map.getHeight(qx, qz) < maxheight)) { removeFromClass(qx, qz, tileclass); } } else if (mode == 2) { if ((g_Map.getHeight(qx, qz) > minheight)&&(g_Map.getHeight(qx, qz) <= maxheight)) { removeFromClass(qx, qz, tileclass); } } else if (mode == 3) { if ((g_Map.getHeight(qx, qz) >= minheight)&&(g_Map.getHeight(qx, qz) <= maxheight)) { removeFromClass(qx, qz, tileclass); } } } } } ///////////////////////////////////////////////////////////////////////////////////////// // getTIPIADBON // // "get The Intended Point In A Direction Based On Height" // gets the N'th point with a specific height in a line and returns it as a [x, y] array // startPoint: [x, y] array defining the start point // endPoint: [x, y] array defining the ending point // heightRange: [min, max] array defining the range which the height of the intended point can be. includes both "min" and "max" // step: how much tile units per turn should the search go. more value means faster but less accurate // n: how many points to skip before ending the search. skips """n-1 points""". // /////////////////////////////////////////////////////////////////////////////////////////// function getTIPIADBON(startPoint, endPoint, heightRange, step, n) { var stepX = step*(endPoint[0]-startPoint[0])/(sqrt((endPoint[0]-startPoint[0])*(endPoint[0]-startPoint[0]) + step*(endPoint[1]-startPoint[1])*(endPoint[1]-startPoint[1]))); var stepY = step*(endPoint[1]-startPoint[1])/(sqrt((endPoint[0]-startPoint[0])*(endPoint[0]-startPoint[0]) + step*(endPoint[1]-startPoint[1])*(endPoint[1]-startPoint[1]))); var y = startPoint[1]; var checked = 0; for (var x = startPoint[0]; true; x += stepX) { if ((floor(x) < g_Map.size)||(floor(y) < g_Map.size)) { if ((g_Map.getHeight(floor(x), floor(y)) <= heightRange[1])&&(g_Map.getHeight(floor(x), floor(y)) >= heightRange[0])) { ++checked; } if (checked >= n) { return [x, y]; } } y += stepY; if ((y > endPoint[1])&&(stepY>0)) break; if ((y < endPoint[1])&&(stepY<0)) break; if ((x > endPoint[1])&&(stepX>0)) break; if ((x < endPoint[1])&&(stepX<0)) break; } return undefined; } ///////////////////////////////////////////////////////////////////////////////////////// // doIntersect // // determines if two lines with the width "width" intersect or collide with each other // x1, y1, x2, y2: determine the position of the first line // x3, y3, x4, y4: determine the position of the second line // width: determines the width of the lines // /////////////////////////////////////////////////////////////////////////////////////////// function checkIfIntersect (x1, y1, x2, y2, x3, y3, x4, y4, width) { if (x1 == x2) { if (((x3 - x1) < width) || ((x4 - x2) < width)) return true; } else { var m = (y1 - y2) / (x1 - x2); var b = y1 - m * x1; var m2 = sqrt(m * m + 1) if ((Math.abs((y3 - x3 * m - b)/m2) < width) || (Math.abs((y4 - x4 * m - b)/m2) < width)) return true; //neccessary for some situations. if (x3 == x4) { if (((x1 - x3) < width) || ((x2 - x4) < width)) return true; } else { var m = (y3 - y4) / (x3 - x4); var b = y3 - m * x3; var m2 = sqrt(m * m + 1) if ((Math.abs((y1 - x1 * m - b)/m2) < width) || (Math.abs((y2 - x2 * m - b)/m2) < width)) return true; } } var s = ((x1 - x2) * (y3 - y1) - (y1 - y2) * (x3 - x1)), p = ((x1 - x2) * (y4 - y1) - (y1 - y2) * (x4 - x1)); if ((s * p) <= 0) { s = ((x3 - x4) * (y1 - y3) - (y3 - y4) * (x1 - x3)); p = ((x3 - x4) * (y2 - y3) - (y3 - y4) * (x2 - x3)); if ((s * p) <= 0) return true; } return false; } ///////////////////////////////////////////////////////////////////////////////////////// // distanceOfPointFromLine // // returns the distance of a point from a line // x1, y1, x2, y2: determine the position of the line // x3, y3: determine the position of the point // /////////////////////////////////////////////////////////////////////////////////////////// function distanceOfPointFromLine (x1, y1, x2, y2, x3, y3) { if (x1 == x2) { return x3 - x1; } else { var m = (y1 - y2) / (x1 - x2); var b = y1 - m * x1; var m2 = sqrt(m * m + 1) return Math.abs((y3 - x3 * m - b)/m2); } } ///////////////////////////////////////////////////////////////////////////////////////// // createRamp // // creates a ramp from point (x1, y1) to (x2, y2). // x1, y1, x2, y2: determine the position of the start and end of the ramp // minHeight, maxHeight: determine the height levels of the start and end point // width: determines the width of the ramp // smoothLevel: determines the smooth level around the edges of the ramp // mainTerrain: (Optional) determines the terrain texture for the ramp // edgeTerrain: (Optional) determines the terrain texture for the edges // tileclass: (Optional) adds the ramp to this tile class // /////////////////////////////////////////////////////////////////////////////////////////// function createRamp (x1, y1, x2, y2, minHeight, maxHeight, width, smoothLevel, mainTerrain, edgeTerrain, tileclass) { var halfWidth = width / 2; var mapSize = g_Map.size; if (y1 == y2) { var x3 = x2; var y3 = y2 + halfWidth; } else { var m = (x1 - x2) / (y1 - y2); var b = y2 + m * x2; var x3 = x2 + halfWidth; var y3 = - m * x3 + b; } var minBoundX = (x1 <= x2 ? (x1 > halfWidth ? x1 - halfWidth : 0) : (x2 > halfWidth ? x2 - halfWidth : 0)); var maxBoundX = (x1 >= x2 ? (x1 < mapSize - halfWidth ? x1 + halfWidth : mapSize) : (x2 < mapSize - halfWidth ? x2 + halfWidth : mapSize)); var minBoundY = (y1 <= y2 ? (y1 > halfWidth ? y1 - halfWidth : 0) : (y2 > halfWidth ? y2 - halfWidth : 0)); var maxBoundY = (y1 >= y2 ? (x1 < mapSize - halfWidth ? y1 + halfWidth : mapSize) : (y2 < mapSize - halfWidth ? y2 + halfWidth : mapSize)); for (var x = minBoundX; x < maxBoundX; ++x) { for (var y = minBoundY; y < maxBoundY; ++y) { var lDist = distanceOfPointFromLine(x3, y3, x2, y2, x, y); var sDist = distanceOfPointFromLine(x1, y1, x2, y2, x, y); var rampLength = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); if (lDist <= rampLength && sDist <= halfWidth) { var h = ((rampLength - lDist) * maxHeight + lDist * minHeight) / rampLength; if (sDist >= halfWidth - smoothLevel) { h = (h - minHeight) * (halfWidth - sDist) / smoothLevel + minHeight; if (edgeTerrain !== undefined) placeTerrain(x, y, edgeTerrain); } else { if (mainTerrain !== undefined) placeTerrain(x, y, mainTerrain); } if (tileclass !== undefined) addToClass(x, y, tileclass); if((g_Map.getHeight(floor(x), floor(y)) < h) && (h <= maxHeight)) g_Map.setHeight(x, y, h); } } } } \ No newline at end of file