Index: ps/trunk/binaries/data/mods/public/maps/random/african_plains.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/african_plains.js +++ ps/trunk/binaries/data/mods/public/maps/random/african_plains.js @@ -39,8 +39,10 @@ var oElephant2 = "gaia/fauna_elephant_african_infant"; var oCrocodile = "gaia/fauna_crocodile_nile"; var oFish = g_Gaia.fish; +var oStoneLarge = g_Gaia.stoneLarge; var oStoneSmall = g_Gaia.stoneSmall; var oMetalLarge = g_Gaia.metalLarge; +var oMetalSmall = g_Gaia.metalSmall; var aBush = g_Decoratives.bushMedium; var aRock = g_Decoratives.rockMedium; @@ -166,23 +168,22 @@ clDirt); Engine.SetProgress(65); -g_Map.log("Creating stone mines"); -createMines( - [ - [new SimpleObject(oStoneSmall, 0, 2, 0, 4)], - [new SimpleObject(oStoneSmall, 2, 5, 1, 3)] - ], - avoidClasses(clWater, 4, clForest, 4, clPlayer, 20, clRock, 10, clHill, 4), - clRock); - g_Map.log("Creating metal mines"); -createMines( - [ - [new SimpleObject(oMetalLarge, 1,1, 0,4)] - ], - avoidClasses(clWater, 4, clForest, 4, clPlayer, 20, clMetal, 18, clRock, 5, clHill, 4), - clMetal +createBalancedMetalMines( + oMetalSmall, + oMetalLarge, + clMetal, + avoidClasses(clWater, 4, clForest, 1, clPlayer, scaleByMapSize(20, 35), clHill, 1) ); + +g_Map.log("Creating stone mines"); +createBalancedStoneMines( + oStoneSmall, + oStoneLarge, + clRock, + avoidClasses(clWater, 4, clForest, 1, clPlayer, scaleByMapSize(20, 35), clHill, 1, clMetal, 10) +); + Engine.SetProgress(70); createDecoration( Index: ps/trunk/binaries/data/mods/public/maps/random/ardennes_forest.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/ardennes_forest.js +++ ps/trunk/binaries/data/mods/public/maps/random/ardennes_forest.js @@ -72,6 +72,7 @@ var clFood = g_Map.createTileClass(); var clBaseResource = g_Map.createTileClass(); var clHillDeco = g_Map.createTileClass(); +var clExplorable = g_Map.createTileClass(); g_Map.log("Creating the central dip"); createArea( @@ -279,6 +280,8 @@ avoidClasses(clPlayer, 1) ]); +new TileClassPainter(clExplorable).paint(explorableArea); + Engine.SetProgress(55); // Add some general noise - after placing height dependant trees @@ -349,40 +352,27 @@ Engine.SetProgress(75); -g_Map.log("Creating stone mines"); -createObjectGroupsByAreasDeprecated( - new SimpleGroup( - [ - new SimpleObject(oStoneSmall, 1, 2, 0, 4, 0, 2 * Math.PI, 1), - new SimpleObject(oStoneLarge, 0, 1, 0, 4, 0, 2 * Math.PI, 4) - ], - true, - clRock), - 0, - [avoidClasses(clHill, 4, clForest, 2, clPlayer, 20, clRock, 10)], - scaleByMapSize(6,20), 100, - [explorableArea]); - -g_Map.log("Creating small stone mines"); -var group = new SimpleGroup([new SimpleObject(oStoneSmall, 2, 5, 1, 3)], true, clRock); -createObjectGroupsByAreasDeprecated(group, 0, - [avoidClasses(clHill, 4, clForest, 2, clPlayer, 20, clRock, 10)], - scaleByMapSize(6,20), 100, - [explorableArea] +g_Map.log("Creating metal mines"); +createBalancedMetalMines( + oMetalSmall, + oMetalLarge, + clMetal, + [stayClasses(clExplorable, 1), avoidClasses(clForest, 0, clPlayer, scaleByMapSize(15, 25), clHill, 1)] ); -g_Map.log("Creating metal mines"); -group = new SimpleGroup([new SimpleObject(oMetalSmall, 1,2, 0,4), new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal); -createObjectGroupsByAreasDeprecated(group, 0, - [avoidClasses(clHill, 4, clForest, 2, clPlayer, 20, clMetal, 10, clRock, 5)], - scaleByMapSize(6,20), 100, - [explorableArea] + +g_Map.log("Creating stone mines"); +createBalancedStoneMines( + oStoneSmall, + oStoneLarge, + clRock, + [stayClasses(clExplorable, 1), avoidClasses(clForest, 0, clPlayer, scaleByMapSize(15, 25), clHill, 1, clMetal, 10)] ); Engine.SetProgress(80); g_Map.log("Creating wildlife"); -group = new SimpleGroup( +let group = new SimpleGroup( [new SimpleObject(oDeer, 5,7, 0,4)], true, clFood ); Index: ps/trunk/binaries/data/mods/public/maps/random/cantabrian_highlands.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/cantabrian_highlands.js +++ ps/trunk/binaries/data/mods/public/maps/random/cantabrian_highlands.js @@ -33,6 +33,7 @@ const oStoneLarge = g_Gaia.stoneLarge; const oStoneSmall = g_Gaia.stoneSmall; const oMetalLarge = g_Gaia.metalLarge; +const oMetalSmall = g_Gaia.metalSmall; const aGrass = g_Decoratives.grass; const aGrassShort = g_Decoratives.grassShort; @@ -196,24 +197,22 @@ clDirt); Engine.SetProgress(50); -g_Map.log("Creating stone mines"); -createMines( - [ - [new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)], - [new SimpleObject(oStoneSmall, 2,5, 1,3)] - ], - avoidClasses(clWater, 0, clForest, 1, clPlayer, 5, clRock, 10, clHill, 1), - clRock); -Engine.SetProgress(55); - g_Map.log("Creating metal mines"); -createMines( - [ - [new SimpleObject(oMetalLarge, 1,1, 0,4)] - ], - avoidClasses(clWater, 0, clForest, 1, clPlayer, 5, clMetal, 10, clRock, 5, clHill, 1), - clMetal +createBalancedMetalMines( + oMetalSmall, + oMetalLarge, + clMetal, + avoidClasses(clWater, 0, clForest, 0, clPlayer, scaleByMapSize(15, 25), clHill, 1) +); + +g_Map.log("Creating stone mines"); +createBalancedStoneMines( + oStoneSmall, + oStoneLarge, + clRock, + avoidClasses(clWater, 0, clForest, 0, clPlayer, scaleByMapSize(15, 25), clHill, 1, clMetal, 10) ); + Engine.SetProgress(60); createDecoration( Index: ps/trunk/binaries/data/mods/public/maps/random/continent.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/continent.js +++ ps/trunk/binaries/data/mods/public/maps/random/continent.js @@ -30,6 +30,7 @@ const oStoneLarge = g_Gaia.stoneLarge; const oStoneSmall = g_Gaia.stoneSmall; const oMetalLarge = g_Gaia.metalLarge; +const oMetalSmall = g_Gaia.metalSmall; const aGrass = g_Decoratives.grass; const aGrassShort = g_Decoratives.grassShort; @@ -162,22 +163,20 @@ clDirt); Engine.SetProgress(55); -g_Map.log("Creating stone mines"); -createMines( - [ - [new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)], - [new SimpleObject(oStoneSmall, 2,5, 1,3)] - ], - [avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), stayClasses(clLand, 6)], - clRock); - g_Map.log("Creating metal mines"); -createMines( - [ - [new SimpleObject(oMetalLarge, 1,1, 0,4)] - ], - [avoidClasses(clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 1), stayClasses(clLand, 6)], - clMetal +createBalancedMetalMines( + oMetalSmall, + oMetalLarge, + clMetal, + [stayClasses(clLand, 6), avoidClasses(clForest, 1, clPlayer, scaleByMapSize(20, 35), clHill, 1)], +); + +g_Map.log("Creating stone mines"); +createBalancedStoneMines( + oStoneSmall, + oStoneLarge, + clRock, + [stayClasses(clLand, 6), avoidClasses(clForest, 1, clPlayer, scaleByMapSize(20, 35), clHill, 1, clMetal, 10)] ); Engine.SetProgress(65); Index: ps/trunk/binaries/data/mods/public/maps/random/corinthian_isthmus.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/corinthian_isthmus.js +++ ps/trunk/binaries/data/mods/public/maps/random/corinthian_isthmus.js @@ -30,6 +30,7 @@ const oStoneLarge = g_Gaia.stoneLarge; const oStoneSmall = g_Gaia.stoneSmall; const oMetalLarge = g_Gaia.metalLarge; +const oMetalSmall = g_Gaia.metalSmall; const oDatePalm = g_Gaia.tree1; const oSDatePalm = g_Gaia.tree2; const oCarob = g_Gaia.tree3; @@ -229,13 +230,12 @@ ); g_Map.log("Creating metal mines"); -createMines( - [ - [new SimpleObject(oMetalLarge, 1, 1, 0, 4)] - ], - avoidClasses(clForest, 4, clPassageway, 10, clPlayer, 15, clMetal, 10, clRock, 5, clWater, 4, clHill, 4), +createBalancedMetalMines( + oMetalSmall, + oMetalLarge, clMetal, - scaleByMapSize(5, 20) + avoidClasses(clPassageway, 1, clWater, 0, clForest, 0, clPlayer, scaleByMapSize(15, 25), clHill, 1, clRock, 10), + 0.9 // less available area -> slightly less metal ); Engine.SetProgress(65); Index: ps/trunk/binaries/data/mods/public/maps/random/gulf_of_bothnia.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/gulf_of_bothnia.js +++ ps/trunk/binaries/data/mods/public/maps/random/gulf_of_bothnia.js @@ -26,6 +26,7 @@ const oStoneLarge = g_Gaia.stoneLarge; const oStoneSmall = g_Gaia.stoneSmall; const oMetalLarge = g_Gaia.metalLarge; +const oMetalSmall = g_Gaia.metalSmall; const oDeer = g_Gaia.mainHuntableAnimal; const oRabbit = g_Gaia.secondaryHuntableAnimal; const oFish = g_Gaia.fish; @@ -174,22 +175,22 @@ clDirt); Engine.SetProgress(65); -g_Map.log("Creating stone mines"); -createMines( - [ - [new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)], - [new SimpleObject(oStoneSmall, 2,5, 1,3)] - ], - avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), - clRock); - g_Map.log("Creating metal mines"); -createMines( - [ - [new SimpleObject(oMetalLarge, 1,1, 0,4)] - ], - avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 1), - clMetal +createBalancedMetalMines( + oMetalSmall, + oMetalLarge, + clMetal, + avoidClasses(clWater, 2, clForest, 0, clPlayer, scaleByMapSize(15, 25), clHill, 1), + 0.9 +); + +g_Map.log("Creating stone mines"); +createBalancedStoneMines( + oStoneSmall, + oStoneLarge, + clRock, + avoidClasses(clWater, 2, clForest, 0, clPlayer, scaleByMapSize(15, 25), clHill, 1, clMetal, 10), + 0.9 ); Engine.SetProgress(70); Index: ps/trunk/binaries/data/mods/public/maps/random/lake.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/lake.js +++ ps/trunk/binaries/data/mods/public/maps/random/lake.js @@ -30,6 +30,7 @@ const oStoneLarge = g_Gaia.stoneLarge; const oStoneSmall = g_Gaia.stoneSmall; const oMetalLarge = g_Gaia.metalLarge; +const oMetalSmall = g_Gaia.metalSmall; const aGrass = g_Decoratives.grass; const aGrassShort = g_Decoratives.grassShort; @@ -161,22 +162,20 @@ clDirt); Engine.SetProgress(55); -g_Map.log("Creating stone mines"); -createMines( - [ - [new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)], - [new SimpleObject(oStoneSmall, 2,5, 1,3)] - ], - avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), - clRock); - g_Map.log("Creating metal mines"); -createMines( - [ - [new SimpleObject(oMetalLarge, 1,1, 0,4)] - ], - avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 1), - clMetal +createBalancedMetalMines( + oMetalSmall, + oMetalLarge, + clMetal, + avoidClasses(clWater, 3, clForest, 1, clPlayer, scaleByMapSize(20, 35), clHill, 1) +); + +g_Map.log("Creating stone mines"); +createBalancedStoneMines( + oStoneSmall, + oStoneLarge, + clRock, + avoidClasses(clWater, 3, clForest, 1, clPlayer, scaleByMapSize(20, 35), clHill, 1, clMetal, 10) ); Engine.SetProgress(65); Index: ps/trunk/binaries/data/mods/public/maps/random/mainland.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/mainland.js +++ ps/trunk/binaries/data/mods/public/maps/random/mainland.js @@ -27,6 +27,7 @@ const oStoneLarge = g_Gaia.stoneLarge; const oStoneSmall = g_Gaia.stoneSmall; const oMetalLarge = g_Gaia.metalLarge; +const oMetalSmall = g_Gaia.metalSmall; const aGrass = g_Decoratives.grass; const aGrassShort = g_Decoratives.grassShort; @@ -116,22 +117,20 @@ clDirt); Engine.SetProgress(55); -g_Map.log("Creating stone mines"); -createMines( - [ - [new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)], - [new SimpleObject(oStoneSmall, 2, 5, 1, 3, 0, 2 * Math.PI, 1)] - ], - avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), - clRock); - g_Map.log("Creating metal mines"); -createMines( - [ - [new SimpleObject(oMetalLarge, 1,1, 0,4)] - ], - avoidClasses(clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 1), - clMetal +createBalancedMetalMines( + oMetalSmall, + oMetalLarge, + clMetal, + avoidClasses(clForest, 1, clPlayer, scaleByMapSize(20, 35), clHill, 1) +); + +g_Map.log("Creating stone mines"); +createBalancedStoneMines( + oStoneSmall, + oStoneLarge, + clRock, + avoidClasses(clForest, 1, clPlayer, scaleByMapSize(20, 35), clHill, 1, clMetal, 10) ); Engine.SetProgress(65); Index: ps/trunk/binaries/data/mods/public/maps/random/neareastern_badlands.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/neareastern_badlands.js +++ ps/trunk/binaries/data/mods/public/maps/random/neareastern_badlands.js @@ -32,6 +32,7 @@ const oStoneLarge = g_Gaia.stoneLarge; const oStoneSmall = g_Gaia.stoneSmall; const oMetalLarge = g_Gaia.metalLarge; +const oMetalSmall = g_Gaia.metalSmall; const oOasisTree = "gaia/tree/senegal_date_palm"; const oDatePalm = g_Gaia.tree1; const oSDatePalm = g_Gaia.tree2; @@ -288,31 +289,25 @@ 50); Engine.SetProgress(70); - -g_Map.log("Creating stone mines"); -var group = new SimpleGroup([new SimpleObject(oStoneSmall, 0, 2, 0, 4), new SimpleObject(oStoneLarge, 1, 1, 0, 4), new RandomObject(aBushes, 2, 4, 0, 2)], true, clRock); -createObjectGroupsDeprecated(group, 0, - [avoidClasses(clOasis, 1, clForest, 1, clPlayer, 10, clRock, 10, clHill1, 1)], - scaleByMapSize(4,16), 100 -); - -group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3), new RandomObject(aBushes, 2,4, 0,2)], true, clRock); -createObjectGroupsDeprecated(group, 0, - [avoidClasses(clOasis, 1, clForest, 1, clPlayer, 10, clRock, 10, clHill1, 1)], - scaleByMapSize(4,16), 100 -); - g_Map.log("Creating metal mines"); -group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4), new RandomObject(aBushes, 2,4, 0,2)], true, clMetal); -createObjectGroupsDeprecated(group, 0, - [avoidClasses(clOasis, 1, clForest, 1, clPlayer, 10, clMetal, 10, clRock, 5, clHill1, 1)], - scaleByMapSize(4,16), 100 +createBalancedMetalMines( + oMetalSmall, + oMetalLarge, + clMetal, + avoidClasses(clOasis, 2, clForest, 0, clPlayer, scaleByMapSize(15, 25), clHill1, 1) ); +g_Map.log("Creating stone mines"); +createBalancedStoneMines( + oStoneSmall, + oStoneLarge, + clRock, + avoidClasses(clOasis, 2, clForest, 0, clPlayer, scaleByMapSize(15, 25), clHill1, 1, clMetal, 10) +); Engine.SetProgress(80); g_Map.log("Creating gazelles"); -group = new SimpleGroup([new SimpleObject(oGazelle, 5,7, 0,4)], true, clFood); +let group = new SimpleGroup([new SimpleObject(oGazelle, 5,7, 0,4)], true, clFood); createObjectGroupsDeprecated(group, 0, avoidClasses(clOasis, 1, clForest, 0, clPlayer, 5, clHill1, 1, clFood, 10), scaleByMapSize(5,20), 50 Index: ps/trunk/binaries/data/mods/public/maps/random/pyrenean_sierra.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/pyrenean_sierra.js +++ ps/trunk/binaries/data/mods/public/maps/random/pyrenean_sierra.js @@ -32,6 +32,7 @@ const oStoneLarge = "gaia/rock/alpine_large"; const oStoneSmall = "gaia/rock/alpine_small"; const oMetalLarge = "gaia/ore/alpine_large"; +const oMetalSmall = "gaia/ore/alpine_small"; const aGrass = "actor|props/flora/grass_soft_small_tall.xml"; const aGrassShort = "actor|props/flora/grass_soft_large.xml"; @@ -404,17 +405,21 @@ Engine.SetProgress(80); -g_Map.log("Creating stone mines"); -group = new SimpleGroup([new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)], true, clRock); -createObjectGroupsDeprecated(group, 0, avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 8, clPyrenneans, 1), scaleByMapSize(4,16), 100 ); - -g_Map.log("Creating small stone quarries"); -group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock); -createObjectGroupsDeprecated(group, 0, avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 8, clPyrenneans, 1), scaleByMapSize(4,16), 100 ); - g_Map.log("Creating metal mines"); -group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal); -createObjectGroupsDeprecated(group, 0, avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clMetal, 8, clRock, 5, clPyrenneans, 1), scaleByMapSize(4,16), 100 ); +createBalancedMetalMines( + oMetalSmall, + oMetalLarge, + clMetal, + avoidClasses(clWater, 2, clForest, 0, clPlayer, scaleByMapSize(15, 25), clPyrenneans, 3) +); + +g_Map.log("Creating stone mines"); +createBalancedStoneMines( + oStoneSmall, + oStoneLarge, + clRock, + avoidClasses(clWater, 2, clForest, 0, clPlayer, scaleByMapSize(15, 25), clPyrenneans, 3, clMetal, 10) +); Engine.SetProgress(85); Index: ps/trunk/binaries/data/mods/public/maps/random/rivers.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rivers.js +++ ps/trunk/binaries/data/mods/public/maps/random/rivers.js @@ -34,6 +34,7 @@ const oStoneLarge = g_Gaia.stoneLarge; const oStoneSmall = g_Gaia.stoneSmall; const oMetalLarge = g_Gaia.metalLarge; +const oMetalSmall = g_Gaia.metalSmall; const aGrass = g_Decoratives.grass; const aGrassShort = g_Decoratives.grassShort; @@ -187,22 +188,20 @@ clDirt); Engine.SetProgress(55); -g_Map.log("Creating stone mines"); -createMines( - [ - [new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)], - [new SimpleObject(oStoneSmall, 2,5, 1,3)] - ], - avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), - clRock); - g_Map.log("Creating metal mines"); -createMines( - [ - [new SimpleObject(oMetalLarge, 1,1, 0,4)] - ], - avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 1), - clMetal +createBalancedMetalMines( + oMetalSmall, + oMetalLarge, + clMetal, + avoidClasses(clWater, 3, clForest, 1, clPlayer, scaleByMapSize(20, 35), clHill, 1) +); + +g_Map.log("Creating stone mines"); +createBalancedStoneMines( + oStoneSmall, + oStoneLarge, + clRock, + avoidClasses(clWater, 3, clForest, 1, clPlayer, scaleByMapSize(20, 35), clHill, 1, clMetal, 10) ); Engine.SetProgress(65); Index: ps/trunk/binaries/data/mods/public/maps/random/rmgen-common/gaia_entities.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rmgen-common/gaia_entities.js +++ ps/trunk/binaries/data/mods/public/maps/random/rmgen-common/gaia_entities.js @@ -120,6 +120,101 @@ } /** + * Place large/small mines on the map in such a way that it should be relatively fair. + * @param oSmall - the small mine object + * @param oLarge - the large mine object + * @param clMine - the 'mine' class to paint. + * @param constraints - Custom constraints. Note that the function automatically avoids clMine as well. + * @param counts - optional, either a single number acting as multiplier to the defaults + * or a dict of numbers{ "largeCount": 0, "smallCount": 1, "randomSmallCount": 2 } + * @param randomness - randomize counts by a random multiplier between [1 - randomness, 1 + randomness] + */ +function createBalancedMines(oSmall, oLarge, clMine, constraints, counts = 1.0, randomness = 0.1) +{ + let largeCount = counts.largeCount; + let smallCount = counts.smallCount; + let randomSmallCount = counts.randomSmallCount; + + if (randomness > 0 && randomness < 1) + { + largeCount = Math.round(largeCount * randFloat(1 - randomness, 1 + randomness)); + smallCount = Math.round(smallCount * randFloat(1 - randomness, 1 + randomness)); + randomSmallCount = Math.round(randomSmallCount * randFloat(1 - randomness, 1 + randomness)); + } + + const arrayConstraints = Array.isArray(constraints) ? constraints : [constraints]; + + // Plop large mines far away from each other. + createObjectGroups( + new SimpleGroup([new SimpleObject(oLarge, 1, 1, 0, 1)], true, clMine), + 0, + new AndConstraint([avoidClasses(clMine, scaleByMapSize(25, 50)), ...arrayConstraints]), + largeCount, + 100); + + // Plop smaller clusters of small mines, also somewhat farther away. + createObjectGroups( + new SimpleGroup([new SimpleObject(oSmall, 2, 3, 0, 2)], true, clMine), + 0, + new AndConstraint([avoidClasses(clMine, scaleByMapSize(18, 35)), ...arrayConstraints]), + smallCount, + 50); + + // Plop a few smaller clusters in a random fashion, occasionally making very good dropsites spots. + createObjectGroups( + new SimpleGroup([new SimpleObject(oSmall, 1, 2, 0, 2)], true, clMine), + 0, + new AndConstraint([avoidClasses(clMine, 5), ...arrayConstraints]), + randomSmallCount, + 50); +} + +/** + * Helper for createBalancedMines with default metal counts. + * The current settings are so that a Small 1v1 has about 40K metal, + * and a Normal 4v4 has about 140K. + * The setup is biaised so that with fewer players, there are more small mines, + * and with more players there are proportionally more big mines, to maintain + * some randomness to the distribution but keep it somewhat fair in 1v1. + */ +function createBalancedMetalMines(oSmall, oLarge, clMine, constraints, counts = 1.0, randomness = 0.05) +{ + return createBalancedMines( + oSmall, + oLarge, + clMine, + constraints, + { + "largeCount": (Math.max(scaleByMapSize(1, 9), getNumPlayers() * 1.8 - 0.8)) * counts, + "smallCount": (scaleByMapSize(4, 12)) * counts, + "randomSmallCount": (scaleByMapSize(1, 8)) * counts, + }, + randomness + ); +} + +/** + * Helper for createBalancedMines with default stone counts. + * There is a little less stone than metal overall. + */ +function createBalancedStoneMines(oSmall, oLarge, clMine, constraints, counts = 1.0, randomness = 0.05) +{ + return createBalancedMines( + oSmall, + oLarge, + clMine, + constraints, + { + "largeCount": (Math.max(scaleByMapSize(1, 9), getNumPlayers() * 1.25)) * counts, + "smallCount": (scaleByMapSize(1, 8)) * counts, + "randomSmallCount": (scaleByMapSize(1, 8)) * counts, + }, + randomness + ); +} + + +/** * Places Entities of the given templateName in a circular pattern (leaving out a quarter of the circle). */ function createStoneMineFormation(position, templateName, terrain, radius = 2.5, count = 8, startAngle = undefined, maxOffset = 1)