Tiled’s tile IDs are quite volatile. Ordinarily, each tileset’s first tile should be 0-index, but unfortunately, this doesn’t seem to be guaranteed and I’m not sure if it should.
In this forum post Bjorn himself suggested not to use tile IDs as a reference, and instead use tile properties to make a harder connection, which is what I’ve done: created an ‘id’ parameter and and just retrieved it from there.
The only issue here is that each tile ID must be manually entered, but this better than figuring out how to make tile IDs behave.
To make it solid, write a tool that reads the C2 caproj, reads the Sprite object, stores the image source for each frame of a Sprite: a text lookup to associate a filename with an ID.
For example, the lookup can read:
proto_walls walls_block.0000.png 0 proto_walls walls_block_cross.0000.png 1 proto_walls walls_block_ne.0000.png 2
Where the first token is the tileset name, followed by the image filename, followed by the animation frame, which is the ID.
Then the tool is run again on the Tiled-side. Going through each line of the lookup, searches for the tileset name, locates the filename (maybe ignores the relative path), then sets the ‘id’ property to the stored value.