Ticket #1449: rms_wall_pack2012-6-20.diff
File rms_wall_pack2012-6-20.diff, 92.3 KB (added by , 12 years ago) |
---|
-
data/mods/public/maps/random/fortress.js
155 155 createArea(placer,[new TerrainPainter(tRoad), paintClass(clPlayer)]); 156 156 157 157 // Place custom fortress 158 if (civ == " celt" || civ == "iber")158 if (civ == "brit" || civ == "celt" || civ == "gaul" || civ == "iber") 159 159 { 160 160 var wall = ['entryTower', 'wall', 'wall', 161 161 'cornerIn', 'wall', 'barracks', 'wall', 'gate', 'wall', 'house', 'wall', -
data/mods/public/maps/random/rmgen/misc.js
68 68 } 69 69 } 70 70 } 71 71 72 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 72 73 //rndRiver is a fuction that creates random values useful for making a jagged river. 73 74 // … … 193 194 if (iberWall == 'towers') 194 195 placePolygonalWall(fx, fz, 15, ['entry'], 'tower', civ, playerid, angle, 7); 195 196 else 196 { 197 placeGenericFortress(fx, fz, 20/*radius*/, playerid, ['tower', 'wall', 'tower', 'entry', 'tower', 'wall'], civ, PI/6/*angle offset (0 to PI/4)*/) 198 } 197 placeGenericFortress(fx, fz, 20/*radius*/, playerid); 199 198 } 200 199 } 201 200 -
data/mods/public/maps/random/rmgen/wall_builder.js
3 3 //////////////////////////////////////////////////////////////////// 4 4 5 5 // To do: 6 // Rename wall elements to fit he entity names so that entity = 'structures/' + 'civ + '_' + wallElement.type in the common case 7 // Add roman army camp to style palisades and add upgraded default palisade fortress types matching civ default fortresses 8 // Add further wall elements cornerHalfIn, cornerHalfOut and adjust default fortress types to better fit in the octagonal territory of a civil center 9 // Add civil center, corral, farmstead, field, market, mill, temple 10 // Adjust default fortress types 11 // Add wall style 'roads' 12 // Add trsures to 'others' 6 // Check if all wall placement methods work with wall elements with entity === undefined (some still might raise errors in that case) 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 strength 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 // Perhaps swap angle and width in WallElement class(?) definition 11 // Adjust argument order to be always the same: 12 // Coordinates (center/start/target) 13 // Wall element arguments (wall/wallPart/fortressType/cornerElement) 14 // playerId (optional, default is 0/gaia) 15 // wallStyle (optional, default is the players civ/"palisades for gaia") 16 // angle/orientation (optional, default is 0) 17 // other (all optional) arguments especially those hard to define (wallPartsAssortment, maybe make an own function for it) 18 // Some arguments don't clearly match to this concept: 19 // endWithFirst (wall or other) 20 // skipFirstWall (wall or other) 21 // gateOccurence (wall or other) 22 // numCorners (wall or other) 23 // skipFirstWall (wall or other) 24 // maxAngle (angle or other) 25 // maxBendOff (angle or other, unused ATM!!!) 26 // irregularity 27 // maxTrys 28 // Add tresures to wall style "others" 13 29 // Adjust documentation 14 // ?Use available civ-type wall elements rather than palisades: Remove 'endLeft' and 'endRight' as default wall elements and adjust default palisade fortress types? 15 // ?Remove endRight, endLeft and adjust generic fortress types palisades? 30 // Perhaps rename "endLeft" to "start" and "endRight" to "end" 31 // ?Use available civ-type wall elements rather than palisades: Remove "endLeft" and "endRight" as default wall elements and adjust default palisade fortress types? 32 // ?Remove "endRight", "endLeft" and adjust generic fortress types palisades? 16 33 // ?Think of something to enable splitting walls into two walls so more complex walls can be build and roads can have branches/crossroads? 17 34 // ?Readjust placement angle for wall elements with bending when used in linear/circular walls by their bending? 18 35 19 36 20 /////////////////////////////// 21 // WallElement class definition 22 /////////////////////////////// 23 24 // argument type: Descriptive string, example: 'wall'. NOTE: Not really needed. Mainly for custom wall elements and to get the wall element type in code. 25 // argument entity: Optional. Template string to be placed, example: 'structures/cart_wall'. Default is undefined (No entity placed) 26 // argument angle: Optional. Placement angle so that 'outside' is 'right' (towards positive X like a unit placed with angle 0). Default is 0 (0*PI) 27 // argument width: Optional. The width it lengthens the wall, width because it's the needed space in a right angle to 'outside'. Default is 0 28 // argument indent: Optional. The indentation means its drawn inside (positive values) or pushed outwards (negative values). Default is 0 29 // NOTE: Bending is only used for fortresses and custom walls. Linear/circular walls walls use no/generic bending 30 // argument bending: Optional. How the direction of the wall is changed after this element, positive is bending 'in' (counter clockwise like entity placement) 37 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 38 // WallElement class definition 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 droppoints right (in rmgen) 41 // The coure of the wall will be changed by corners (bending != 0) and so the "inside"/"outside" direction 42 // 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 // entity Optional. Template name string of the entity to be placed, example: "structures/cart_wall_long". Default is undefined (No entity placed) 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 0 47 // indent Optional. The lateral indentation of the entity, drawn "inside" (positive values) or pushed "outside" (negative values). Default is 0 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 // NOTE: Bending is not supported by all placement functions (see there) 50 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 31 51 function WallElement(type, entity, angle, width, indent, bending) 32 52 { 33 // NOTE: Not all wall elements have a symetry. So there's an direction 'outside' (towards right/positive X by default)34 // In this sense 'left'/'right' means left/right of you when standing upon the wall and look 'outside'35 // The wall is build towards 'left' so the next wall element will be placed left of the previous one (towards positive Y by default)36 // In this sense the wall's direction is left meaning the 'bending' of a corner is used for the element following the corner37 // With 'inside' and 'outside' defined as above, corners bend 'in'/'out' meaning placemant angle is increased/decreased (counter clockwise like object placement)38 53 this.type = type; 39 // Wall element type documentation:54 // Default wall element type documentation: 40 55 // Enlengthening straight blocking (mainly left/right symetric) wall elements (Walls and wall fortifications) 41 // 'wall':A blocking straight wall element that mainly lengthens the wall, self-explanatory42 // 'wallShort':self-explanatory43 // 'wallLong':self-explanatory44 // 'tower':A blocking straight wall element with damage potential (but for palisades) that slightly lengthens the wall, exsample: wall tower, palisade tower(No attack)45 // 'wallFort':A blocking straight wall element with massive damage potential that lengthens the wall, exsample: fortress, palisade fort56 // "wall" A blocking straight wall element that mainly lengthens the wall, self-explanatory 57 // "wallShort" self-explanatory 58 // "wallLong" self-explanatory 59 // "tower" A blocking straight wall element with damage potential (but for palisades) that slightly lengthens the wall, exsample: wall tower, palisade tower(No attack) 60 // "wallFort" A blocking straight wall element with massive damage potential that lengthens the wall, exsample: fortress, palisade fort 46 61 // Enlengthening straight non/custom blocking (mainly left/right symetric) wall elements (Gates and entrys) 47 // 'gate':A blocking straight wall element with passability determined by owner, example: gate (Functionality not yet implemented)48 // 'entry':A non-blocking straight wall element (same width as gate) but without an actual template or just a flag/column/obelisk49 // 'entryTower':A non-blocking straight wall element (same width as gate) represented by a single (maybe indented) template, example: defense tower, wall tower, outpost, watchtower50 // 'entryFort':A non-blocking straight wall element represented by a single (maybe indented) template, example: fortress, palisade fort62 // "gate" A blocking straight wall element with passability determined by owner, example: gate (Functionality not yet implemented) 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: defense tower, wall tower, outpost, watchtower 65 // "entryFort" A non-blocking straight wall element represented by a single (maybe indented) template, example: fortress, palisade fort 51 66 // Bending wall elements (Wall corners) 52 // 'cornerIn': A wall element bending the wall by PI/2 'inside'(left, +, see above), example: wall tower, palisade curve53 // 'cornerOut': A wall element bending the wall by PI/2 'outside'(right, -, see above), example: wall tower, palisade curve54 // 'cornerHalfIn': A wall element bending the wall by PI/4 'inside'(left, +, see above), example: wall tower, palisade curve. NOTE: Not yet implemented55 // 'cornerHalfOut': A wall element bending the wall by PI/4 'outside'(right, -, see above), example: wall tower, palisade curve. NOTE: Not yet implemented67 // "cornerIn" A wall element bending the wall by PI/2 "inside" (left, +, see above), example: wall tower, palisade curve 68 // "cornerOut" A wall element bending the wall by PI/2 "outside" (right, -, see above), example: wall tower, palisade curve 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 // "cornerHalfOut" A wall element bending the wall by PI/4 "outside" (right, -, see above), example: wall tower, palisade curve. NOTE: Not yet implemented 56 71 // Zero length straight indented (mainly left/right symetric) wall elements (Outposts/watchtowers and non-defensive base structures) 57 // 'outpost':A zero-length wall element without bending far indented so it stands outside the wall, exsample: outpost, defense tower, watchtower58 // 'house':A zero-length wall element without bending far indented so it stands inside the wall that grants population bonus, exsample: house, hut, longhouse59 // 'barracks':A zero-length wall element without bending far indented so it stands inside the wall that grants unit production, exsample: barracks, tavern, ...72 // "outpost" A zero-length wall element without bending far indented so it stands outside the wall, exsample: outpost, defense tower, watchtower 73 // "house" A zero-length wall element without bending far indented so it stands inside the wall that grants population bonus, exsample: house, hut, longhouse 74 // "barracks" A zero-length wall element without bending far indented so it stands inside the wall that grants unit production, exsample: barracks, tavern, ... 60 75 this.entity = entity; 61 76 this.angle = (angle !== undefined) ? angle : 0*PI; 62 77 this.width = (width !== undefined) ? width : 0; … … 64 79 this.bending = (bending !== undefined) ? bending : 0*PI; 65 80 } 66 81 67 68 // //////////////////////////69 // Fortress class definition70 // //////////////////////////71 72 // A list would do for symetric fortresses but if 'getCenter' don't do sufficient the center can be set manually73 // argument type: Descriptive string, example: 'tiny'. Not really needed (WallTool.wallTypes['type string'] is used). Mainly for custom wall elements.74 // argument wall:Optional. Array of wall element strings. Can be set afterwards. Default is an epty array.75 // Example: ['entrance', 'wall', 'cornerIn', 'wall', 'gate', 'wall', 'entrance', 'wall', 'cornerIn', 'wall', 'gate', 'wall', 'cornerIn', 'wall']76 // argument center: Optional. Array of 2 floats determinig the vector from the center to the 1st wall element. Can be set afterwards. Default is [0, 0]. (REALLY???)77 // NOTE: The center will be recalculated when WallTool.setFortress is called. To avoid this set WallTool.calculateCenter to false. 78 function Fortress(type, wall, center )82 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 83 // Fortress class definition 84 // 85 // A "fortress" here is a closed wall build of multiple wall elements attached togather defined in Fortress.wall 86 // It's mainly the abstract shape defined in a Fortress instances wall because different styles can be used for it (see wallStyles) 87 // 88 // type Descriptive string, example: "tiny". Not really needed (WallTool.wallTypes["type string"] is used). Mainly for custom wall elements 89 // wall Optional. Array of wall element strings. Can be set afterwards. Default is an epty array. 90 // Example: ["entrance", "wall", "cornerIn", "wall", "gate", "wall", "entrance", "wall", "cornerIn", "wall", "gate", "wall", "cornerIn", "wall"] 91 // centerToFirstElement Optional. Object with propertys "x" and "y" representing a vector from the visual center to the first wall element. Default is undefined 92 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 93 function Fortress(type, wall, centerToFirstElement) 79 94 { 80 this.type = type; // Only usefull to get the type of the actual fortress (by 'WallTool.fortress.type')95 this.type = type; // Only usefull to get the type of the actual fortress 81 96 this.wall = (wall !== undefined) ? wall : []; 82 this.center = [0, 0]; // X/Z offset (in default orientation) from first wall element to center, perhaps should be the other way around...97 this.centerToFirstElement = undefined; 83 98 } 84 99 85 100 86 /////////////////////////////////////////////// 87 // Setup data structure for default wall styles 88 /////////////////////////////////////////////// 89 90 // A wall style is an associative array with all wall elements of that style in it associated with the wall element type string. 91 // wallStyles holds all the wall styles within an associative array while a wall style is associated with the civ string or another descriptive strings like 'palisades', 'fence', 'cart', 'celt'... 101 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 102 // wallStyles data structure for default wall styles 103 // 104 // A wall style is an associative array with all wall elements of that style in it associated with the wall element type string 105 // wallStyles holds all the wall styles within an associative array with the civ string or another descriptive strings as key 106 // Examples: "athen", "rome_siege", "palisades", "fence", "road" 107 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 92 108 var wallStyles = {}; 93 109 94 // Generic civ dependent wall style definition. 'rome_siege'needs some tweek...95 var scaleByCiv = {'athen' : 1.5, 'cart' : 1.8, 'celt' : 1.5, 'hele' : 1.5, 'iber' : 1.5, 'mace' : 1.5, 'pers' : 1.5, 'rome' : 1.5, 'spart' : 1.5, 'rome_siege': 1.5};96 for (var style in scaleByCiv)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, "pers" : 1.5, "rome" : 1.5, "spart" : 1.5, "rome_siege" : 1.5}; 112 for (var style in wallScaleByType) 97 113 { 98 114 var civ = style; 99 if (style == 'rome_siege')100 civ = 'rome';115 if (style == "rome_siege") 116 civ = "rome"; 101 117 wallStyles[style] = {}; 102 118 // Default wall elements 103 wallStyles[style]['tower'] = new WallElement('tower', 'structures/' + style + '_wall_tower', PI, scaleByCiv[style]); 104 wallStyles[style]['endLeft'] = new WallElement('endLeft', 'structures/' + style + '_wall_tower', PI, scaleByCiv[style]); // Same as tower. To be compatible with palisades... 105 wallStyles[style]['endRight'] = new WallElement('endRight', 'structures/' + style + '_wall_tower', PI, scaleByCiv[style]); // Same as tower. To be compatible with palisades... 106 wallStyles[style]['cornerIn'] = new WallElement('cornerIn', 'structures/' + style + '_wall_tower', 5*PI/4, 0, 0.35*scaleByCiv[style], PI/2); // 2^0.5 / 4 ~= 0.35 ~= 1/3 107 wallStyles[style]['cornerOut'] = new WallElement('cornerOut', 'structures/' + style + '_wall_tower', 3*PI/4, 0.71*scaleByCiv[style], 0, -PI/2); // // 2^0.5 / 2 ~= 0.71 ~= 2/3 108 wallStyles[style]['wallShort'] = new WallElement('wallShort', 'structures/' + style + '_wall_short', 0*PI, 2*scaleByCiv[style]); 109 wallStyles[style]['wall'] = new WallElement('wall', 'structures/' + style + '_wall_medium', 0*PI, 4*scaleByCiv[style]); 110 wallStyles[style]['wallLong'] = new WallElement('wallLong', 'structures/' + style + '_wall_long', 0*PI, 6*scaleByCiv[style]); 119 wallStyles[style]["tower"] = new WallElement("tower", "structures/" + style + "_wall_tower", PI, wallScaleByType[style]); 120 wallStyles[style]["endLeft"] = new WallElement("endLeft", "structures/" + style + "_wall_tower", PI, wallScaleByType[style]); // Same as tower. To be compatible with palisades... 121 wallStyles[style]["endRight"] = new WallElement("endRight", "structures/" + style + "_wall_tower", PI, wallScaleByType[style]); // Same as tower. To be compatible with palisades... 122 wallStyles[style]["cornerIn"] = new WallElement("cornerIn", "structures/" + style + "_wall_tower", 5*PI/4, 0, 0.35*wallScaleByType[style], PI/2); // 2^0.5 / 4 ~= 0.35 ~= 1/3 123 wallStyles[style]["cornerOut"] = new WallElement("cornerOut", "structures/" + style + "_wall_tower", 3*PI/4, 0.71*wallScaleByType[style], 0, -PI/2); // // 2^0.5 / 2 ~= 0.71 ~= 2/3 124 wallStyles[style]["wallShort"] = new WallElement("wallShort", "structures/" + style + "_wall_short", 0*PI, 2*wallScaleByType[style]); 125 wallStyles[style]["wall"] = new WallElement("wall", "structures/" + style + "_wall_medium", 0*PI, 4*wallScaleByType[style]); 126 wallStyles[style]["wallMedium"] = new WallElement("wall", "structures/" + style + "_wall_medium", 0*PI, 4*wallScaleByType[style]); 127 wallStyles[style]["wallLong"] = new WallElement("wallLong", "structures/" + style + "_wall_long", 0*PI, 6*wallScaleByType[style]); 111 128 // Gate and entrance wall elements 112 if (style == 'cart') 113 var gateWidth = 3.5*scaleByCiv[style]; 114 else if (style == 'celt') 115 var gateWidth = 4*scaleByCiv[style]; 116 // else if (style == 'iber') 117 // var gateWidth = 5.5*scaleByCiv[style]; 129 if (style == "cart") 130 var gateWidth = 3.5*wallScaleByType[style]; 131 else if (style == "brit" || style == "celt" || style == "gaul") 132 var gateWidth = 4*wallScaleByType[style]; 118 133 else 119 var gateWidth = 6*scaleByCiv[style]; 120 wallStyles[style]['gate'] = new WallElement('gate', 'structures/' + style + '_wall_gate', 0*PI, gateWidth); 121 wallStyles[style]['entry'] = new WallElement('entry', undefined, 0*PI, gateWidth); 122 if (civ == 'iber') // Adjust iberians to have no upkeep at entries with a tower for convinience ATM, may be changed 123 wallStyles[style]['entryTower'] = new WallElement('entryTower', 'structures/' + civ + '_wall_tower', PI, gateWidth, -4*scaleByCiv[style]); 124 else 125 wallStyles[style]['entryTower'] = new WallElement('entryTower', 'structures/' + civ + '_defense_tower', PI, gateWidth, -4*scaleByCiv[style]); 126 wallStyles[style]['entryFort'] = new WallElement('entryFort', 'structures/' + civ + '_fortress', 0*PI, 8*scaleByCiv[style], 6*scaleByCiv[style]); 134 var gateWidth = 6*wallScaleByType[style]; 135 wallStyles[style]["gate"] = new WallElement("gate", "structures/" + style + "_wall_gate", 0*PI, gateWidth); 136 wallStyles[style]["entry"] = new WallElement("entry", undefined, 0*PI, gateWidth); 137 wallStyles[style]["entryTower"] = new WallElement("entryTower", "structures/" + civ + "_defense_tower", PI, gateWidth, -4*wallScaleByType[style]); 138 wallStyles[style]["entryFort"] = new WallElement("entryFort", "structures/" + civ + "_fortress", 0*PI, 8*wallScaleByType[style], 6*wallScaleByType[style]); 127 139 // Defensive wall elements with 0 width outside the wall 128 wallStyles[style][ 'outpost'] = new WallElement('outpost', 'structures/' + civ + '_outpost', PI, 0, -4*scaleByCiv[style]);129 wallStyles[style][ 'defenseTower'] = new WallElement('defenseTower', 'structures/' + civ + '_defenseTower', PI, 0, -4*scaleByCiv[style]);140 wallStyles[style]["outpost"] = new WallElement("outpost", "structures/" + civ + "_outpost", PI, 0, -4*wallScaleByType[style]); 141 wallStyles[style]["defenseTower"] = new WallElement("defenseTower", "structures/" + civ + "_defenseTower", PI, 0, -4*wallScaleByType[style]); 130 142 // Base buildings wall elements with 0 width inside the wall 131 wallStyles[style][ 'barracks'] = new WallElement('barracks', 'structures/' + civ + '_barracks', PI, 0, 4.5*scaleByCiv[style]);132 wallStyles[style][ 'civilCentre'] = new WallElement('civilCentre', 'structures/' + civ + '_civil_centre', PI, 0, 4.5*scaleByCiv[style]);133 wallStyles[style][ 'farmstead'] = new WallElement('farmstead', 'structures/' + civ + '_farmstead', PI, 0, 4.5*scaleByCiv[style]);134 wallStyles[style][ 'field'] = new WallElement('field', 'structures/' + civ + '_field', PI, 0, 4.5*scaleByCiv[style]);135 wallStyles[style][ 'fortress'] = new WallElement('fortress', 'structures/' + civ + '_fortress', PI, 0, 4.5*scaleByCiv[style]);136 wallStyles[style][ 'house'] = new WallElement('house', 'structures/' + civ + '_house', PI, 0, 4.5*scaleByCiv[style]);137 wallStyles[style][ 'market'] = new WallElement('market', 'structures/' + civ + '_market', PI, 0, 4.5*scaleByCiv[style]);138 wallStyles[style][ 'mill'] = new WallElement('mill', 'structures/' + civ + '_mill', PI, 0, 4.5*scaleByCiv[style]);139 wallStyles[style][ 'temple'] = new WallElement('temple', 'structures/' + civ + '_temple', PI, 0, 4.5*scaleByCiv[style]);143 wallStyles[style]["barracks"] = new WallElement("barracks", "structures/" + civ + "_barracks", PI, 0, 4.5*wallScaleByType[style]); 144 wallStyles[style]["civilCentre"] = new WallElement("civilCentre", "structures/" + civ + "_civil_centre", PI, 0, 4.5*wallScaleByType[style]); 145 wallStyles[style]["farmstead"] = new WallElement("farmstead", "structures/" + civ + "_farmstead", PI, 0, 4.5*wallScaleByType[style]); 146 wallStyles[style]["field"] = new WallElement("field", "structures/" + civ + "_field", PI, 0, 4.5*wallScaleByType[style]); 147 wallStyles[style]["fortress"] = new WallElement("fortress", "structures/" + civ + "_fortress", PI, 0, 4.5*wallScaleByType[style]); 148 wallStyles[style]["house"] = new WallElement("house", "structures/" + civ + "_house", PI, 0, 4.5*wallScaleByType[style]); 149 wallStyles[style]["market"] = new WallElement("market", "structures/" + civ + "_market", PI, 0, 4.5*wallScaleByType[style]); 150 wallStyles[style]["mill"] = new WallElement("mill", "structures/" + civ + "_mill", PI, 0, 4.5*wallScaleByType[style]); 151 wallStyles[style]["temple"] = new WallElement("temple", "structures/" + civ + "_temple", PI, 0, 4.5*wallScaleByType[style]); 140 152 // Generic space/gap wall elements 141 wallStyles[style][ 'space1'] = new WallElement('space1', undefined, 0*PI, scaleByCiv[style]);142 wallStyles[style][ 'space2'] = new WallElement('space2', undefined, 0*PI, 2*scaleByCiv[style]);143 wallStyles[style][ 'space3'] = new WallElement('space3', undefined, 0*PI, 3*scaleByCiv[style]);144 wallStyles[style][ 'space4'] = new WallElement('space4', undefined, 0*PI, 4*scaleByCiv[style]);153 wallStyles[style]["space1"] = new WallElement("space1", undefined, 0*PI, wallScaleByType[style]); 154 wallStyles[style]["space2"] = new WallElement("space2", undefined, 0*PI, 2*wallScaleByType[style]); 155 wallStyles[style]["space3"] = new WallElement("space3", undefined, 0*PI, 3*wallScaleByType[style]); 156 wallStyles[style]["space4"] = new WallElement("space4", undefined, 0*PI, 4*wallScaleByType[style]); 145 157 } 146 147 158 // Add wall fortresses for all generic styles 148 wallStyles['athen']['wallFort'] = new WallElement('wallFort', 'structures/athen_fortress', 2*PI/2 /* PI/2 */, 5.1 /* 5.6 */, 1.9 /* 1.9 */); 149 wallStyles['cart']['wallFort'] = new WallElement('wallFort', 'structures/cart_fortress', PI, 5.1, 1.6); 150 wallStyles['celt']['wallFort'] = new WallElement('wallFort', 'structures/celt_fortress_g', PI, 4.2, 1.5); 151 wallStyles['hele']['wallFort'] = new WallElement('wallFort', 'structures/hele_fortress', 2*PI/2 /* PI/2 */, 5.1 /* 5.6 */, 1.9 /* 1.9 */); 152 wallStyles['iber']['wallFort'] = new WallElement('wallFort', 'structures/iber_fortress', PI, 5, 0.2); 153 wallStyles['mace']['wallFort'] = new WallElement('wallFort', 'structures/mace_fortress', 2*PI/2 /* PI/2 */, 5.1 /* 5.6 */, 1.9 /* 1.9 */); 154 wallStyles['pers']['wallFort'] = new WallElement('wallFort', 'structures/pers_fortress', PI, 5.6/*5.5*/, 1.9/*1.7*/); 155 wallStyles['rome']['wallFort'] = new WallElement('wallFort', 'structures/rome_fortress', PI, 6.3, 2.1); 156 wallStyles['spart']['wallFort'] = new WallElement('wallFort', 'structures/spart_fortress', 2*PI/2 /* PI/2 */, 5.1 /* 5.6 */, 1.9 /* 1.9 */); 157 // Adjust 'rome_siege' style 158 wallStyles['rome_siege']['wallFort'] = new WallElement('wallFort', 'structures/rome_army_camp', PI, 7.2, 2); 159 wallStyles['rome_siege']['entryFort'] = new WallElement('entryFort', 'structures/rome_army_camp', PI, 12, 7); 160 wallStyles['rome_siege']['house'] = new WallElement('house', 'structures/rome_tent', PI, 0, 4); 159 wallStyles["athen"]["wallFort"] = new WallElement("wallFort", "structures/athen_fortress", 2*PI/2 /* PI/2 */, 5.1 /* 5.6 */, 1.9 /* 1.9 */); 160 wallStyles["brit"]["wallFort"] = new WallElement("wallFort", "structures/brit_fortress", PI, 2.8); 161 wallStyles["cart"]["wallFort"] = new WallElement("wallFort", "structures/cart_fortress", PI, 5.1, 1.6); 162 wallStyles["celt"]["wallFort"] = new WallElement("wallFort", "structures/celt_fortress_g", PI, 4.2, 1.5); 163 wallStyles["gaul"]["wallFort"] = new WallElement("wallFort", "structures/gaul_fortress", PI, 4.2, 1.5); 164 wallStyles["hele"]["wallFort"] = new WallElement("wallFort", "structures/hele_fortress", 2*PI/2 /* PI/2 */, 5.1 /* 5.6 */, 1.9 /* 1.9 */); 165 wallStyles["iber"]["wallFort"] = new WallElement("wallFort", "structures/iber_fortress", PI, 5, 0.2); 166 wallStyles["mace"]["wallFort"] = new WallElement("wallFort", "structures/mace_fortress", 2*PI/2 /* PI/2 */, 5.1 /* 5.6 */, 1.9 /* 1.9 */); 167 wallStyles["pers"]["wallFort"] = new WallElement("wallFort", "structures/pers_fortress", PI, 5.6/*5.5*/, 1.9/*1.7*/); 168 wallStyles["rome"]["wallFort"] = new WallElement("wallFort", "structures/rome_fortress", PI, 6.3, 2.1); 169 wallStyles["spart"]["wallFort"] = new WallElement("wallFort", "structures/spart_fortress", 2*PI/2 /* PI/2 */, 5.1 /* 5.6 */, 1.9 /* 1.9 */); 170 // Adjust "rome_siege" style 171 wallStyles["rome_siege"]["wallFort"] = new WallElement("wallFort", "structures/rome_army_camp", PI, 7.2, 2); 172 wallStyles["rome_siege"]["entryFort"] = new WallElement("entryFort", "structures/rome_army_camp", PI, 12, 7); 173 wallStyles["rome_siege"]["house"] = new WallElement("house", "structures/rome_tent", PI, 0, 4); 161 174 162 175 // Add special wall styles not well to implement generic (and to show how custom styles can be added) 163 176 164 // Add special wall style 'palisades' 165 wallStyles['palisades'] = {}; 166 wallStyles['palisades']['wall'] = new WallElement('wall', 'other/palisades_rocks_medium', 0*PI, 2.3); 167 wallStyles['palisades']['wallLong'] = new WallElement('wall', 'other/palisades_rocks_long', 0*PI, 3.5); 168 wallStyles['palisades']['wallShort'] = new WallElement('wall', 'other/palisades_rocks_short', 0*PI, 1.2); 169 wallStyles['palisades']['tower'] = new WallElement('tower', 'other/palisades_rocks_tower', -PI/2, 0.7); 170 wallStyles['palisades']['wallFort'] = new WallElement('wallFort', 'other/palisades_rocks_fort', PI, 1.7); 171 wallStyles['palisades']['gate'] = new WallElement('gate', 'other/palisades_rocks_gate', 0*PI, 3.6); 172 wallStyles['palisades']['entry'] = new WallElement('entry', undefined, wallStyles['palisades']['gate'].angle, wallStyles['palisades']['gate'].width); 173 wallStyles['palisades']['entryTower'] = new WallElement('entryTower', 'other/palisades_rocks_watchtower', 0*PI, wallStyles['palisades']['gate'].width, -3); 174 wallStyles['palisades']['entryFort'] = new WallElement('entryFort', 'other/palisades_rocks_fort', PI, 6, 3); 175 wallStyles['palisades']['cornerIn'] = new WallElement('cornerIn', 'other/palisades_rocks_curve', 3*PI/4, 2.1, 0.7, PI/2); 176 wallStyles['palisades']['cornerOut'] = new WallElement('cornerOut', 'other/palisades_rocks_curve', 5*PI/4, 2.1, -0.7, -PI/2); 177 wallStyles['palisades']['outpost'] = new WallElement('outpost', 'other/palisades_rocks_outpost', PI, 0, -2); 178 wallStyles['palisades']['house'] = new WallElement('house', 'other/celt_hut', PI, 0, 5); 179 wallStyles['palisades']['barracks'] = new WallElement('barracks', 'other/celt_tavern', PI, 0, 5); 180 wallStyles['palisades']['endRight'] = new WallElement('endRight', 'other/palisades_rocks_end', -PI/2, 0.2); 181 wallStyles['palisades']['endLeft'] = new WallElement('endLeft', 'other/palisades_rocks_end', PI/2, 0.2); 177 // Add wall style "palisades" 178 wallScaleByType["palisades"] = 0.55; 179 wallStyles["palisades"] = {}; 180 wallStyles["palisades"]["wall"] = new WallElement("wall", "other/palisades_rocks_medium", 0*PI, 2.3); 181 wallStyles["palisades"]["wallMedium"] = new WallElement("wall", "other/palisades_rocks_medium", 0*PI, 2.3); 182 wallStyles["palisades"]["wallLong"] = new WallElement("wall", "other/palisades_rocks_long", 0*PI, 3.5); 183 wallStyles["palisades"]["wallShort"] = new WallElement("wall", "other/palisades_rocks_short", 0*PI, 1.2); 184 wallStyles["palisades"]["tower"] = new WallElement("tower", "other/palisades_rocks_tower", -PI/2, 0.7); 185 wallStyles["palisades"]["wallFort"] = new WallElement("wallFort", "other/palisades_rocks_fort", PI, 1.7); 186 wallStyles["palisades"]["gate"] = new WallElement("gate", "other/palisades_rocks_gate", PI, 3.6); 187 wallStyles["palisades"]["entry"] = new WallElement("entry", undefined, wallStyles["palisades"]["gate"].angle, wallStyles["palisades"]["gate"].width); 188 wallStyles["palisades"]["entryTower"] = new WallElement("entryTower", "other/palisades_rocks_watchtower", 0*PI, wallStyles["palisades"]["gate"].width, -3); 189 wallStyles["palisades"]["entryFort"] = new WallElement("entryFort", "other/palisades_rocks_fort", PI, 6, 3); 190 wallStyles["palisades"]["cornerIn"] = new WallElement("cornerIn", "other/palisades_rocks_curve", 3*PI/4, 2.1, 0.7, PI/2); 191 wallStyles["palisades"]["cornerOut"] = new WallElement("cornerOut", "other/palisades_rocks_curve", 5*PI/4, 2.1, -0.7, -PI/2); 192 wallStyles["palisades"]["outpost"] = new WallElement("outpost", "other/palisades_rocks_outpost", PI, 0, -2); 193 wallStyles["palisades"]["house"] = new WallElement("house", "other/celt_hut", PI, 0, 5); 194 wallStyles["palisades"]["barracks"] = new WallElement("barracks", "other/celt_tavern", PI, 0, 5); 195 wallStyles["palisades"]["endRight"] = new WallElement("endRight", "other/palisades_rocks_end", -PI/2, 0.2); 196 wallStyles["palisades"]["endLeft"] = new WallElement("endLeft", "other/palisades_rocks_end", PI/2, 0.2); 182 197 183 // Add special wall style 'road' 198 // Add special wall style "road" 199 // NOTE: This is not a wall style in the common sense. Use with care! 200 wallStyles["road"] = {}; 201 wallStyles["road"]["short"] = new WallElement("road", "actor|props/special/eyecandy/road_temperate_short.xml", PI/2, 4.5); 202 wallStyles["road"]["long"] = new WallElement("road", "actor|props/special/eyecandy/road_temperate_long.xml", PI/2, 9.5); 203 wallStyles["road"]["cornerLeft"] = new WallElement("road", "actor|props/special/eyecandy/road_temperate_corner.xml", -PI/2, 4.5-2*1.25, 1.25, PI/2); // Correct width by -2*indent to fit xStraicht/corner 204 wallStyles["road"]["cornerRight"] = new WallElement("road", "actor|props/special/eyecandy/road_temperate_corner.xml", 0*PI, 4.5-2*1.25, -1.25, -PI/2); // Correct width by -2*indent to fit xStraicht/corner 205 wallStyles["road"]["curveLeft"] = new WallElement("road", "actor|props/special/eyecandy/road_temperate_curve_small.xml", -PI/2, 4.5+2*0.2, -0.2, PI/2); // Correct width by -2*indent to fit xStraicht/corner 206 wallStyles["road"]["curveRight"] = new WallElement("road", "actor|props/special/eyecandy/road_temperate_curve_small.xml", 0*PI, 4.5+2*0.2, 0.2, -PI/2); // Correct width by -2*indent to fit xStraicht/corner 207 wallStyles["road"]["start"] = new WallElement("road", "actor|props/special/eyecandy/road_temperate_end.xml", PI/2, 2); 208 wallStyles["road"]["end"] = new WallElement("road", "actor|props/special/eyecandy/road_temperate_end.xml", -PI/2, 2); 209 wallStyles["road"]["xStraight"] = new WallElement("road", "actor|props/special/eyecandy/road_temperate_intersect_x.xml", 0*PI, 4.5); 210 wallStyles["road"]["xLeft"] = new WallElement("road", "actor|props/special/eyecandy/road_temperate_intersect_x.xml", 0*PI, 4.5, 0, PI/2); 211 wallStyles["road"]["xRight"] = new WallElement("road", "actor|props/special/eyecandy/road_temperate_intersect_x.xml", 0*PI, 4.5, 0, -PI/2); 212 wallStyles["road"]["tLeft"] = new WallElement("road", "actor|props/special/eyecandy/road_temperate_intersect_T.xml", PI, 4.5, 1.25); 213 wallStyles["road"]["tRight"] = new WallElement("road", "actor|props/special/eyecandy/road_temperate_intersect_T.xml", 0*PI, 4.5, -1.25); 184 214 185 // Add special wall element collection 'other'215 // Add special wall element collection "other" 186 216 // NOTE: This is not a wall style in the common sense. Use with care! 187 wallStyles['other'] = {}; 188 wallStyles['other']['fence'] = new WallElement('fence', 'other/fence_long', -PI/2, 3.1); 189 wallStyles['other']['fence_short'] = new WallElement('fence_short', 'other/fence_short', -PI/2, 1.5); 190 wallStyles['other']['fence_stone'] = new WallElement('fence_stone', 'other/fence_stone', -PI/2, 2.5); 191 wallStyles['other']['palisade'] = new WallElement('palisade', 'other/palisades_rocks_short', 0, 1.2); 192 wallStyles['other']['column'] = new WallElement('column', 'other/column_doric', 0, 1); 193 wallStyles['other']['obelisk'] = new WallElement('obelisk', 'other/obelisk', 0, 2); 194 wallStyles['other']['spike'] = new WallElement('spike', 'other/palisades_angle_spike', -PI/2, 1); 195 wallStyles['other']['bench'] = new WallElement('bench', 'other/bench', PI/2, 1.5); 196 wallStyles['other']['benchForTable'] = new WallElement('benchForTable', 'other/bench', 0, 0.5); 197 wallStyles['other']['table'] = new WallElement('table', 'other/table_rectangle', 0, 1); 198 wallStyles['other']['table_square'] = new WallElement('table_square', 'other/table_square', PI/2, 1); 199 wallStyles['other']['flag'] = new WallElement('flag', 'special/rallypoint', PI, 1); 200 wallStyles['other']['standing_stone'] = new WallElement('standing_stone', 'gaia/special_ruins_standing_stone', PI, 1); 201 wallStyles['other']['settlement'] = new WallElement('settlement', 'gaia/special_settlement', PI, 6); 202 wallStyles['other']['gap'] = new WallElement('gap', undefined, 0, 2); 203 wallStyles['other']['gapSmall'] = new WallElement('gapSmall', undefined, 0, 1); 204 wallStyles['other']['gapLarge'] = new WallElement('gapLarge', undefined, 0, 4); 205 wallStyles['other']['cornerIn'] = new WallElement('cornerIn', undefined, 0, 0, 0, PI/2); 206 wallStyles['other']['cornerOut'] = new WallElement('cornerOut', undefined, 0, 0, 0, -PI/2); 217 wallStyles["other"] = {}; 218 wallStyles["other"]["fence"] = new WallElement("fence", "other/fence_long", -PI/2, 3.1); 219 wallStyles["other"]["fence_medium"] = new WallElement("fence", "other/fence_long", -PI/2, 3.1); 220 wallStyles["other"]["fence_short"] = new WallElement("fence_short", "other/fence_short", -PI/2, 1.5); 221 wallStyles["other"]["fence_stone"] = new WallElement("fence_stone", "other/fence_stone", -PI/2, 2.5); 222 wallStyles["other"]["palisade"] = new WallElement("palisade", "other/palisades_rocks_short", 0, 1.2); 223 wallStyles["other"]["column"] = new WallElement("column", "other/column_doric", 0, 1); 224 wallStyles["other"]["obelisk"] = new WallElement("obelisk", "other/obelisk", 0, 2); 225 wallStyles["other"]["spike"] = new WallElement("spike", "other/palisades_angle_spike", -PI/2, 1); 226 wallStyles["other"]["bench"] = new WallElement("bench", "other/bench", PI/2, 1.5); 227 wallStyles["other"]["benchForTable"] = new WallElement("benchForTable", "other/bench", 0, 0.5); 228 wallStyles["other"]["table"] = new WallElement("table", "other/table_rectangle", 0, 1); 229 wallStyles["other"]["table_square"] = new WallElement("table_square", "other/table_square", PI/2, 1); 230 wallStyles["other"]["flag"] = new WallElement("flag", "special/rallypoint", PI, 1); 231 wallStyles["other"]["standing_stone"] = new WallElement("standing_stone", "gaia/special_ruins_standing_stone", PI, 1); 232 wallStyles["other"]["settlement"] = new WallElement("settlement", "gaia/special_settlement", PI, 6); 233 wallStyles["other"]["gap"] = new WallElement("gap", undefined, 0, 2); 234 wallStyles["other"]["gapSmall"] = new WallElement("gapSmall", undefined, 0, 1); 235 wallStyles["other"]["gapLarge"] = new WallElement("gapLarge", undefined, 0, 4); 236 wallStyles["other"]["cornerIn"] = new WallElement("cornerIn", undefined, 0, 0, 0, PI/2); 237 wallStyles["other"]["cornerOut"] = new WallElement("cornerOut", undefined, 0, 0, 0, -PI/2); 207 238 208 239 209 /////////////////////////////////////////////////////// 210 // Setup data structure for some default fortress types 211 /////////////////////////////////////////////////////// 212 213 // A fortress type is just an instance of the fortress class with actually something in it. 214 // fortressTypes holds all the fortressess within an associative array while a fortress is associated with a descriptive string maching the map sizes, example: 'tiny', 'giant' 240 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 241 // fortressTypes data structure for some default fortress types 242 // 243 // A fortress type is just an instance of the Fortress class with actually something in it 244 // fortressTypes holds all the fortressess within an associative array with a descriptive string as key (e.g. maching the map size) 245 // Eexamples: "tiny", "veryLarge" 246 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 215 247 var fortressTypes = {}; 216 248 // Setup some default fortress types 217 // Add fortress type 'tiny'218 fortressTypes[ 'tiny'] = new Fortress('tiny');219 var wallPart = [ 'entry', 'wall', 'cornerIn', 'wall'];220 fortressTypes[ 'tiny'].wall = wallPart.concat(wallPart, wallPart, wallPart);221 // Add fortress type 'small'222 fortressTypes[ 'small'] = new Fortress('small');223 var wallPart = [ 'entry', 'endLeft', 'wall', 'cornerIn', 'wall', 'endRight'];224 fortressTypes[ 'small'].wall = wallPart.concat(wallPart, wallPart, wallPart);225 // Add fortress type 'medium'226 fortressTypes[ 'medium'] = new Fortress('medium');227 var wallPart = [ 'entry', 'endLeft', 'wall', 'outpost', 'wall',228 'cornerIn', 'wall', 'outpost', 'wall', 'endRight'];229 fortressTypes[ 'medium'].wall = wallPart.concat(wallPart, wallPart, wallPart);230 // Add fortress type 'normal'231 fortressTypes[ 'normal'] = new Fortress('normal');232 var wallPart = [ 'entry', 'endLeft', 'wall', 'tower', 'wall',233 'cornerIn', 'wall', 'tower', 'wall', 'endRight'];234 fortressTypes[ 'normal'].wall = wallPart.concat(wallPart, wallPart, wallPart);235 // Add fortress type 'large'236 fortressTypes[ 'large'] = new Fortress('large');237 var wallPart = [ 'entry', 'endLeft', 'wall', 'outpost', 'wall', 'cornerIn', 'wall',238 'cornerOut', 'wall', 'cornerIn', 'wall', 'outpost', 'wall', 'endRight'];239 fortressTypes[ 'large'].wall = wallPart.concat(wallPart, wallPart, wallPart);240 // Add fortress type 'veryLarge'241 fortressTypes[ 'veryLarge'] = new Fortress('veryLarge');242 var wallPart = [ 'entry', 'endLeft', 'wall', 'tower', 'wall', 'cornerIn', 'wall',243 'cornerOut', 'wall', 'cornerIn', 'wall', 'tower', 'wall', 'endRight'];244 fortressTypes[ 'veryLarge'].wall = wallPart.concat(wallPart, wallPart, wallPart);245 // Add fortress type 'giant'246 fortressTypes[ 'giant'] = new Fortress('giant');247 var wallPart = [ 'entry', 'endLeft', 'wall', 'outpost', 'wall', 'cornerIn', 'wall', 'outpost', 'wall',248 'cornerOut', 'wall', 'outpost', 'wall', 'cornerIn', 'wall', 'outpost', 'wall', 'endRight'];249 fortressTypes[ 'giant'].wall = wallPart.concat(wallPart, wallPart, wallPart);249 // Add fortress type "tiny" 250 fortressTypes["tiny"] = new Fortress("tiny"); 251 var wallPart = ["entry", "wall", "cornerIn", "wall"]; 252 fortressTypes["tiny"].wall = wallPart.concat(wallPart, wallPart, wallPart); 253 // Add fortress type "small" 254 fortressTypes["small"] = new Fortress("small"); 255 var wallPart = ["entry", "endLeft", "wall", "cornerIn", "wall", "endRight"]; 256 fortressTypes["small"].wall = wallPart.concat(wallPart, wallPart, wallPart); 257 // Add fortress type "medium" 258 fortressTypes["medium"] = new Fortress("medium"); 259 var wallPart = ["entry", "endLeft", "wall", "outpost", "wall", 260 "cornerIn", "wall", "outpost", "wall", "endRight"]; 261 fortressTypes["medium"].wall = wallPart.concat(wallPart, wallPart, wallPart); 262 // Add fortress type "normal" 263 fortressTypes["normal"] = new Fortress("normal"); 264 var wallPart = ["entry", "endLeft", "wall", "tower", "wall", 265 "cornerIn", "wall", "tower", "wall", "endRight"]; 266 fortressTypes["normal"].wall = wallPart.concat(wallPart, wallPart, wallPart); 267 // Add fortress type "large" 268 fortressTypes["large"] = new Fortress("large"); 269 var wallPart = ["entry", "endLeft", "wall", "outpost", "wall", "cornerIn", "wall", 270 "cornerOut", "wall", "cornerIn", "wall", "outpost", "wall", "endRight"]; 271 fortressTypes["large"].wall = wallPart.concat(wallPart, wallPart, wallPart); 272 // Add fortress type "veryLarge" 273 fortressTypes["veryLarge"] = new Fortress("veryLarge"); 274 var wallPart = ["entry", "endLeft", "wall", "tower", "wall", "cornerIn", "wall", 275 "cornerOut", "wall", "cornerIn", "wall", "tower", "wall", "endRight"]; 276 fortressTypes["veryLarge"].wall = wallPart.concat(wallPart, wallPart, wallPart); 277 // Add fortress type "giant" 278 fortressTypes["giant"] = new Fortress("giant"); 279 var wallPart = ["entry", "endLeft", "wall", "outpost", "wall", "cornerIn", "wall", "outpost", "wall", 280 "cornerOut", "wall", "outpost", "wall", "cornerIn", "wall", "outpost", "wall", "endRight"]; 281 fortressTypes["giant"].wall = wallPart.concat(wallPart, wallPart, wallPart); 250 282 251 // Add (some) iberian civ bonus fortress (The civ can still be set, just an uncommon default fortress) 252 var wall = ['gate', 'tower', 'wall', 'cornerIn', 'wallLong', 'tower', 253 'gate', 'tower', 'wallLong', 'cornerIn', 'wall', 'tower', 254 'gate', 'wall', 'cornerIn', 'wall', 'cornerOut', 'wall', 'cornerIn', 'wallLong', 'tower', 255 'gate', 'tower', 'wallLong', 'cornerIn', 'wall', 'tower', 'wall', 'cornerIn', 'wall']; 256 fortressTypes['iberCivBonus'] = new Fortress('iberCivBonus', wall); 257 var wall = ['gate', 'tower', 'wall', 'cornerIn', 'wall', 'cornerOut', 'wall', 'cornerIn', 'wallLong', 'tower', 258 'gate', 'tower', 'wallLong', 'cornerIn', 'wall', 'tower', 'wall', 'cornerIn', 'wall', 'cornerOut', 259 'gate', 'tower', 'wall', 'cornerIn', 'wallLong', 'tower', 260 'gate', 'tower', 'wallLong', 'cornerIn', 'wall', 'tower']; 261 fortressTypes['iberCivBonus2'] = new Fortress('iberCivBonus2', wall); 262 var wall = ['gate', 'tower', 'wall', 'cornerOut', 'wallShort', 'cornerIn', 'wall', 'cornerIn', 'wallLong', 'cornerIn', 'wallShort', 'cornerOut', 'wall', 'tower', 263 'gate', 'tower', 'wallLong', 'cornerIn', 'wallLong', 'cornerIn', 'wallShort', 'cornerOut', 264 'gate', 'tower', 'wall', 'cornerIn', 'wall', 'cornerOut', 'wallShort', 'cornerIn', 'wall', 'tower', 265 'gate', 'tower', 'wallShort', 'cornerIn', 'wall', 'tower', 'wallShort', 'tower']; 266 fortressTypes['iberCivBonus3'] = new Fortress('iberCivBonus3', wall); 267 268 269 // Setup some semi default fortresses for 'palisades' style 270 var fortressTypeKeys = ['tiny', 'small', 'medium', 'normal', 'large', 'veryLarge', 'giant']; 283 // Setup some better looking semi default fortresses for "palisades" style 284 var fortressTypeKeys = ["tiny", "small", "medium", "normal", "large", "veryLarge", "giant"]; 271 285 for (var i = 0; i < fortressTypeKeys.length; i++) 272 286 { 273 var newKey = fortressTypeKeys[i] + 'Palisades';287 var newKey = fortressTypeKeys[i] + "Palisades"; 274 288 var oldWall = fortressTypes[fortressTypeKeys[i]].wall; 275 fortressTypes[newKey] = new Fortress(newKey , []); // [] just to make sure it's an array though it's an array by default276 var fillTowersBetween = [ 'wall', 'endLeft', 'endRight', 'cornerIn', 'cornerOut'];289 fortressTypes[newKey] = new Fortress(newKey); 290 var fillTowersBetween = ["wall", "endLeft", "endRight", "cornerIn", "cornerOut"]; 277 291 for (var j = 0; j < oldWall.length; j++) 278 292 { 279 fortressTypes[newKey].wall.push(oldWall[j]); // Only works if the first element is an entry or gate (not in fillTowersBetween)293 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) 280 294 if (j+1 < oldWall.length) 281 if (fillTowersBetween.indexOf(oldWall[j]) > -1 && fillTowersBetween.indexOf(oldWall[j+1]) > -1) // ... > -1 means 'exists'here282 fortressTypes[newKey].wall.push( 'tower');295 if (fillTowersBetween.indexOf(oldWall[j]) > -1 && fillTowersBetween.indexOf(oldWall[j+1]) > -1) // ... > -1 means "exists" here 296 fortressTypes[newKey].wall.push("tower"); 283 297 } 284 298 } 285 299 300 // Setup some balanced (to civ type fortresses) semi default fortresses for "palisades" style 301 // TODO 286 302 287 /////////////////////////////////////////////////////////////////////////////// 288 // Define some helper functions: getWallAlignment, getWallCenter, getWallLength 289 /////////////////////////////////////////////////////////////////////////////// 303 // Add some "fortress types" for roads (will only work with style "road") 304 // ["start", "short", "xRight", "xLeft", "cornerLeft", "xStraight", "long", "xLeft", "xRight", "cornerRight", "tRight", "tLeft", "xRight", "xLeft", "curveLeft", "xStraight", "curveRight", "end"]; 305 var wall = ["short", "curveLeft", "short", "curveLeft", "short", "curveLeft", "short", "curveLeft"]; 306 fortressTypes["road01"] = new Fortress("road01", wall); 307 var wall = ["short", "cornerLeft", "short", "cornerLeft", "short", "cornerLeft", "short", "cornerLeft"]; 308 fortressTypes["road02"] = new Fortress("road02", wall); 309 var wall = ["xStraight", "curveLeft", "xStraight", "curveLeft", "xStraight", "curveLeft", "xStraight", "curveLeft"]; 310 fortressTypes["road03"] = new Fortress("road03", wall); 311 var wall = ["start", "curveLeft", "tRight", "cornerLeft", "tRight", "curveRight", "short", "xRight", "curveLeft", "xRight", "short", "cornerLeft", "tRight", "short", 312 "curveLeft", "short", "tRight", "cornerLeft", "short", "xRight", "curveLeft", "xRight", "short", "curveRight", "tRight", "cornerLeft", "tRight", "curveLeft", "end"]; 313 fortressTypes["road04"] = new Fortress("road04", wall); 314 var wall = ["start", "tLeft", "short", "xRight", 315 "curveLeft", "xRight", "tRight", "cornerLeft", "tRight", 316 "curveLeft", "short", "tRight", "cornerLeft", "xRight", 317 "cornerLeft", "xRight", "short", "tRight", "curveLeft", "end"]; 318 fortressTypes["road05"] = new Fortress("road05", wall); 290 319 291 // Get alignment of a wall 292 // Returns a list of lists of most arguments needed to place the different wall elements for a given wall 293 // Placing the first wall element at startX/startY placed with angle given by orientation 294 // An alignement can be used to get the center of a 'wall' (more likely used for closed walls like fortresses) with the getWallCenter function 320 321 /////////////////////////////// 322 // Define some helper functions 323 /////////////////////////////// 324 325 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 326 // getWallAlignment 327 // 328 // Returns a list of objects containing all information to place all the wall elements entities with placeObject (but the player ID) 329 // Placing the first wall element at startX/startY placed with an angle given by orientation 330 // An alignement can be used to get the "center" of a "wall" (more likely used for fortresses) with getCenterToFirstElement 331 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 295 332 function getWallAlignment(startX, startY, wall, style, orientation) 296 333 { 297 orientation = (orientation !== undefined) ? orientation : 0*PI;298 var alignment = [] 334 orientation = (orientation || 0); 335 var alignment = []; 299 336 var wallX = startX; 300 337 var wallY = startY; 301 338 for (var i = 0; i < wall.length; i++) 302 339 { 303 if (wallStyles[style][wall[i]] === undefined)304 warn('No valid wall element: ' + wall[i]);305 var element = wallStyles[style][wall[i]]340 var element = wallStyles[style][wall[i]]; 341 if (element === undefined && i == 0) 342 warn("No valid wall element: " + wall[i]); 306 343 // Indentation 307 344 var placeX = wallX - element.indent * cos(orientation); 308 345 var placeY = wallY - element.indent * sin(orientation); 309 // Add elementalignment310 alignment.push( [placeX, placeY, element.entity, orientation + element.angle]);346 // Add wall elements entity placement arguments to the alignment 347 alignment.push({"x": placeX, "y": placeY, "entity": element.entity, "angle":orientation + element.angle}); 311 348 // Preset vars for the next wall element 312 349 if (i+1 < wall.length) 313 350 { 314 351 orientation += element.bending; 315 if (wallStyles[style][wall[i+1]] === undefined)316 warn('No valid wall element: ' + wall[i+1]);317 352 var nextElement = wallStyles[style][wall[i+1]]; 353 if (nextElement === undefined) 354 warn("No valid wall element: " + wall[i+1]); 318 355 var distance = (element.width + nextElement.width)/2; 319 356 // Corrections for elements with indent AND bending 320 if (element.bending !== 0 && element.indent !== 0) 357 var indent = element.indent; 358 var bending = element.bending; 359 if (bending !== 0 && indent !== 0) 321 360 { 322 361 // Indent correction to adjust distance 323 distance += element.indent*sin(element.bending);362 distance += indent*sin(bending); 324 363 // Indent correction to normalize indentation 325 wallX += element.indent * cos(orientation);326 wallY += element.indent * sin(orientation);364 wallX += indent * cos(orientation); 365 wallY += indent * sin(orientation); 327 366 } 328 // Set the next coordinates of the next element in the wall (meaning without indentation adjustment)367 // Set the next coordinates of the next element in the wall without indentation adjustment 329 368 wallX -= distance * sin(orientation); 330 369 wallY += distance * cos(orientation); 331 370 } … … 333 372 return alignment; 334 373 } 335 374 336 // Get the center of a wall (mainly usefull for closed walls like fortresses) 337 // Center calculation works like getting the center of mass assuming all wall elements have the same 'waight' 338 // It returns the vector (array [x, y]) from the first wall element to the center 339 function getWallCenter(alignment) 375 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 376 // getCenterToFirstElement 377 // 378 // Center calculation works like getting the center of mass assuming all wall elements have the same "weight" 379 // 380 // It returns the vector from the center to the first wall element 381 // Used to get centerToFirstElement of fortresses by default 382 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 383 function getCenterToFirstElement(alignment) 340 384 { 341 var x = 0; 342 var y = 0; 385 var centerToFirstElement = {"x": 0, "y": 0}; 343 386 for (var i = 0; i < alignment.length; i++) 344 387 { 345 x += alignment[i][0]/alignment.length;346 y += alignment[i][1]/alignment.length;388 centerToFirstElement.x -= alignment[i].x/alignment.length; 389 centerToFirstElement.y -= alignment[i].y/alignment.length; 347 390 } 348 var center = [x, y]; 349 return center; 391 return centerToFirstElement; 350 392 } 351 393 352 // Get the length of a wall used by placeIrregularPolygonalWall 353 // NOTE: Does not support bending wall elements like corners! 394 ////////////////////////////////////////////////////////////////// 395 // getWallLength 396 // 397 // NOTE: Does not support bending wall elements like corners! 398 // e.g. used by placeIrregularPolygonalWall 399 ////////////////////////////////////////////////////////////////// 354 400 function getWallLength(wall, style) 355 401 { 356 402 var length = 0; … … 366 412 // Define the different wall placer functions 367 413 ///////////////////////////////////////////// 368 414 369 ///////////////////////////////////////////////////////////////////////////////// 370 // Place simple wall starting with the first wall element placed at startX/startY 371 ///////////////////////////////////////////////////////////////////////////////// 372 // orientation: 0 means 'outside' or 'front' of the wall is right (positive X) like placeObject 373 // It will then be build towards top (positive Y) if no bending wall elements like corners are used 374 // Raising orientation means the wall is rotated counter-clockwise like placeObject 415 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 416 // placeWall 417 // 418 // Places a wall with wall elements attached to another like determined by WallElement properties. 419 // 420 // startX, startY Where the first wall element should be placed 421 // wall Array of wall element type strings. Example: ["endLeft", "wallLong", "tower", "wallLong", "endRight"] 422 // style Optional. Wall style string. Default is the civ of the given player, "palisades" for gaia 423 // playerId Optional. Number of the player the wall will be placed for. Default is 0 (gaia) 424 // orientation Optional. Angle the first wall element is placed. Default is 0 425 // 0 means "outside" or "front" of the wall is right (positive X) like placeObject 426 // It will then be build towards top/positive Y (if no bending wall elements like corners are used) 427 // Raising orientation means the wall is rotated counter-clockwise like placeObject 428 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 375 429 function placeWall(startX, startY, wall, style, playerId, orientation) 376 430 { 431 // Setup optional arguments 432 playerId = (playerId || 0); 433 if (playerId == 0) 434 style = (style || "palisades"); 435 else 436 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 437 orientation = (orientation || 0); 438 // Get wall alignment 377 439 var AM = getWallAlignment(startX, startY, wall, style, orientation); 440 // Place the wall 378 441 for (var iWall = 0; iWall < wall.length; iWall++) 379 442 { 380 if (AM[iWall][2] !== undefined) 381 placeObject(AM[iWall][0], AM[iWall][1], AM[iWall][2], playerId, AM[iWall][3]); 443 var entity = AM[iWall].entity; 444 if (entity !== undefined) 445 placeObject(AM[iWall].x, AM[iWall].y, entity, playerId, AM[iWall].angle); 382 446 } 383 447 } 384 448 385 ////////////////////////////////////////////////////////////////////////////////////////////////// 386 // Place a fortress (mainly a closed wall build like placeWall) with the center at centerX/centerY 387 ////////////////////////////////////////////////////////////////////////////////////////////////// 388 // Should always start with the main entrance (like 'entry' or 'gate') to get the orientation right (like placeObject) 389 function placeCustomFortress(centerX, centerY, fortress, style, playerId, orientation, scipGetCenter) 449 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 450 // placeCustomFortress 451 // 452 // Place a fortress (mainly a closed wall build like placeWall) centered at centerX/centerY 453 // The fortress wall should always start with the main entrance (like "entry" or "gate") to get the orientation right (like placeObject) 454 // 455 // fortress An instance of Fortress with a wall defined 456 // style Optional. Wall style string. Default is the civ of the given player, "palisades" for gaia 457 // playerId Optional. Number of the player the wall will be placed for. Default is 0 (gaia) 458 // orientation Optional. Angle the first wall element (should be a gate or entrance) is placed. Default is 0 459 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 460 function placeCustomFortress(centerX, centerY, fortress, style, playerId, orientation) 390 461 { 391 if (!scipGetCenter) 392 { 393 var alignment = getWallAlignment(0, 0, fortress.wall, style); 394 var center = getWallCenter(alignment); 395 var startX = centerX - center[0] * cos(orientation) + center[1] * sin(orientation); 396 var startY = centerY - center[1] * cos(orientation) - center[0] * sin(orientation); 397 } 462 // Setup optional arguments 463 fortress = (fortress || fortressTypes["tiny"]); 464 playerId = (playerId || 0); 465 if (playerId == 0) 466 style = (style || "palisades"); 398 467 else 399 { 400 var startX = centerX + fortress.center[0]; 401 var startY = centerY + fortress.center[1]; 402 } 468 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 469 orientation = (orientation || 0); 470 // Calculate center if fortress.centerToFirstElement is undefined (default) 471 var centerToFirstElement = fortress.centerToFirstElement; 472 if (centerToFirstElement === undefined) 473 centerToFirstElement = getCenterToFirstElement(getWallAlignment(0, 0, fortress.wall, style)); 474 // Placing the fortress wall 475 var startX = centerX + centerToFirstElement.x * cos(orientation) - centerToFirstElement.y * sin(orientation); 476 var startY = centerY + centerToFirstElement.y * cos(orientation) + centerToFirstElement.x * sin(orientation); 403 477 placeWall(startX, startY, fortress.wall, style, playerId, orientation) 404 478 } 405 479 406 function placeFortress(centerX, centerY, type, style, playerId, orientation, scipGetCenter) 480 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 481 // placeFortress 482 // 483 // Like placeCustomFortress just it takes type (a fortress type string, has to be in fortressTypes) instead of an instance of Fortress 484 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 485 function placeFortress(centerX, centerY, type, style, playerId, orientation) 407 486 { 408 placeCustomFortress(centerX, centerY, fortressTypes[type], style, playerId, orientation, scipGetCenter); 487 // Setup optional arguments 488 type = (type || "tiny"); 489 playerId = (playerId || 0); 490 if (playerId == 0) 491 style = (style || "palisades"); 492 else 493 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 494 orientation = (orientation || 0); 495 // Call placeCustomFortress with the given arguments 496 placeCustomFortress(centerX, centerY, fortressTypes[type], style, playerId, orientation); 409 497 } 410 498 411 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 412 // Place a linear wall of repeatant wall elements given in the argument wallPart from startX/startY to targetX/targetY 413 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 414 // startX: x coordinate of the beginning of the wall 415 // startY: y coordinate of the beginning of the wall 416 // targetX: x coordinate of the ending of the wall 417 // targetY: y coordinate of the ending of the wall 418 // NOTE: Start and target coordinates are exact (besides the scale offset) meaning the wall will begin/end at the given coordinates (not the first/last entity is placed there) 419 // wallPart: Optional. An array of wall element type strings (see WallElement.type). Default is ['wall'] 420 // NOTE: Don't use wall elements with bending like corners! 421 // style: Optional. An wall style string (like defined in the 'wallStyles' dictionary). Default is 'palisades' 422 // playerId: Optional. The walls owners player ID (like in the function 'placeObject' so 0 is gaia, 1 is the first player), Default is 0 (gaia) 423 // endWithFirst: Optional. A boolean value. If true the 1st wall element in the wallPart array will finalize the wall. Default is true 499 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 500 // placeLinearWall 501 // 502 // Places a straight wall from a given coordinate to an other repeatant using the wall parts. 503 // 504 // startX/startY Coordinate of the approximate beginning of the wall (Not the place of the first wall element) 505 // targetX/targetY Coordinate of the approximate ending of the wall (Not the place of the last wall element) 506 // wallPart Optional. An array of NON-BENDING wall element type strings. Default is ["tower", "wallLong"] 507 // style Optional. Wall style string. Default is the civ of the given player, "palisades" for gaia 508 // playerId Optional. Integer number of the player. Default is 0 (gaia) 509 // endWithFirst Optional. A boolean value. If true the 1st wall element in the wallPart array will finalize the wall. Default is true 510 // 511 // TODO: Maybe add angle offset for more generic looking? 512 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 424 513 function placeLinearWall(startX, startY, targetX, targetY, wallPart, style, playerId, endWithFirst) 425 514 { 426 515 // Setup optional arguments to the default 427 wallPart = (wallPart || ['wall']); 428 style = (style || 'palisades'); 516 wallPart = (wallPart || ["tower", "wallLong"]); 429 517 playerId = (playerId || 0); 430 // endWithFirst = (endWithFirst || true); 431 endWithFirst = typeof endWithFirst == 'undefined' ? true : endWithFirst; 518 if (playerId == 0) 519 style = (style || "palisades"); 520 else 521 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 522 endWithFirst = typeof endWithFirst == "undefined" ? true : endWithFirst; 432 523 // Check arguments 433 524 for (var elementIndex = 0; elementIndex < wallPart.length; elementIndex++) 434 if (wallStyles[style][wallPart[elementIndex]].bending != 0) 525 { 526 var bending = wallStyles[style][wallPart[elementIndex]].bending; 527 if (bending != 0) 435 528 warn("Bending is not supported by placeLinearWall but a bending wall element is used: " + wallPart[elementIndex] + " -> wallStyles[style][wallPart[elementIndex]].entity"); 529 } 436 530 // Setup number of wall parts 437 531 var totalLength = getDistance(startX, startY, targetX, targetY); 438 532 var wallPartLength = 0; … … 440 534 wallPartLength += wallStyles[style][wallPart[elementIndex]].width; 441 535 var numParts = 0; 442 536 if (endWithFirst == true) 443 numParts = ceil((totalLength - wallStyles[style][wallPart[0]].width) / wallPartLength) 537 numParts = ceil((totalLength - wallStyles[style][wallPart[0]].width) / wallPartLength); 444 538 else 445 539 numParts = ceil(totalLength / wallPartLength); 446 540 // Setup scale factor 447 541 var scaleFactor = 1; 448 542 if (endWithFirst == true) 449 scaleFactor = totalLength / (numParts * wallPartLength + wallStyles[style][wallPart[0]].width) 543 scaleFactor = totalLength / (numParts * wallPartLength + wallStyles[style][wallPart[0]].width); 450 544 else 451 545 scaleFactor = totalLength / (numParts * wallPartLength); 452 546 // Setup angle 453 var wallAngle = getAngle(startX, startY, targetX, targetY); // NOTE: function 'getAngle()'is about to be changed...547 var wallAngle = getAngle(startX, startY, targetX, targetY); // NOTE: function "getAngle()" is about to be changed... 454 548 var placeAngle = wallAngle - PI/2; 455 549 // Place wall entities 456 550 var x = startX; … … 467 561 var placeX = x - wallEle.indent * sin(wallAngle); 468 562 var placeY = y + wallEle.indent * cos(wallAngle); 469 563 // Placement 470 if (wallEle.entity !== undefined) 471 placeObject(placeX, placeY, wallEle.entity, playerId, placeAngle + wallEle.angle); 564 var entity = wallEle.entity; 565 if (entity !== undefined) 566 placeObject(placeX, placeY, entity, playerId, placeAngle + wallEle.angle); 472 567 x += scaleFactor * wallEle.width/2 * cos(wallAngle); 473 568 y += scaleFactor * wallEle.width/2 * sin(wallAngle); 474 569 } … … 478 573 var wallEle = wallStyles[style][wallPart[0]]; 479 574 x += scaleFactor * wallEle.width/2 * cos(wallAngle); 480 575 y += scaleFactor * wallEle.width/2 * sin(wallAngle); 481 if (wallEle.entity !== undefined) 482 placeObject(x, y, wallEle.entity, playerId, placeAngle + wallEle.angle); 576 var entity = wallEle.entity; 577 if (entity !== undefined) 578 placeObject(x, y, entity, playerId, placeAngle + wallEle.angle); 483 579 } 484 580 } 485 581 486 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 487 // Place a circular wall of repeatant wall elements given in the argument wallPart arround centerX/centerY with the given radius 488 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 489 // The wall is not necessarily closed depending on the optional argument maxAngle (better name?) 490 // NOTE: Don't use wall elements with bending like corners! 491 // Todo: add eccentricity 582 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 583 // placeCircularWall 584 // 585 // Place a circular wall of repeatant wall elements given in the argument wallPart arround centerX/centerY with the given radius 586 // The wall can be opend forming more an arc than a circle if maxAngle < 2*PI 587 // The orientation then determines where this open part faces (0 means right like unrotated building's droppoints) 588 // 589 // centerX/Y Coordinates of the circle's center 590 // radius How wide the circle should be (aproximate, especially if maxBendOff != 0) 591 // wallPart Optional. An array of NON-BENDING wall element type strings. Default is ["tower", "wallLong"] 592 // style Optional. Wall style string. Default is the civ of the given player, "palisades" for gaia 593 // playerId Optional. Integer number of the player. Default is 0 (gaia) 594 // orientation Optional. Where the open part of the (circular) arc should face (if maxAngle is < 2*PI). Default is 0 595 // maxAngle Optional. How far the wall should circumvent the center. Default is 2*PI (full circle) 596 // endWithFirst Optional. Boolean. If true the 1st wall element in the wallPart array will finalize the wall. Default is false for full circles, else true 597 // maxBendOff Optional. How irregular the circle should be. 0 means regular circle, PI/2 means very irregular. Default is 0 (regular circle) 598 // 599 // NOTE: Don't use wall elements with bending like corners! 600 // TODO: Perhaps add eccentricity and maxBendOff functionality (untill now an unused argument) 601 // TODO: Perhaps add functionality for spirals 602 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 492 603 function placeCircularWall(centerX, centerY, radius, wallPart, style, playerId, orientation, maxAngle, endWithFirst, maxBendOff) 493 604 { 494 605 // Setup optional arguments to the default 495 wallPart = (wallPart || ['wall']); 496 style = (style || 'palisades'); 606 wallPart = (wallPart || ["tower", "wallLong"]); 497 607 playerId = (playerId || 0); 608 if (playerId == 0) 609 style = (style || "palisades"); 610 else 611 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 498 612 orientation = (orientation || 0); 499 613 maxAngle = (maxAngle || 2*PI); 500 614 if (endWithFirst === undefined) 501 615 { 502 616 if (maxAngle >= 2*PI - 0.001) // Can this be done better? 503 {504 617 endWithFirst = false; 505 }506 618 else 507 {508 619 endWithFirst = true; 509 }510 620 } 511 621 maxBendOff = (maxBendOff || 0); 512 622 // Check arguments 513 623 if (maxBendOff > PI/2 || maxBendOff < 0) 514 warn( 'placeCircularWall maxBendOff sould satisfy 0 < maxBendOff < PI/2 (~1.5) but it is: '+ maxBendOff);624 warn("placeCircularWall maxBendOff sould satisfy 0 < maxBendOff < PI/2 (~1.5) but it is: " + maxBendOff); 515 625 for (var elementIndex = 0; elementIndex < wallPart.length; elementIndex++) 516 if (wallStyles[style][wallPart[elementIndex]].bending != 0) 626 { 627 var bending = wallStyles[style][wallPart[elementIndex]].bending; 628 if (bending != 0) 517 629 warn("Bending is not supported by placeCircularWall but a bending wall element is used: " + wallPart[elementIndex]); 630 } 518 631 // Setup number of wall parts 519 632 var totalLength = maxAngle * radius; 520 633 var wallPartLength = 0; … … 532 645 // Setup scale factor 533 646 var scaleFactor = 1; 534 647 if (endWithFirst == true) 535 scaleFactor = totalLength / (numParts * wallPartLength + wallStyles[style][wallPart[0]].width) 648 scaleFactor = totalLength / (numParts * wallPartLength + wallStyles[style][wallPart[0]].width); 536 649 else 537 650 scaleFactor = totalLength / (numParts * wallPartLength); 538 651 // Place wall entities … … 555 668 placeX -= wallEle.indent * cos(placeAngle); 556 669 placeY -= wallEle.indent * sin(placeAngle); 557 670 // Placement 558 if (wallEle.entity !== undefined) 559 placeObject(placeX, placeY, wallEle.entity, playerId, placeAngle + wallEle.angle); 671 var entity = wallEle.entity; 672 if (entity !== undefined) 673 placeObject(placeX, placeY, entity, playerId, placeAngle + wallEle.angle); 560 674 // Prepare for the next wall element 561 675 actualAngle += addAngle; 562 676 x = centerX + radius*cos(actualAngle); … … 577 691 } 578 692 579 693 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 580 // Place a polygonal wall of repeatant wall elements given in the argument wallPart arround centerX/centerY with the given radius 694 // placePolygonalWall 695 // 696 // Place a polygonal wall of repeatant wall elements given in the argument wallPart arround centerX/centerY with the given radius 697 // 698 // centerX/Y Coordinates of the polygon's center 699 // radius How wide the circle should be in wich the polygon fits 700 // wallPart Optional. An array of NON-BENDING wall element type strings. Default is ["wallLong", "tower"] 701 // cornerWallElement Optional. Wall element to be placed at the polygon's corners. Default is "tower" 702 // style Optional. Wall style string. Default is the civ of the given player, "palisades" for gaia 703 // playerId Optional. Integer number of the player. Default is 0 (gaia) 704 // orientation Optional. Angle from the center to the first linear wall part placed. Default is 0 (towards positive X/right) 705 // numCorners Optional. How many corners the polygon will have. Default is 8 (matching a civ centers territory) 706 // skipFirstWall Optional. Boolean. If the first linear wall part will be left opened as entrance. Default is true 707 // 708 // NOTE: Don't use wall elements with bending like corners! 709 // TODO: Replace skipFirstWall with firstWallPart to enable gate/defended entrance placement 710 // TODO: Check some arguments 711 // TODO: Add eccentricity and perhaps make it just call placeIrregularPolygonalWall with irregularity = 0 581 712 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 582 // NOTE: Don't use wall elements with bending like corners!583 // TODO: Check some arguments584 // TODO: Add eccentricity and irregularity (how far the corners can differ from a regulare convex poygon)585 713 function placePolygonalWall(centerX, centerY, radius, wallPart, cornerWallElement, style, playerId, orientation, numCorners, skipFirstWall) 586 714 { 587 715 // Setup optional arguments to the default 588 wallPart = (wallPart || ['wall']); 589 cornerWallElement = (cornerWallElement || 'tower'); // Don't use wide elements for this. Not supported well... 590 style = (style || 'palisades'); 716 wallPart = (wallPart || ["wallLong", "tower"]); 717 cornerWallElement = (cornerWallElement || "tower"); // Don't use wide elements for this. Not supported well... 591 718 playerId = (playerId || 0); 719 if (playerId == 0) 720 style = (style || "palisades"); 721 else 722 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 592 723 orientation = (orientation || 0); 593 724 numCorners = (numCorners || 8); 594 skipFirstWall = (skipFirstWall || false);725 skipFirstWall = (skipFirstWall || true); 595 726 // Setup angles 596 727 var angleAdd = 2*PI/numCorners; 597 728 var angleStart = orientation - angleAdd/2; … … 618 749 } 619 750 620 751 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 621 // Place an irregular polygonal wall of some wall parts to choose from arround centerX/centerY with the given radius 752 // placeIrregularPolygonalWall 753 // 754 // Place an irregular polygonal wall of some wall parts to choose from arround centerX/centerY with the given radius 755 // 756 // centerX/Y Coordinates of the polygon's center 757 // radius How wide the circle should be in wich the polygon fits 758 // cornerWallElement Optional. Wall element to be placed at the polygon's corners. Default is "tower" 759 // style Optional. Wall style string. Default is the civ of the given player, "palisades" for gaia 760 // playerId Optional. Integer number of the player. Default is 0 (gaia) 761 // orientation Optional. Angle from the center to the first linear wall part placed. Default is 0 (towards positive X/right) 762 // numCorners Optional. How many corners the polygon will have. Default is 8 (matching a civ centers territory) 763 // irregularity Optional. How irregular the polygon will be. 0 means regular, 1 means VERY irregular. Default is 0.5 764 // skipFirstWall Optional. Boolean. If the first linear wall part will be left opened as entrance. Default is true 765 // wallPartsAssortment Optional. An array of wall part arrays to choose from for each linear wall connecting the corners. Default is hard to decribe ^^ 766 // 767 // NOTE: wallPartsAssortment is put to the end because it's hardest to set 768 // NOTE: Don't use wall elements with bending like corners! 769 // TODO: Replace skipFirstWall with firstWallPart to enable gate/defended entrance placement 770 // TODO: Check some arguments 771 // TODO: Perhaps add eccentricity 622 772 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 623 // NOTE: Under construction!!!624 // NOTE: wallPartList is put to the end because it's hardest to set625 // NOTE: Don't use wall elements with bending like corners!626 // TODO: Check some arguments627 // TODO: Add eccentricity and irregularity (how far the corners can differ from a regulare convex poygon)628 773 function placeIrregularPolygonalWall(centerX, centerY, radius, cornerWallElement, style, playerId, orientation, numCorners, irregularity, skipFirstWall, wallPartsAssortment) 629 774 { 775 // Setup optional arguments 776 playerId = (playerId || 0); 777 if (playerId == 0) 778 style = (style || "palisades"); 779 else 780 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 630 781 // Generating a generic wall part assortment with each wall part including 1 gate enlengthend by walls and towers 631 782 // NOTE: It might be a good idea to write an own function for that... 632 var defaultWallPartsAssortment = [[ 'wallShort'], ['wall'], ['wallLong'], ['gate', 'tower', 'wallShort']];633 var centeredWallPart = [ 'gate']; // NOTE: Since gates are not functional yet entrys are used instead...634 var extandingWallPartAssortment = [[ 'tower', 'wallLong'], ['tower', 'wall']];635 defaultWallPartsAssortment.push(centeredWallPart) 783 var defaultWallPartsAssortment = [["wallShort"], ["wall"], ["wallLong"], ["gate", "tower", "wallShort"]]; 784 var centeredWallPart = ["gate"]; // NOTE: Since gates are not functional yet entrys are used instead... 785 var extandingWallPartAssortment = [["tower", "wallLong"], ["tower", "wall"]]; 786 defaultWallPartsAssortment.push(centeredWallPart); 636 787 for (var i = 0; i < extandingWallPartAssortment.length; i++) 637 788 { 638 789 var wallPart = centeredWallPart; … … 651 802 } 652 803 // Setup optional arguments to the default 653 804 wallPartsAssortment = (wallPartsAssortment || defaultWallPartsAssortment); 654 cornerWallElement = (cornerWallElement || 'tower'); // Don't use wide elements for this. Not supported well...655 style = (style || 'palisades');805 cornerWallElement = (cornerWallElement || "tower"); // Don't use wide elements for this. Not supported well... 806 style = (style || "palisades"); 656 807 playerId = (playerId || 0); 657 808 orientation = (orientation || 0); 658 809 numCorners = (numCorners || randInt(5, 7)); … … 674 825 { 675 826 corners.push([centerX + radius*cos(angleActual), centerY + radius*sin(angleActual)]); 676 827 if (i < numCorners - 1) 677 angleActual += angleAddList[i+1] 828 angleActual += angleAddList[i+1]; 678 829 } 679 830 // Setup best wall parts for the different walls (a bit confusing naming...) 680 831 var wallPartLengths = []; 681 832 var maxWallPartLength = 0; 682 833 for (var partIndex = 0; partIndex < wallPartsAssortment.length; partIndex++) 683 834 { 835 var length = wallPartLengths[partIndex]; 684 836 wallPartLengths.push(getWallLength(wallPartsAssortment[partIndex], style)); 685 if ( wallPartLengths[partIndex]> maxWallPartLength)686 maxWallPartLength = wallPartLengths[partIndex];837 if (length > maxWallPartLength) 838 maxWallPartLength = length; 687 839 } 688 840 var wallPartList = []; // This is the list of the wall parts to use for the walls between the corners, not to confuse with wallPartsAssortment! 689 841 for (var i = 0; i < numCorners; i++) … … 691 843 var bestWallPart = []; // This is a simpel wall part not a wallPartsAssortment! 692 844 var bestWallLength = 99999999; 693 845 // NOTE: This is not exsactly like the length the wall will be in the end. Has to be tweeked... 694 var wallLength = getDistance(corners[i][0], corners[i][1], corners[(i+1)%numCorners][0], corners[(i+1)%numCorners][1]) 846 var wallLength = getDistance(corners[i][0], corners[i][1], corners[(i+1)%numCorners][0], corners[(i+1)%numCorners][1]); 695 847 var numWallParts = ceil(wallLength/maxWallPartLength); 696 848 for (var partIndex = 0; partIndex < wallPartsAssortment.length; partIndex++) 697 849 { 698 if (numWallParts*wallPartLengths[partIndex] < bestWallLength && numWallParts*wallPartLengths[partIndex] > wallLength) 850 var linearWallLength = numWallParts*wallPartLengths[partIndex]; 851 if (linearWallLength < bestWallLength && linearWallLength > wallLength) 699 852 { 700 853 bestWallPart = wallPartsAssortment[partIndex]; 701 bestWallLength = numWallParts*wallPartLengths[partIndex];854 bestWallLength = linearWallLength; 702 855 } 703 856 } 704 wallPartList.push(bestWallPart) 857 wallPartList.push(bestWallPart); 705 858 } 706 859 // Place Corners and walls 707 860 for (var i = 0; i < numCorners; i++) … … 721 874 } 722 875 } 723 876 724 // Just a test function, USE WITH CARE! 725 // radius: A float seting the aproximate radius of the fortress 726 // maxBendOff: Optional, The maximum random bending offset of the wall elements NOTE: If maxBendOff > PI/2 the wall might never close!!! 727 // wallPart: Optional, An array of wall element string, example: ["tower", "wall"] NOTE: Don't use wall elements with bending!!! 728 function placeGenericFortress(centerX, centerY, radius, playerId, wallPart, style, maxBendOff) 877 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 878 // placeGenericFortress 879 // 880 // Places a generic fortress with towers at the edges connected with long walls and gates (entries untill gates work) 881 // This is the default Iberian civ bonus starting wall 882 // 883 // centerX/Y The aproximate center coordinates of the fortress 884 // radius The approximate radius of the wall to be placed 885 // playerId Optional. Integer number of the player. Default is 0 (gaia) 886 // style Optional. Wall style string. Default is the civ of the given player, "palisades" for gaia 887 // irregularity Optional. Float between 0 (circle) and 1 (very spiky), default is 1/2 888 // gateOccurence Optional. Integer number, every n-th walls will be a gate instead. Default is 3 889 // maxTrys Optional. How often the function tries to find a better fitting shape at max. Default is 100 890 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 891 function placeGenericFortress(centerX, centerY, radius, playerId, style, irregularity, gateOccurence, maxTrys) 729 892 { 730 if (wallPart == undefined) 731 wallPart = ['tower', 'wall', 'tower', 'entry', 'tower', 'wall']; 732 if (maxBendOff > PI/2 || maxBendOff < 0) 733 warn("setGenericFortress maxBendOff sould satisfy 0 < maxBendOff < PI/2 (~1.5) but it is: " + maxBendOff); 734 if (maxBendOff === undefined) 735 maxBendOff = 0; 736 var wallLength = 0; 737 for (var eleIndex = 0; eleIndex < wallPart.length; eleIndex++) 893 // Setup optional arguments 894 radius = (radius || 20); 895 playerId = (playerId || 0); 896 if (playerId == 0) 897 style = (style || "palisades"); 898 else 899 style = (style || g_MapSettings.PlayerData[playerId-1].Civ); 900 irregularity = (irregularity || 1/2); 901 gateOccurence = (gateOccurence || 3); 902 maxTrys = (maxTrys || 100); 903 // Setup some vars 904 var startAngle = randFloat(0, 2*PI); 905 var actualOffX = radius*cos(startAngle); 906 var actualOffY = radius*sin(startAngle); 907 var actualAngle = startAngle; 908 var pointDistance = wallStyles[style]["wallLong"].width + wallStyles[style]["tower"].width; 909 // Searching for a well fitting point derivation 910 var tries = 0; 911 var bestPointDerivation = undefined; 912 var minOverlap = 1000; 913 var overlap = undefined; 914 while (tries < maxTrys && minOverlap > wallStyles[style]["tower"].width / 10) 738 915 { 739 wallLength += wallStyles[style][wallPart[eleIndex]].width 916 var pointDerivation = []; 917 var distanceToTarget = 1000; 918 var targetReached = false; 919 while (!targetReached) 920 { 921 var indent = randFloat(-irregularity*pointDistance, irregularity*pointDistance); 922 var tmpAngle = getAngle(actualOffX, actualOffY, 923 (radius + indent)*cos(actualAngle + (pointDistance / radius)), 924 (radius + indent)*sin(actualAngle + (pointDistance / radius))); 925 actualOffX += pointDistance*cos(tmpAngle); 926 actualOffY += pointDistance*sin(tmpAngle); 927 actualAngle = getAngle(0, 0, actualOffX, actualOffY); 928 pointDerivation.push([actualOffX, actualOffY]); 929 distanceToTarget = getDistance(actualOffX, actualOffY, pointDerivation[0][0], pointDerivation[0][1]); 930 var numPoints = pointDerivation.length; 931 if (numPoints > 3 && distanceToTarget < pointDistance) // Could be done better... 932 { 933 targetReached = true; 934 overlap = pointDistance - getDistance(pointDerivation[numPoints - 1][0], pointDerivation[numPoints - 1][1], pointDerivation[0][0], pointDerivation[0][1]); 935 if (overlap < minOverlap) 936 { 937 minOverlap = overlap; 938 bestPointDerivation = pointDerivation; 939 } 940 } 941 } 942 tries++; 740 943 } 741 if (wallLength > 2*PI*radius || wallLength <= 0) 742 warn("setGenericFortress: sum of the width of wall's elements should satisfy 0 < total length < 2*PI*radius but: radius = " + radius + ", wallPart = " + wallPart + " with total length of " + wallLength); 743 744 var minEleWidth = 1000000; // Assuming the smallest element is about as wide as deep. 745 for (var eleIndex = 0; eleIndex < wallPart.length; eleIndex++) 944 log("placeGenericFortress: Reduced overlap to " + minOverlap + " after " + tries + " tries"); 945 // Place wall 946 for (var pointIndex = 0; pointIndex < bestPointDerivation.length; pointIndex++) 746 947 { 747 eleWidth = wallStyles[style][wallPart[eleIndex]].width; 748 if (eleWidth < minEleWidth) 749 minEleWidth = eleWidth; 948 var startX = centerX + bestPointDerivation[pointIndex][0]; 949 var startY = centerY + bestPointDerivation[pointIndex][1]; 950 var targetX = centerX + bestPointDerivation[(pointIndex + 1) % bestPointDerivation.length][0]; 951 var targetY = centerY + bestPointDerivation[(pointIndex + 1) % bestPointDerivation.length][1]; 952 var angle = getAngle(startX, startY, targetX, targetY); 953 var wallElement = "wallLong"; 954 if ((pointIndex + 1) % gateOccurence == 0) 955 wallElement = "entry"; // Has to be changed to "gate" if gates work... 956 var entity = wallStyles[style][wallElement].entity; 957 if (entity) 958 { 959 placeObject(startX + (getDistance(startX, startY, targetX, targetY)/2)*cos(angle), // placeX 960 startY + (getDistance(startX, startY, targetX, targetY)/2)*sin(angle), // placeY 961 entity, playerId, angle - PI/2 + wallStyles[style][wallElement].angle); 962 } 963 // Place tower 964 var startX = centerX + bestPointDerivation[(pointIndex + bestPointDerivation.length - 1) % bestPointDerivation.length][0]; 965 var startY = centerY + bestPointDerivation[(pointIndex + bestPointDerivation.length - 1) % bestPointDerivation.length][1]; 966 var angle = getAngle(startX, startY, targetX, targetY); 967 placeObject(centerX + bestPointDerivation[pointIndex][0], centerY + bestPointDerivation[pointIndex][1], wallStyles[style]["tower"].entity, playerId, angle - PI/2 + wallStyles[style]["tower"].angle); 750 968 } 751 var widthSafty = minEleWidth/4; // Can be done better...752 753 var x = radius;754 var y = 0;755 var angle = 0;756 var targetX = radius;757 var targetY = 0;758 var targetReached = false;759 var eleIndex = 0;760 while (targetReached == false)761 {762 var wallElement = wallStyles[style][wallPart[eleIndex % wallPart.length]];763 var eleWidth = wallElement.width - widthSafty;764 // Stabalized bendOff765 var actualRadius = getDistance(centerX, centerY, centerX + x, centerY + y);766 var bendOff = randFloat(-maxBendOff*radius/actualRadius, maxBendOff*actualRadius/radius);767 // Element width in radians768 var eleAngleWidth = eleWidth*cos(bendOff) / radius; // A/L = da/dl -> da = A * dl / L -> da = 2*PI * eleWidth / (2*PI * radius) -> da = eleWidth/radius769 var eleAngle = angle + eleAngleWidth/2 + bendOff;770 var placeX = x - eleWidth/2 * sin(eleAngle);771 var placeY = y + eleWidth/2 * cos(eleAngle);772 if (wallElement.entity)773 placeObject(centerX + placeX, centerY + placeY, wallElement.entity, playerId, eleAngle + wallElement.angle);774 x = placeX - eleWidth/2 * sin(eleAngle);775 y = placeY + eleWidth/2 * cos(eleAngle);776 angle += eleAngleWidth;777 if (eleIndex % wallPart.length == 0 && eleIndex > wallPart.length && (getDistance(x, y, targetX, targetY) < wallLength || angle > 2*PI))778 targetReached = true;779 eleIndex++;780 // if (eleIndex == 10)781 // break;782 }783 placeLinearWall(centerX + x, centerY + y, centerX + targetX, centerY + targetY, ['wall', 'tower'], style, playerId, true);784 969 } -
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', 'cart', 'celt', 'hele', 'iber', 'mace', 'pers', 'rome', 'spart', 'rome_siege', 'palisades'];66 const wallStyleList = ["athen", "brit", "cart", "celt", "gaul", "hele", "iber", "mace", "pers", "rome", "spart", "rome_siege", "palisades"]; 67 67 68 68 69 69 //////////////////////////////////////// … … 111 111 for (var styleIndex = 0; styleIndex < wallStyleList.length; styleIndex++) 112 112 { 113 113 var centerX = actualX + radius + styleIndex * buildableMapSize/wallStyleList.length; // X coordinate of the center of the wall circle 114 var playerI D= 0; // Player ID of the player owning the wall, 0 is Gaia, 1 is the first player (default blue), ...114 var playerId = 0; // Player ID of the player owning the wall, 0 is Gaia, 1 is the first player (default blue), ... 115 115 var wallPart = ['tower', 'wall', 'house']; // List of wall elements the wall will be build of. Optional, default id ['wall'] 116 116 var style = wallStyleList[styleIndex]; // The wall's style like 'cart', 'celt', 'hele', 'iber', 'pers', 'rome', 'romeSiege' or 'palisades' 117 117 var maxAngle = PI/2 * (styleIndex%3 + 2); // How far the wall should circumvent the center 118 placeCircularWall(centerX, centerY, radius, wallPart, style, playerI D, orientation, maxAngle); // Actually placing the wall118 placeCircularWall(centerX, centerY, radius, wallPart, style, playerId, orientation, maxAngle); // Actually placing the wall 119 119 placeObject(centerX, centerY, 'other/obelisk', 0, 0*PI); // Place visual marker to see the center of the wall circle 120 120 orientation += PI/16; // Increasing orientation to see how rotation works (like for object placement) 121 121 } … … 132 132 for (var styleIndex = 0; styleIndex < wallStyleList.length; styleIndex++) 133 133 { 134 134 var centerX = actualX + radius + styleIndex * buildableMapSize/wallStyleList.length; // X coordinate of the center of the wall circle 135 var playerI D= 0; // Player ID of the player owning the wall, 0 is Gaia, 1 is the first player (default blue), ...135 var playerId = 0; // Player ID of the player owning the wall, 0 is Gaia, 1 is the first player (default blue), ... 136 136 var cornerWallElement = 'tower'; // With wall element type will be uset for the corners of the polygon 137 137 var wallPart = ['wall', 'tower']; // List of wall elements the wall will be build of. Optional, default id ['wall'] 138 138 var style = wallStyleList[styleIndex]; // The wall's style like 'cart', 'celt', 'hele', 'iber', 'pers', 'rome', 'romeSiege' or 'palisades' 139 139 var numCorners = (styleIndex)%6 + 3; // How many corners the plogon will have 140 140 var skipFirstWall = true; // If the wall should be open towards orientation 141 placePolygonalWall(centerX, centerY, radius, wallPart, cornerWallElement, style, playerI D, orientation, numCorners, skipFirstWall);141 placePolygonalWall(centerX, centerY, radius, wallPart, cornerWallElement, style, playerId, orientation, numCorners, skipFirstWall); 142 142 placeObject(centerX, centerY, 'other/obelisk', 0, 0*PI); // Place visual marker to see the center of the wall circle 143 143 orientation += PI/16; // Increasing orientation to see how rotation works (like for object placement) 144 144 } … … 157 157 { 158 158 var startX = actualX + (styleIndex * numWallsPerStyle + wallIndex) * distToOtherWalls; // X coordinate the wall will start from 159 159 var startY = actualY; // Y coordinate the wall will start from 160 var endX = actualX + (styleIndex * numWallsPerStyle + wallIndex) * distToOtherWalls; // X coordinate the wall will end160 var endX = startX; // X coordinate the wall will end 161 161 var endY = actualY + (wallIndex + 1) * maxWallLength/numWallsPerStyle; // Y coordinate the wall will end 162 var playerI D= 0; // Player ID of the player owning the wall, 0 is Gaia, 1 is the first player (default blue), ...162 var playerId = 0; // Player ID of the player owning the wall, 0 is Gaia, 1 is the first player (default blue), ... 163 163 var wallPart = ['tower', 'wall']; // List of wall elements the wall will be build of 164 164 var style = wallStyleList[styleIndex]; // The wall's style like 'cart', 'celt', 'hele', 'iber', 'pers', 'rome', 'romeSiege' or 'palisades' 165 placeLinearWall(startX, startY, endX, endY, wallPart, style, playerI D, false); // Actually placing the wall165 placeLinearWall(startX, startY, endX, endY, wallPart, style, playerId); // Actually placing the wall 166 166 // placeObject(startX, startY, 'other/obelisk', 0, 0*PI); // Place visual marker to see where exsactly the wall begins 167 167 // placeObject(endX, endY, 'other/obelisk', 0, 0*PI); // Place visual marker to see where exsactly the wall ends 168 168 }