Ticket #2258: undefined_civ_fex.diff
File undefined_civ_fex.diff, 31.4 KB (added by , 11 years ago) |
---|
-
data/mods/public/maps/random/rmgen/library.js
11 11 const HEIGHT_UNITS_PER_METRE = 732; 12 12 const MIN_MAP_SIZE = 128; 13 13 const MAX_MAP_SIZE = 512; 14 const FALLBACK_CIV = "athen"; 14 15 15 16 ///////////////////////////////////////////////////////////////////////////////////////////// 16 17 // Utility functions … … 395 396 396 397 function getCivCode(player) 397 398 { 398 return g_MapSettings.PlayerData[player].Civ; 399 if (g_MapSettings.PlayerData[player].Civ) 400 return g_MapSettings.PlayerData[player].Civ; 401 402 warn("undefined civ specified for player " + (player + 1) + ", falling back to '" + FALLBACK_CIV + "'"); 403 return FALLBACK_CIV; 399 404 } 400 405 401 406 function areAllies(player1, player2) … … 470 475 var civ = getCivCode(player); 471 476 if (!g_CivData[civ] || !g_CivData[civ].StartEntities || !g_CivData[civ].StartEntities.length) 472 477 { 473 warn("Invalid or unimplemented civ '"+civ+"' specified, falling back to ' athen'");474 civ = "athen";478 warn("Invalid or unimplemented civ '"+civ+"' specified, falling back to '" + FALLBACK_CIV + "'"); 479 civ = FALLBACK_CIV; 475 480 } 476 481 477 482 return g_CivData[civ].StartEntities; -
data/mods/public/maps/random/rmgen/wall_builder.js
5 5 // To do: 6 6 // Check if all wall placement methods work with wall elements with entity === undefined (some still might raise errors in that case) 7 7 // Rename wall elements to fit the entity names so that entity = "structures/" + "civ + "_" + wallElement.type in the common case (as far as possible) 8 // Perhaps add roman army camp to style palisades and add upgraded/balanced default palisade fortress types matching civ default fortresses strength8 // Perhaps add Roman army camp to style palisades and add upgraded/balanced default palisade fortress types matching civ default fortresses strength 9 9 // Perhaps add further wall elements cornerInHalf, cornerOutHalf (banding PI/4) and adjust default fortress types to better fit in the octagonal territory of a civil center 10 10 // Perhaps swap angle and width in WallElement class(?) definition 11 11 // Adjust argument order to be always the same: … … 25 25 // maxBendOff (angle or other, unused ATM!!!) 26 26 // irregularity 27 27 // maxTrys 28 // Add tre sures to wall style "others"28 // Add treasures to wall style "others" 29 29 // Adjust documentation 30 30 // Perhaps rename "endLeft" to "start" and "endRight" to "end" 31 31 // ?Use available civ-type wall elements rather than palisades: Remove "endLeft" and "endRight" as default wall elements and adjust default palisade fortress types? … … 37 37 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 38 38 // WallElement class definition 39 39 // 40 // Concept: If placed unrotated the wall's course is towards positive Y (top) with "outside" right (+X) and "inside" left (-X) like unrotated entities has their drop points right (in rmgen)41 // The cour e of the wall will be changed by corners (bending != 0) and so the "inside"/"outside" direction40 // Concept: If placed unrotated the wall's course is towards positive Y (top) with "outside" right (+X) and "inside" left (-X) like unrotated entities has their drop-points right (in rmgen) 41 // The course of the wall will be changed by corners (bending != 0) and so the "inside"/"outside" direction 42 42 // 43 43 // type Descriptive string, example: "wallLong". NOTE: Not really needed. Mainly for custom wall elements and to get the wall element type in code 44 44 // entity Optional. Template name string of the entity to be placed, example: "structures/cart_wall_long". Default is undefined (No entity placed) 45 45 // angle Optional. The angle (float) added to place the entity so "outside" is right when the wall element is placed unrotated. Default is 0 46 // width Optional. How far this wall element enlengthens the wall (float), if unrotated the Y space needed. Default is 046 // width Optional. How far this wall element lengthens the wall (float), if unrotated the Y space needed. Default is 0 47 47 // indent Optional. The lateral indentation of the entity, drawn "inside" (positive values) or pushed "outside" (negative values). Default is 0 48 48 // bending Optional. How the course of the wall is changed after this element, positive is bending "in"/left/counter clockwise (like entity placement) 49 49 // NOTE: Bending is not supported by all placement functions (see there) … … 52 52 { 53 53 this.type = type; 54 54 // Default wall element type documentation: 55 // Enlengthening straight blocking (mainly left/right symetric) wall elements (Walls and wall fortifications)55 // Lengthening straight blocking (mainly left/right symmetric) wall elements (Walls and wall fortifications) 56 56 // "wall" A blocking straight wall element that mainly lengthens the wall, self-explanatory 57 57 // "wallShort" self-explanatory 58 58 // "wallLong" self-explanatory 59 // "tower" A blocking straight wall element with damage potential (but for palisades) that slightly lengthens the wall, ex sample: wall tower, palisade tower(No attack)60 // "wallFort" A blocking straight wall element with massive damage potential that lengthens the wall, ex sample: fortress, palisade fort61 // Enlengthening straight non/custom blocking (mainly left/right symetric) wall elements (Gates and entrys)59 // "tower" A blocking straight wall element with damage potential (but for palisades) that slightly lengthens the wall, example: wall tower, palisade tower(No attack) 60 // "wallFort" A blocking straight wall element with massive damage potential that lengthens the wall, example: fortress, palisade fort 61 // Lengthening straight non/custom blocking (mainly left/right symmetric) wall elements (Gates and entries) 62 62 // "gate" A blocking straight wall element with passability determined by owner, example: gate (Functionality not yet implemented) 63 63 // "entry" A non-blocking straight wall element (same width as gate) but without an actual template or just a flag/column/obelisk 64 // "entryTower" A non-blocking straight wall element (same width as gate) represented by a single (maybe indented) template, example: defen se tower, wall tower, outpost, watchtower64 // "entryTower" A non-blocking straight wall element (same width as gate) represented by a single (maybe indented) template, example: defence tower, wall tower, outpost, watchtower 65 65 // "entryFort" A non-blocking straight wall element represented by a single (maybe indented) template, example: fortress, palisade fort 66 66 // Bending wall elements (Wall corners) 67 67 // "cornerIn" A wall element bending the wall by PI/2 "inside" (left, +, see above), example: wall tower, palisade curve 68 68 // "cornerOut" A wall element bending the wall by PI/2 "outside" (right, -, see above), example: wall tower, palisade curve 69 69 // "cornerHalfIn" A wall element bending the wall by PI/4 "inside" (left, +, see above), example: wall tower, palisade curve. NOTE: Not yet implemented 70 70 // "cornerHalfOut" A wall element bending the wall by PI/4 "outside" (right, -, see above), example: wall tower, palisade curve. NOTE: Not yet implemented 71 // Zero length straight indented (mainly left/right sym etric) wall elements (Outposts/watchtowers and non-defensive base structures)72 // "outpost" A zero-length wall element without bending far indented so it stands outside the wall, ex sample: outpost, defense tower, watchtower73 // "house" A zero-length wall element without bending far indented so it stands inside the wall that grants population bonus, ex sample: house, hut, longhouse74 // "barracks" A zero-length wall element without bending far indented so it stands inside the wall that grants unit production, ex sample: barracks, tavern, ...71 // Zero length straight indented (mainly left/right symmetric) wall elements (Outposts/watchtowers and non-defensive base structures) 72 // "outpost" A zero-length wall element without bending far indented so it stands outside the wall, example: outpost, defence tower, watchtower 73 // "house" A zero-length wall element without bending far indented so it stands inside the wall that grants population bonus, example: house, hut, longhouse 74 // "barracks" A zero-length wall element without bending far indented so it stands inside the wall that grants unit production, example: barracks, tavern, ... 75 75 this.entity = entity; 76 76 this.angle = (angle !== undefined) ? angle : 0*PI; 77 77 this.width = (width !== undefined) ? width : 0; … … 82 82 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 83 83 // Fortress class definition 84 84 // 85 // A "fortress" here is a closed wall build of multiple wall elements attached tog ather defined in Fortress.wall85 // A "fortress" here is a closed wall build of multiple wall elements attached together defined in Fortress.wall 86 86 // It's mainly the abstract shape defined in a Fortress instances wall because different styles can be used for it (see wallStyles) 87 87 // 88 88 // type Descriptive string, example: "tiny". Not really needed (WallTool.wallTypes["type string"] is used). Mainly for custom wall elements 89 89 // wall Optional. Array of wall element strings. Can be set afterwards. Default is an epty array. 90 90 // Example: ["entrance", "wall", "cornerIn", "wall", "gate", "wall", "entrance", "wall", "cornerIn", "wall", "gate", "wall", "cornerIn", "wall"] 91 // centerToFirstElement Optional. Object with propert ys "x" and "y" representing a vector from the visual center to the first wall element. Default is undefined91 // centerToFirstElement Optional. Object with properties "x" and "y" representing a vector from the visual center to the first wall element. Default is undefined 92 92 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 93 93 function Fortress(type, wall, centerToFirstElement) 94 94 { … … 108 108 var wallStyles = {}; 109 109 110 110 // Generic civ dependent wall style definition. "rome_siege" needs some tweek... 111 var wallScaleByType = {"athen" : 1.5, "brit" : 1.5, "cart" : 1.8, "celt" : 1.5, "gaul" : 1.5, "hele" : 1.5, "iber" : 1.5, "mace" : 1.5, "maur": 1.5, "pers" : 1.5, " rome" : 1.5, "spart" : 1.5, "rome_siege" : 1.5};111 var wallScaleByType = {"athen" : 1.5, "brit" : 1.5, "cart" : 1.8, "celt" : 1.5, "gaul" : 1.5, "hele" : 1.5, "iber" : 1.5, "mace" : 1.5, "maur": 1.5, "pers" : 1.5, "ptol" : 1.5, "rome" : 1.5, "spart" : 1.5, "rome_siege" : 1.5}; 112 112 for (var style in wallScaleByType) 113 113 { 114 114 var civ = style; … … 127 127 wallStyles[style]["wallLong"] = new WallElement("wallLong", "structures/" + style + "_wall_long", 0*PI, 6*wallScaleByType[style]); 128 128 // Gate and entrance wall elements 129 129 var gateWidth = 6*wallScaleByType[style]; 130 wallStyles[style]["gate"] = new WallElement("gate", "structures/" + style + "_wall_gate", 0*PI, gateWidth);130 wallStyles[style]["gate"] = new WallElement("gate", "structures/" + style + "_wall_gate", PI, gateWidth); 131 131 wallStyles[style]["entry"] = new WallElement("entry", undefined, 0*PI, gateWidth); 132 132 wallStyles[style]["entryTower"] = new WallElement("entryTower", "structures/" + civ + "_defense_tower", PI, gateWidth, -4*wallScaleByType[style]); 133 133 wallStyles[style]["entryFort"] = new WallElement("entryFort", "structures/" + civ + "_fortress", 0*PI, 8*wallScaleByType[style], 6*wallScaleByType[style]); … … 161 161 wallStyles["mace"]["wallFort"] = new WallElement("wallFort", "structures/mace_fortress", 2*PI/2 /* PI/2 */, 5.1 /* 5.6 */, 1.9 /* 1.9 */); 162 162 wallStyles["maur"]["wallFort"] = new WallElement("wallFort", "structures/maur_fortress", PI, 5.5); 163 163 wallStyles["pers"]["wallFort"] = new WallElement("wallFort", "structures/pers_fortress", PI, 5.6/*5.5*/, 1.9/*1.7*/); 164 wallStyles["ptol"]["wallFort"] = new WallElement("wallFort", "structures/athen_fortress", 2*PI/2 /* PI/2 */, 5.1 /* 5.6 */, 1.9 /* 1.9 */); 164 165 wallStyles["rome"]["wallFort"] = new WallElement("wallFort", "structures/rome_fortress", PI, 6.3, 2.1); 165 166 wallStyles["spart"]["wallFort"] = new WallElement("wallFort", "structures/spart_fortress", 2*PI/2 /* PI/2 */, 5.1 /* 5.6 */, 1.9 /* 1.9 */); 166 167 // Adjust "rome_siege" style … … 237 238 // fortressTypes data structure for some default fortress types 238 239 // 239 240 // A fortress type is just an instance of the Fortress class with actually something in it 240 // fortressTypes holds all the fortresses s within an associative array with a descriptive string as key (e.g. maching the map size)241 // E examples: "tiny", "veryLarge"241 // fortressTypes holds all the fortresses within an associative array with a descriptive string as key (e.g. matching the map size) 242 // Examples: "tiny", "veryLarge" 242 243 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 243 244 var fortressTypes = {}; 244 245 // Setup some default fortress types 245 246 // Add fortress type "tiny" 246 247 fortressTypes["tiny"] = new Fortress("tiny"); 247 var wallPart = ["gate", " wall", "cornerIn", "wall"];248 var wallPart = ["gate", "tower", "wallShort", "cornerIn", "wallShort", "tower"]; 248 249 fortressTypes["tiny"].wall = wallPart.concat(wallPart, wallPart, wallPart); 249 250 // Add fortress type "small" 250 251 fortressTypes["small"] = new Fortress("small"); 251 var wallPart = ["gate", " endLeft", "wall", "cornerIn", "wall", "endRight"];252 var wallPart = ["gate", "tower", "wall", "cornerIn", "wall", "tower"]; 252 253 fortressTypes["small"].wall = wallPart.concat(wallPart, wallPart, wallPart); 253 254 // Add fortress type "medium" 254 255 fortressTypes["medium"] = new Fortress("medium"); 255 var wallPart = ["gate", "endLeft", "wall", "outpost", "wall", 256 "cornerIn", "wall", "outpost", "wall", "endRight"]; 256 var wallPart = ["gate", "tower", "wallLong", "cornerIn", "wallLong", "tower"]; 257 257 fortressTypes["medium"].wall = wallPart.concat(wallPart, wallPart, wallPart); 258 258 // Add fortress type "normal" 259 259 fortressTypes["normal"] = new Fortress("normal"); 260 var wallPart = ["gate", "endLeft", "wall", "tower", "wall", 261 "cornerIn", "wall", "tower", "wall", "endRight"]; 260 var wallPart = ["gate", "tower", "wall", "cornerIn", "wall", "cornerOut", "wall", "cornerIn", "wall", "tower"]; 262 261 fortressTypes["normal"].wall = wallPart.concat(wallPart, wallPart, wallPart); 263 262 // Add fortress type "large" 264 263 fortressTypes["large"] = new Fortress("large"); 265 var wallPart = ["gate", "endLeft", "wall", "outpost", "wall", "cornerIn", "wall", 266 "cornerOut", "wall", "cornerIn", "wall", "outpost", "wall", "endRight"]; 264 var wallPart = ["gate", "tower", "wallLong", "cornerIn", "wallLong", "cornerOut", "wallLong", "cornerIn", "wallLong", "tower"]; 267 265 fortressTypes["large"].wall = wallPart.concat(wallPart, wallPart, wallPart); 268 266 // Add fortress type "veryLarge" 269 267 fortressTypes["veryLarge"] = new Fortress("veryLarge"); 270 var wallPart = ["gate", "endLeft", "wall", "tower", "wall", "cornerIn", "wall", 271 "cornerOut", "wall", "cornerIn", "wall", "tower", "wall", "endRight"]; 268 var wallPart = ["gate", "tower", "wall", "cornerIn", "wall", "cornerOut", "wallLong", "cornerIn", "wallLong", "cornerOut", "wall", "cornerIn", "wall", "tower"]; 272 269 fortressTypes["veryLarge"].wall = wallPart.concat(wallPart, wallPart, wallPart); 273 270 // Add fortress type "giant" 274 271 fortressTypes["giant"] = new Fortress("giant"); 275 var wallPart = ["gate", "endLeft", "wall", "outpost", "wall", "cornerIn", "wall", "outpost", "wall", 276 "cornerOut", "wall", "outpost", "wall", "cornerIn", "wall", "outpost", "wall", "endRight"]; 272 var wallPart = ["gate", "tower", "wallLong", "cornerIn", "wallLong", "cornerOut", "wallLong", "cornerIn", "wallLong", "cornerOut", "wallLong", "cornerIn", "wallLong", "tower"]; 277 273 fortressTypes["giant"].wall = wallPart.concat(wallPart, wallPart, wallPart); 278 274 279 275 // Setup some better looking semi default fortresses for "palisades" style … … 283 279 var newKey = fortressTypeKeys[i] + "Palisades"; 284 280 var oldWall = fortressTypes[fortressTypeKeys[i]].wall; 285 281 fortressTypes[newKey] = new Fortress(newKey); 286 var fillTowersBetween = ["wall ", "endLeft", "endRight", "cornerIn", "cornerOut"];282 var fillTowersBetween = ["wallShort", "wall", "wallLong", "endLeft", "endRight", "cornerIn", "cornerOut"]; 287 283 for (var j = 0; j < oldWall.length; j++) 288 284 { 289 285 fortressTypes[newKey].wall.push(oldWall[j]); // Only works if the first element is not in fillTowersBetween (e.g. entry or gate like it should be) … … 323 319 // 324 320 // Returns a list of objects containing all information to place all the wall elements entities with placeObject (but the player ID) 325 321 // Placing the first wall element at startX/startY placed with an angle given by orientation 326 // An align ement can be used to get the "center" of a "wall" (more likely used for fortresses) with getCenterToFirstElement322 // An alignment can be used to get the "center" of a "wall" (more likely used for fortresses) with getCenterToFirstElement 327 323 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 328 324 function getWallAlignment(startX, startY, wall, style, orientation) 329 325 { 326 // Graciously handle arguments 327 if (wall === undefined) 328 wall = []; 329 if (!wallStyles.hasOwnProperty(style)) 330 { 331 warn("Function getWallAlignment: Unknown style: " + style + ' (falling back to "athen")'); 332 style = "athen"; 333 } 330 334 orientation = (orientation || 0); 335 331 336 var alignment = []; 332 337 var wallX = startX; 333 338 var wallY = startY; … … 395 400 ////////////////////////////////////////////////////////////////// 396 401 function getWallLength(wall, style) 397 402 { 403 // Graciously handle arguments 404 if (wall === undefined) 405 wall = []; 406 if (!wallStyles.hasOwnProperty(style)) 407 { 408 warn("Function getWallLength: Unknown style: " + style + ' (falling back to "athen")'); 409 style = "athen"; 410 } 411 398 412 var length = 0; 399 413 for (var i = 0; i < wall.length; i++) 400 414 { … … 424 438 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 425 439 function placeWall(startX, startY, wall, style, playerId, orientation) 426 440 { 427 // Setup optional arguments 441 // Graciously handle arguments 442 if (wall === undefined) 443 wall = []; 428 444 playerId = (playerId || 0); 429 if (playerId == 0) 430 style = (style || "palisades"); 431 else 432 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 445 if (!wallStyles.hasOwnProperty(style)) 446 { 447 if (playerId == 0) 448 style = (style || "palisades"); 449 else 450 style = (getCivCode(playerId-1)); 451 } 433 452 orientation = (orientation || 0); 453 434 454 // Get wall alignment 435 455 var AM = getWallAlignment(startX, startY, wall, style, orientation); 436 456 // Place the wall … … 455 475 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 456 476 function placeCustomFortress(centerX, centerY, fortress, style, playerId, orientation) 457 477 { 458 // Setup optionalarguments459 fortress = (fortress || fortressTypes[" tiny"]);478 // Graciously handle arguments 479 fortress = (fortress || fortressTypes["medium"]); 460 480 playerId = (playerId || 0); 461 if (playerId == 0) 462 style = (style || "palisades"); 463 else 464 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 481 if (!wallStyles.hasOwnProperty(style)) 482 { 483 if (playerId == 0) 484 style = (style || "palisades"); 485 else 486 style = (getCivCode(playerId-1)); 487 } 465 488 orientation = (orientation || 0); 489 466 490 // Calculate center if fortress.centerToFirstElement is undefined (default) 467 491 var centerToFirstElement = fortress.centerToFirstElement; 468 492 if (centerToFirstElement === undefined) … … 480 504 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 481 505 function placeFortress(centerX, centerY, type, style, playerId, orientation) 482 506 { 483 // Setup optionalarguments484 type = (type || " tiny");507 // Graciously handle arguments 508 type = (type || "medium"); 485 509 playerId = (playerId || 0); 486 if (playerId == 0) 487 style = (style || "palisades"); 488 else 489 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 510 if (!wallStyles.hasOwnProperty(style)) 511 { 512 if (playerId == 0) 513 style = (style || "palisades"); 514 else 515 style = (getCivCode(playerId-1)); 516 } 490 517 orientation = (orientation || 0); 518 491 519 // Call placeCustomFortress with the given arguments 492 520 placeCustomFortress(centerX, centerY, fortressTypes[type], style, playerId, orientation); 493 521 } … … 495 523 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 496 524 // placeLinearWall 497 525 // 498 // Places a straight wall from a given coordinate to an other repeat antusing the wall parts.526 // Places a straight wall from a given coordinate to an other repeatedly using the wall parts. 499 527 // 500 528 // startX/startY Coordinate of the approximate beginning of the wall (Not the place of the first wall element) 501 529 // targetX/targetY Coordinate of the approximate ending of the wall (Not the place of the last wall element) … … 511 539 // Setup optional arguments to the default 512 540 wallPart = (wallPart || ["tower", "wallLong"]); 513 541 playerId = (playerId || 0); 514 if (playerId == 0) 515 style = (style || "palisades"); 516 else 517 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 542 if (!wallStyles.hasOwnProperty(style)) 543 { 544 if (playerId == 0) 545 style = (style || "palisades"); 546 else 547 style = (getCivCode(playerId-1)); 548 } 518 549 endWithFirst = typeof endWithFirst == "undefined" ? true : endWithFirst; 550 519 551 // Check arguments 520 552 for (var elementIndex = 0; elementIndex < wallPart.length; elementIndex++) 521 553 { … … 578 610 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 579 611 // placeCircularWall 580 612 // 581 // Place a circular wall of repeat ant wall elements given in the argument wallPart arround centerX/centerY with the given radius582 // The wall can be open d forming more an arc than a circle if maxAngle < 2*PI583 // The orientation then determines where this open part faces (0 means right like unrotated building's drop points)613 // Place a circular wall of repeated wall elements given in the argument wallPart around centerX/centerY with the given radius 614 // The wall can be opened forming more an arc than a circle if maxAngle < 2*PI 615 // The orientation then determines where this open part faces (0 means right like unrotated building's drop-points) 584 616 // 585 617 // centerX/Y Coordinates of the circle's center 586 // radius How wide the circle should be (ap roximate, especially if maxBendOff != 0)618 // radius How wide the circle should be (approximate, especially if maxBendOff != 0) 587 619 // wallPart Optional. An array of NON-BENDING wall element type strings. Default is ["tower", "wallLong"] 588 620 // style Optional. Wall style string. Default is the civ of the given player, "palisades" for gaia 589 621 // playerId Optional. Integer number of the player. Default is 0 (gaia) … … 601 633 // Setup optional arguments to the default 602 634 wallPart = (wallPart || ["tower", "wallLong"]); 603 635 playerId = (playerId || 0); 604 if (playerId == 0) 605 style = (style || "palisades"); 606 else 607 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 636 if (!wallStyles.hasOwnProperty(style)) 637 { 638 if (playerId == 0) 639 style = (style || "palisades"); 640 else 641 style = (getCivCode(playerId-1)); 642 } 608 643 orientation = (orientation || 0); 609 644 maxAngle = (maxAngle || 2*PI); 610 645 if (endWithFirst === undefined) … … 615 650 endWithFirst = true; 616 651 } 617 652 maxBendOff = (maxBendOff || 0); 653 618 654 // Check arguments 619 655 if (maxBendOff > PI/2 || maxBendOff < 0) 620 656 warn("placeCircularWall maxBendOff sould satisfy 0 < maxBendOff < PI/2 (~1.5) but it is: " + maxBendOff); … … 689 725 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 690 726 // placePolygonalWall 691 727 // 692 // Place a polygonal wall of repeat ant wall elements given in the argument wallPart arround centerX/centerY with the given radius728 // Place a polygonal wall of repeated wall elements given in the argument wallPart around centerX/centerY with the given radius 693 729 // 694 730 // centerX/Y Coordinates of the polygon's center 695 // radius How wide the circle should be in w ich the polygon fits731 // radius How wide the circle should be in which the polygon fits 696 732 // wallPart Optional. An array of NON-BENDING wall element type strings. Default is ["wallLong", "tower"] 697 733 // cornerWallElement Optional. Wall element to be placed at the polygon's corners. Default is "tower" 698 734 // style Optional. Wall style string. Default is the civ of the given player, "palisades" for gaia … … 712 748 wallPart = (wallPart || ["wallLong", "tower"]); 713 749 cornerWallElement = (cornerWallElement || "tower"); // Don't use wide elements for this. Not supported well... 714 750 playerId = (playerId || 0); 715 if (playerId == 0) 716 style = (style || "palisades"); 717 else 718 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 751 if (!wallStyles.hasOwnProperty(style)) 752 { 753 if (playerId == 0) 754 style = (style || "palisades"); 755 else 756 style = (getCivCode(playerId-1)); 757 } 719 758 orientation = (orientation || 0); 720 759 numCorners = (numCorners || 8); 721 760 skipFirstWall = (skipFirstWall || true); 761 722 762 // Setup angles 723 763 var angleAdd = 2*PI/numCorners; 724 764 var angleStart = orientation - angleAdd/2; … … 747 787 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 748 788 // placeIrregularPolygonalWall 749 789 // 750 // Place an irregular polygonal wall of some wall parts to choose from ar round centerX/centerY with the given radius790 // Place an irregular polygonal wall of some wall parts to choose from around centerX/centerY with the given radius 751 791 // 752 792 // centerX/Y Coordinates of the polygon's center 753 // radius How wide the circle should be in w ich the polygon fits793 // radius How wide the circle should be in which the polygon fits 754 794 // cornerWallElement Optional. Wall element to be placed at the polygon's corners. Default is "tower" 755 795 // style Optional. Wall style string. Default is the civ of the given player, "palisades" for gaia 756 796 // playerId Optional. Integer number of the player. Default is 0 (gaia) … … 758 798 // numCorners Optional. How many corners the polygon will have. Default is 8 (matching a civ centers territory) 759 799 // irregularity Optional. How irregular the polygon will be. 0 means regular, 1 means VERY irregular. Default is 0.5 760 800 // skipFirstWall Optional. Boolean. If the first linear wall part will be left opened as entrance. Default is true 761 // wallPartsAssortment Optional. An array of wall part arrays to choose from for each linear wall connecting the corners. Default is hard to de cribe ^^801 // wallPartsAssortment Optional. An array of wall part arrays to choose from for each linear wall connecting the corners. Default is hard to describe ^^ 762 802 // 763 803 // NOTE: wallPartsAssortment is put to the end because it's hardest to set 764 804 // NOTE: Don't use wall elements with bending like corners! … … 770 810 { 771 811 // Setup optional arguments 772 812 playerId = (playerId || 0); 773 if (playerId == 0) 774 style = (style || "palisades"); 775 else 776 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 777 // Generating a generic wall part assortment with each wall part including 1 gate enlengthend by walls and towers 813 if (!wallStyles.hasOwnProperty(style)) 814 { 815 if (playerId == 0) 816 style = (style || "palisades"); 817 else 818 style = (getCivCode(playerId-1)); 819 } 820 821 // Generating a generic wall part assortment with each wall part including 1 gate lengthened by walls and towers 778 822 // NOTE: It might be a good idea to write an own function for that... 779 823 var defaultWallPartsAssortment = [["wallShort"], ["wall"], ["wallLong"], ["gate", "tower", "wallShort"]]; 780 824 var centeredWallPart = ["gate"]; … … 838 882 { 839 883 var bestWallPart = []; // This is a simpel wall part not a wallPartsAssortment! 840 884 var bestWallLength = 99999999; 841 // NOTE: This is not ex sactly like the length the wall will be in the end. Has to be tweeked...885 // NOTE: This is not exactly like the length the wall will be in the end. Has to be tweaked... 842 886 var wallLength = getDistance(corners[i][0], corners[i][1], corners[(i+1)%numCorners][0], corners[(i+1)%numCorners][1]); 843 887 var numWallParts = ceil(wallLength/maxWallPartLength); 844 888 for (var partIndex = 0; partIndex < wallPartsAssortment.length; partIndex++) … … 873 917 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 874 918 // placeGenericFortress 875 919 // 876 // Places a generic fortress with towers at the edges connected with long walls and gates (entries until lgates work)920 // Places a generic fortress with towers at the edges connected with long walls and gates (entries until gates work) 877 921 // This is the default Iberian civ bonus starting wall 878 922 // 879 // centerX/Y The ap roximate center coordinates of the fortress923 // centerX/Y The approximate center coordinates of the fortress 880 924 // radius The approximate radius of the wall to be placed 881 925 // playerId Optional. Integer number of the player. Default is 0 (gaia) 882 926 // style Optional. Wall style string. Default is the civ of the given player, "palisades" for gaia … … 889 933 // Setup optional arguments 890 934 radius = (radius || 20); 891 935 playerId = (playerId || 0); 892 if (playerId == 0) 893 style = (style || "palisades"); 894 else 895 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 936 if (!wallStyles.hasOwnProperty(style)) 937 { 938 if (playerId == 0) 939 style = (style || "palisades"); 940 else 941 style = (getCivCode(playerId-1)); 942 } 896 943 irregularity = (irregularity || 1/2); 897 944 gateOccurence = (gateOccurence || 3); 898 945 maxTrys = (maxTrys || 100); 946 899 947 // Setup some vars 900 948 var startAngle = randFloat(0, 2*PI); 901 949 var actualOffX = radius*cos(startAngle); -
data/mods/public/maps/random/wall_demo.js
63 63 var actualY = distToMapBorder; 64 64 // Wall styles are chosen by strings so the civ strings got by g_MapSettings.PlayerData[playerId - 1].Civ can be used 65 65 // Other styles may be present as well but besides the civ styles only 'palisades' includes all wall element types (yet) 66 const wallStyleList = ["athen", "brit", "cart", "celt", "gaul", "hele", "iber", "mace", "maur", "pers", " rome", "spart", "rome_siege", "palisades"];66 const wallStyleList = ["athen", "brit", "cart", "celt", "gaul", "hele", "iber", "mace", "maur", "pers", "ptol", "rome", "spart", "rome_siege", "palisades"]; 67 67 68 68 69 69 ////////////////////////////////////////