Index: binaries/data/mods/public/gui/credits/texts/programming.json =================================================================== --- binaries/data/mods/public/gui/credits/texts/programming.json +++ binaries/data/mods/public/gui/credits/texts/programming.json @@ -216,7 +216,8 @@ {"nick": "Zeusthor", "name": "Jeffrey Tavares"}, {"nick": "zoot"}, {"nick": "zsol", "name": "Zsolt Dollenstein"}, - {"nick": "Zyi", "name": "Charles De Meulenaer"} + {"nick": "Zyi", "name": "Charles De Meulenaer"}, + {"nick": "rapidelectron", "name": "Christian Weihsbach"} ] } ] Index: binaries/data/mods/public/maps/random/mainland.js =================================================================== --- binaries/data/mods/public/maps/random/mainland.js +++ binaries/data/mods/public/maps/random/mainland.js @@ -236,9 +236,10 @@ log("Creating stone mines..."); // create stone quarries + createMines( [ - [new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)], + [new SimpleObject(oStoneSmall, 0,2, 0,2),new SimpleObject(oStoneLarge, 1,1, 0,1)], [new SimpleObject(oStoneSmall, 2,5, 1,3)] ] ); Index: binaries/data/mods/public/maps/random/rmgen/placer.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/placer.js +++ binaries/data/mods/public/maps/random/rmgen/placer.js @@ -356,8 +356,8 @@ var distance = randFloat(this.minDistance, this.maxDistance); var direction = randFloat(0, 2*PI); - var x = cx + 0.5 + distance*cos(direction); - var z = cz + 0.5 + distance*sin(direction); + var x = cx + 0.5 * distance*cos(direction); + var z = cz + 0.5 * distance*sin(direction); var fail = false; // reset place failure flag if (!g_Map.validT(x, z)) @@ -369,8 +369,8 @@ var length = resultObjs.length; for (var i = 0; (i < length) && !fail; i++) { - var dx = x - resultObjs[i].position.x; - var dy = z - resultObjs[i].position.z; + var dx = x - resultObjs[i].position.x / CELL_SIZE; + var dy = z - resultObjs[i].position.z / CELL_SIZE; if (dx*dx + dy*dy < 1) fail = true; @@ -447,8 +447,8 @@ var distance = randFloat(this.minDistance, this.maxDistance); var direction = randFloat(0, 2*PI); - var x = cx + 0.5 + distance*cos(direction); - var z = cz + 0.5 + distance*sin(direction); + var x = cx + 0.5 * distance*cos(direction); + var z = cz + 0.5 * distance*sin(direction); var fail = false; // reset place failure flag if (!g_Map.validT(x, z)) @@ -460,8 +460,8 @@ var length = resultObjs.length; for (var i = 0; (i < length) && !fail; i++) { - var dx = x - resultObjs[i].position.x; - var dy = z - resultObjs[i].position.z; + var dx = x - resultObjs[i].position.x / CELL_SIZE; + var dy = z - resultObjs[i].position.z / CELL_SIZE; if (dx*dx + dy*dy < 1) fail = true; @@ -508,31 +508,82 @@ // ///////////////////////////////////////////////////////////////////////////////////////// -function SimpleGroup(elements, avoidSelf, tileClass, x, z) +function SimpleGroup(elements, avoidSelf, tileClass, x, z, minObjectDistance, maxObjectDistance) { this.elements = elements; this.tileClass = tileClass !== undefined ? getTileClass(tileClass) : undefined; this.avoidSelf = avoidSelf !== undefined ? avoidSelf : false; this.x = x !== undefined ? x : -1; this.z = z !== undefined ? z : -1; + this.minObjectDistance = minObjectDistance !== undefined ? minObjectDistance : 0; + this.maxObjectDistance = maxObjectDistance !== undefined ? maxObjectDistance : 0; } -SimpleGroup.prototype.place = function(player, constraint) +SimpleGroup.prototype.place = function(player, constraint, maxFailCount = 20) { var resultObjs = []; + var failCount = 0; - // Try placement of objects for (let element of this.elements) { - var objs = element.place(this.x, this.z, player, this.avoidSelf, constraint); + while(true) + { + var distance = randFloat(this.minObjectDistance, this.maxObjectDistance); + var direction = randFloat(0, 2*PI); - if (objs === undefined) - return false; + var xo = this.x + 0.5*distance*cos(direction); + var zo = this.z + 0.5*distance*sin(direction); + + var fail = false; // reset place failure flag - resultObjs = resultObjs.concat(objs); - } + if (!g_Map.validT(xo, zo)) + fail = true; + else + { + if (this.avoidSelf) + { + var length = resultObjs.length; + for (var i = 0; (i < length) && !fail; i++) + { + var dx = xo - resultObjs[i].position.x / CELL_SIZE; + var dz = zo - resultObjs[i].position.z / CELL_SIZE; + + + if (dx*dx + dz*dz < this.minObjectDistance * this.minObjectDistance) + fail = true; + } + } + if (!fail) + { + if (!constraint.allows(Math.floor(xo), Math.floor(zo))) + fail = true; + else + { + var objs = element.place(xo, zo, player, this.avoidSelf, constraint); + + if (objs === undefined) + fail = true; + else + { + resultObjs = resultObjs.concat(objs); + break; + } + } + } + } + + if (fail) + { + failCount++; + if (failCount > maxFailCount) + return false; + } + } + } + // Add placed objects to map + for (let obj of resultObjs) { if (g_Map.validT(obj.position.x / CELL_SIZE, obj.position.z / CELL_SIZE, MAP_BORDER_WIDTH)) @@ -542,7 +593,7 @@ if (this.tileClass !== undefined) this.tileClass.add(Math.floor(obj.position.x/CELL_SIZE), Math.floor(obj.position.z/CELL_SIZE)); } - + return true; }; Index: binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js +++ binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js @@ -185,9 +185,10 @@ tileclass = (tileclass !== undefined ? tileclass : clRock); constraint = (constraint !== undefined ? constraint : avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1)); count = (count !== undefined ? count : scaleByMapSize(4,16)); + for (var i = 0; i < mines.length; ++i) { - var group = new SimpleGroup(mines[i], true, tileclass); + var group = new SimpleGroup(mines[i], true, tileclass, undefined, undefined, 3,5); createObjectGroups(group, 0, constraint, count, 70