Ticket #5090: meh.patch
File meh.patch, 10.7 KB (added by , 6 years ago) |
---|
-
binaries/data/mods/public/maps/random/jebel_barkal.js
var layoutKushTemples = [ 244 244 */ 245 245 const layoutKushCity = [ 246 246 { 247 247 "templateName": "uncapturable|" + oHouse, 248 248 "difficulty": "Very Easy", 249 "painters": new TileClassPainter(clHouse) 249 "painters": new TileClassPainter(clHouse), 250 "faceTowardsBorder": false 250 251 }, 251 252 { 252 253 "templateName": "uncapturable|" + oFortress, 253 254 "difficulty": "Medium", 254 255 "constraints": [avoidClasses(clFortress, 25), new NearTileClassConstraint(clPath, 8)], 255 "painters": new TileClassPainter(clFortress) 256 "painters": new TileClassPainter(clFortress), 257 "faceTowardsBorder": true 256 258 }, 257 259 { 258 260 "templateName": "uncapturable|" + oCivicCenter, 259 261 "difficulty": "Easy", 260 262 "constraints": [avoidClasses(clCivicCenter, 60), new NearTileClassConstraint(clPath, 8)], 261 "painters": new TileClassPainter(clCivicCenter) 263 "painters": new TileClassPainter(clCivicCenter), 264 "faceTowardsBorder": true 262 265 }, 263 266 { 264 267 "templateName": "uncapturable|" + oElephantStables, 265 268 "difficulty": "Medium", 266 269 "constraints": avoidClasses(clElephantStables, 10), 267 "painters": new TileClassPainter(clElephantStables) 270 "painters": new TileClassPainter(clElephantStables), 271 "faceTowardsBorder": true 268 272 }, 269 273 { 270 274 "templateName": "uncapturable|" + oStable, 271 275 "difficulty": "Easy", 272 276 "constraints": avoidClasses(clStable, 20), 273 "painters": new TileClassPainter(clStable) 277 "painters": new TileClassPainter(clStable), 278 "faceTowardsBorder": true 274 279 }, 275 280 { 276 281 "templateName": "uncapturable|" + oBarracks, 277 282 "difficulty": "Easy", 278 283 "constraints": avoidClasses(clBarracks, 12), 279 "painters": new TileClassPainter(clBarracks) 284 "painters": new TileClassPainter(clBarracks), 285 "faceTowardsBorder": true 280 286 }, 281 287 { 282 288 "templateName": "uncapturable|" + oTower, 283 289 "difficulty": "Medium", 284 290 "constraints": avoidClasses(clTower, 17), 285 "painters": new TileClassPainter(clTower) 291 "painters": new TileClassPainter(clTower), 292 "faceTowardsBorder": false 286 293 }, 287 294 { 288 295 "templateName": "uncapturable|" + oMarket, 289 296 "difficulty": "Very Easy", 290 297 "constraints": avoidClasses(clMarket, 15), 291 "painters": new TileClassPainter(clMarket) 298 "painters": new TileClassPainter(clMarket), 299 "faceTowardsBorder": true 292 300 }, 293 301 { 294 302 "templateName": "uncapturable|" + oBlacksmith, 295 303 "difficulty": "Very Easy", 296 304 "constraints": avoidClasses(clBlacksmith, 30), 297 "painters": new TileClassPainter(clBlacksmith) 305 "painters": new TileClassPainter(clBlacksmith), 306 "faceTowardsBorder": true 298 307 }, 299 308 { 300 309 "templateName": "uncapturable|" + oNubaVillage, 301 310 "difficulty": "Easy", 302 311 "constraints": avoidClasses(clNubaVillage, 30), 303 "painters": new TileClassPainter(clNubaVillage) 312 "painters": new TileClassPainter(clNubaVillage), 313 "faceTowardsBorder": true 304 314 }, 305 315 { 306 316 "templateName": "uncapturable|" + oBlemmyeCamp, 307 317 "difficulty": "Easy", 308 318 "constraints": avoidClasses(clBlemmyeCamp, 30), 309 "painters": new TileClassPainter(clBlemmyeCamp) 319 "painters": new TileClassPainter(clBlemmyeCamp), 320 "faceTowardsBorder": true 310 321 } 311 322 ].filter(building => getDifficulty() >= getDifficulties().find(difficulty => difficulty.Name == building.difficulty).Difficulty); 312 323 313 324 g_WallStyles.napata = { 314 325 "short": readyWallElement("uncapturable|" + oWallMedium), -
binaries/data/mods/public/maps/random/new_rms_test.js
var g_Map = new RandomMap(0, "grass1_spr 5 5 6 6 placePlayerBases({ 7 7 "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.39)) 8 8 }); 9 9 10 createArea( 11 new DiskPlacer(g_Map.getSize() / 3, g_Map.getCenter()), 12 [ 13 new TerrainPainter("blue"), 14 new CityPainter([{ 15 "templateName": "uncapturable|structures/kush_elephant_stables", 16 "faceTowardsBorder": true 17 }], Math.PI / 2, 0) 18 ]); 19 10 20 placePlayersNomad(g_Map.createTileClass()); 11 21 12 22 g_Map.ExportMap(); -
binaries/data/mods/public/maps/random/rmgen/Area.js
Area.prototype.getClosestPointTo = funct 41 41 } 42 42 } 43 43 44 44 return closestPoint; 45 45 }; 46 47 /** 48 * Returns an area consisting of all points adjacent to this area. 49 */ 50 Area.prototype.getBorderArea = function(borderWidth) 51 { 52 let tileclassArea = g_Map.createTileClass(); 53 54 createArea( 55 new MapBoundsPlacer(), 56 new TileClassPainter(tileclassArea), 57 new StayAreasConstraint([this])); 58 59 return createArea( 60 new MapBoundsPlacer(), 61 undefined, 62 [ 63 new AvoidAreasConstraint([this]), 64 new NearTileClassConstraint(tileclassArea, borderWidth), 65 ]); 66 }; -
binaries/data/mods/public/maps/random/rmgen/library.js
function getDifficulties() 333 333 function getDifficulty() 334 334 { 335 335 let level = g_MapSettings.TriggerDifficulty || 3; 336 336 return getDifficulties().find(difficulty => difficulty.Difficulty == level).Difficulty; 337 337 } 338 339 function findPointInDirection(startPoint, endPoint, constraint, offset = 0) 340 { 341 let stepVec = Vector2D.sub(endPoint, startPoint); 342 let distance = Math.ceil(stepVec.length()); 343 stepVec.normalize(); 344 345 for (let i = 0; i < distance; ++i) 346 { 347 let pos = Vector2D.add(startPoint, Vector2D.mult(stepVec, i)); 348 let ipos = pos.clone().round(); 349 350 if (!g_Map.inMapBounds(ipos)) 351 return undefined; 352 353 if (constraint.allows(ipos)) 354 return pos.add(stepVec.mult(offset)); 355 } 356 357 return undefined; 358 } -
binaries/data/mods/public/maps/random/rmgen/painter/CityPainter.js
function CityPainter(templates, angle, p 11 11 return { 12 12 "templateName": template.templateName, 13 13 "maxCount": template.maxCount !== undefined ? template.maxCount : Infinity, 14 14 "constraint": template.constraints && new AndConstraint(template.constraints), 15 15 "painter": template.painters && new MultiPainter(template.painters), 16 "obstructionMaxLengthSquared": Math.square(1.5 * Math.max(obstructionSize.x, obstructionSize.y)), 17 "obstructionCenter": Vector2D.div(obstructionSize, 2), 16 18 "obstructionCorners": [ 17 new Vector2D(0, 0), 18 new Vector2D(obstructionSize.x, 0), 19 new Vector2D(0, obstructionSize.y), 20 obstructionSize 21 ] 19 new Vector2D(-obstructionSize.x, +obstructionSize.y).div(2), 20 new Vector2D(-obstructionSize.x, -obstructionSize.y).div(2), 21 new Vector2D(+obstructionSize.x, +obstructionSize.y).div(2), 22 new Vector2D(+obstructionSize.x, -obstructionSize.y).div(2) 23 ], 24 "faceTowardsBorder": template.faceTowardsBorder 22 25 }; 23 26 }); 24 27 } 25 28 26 29 CityPainter.prototype.paint = function(area) … … CityPainter.prototype.paint = function(a 38 41 // The city would be much denser if it would test for actual shape intersection or 39 42 // if it would use a custom, more fine-grained obstruction grid 40 43 let tileClass = g_Map.createTileClass(); 41 44 42 45 let processed = new Array(mapSize).fill(0).map(() => new Uint8Array(mapSize)); 46 let borderPoints = area.getBorderArea(1); 47 43 48 44 49 for (let x = 0; x < mapSize; x += 0.5) 45 50 for (let y = 0; y < mapSize; y += 0.5) 46 51 { 47 52 let point = new Vector2D(x, y).rotateAround(this.angle, mapCenter).round(); … … CityPainter.prototype.paint = function(a 53 58 for (let template of shuffleArray(templates)) 54 59 { 55 60 if (template.constraint && !template.constraint.allows(point)) 56 61 continue; 57 62 58 // Randomize building angle while keeping it aligned 59 let buildingAngle = this.angle + randIntInclusive(0, 3) * Math.PI / 2; 63 let buildingAngle = this.getBuildingAngle(point, area, borderPoints, template); 60 64 61 65 // Place the entity if all points are within the boundaries and don't collide with the other entities 62 66 let obstructionCorners = template.obstructionCorners.map(obstructionCorner => 63 67 Vector2D.add(point, obstructionCorner.clone().rotate(buildingAngle))); 64 68 … … CityPainter.prototype.paint = function(a 80 84 templates = templates.filter(template => templateCounts[template.templateName] < template.maxCount); 81 85 break; 82 86 } 83 87 } 84 88 }; 89 90 CityPainter.prototype.getBuildingAngle = function(point, area, borderPoints, template) 91 { 92 let buildingAngle = this.angle + randIntInclusive(0, 3) * Math.PI / 2; 93 if (!template.faceTowardsBorder) 94 return buildingAngle; 95 96 let isAtBorder = borderPoints.getClosestPointTo(point).distanceToSquared(point) < template.obstructionMaxLengthSquared; 97 if (!isAtBorder) 98 return buildingAngle; 99 100 let mapSize = g_Map.getSize(); 101 let borderDistance = Infinity; 102 for (let i = 0; i < 4; ++i) 103 { 104 let angle = this.angle + i * Math.PI / 2; 105 let borderPoint = findPointInDirection(point, new Vector2D(mapSize, 0).rotate(angle).add(point), new AvoidAreasConstraint([area]), 0); 106 107 let distance = point.distanceTo(borderPoint); 108 if (distance >= borderDistance) 109 continue; 110 111 borderDistance = distance; 112 buildingAngle = angle; 113 } 114 115 return buildingAngle; 116 }; -
binaries/data/mods/public/maps/random/rmgen-common/gaia_terrain.js
function createPassage(args) 588 588 /** 589 589 * Returns the first location between startPoint and endPoint that lies within the given heightrange. 590 590 */ 591 591 function findLocationInDirectionBasedOnHeight(startPoint, endPoint, minHeight, maxHeight, offset = 0) 592 592 { 593 let stepVec = Vector2D.sub(endPoint, startPoint); 594 let distance = Math.ceil(stepVec.length()); 595 stepVec.normalize(); 596 597 for (let i = 0; i < distance; ++i) 598 { 599 let pos = Vector2D.add(startPoint, Vector2D.mult(stepVec, i)); 600 let ipos = pos.clone().round(); 601 602 if (g_Map.validHeight(ipos) && 603 g_Map.getHeight(ipos) >= minHeight && 604 g_Map.getHeight(ipos) <= maxHeight) 605 return pos.add(stepVec.mult(offset)); 606 } 607 608 return undefined; 593 return findPointInDirection(startPoint, endPoint, new HeightConstraint(minHeight, maxHeight), offset); 609 594 }