Recent Forum posts
The Dorian Invasion (2 replies)
Posted 3 weeks ago by Eurotool
Is it possible to rip sprites and icons ... (2 replies)
Posted 3 weeks ago by PhatFish
Championship 1v1 ROR Tournament (New)
Posted 1 month ago by Zarrr
Any players out there? (2 replies)
Posted 1 month ago by pianolarva
Livestream friendly battle VN and CN ... (3 replies)
Posted 1 month ago by pianolarva
Long time lurker (9 replies)
Posted 1 month ago by pianolarva
Porting AOE Definitive Edition Maps ... (3 replies)
Posted 2 months ago by Filthydelphia
Do ROR scenarios have triggers and everything ... (2 replies)
Posted 2 months ago by PhatFish
Original AoE1 graphics mod for Return ... (6 replies)
Posted 2 months ago by PartizanLegis
A guide to using Triggers (New)
Posted 2 months ago by PhatFish
Latest Files
Age of Empires Heaven :: Download Central
Random Screenshot
  • aoefpvoobly.jpg
  • History Tidbits
    Loading Quotes...
    The Use of .CTY Files

    The Use of .CTY Files

    By Bruce Denyes

    Download the text file version

    As a browser of AOE web sites for some time now, it has become quite apparent to me that no one really understands how .cty files work!! – this is quite evident by the lack of response to questions such as this and by the total lack of any articles being posted on the subject.

    I have spent more than a few hours myself looking into .cty files – trying to understand their format and how they function. In my opinion, Ensemble Studios should never have included the “City Plan” setting on the “Players” section of the Scenario Builder without providing proper documentation. Only the “Default.cty” file was included with the game – no guidance whatsoever was given on how to interpret the numbers in the “Default.cty” file or how to write .cty files that function correctly. Why the “Default.cty” file was packaged with the game at all is not apparent – perhaps it was simply to whet the appetite of AOE scenario designers for the future marketing of a proper city layout designer/editor. Only Ensemble Studios appears to know. The “Default.cty” file is not a complete or properly functioning .cty file (see error listing below). In general, my experience with .cty files (described below) met with varied success. Most of the time, a .cty file would only excute reliably up to a certain a certain point in the plan – then it would begin to place buildings in a random pattern. The author has had absolutely no success in using .cty files to control the location of walls and towers.

    Several weeks ago I actually took the time to plot the entire “Default.cty” file on graph paper – an interesting exercise to say the least!! – but an essential first step in understanding how .cty files work. The town perimeter is actually a square. A single width wall is built around the perimeter at a distance of 11 tiles from the Town Center. The wall has 4 gates – each 3 tiles wide – located on the north, east, south and west axes. Inside the walls, the town has 4 quadrants – in each quadrant, space is provided for 3 buildings of size 3×3 tiles and 3 buildings of size 2×2 tiles – this results in a total of 12 @ 3×3 buildings and 12 @ 2×2 buildings within the walls. The 2×2 building spaces provide enough houses to support the population limit i.e. (12 houses x 4 villagers each) + (4 villagers supported by the Town Center) = housing for 52 villagers (versus the population cap of 50). Two guard towers are built outside the walls on beside each gate (a total of 8 towers). Space is also provided for 8 more 2×2 tile and 8 more 3×3 tile buildings outside but immediately adjacent to the walls. Ample space is provided around all buildings for the movement of villagers and military units.

    Looking into the .cty file itself, there are a series of location slots for buildings of various sizes along with the x/y co-ordinates which define where the building will appear on the game screen. Most buildings require a space 3×3 tiles – except for houses and towers which need 2×2 tiles, walls which require a 1×1 tile space and the almighty Wonder which is 5×5 tiles. When a building order is issued by the .ai file, the program looks in the .cty file for the first “available slot” on the list. What constitutes an “available slot”? If the first available slot is designated as “-1” “Any_Type”, then the building will be constructed there if the tile size requirements are met (Note: it is the “-1” that governs – “Any_Type” is used only for the purpose of describing the building). If the slot has a valid building code number (ex. 87 for Range1) assigned instead of the “-1”, then that slot is reserved for the designated building. If the building to be constructed matches the code, then the program will use that slot – otherwise it skips to the next available slot, checks it for suitability, and so on, until a valid slot is found. The building is then constructed using the co-ordinates defined for the slot.

    The only way to control the placement of buildings (not walls and towers) is to know the exact number of each building type to be built and to assign each a coded building slot in the .cty file (i.e. replace “-1” with the building code number). This requires, however, that careful attention be paid to the x/y co-ordinates assigned to the slot, the building size and the amount of room left around the building for movement of villagers and military units. Care must be taken to ensure each building does not “overlap” on space reserved for an adjacent building. Such a layout design process pretty much makes the use of pencil and graph paper mandatory – certainly a cumbersome process and unnecessary in our high-tech computer age!! In turn, this points to the need for development of a town layout design and edit utility which would let the designer graphically layout towns (much as they are now in the AOE Scenario Builder) – the exception being that the finalized town layout could be saved to a .cty file.

    The “Default.cty” file contains several errors. Firstly, the co-ordinates are wrong on 2 lines as follows:

    Line 26 “9.500000 12.500000” should read “-12.500000”, and

    Line 37 “3.000000 8.000000” should read “-8.000000”. 

    After these corrections are made, the graphical version of the “Default.cty” file is sound and well laid out.

    A second problem with the “Default.cty” file is that it contains no provision (slot) for construction of a Wonder. If your scenario calls for the building of a Wonder, it is recommended that the “City Plan” always be set to “None”. Otherwise, the “276” building code for a Wonder must be substituted for the “-1” in an appropriate building slot. (The author has prepared an information package which outlines this problem further – available for the asking).

    Thirdly, the plus/minus directions used for the x/y axis co-ordinates in the “Default.cty” file do not conform to standard geometric practice (i.e. + x should be to the right, + y should point up, – x to the left and – y down). When viewed on the AOE game screen, a + x axis co-ordinate in the .cty file actually lies on an axis which points in the North/East direction (to the upper right corner of the screen), a + y axis points to the South/East (lower right), the – x axis points South/West (lower left) and the – y axis points North/West (upper left). The on-screen result of plotting the co-ordinates in the .cty file can be extremely disorientating and difficult to interpret!!!

    Fourthly, while success can be gained with the placement of conventional buildings using .cty files, walls and towers simply do not build in accordance with the co-ordinates specified in the .cty file. Again, the author has prepared an information package on successful wall and tower building (available for the asking).

    And lastly, the building code for a “Watch_Tower” is “79” – not “69” as shown in the “Default.cty” file. Perhaps, “69” was intentionally put into the file simply to disable the building slots??

    In .per files, SN168 “SNRandomPlacementFactor” is supposed to permit the “computer player to randomize building placement off the calculated ideal”. SN168 certainly appears to have some effect on building placement – but again Ensemble Studios has not provided enough information on how it functions.

    Considering the present format of .cty files, the difficulties in working with them, their inconsistent functioning and the lack of graphical tools available to help with transposing them to the game screen, I have concluded that .cty files are simply not worth the effort at the present time!!! They are too cumbersome and time-consuming to develop and edit – and what’s more, certain aspects simply can’t be made to work. It is recommended that AOE scenario designers simply leave the “City Plan” set to “None” until such time as a proper town layout design/edit utility becomes available. Perhaps Ensemble Studios will develop one for inclusion in a possible future AOE add-on or expansion pack.

    The opinions expressed here regarding .cty files should be interpreted in a positive and constructive fashion. The notes are not necessarily complete, but it is hoped that they will help those scenario designers presently struggling with AOE .cty files. Perhaps the notes will contribute in some small way to the future enhancement of an already terrific game!!

    © HeavenGames. All Rights Reserved. Please read our Disclaimer & Privacy Statement. © Microsoft Age of Empires.