Home and Links
 Your PC and Security
 Server NAS
 DVD making
 Raspberry Pi
 PIC projects
 Other projects
 Next >>

New terrain tiles for Crimson Fields

New CF Tiles

Adding new terrain tiles

The tile artwork in CFTiles.bmp contains the 'icons' for 384 tiles in 16 rows of 24. The first 8 tiles (000-007) are 'reserved' for program use. Terrain tiles thus start at 008 (HQ entrance, FNA (brown) South facing)

The Tile definitions, held in default.tsrc, are automatically assigned Tile ID codes in order starting from 000. Each definition has a reference to one of the tile icon bmp's. Combat maps terrain (map raw) use the Tile ID codes, not the bmp artwork references

For a full description, see my CF terrain tile definitions page

In CoMET, the map edit utility, terrain tiles are shown in the order they have been defined in the .tsrc file. The definition file sets the ID sequence numbers.
To make it easy to find the right terrain tile, similar tiles are defined in 'sets' (i.e. grouped together = all buildings, then grass, hills, roads, rails, rivers etc.)

Whilst are a few 'spare' positions (6) and some of the bmp's are 'unused' (7 are not referenced in any definition), to get enough space for the 'beaches' set I added an extra row (24)

Changes to the buildings

One of the first things I did when modifying the terrain tile set was to 'fix' the buildings :-

First, the 3 pointless 'Neutral' HQ entrances were removed, and the first 8 tiles dedicated to HQ entrances i.e. one in each of Player 1 & 2 colours, N,S,E & W .
The next 4 tiles were used as the HQ building 'sides' (N,S,E & W)
After this came 12 tiles dedicated to Factory entrances, a full set of Player 1, 2 and Neutral, N,S,E & W facing.
Finally, 4 tiles are added for the Factory building 'sides' (N,S,E & W)
This accounts for the first 28 tiles. The next two are sort of 'spare' since Tile 30 has to be kept as 'grass' (since code #030 is hard coded into the CoMET random terrain generator)
Three of the 'reserved' tiles (black positions in the standard set) are used for a single tile 'Depot' entrance tile for Player 1, 2, neutral. These are single tile 'bunker' style entrances (with no sides).

Adding or removing a tile from the .tsrc sequence would result in all the 'maps' picking up incorrect icon's for every tile, so the tiles had to be kept in the same place as much as possible.

Even so, just fixing the Depot/Factory 'set' involved quite a lot of 'search & replace' on all the existing map definitions *.src files just to 'sort out' the depot's and factories

Due to the large number of maps involved (> 100, when including the Battle Isle sets), a VB Script was written to do the 'replacements' (after doing a 'search & replace in files' to convert the unix 'LineFeed' to a Windows 'CarriageReturn / LineFeed' pair).
The 'Building under construction' tiles were replaced by 'mountains'

As already noted, the 'function' of a building is defined independently of it's icon. The difference between a 'factory' and a 'depot' is that one 'generates crystals' and 'builds' (or 'buys') units whilst the other is simply a 'store' with a unit 'repair' capability

Other changes

Note that Tile icons can be placed anywhere in the bmp file. Grouping them together just makes it easier to ensure none of the required 'facings' are 'missed out'

I wanted to offer desert / beach landing maps, so needed a totally new set of desert and beach tiles.

Image The 6 existing tiles consisting of one hex edge grass (5 edges water) where modified to remove the 'grass' (so 1 side sand, 5 sides water))

The remainder of the water <> beach were added, 18 tiles, being 3 sets of 6 (i.e. a set of '2 hex sides beach', '3 sides beach' and '4 sides beach')

One all sand tile plus a set of 6, half sand / half grass tiles (to support sand<>grass terrain transition)

To repair bridges, a set of 3 'Pontoon over water' tiles are required.

Image Assault from the sea' is restricted to North <> South, requiring one each of Pontoon to 'North beach to water', 'South beach to water', 'South grass beach to water' & 'North grass beach to water'.

Some additional 'house' tiles were added (at the 'spare' positions after the woods tiles).

One final spare tile became an additional 'rocks' tile

Generating a new default.tiles 'compiled' file

The simplest approach is to 'make' / 'make install' the entire Crimson Fields Source (it doesn't take long). This ensure that any new 'types' are picked up

If the ONLY changes are to the artwork (tile bmp images) or the definitions (and the map have already been adjusted = see below) you can simply rebuild the 'default.tiles'. Navigate to the \tools folder and to generate the default.tiles, use :-

mktileset ../gfx/CFTiles.bmp default.tsrc default.tiles

Adjust the map .src files

My 'tile swap' QBasic script (and a 'tiles swap' list) can be found in my CF 0.6.0 new Units and Tiles 'pack'(right click and 'save link as' to download the .zip from here) pack

If you 'add' or 'remove' definitions, all the tile ID codes from that point on will be changed .. this will mean that all existing maps (.src / .lev) will 'pick up' the 'wrong' terrain tiles. Whilst it's possible to 'hand edit' the map .src to change a few tile codes this can be a real pain. Far better is to 'script' the changes and automate the whole process

Notepad++ has a 'replace in files' function. This is fine for changing one or two ID codes, but can be a right pain when you have a dozen to change, especially if your need to 'swap over' two codes (eg existing code 10 to new 20 and existing 20 to new code 10)

Scripting the changes is, of course, harder than it sounds :-)

What's the problem with 'scripting' changes ?

The *.src file in the /levels/ folder use the hex code '0A' as the 'line terminator'. Whilst Notepad++ is OK with this, other text edit software may not be - and, for sure, any QBasic script will 'fall over' with an 'Out of string space' error when trying to 'read' (line input) from the *.src files.

Fortunately, CoMET on Windows correctly uses '0D'+'0A' when 'Exporting' a .lev map as a 'source' file. So 'all' you have to do is 'Load' the .lev version of the existing map files and then 'Export' them as .src - and CoMET will then create an 0D+0A formatted file, which you can then process using QBasic scripts

Another way to 'fix' the line ends is to open the map '.src' in Windows 'Wordpad' and then 'save as' 'Text Document MSDOS format' which will change the line end codes to CR+LF (note that neither Notepad nor Notepad++ will change the line ends)

How do I 'compile' a modified map .src file ?

Of course CoMET can't load a source (.src) file, only a .lev version. So after 'processing' (eg swapping tile numbers around) the next step is to 'compile' the .src to .lev using the 'cfed' utility together with the new default.tiles & default.units

Assuming your modified .src is in the /levels folder (and that your new unit + tile set is in the 'next folder up'), to compile 'name.src' into 'name.lev', 'cd' to /levels and type :-
cfed {name}.src --tiles ..\default.tiles --units ..\default.units

Clicking "Next >>" (nav bar, left) will take you to my crimson-0.6.0.exe (code changes) Page

Next page :- Supplies Repair and Construction