
Move landscape and change it! (screenshot example here)
| View previous topic :: View next topic |
| Author |
Message |
jlangsdo

Cutthroat 
Posts: 398 

 
11012 Gold -

|
Posted: Sat Dec 08, 2012 10:52 pm Post subject: |
|
|
Well, that all depends.
If you use this mod:
landscape.ini
which relocates Bermuda just far enough south.....
 |
|
| Back to top |
|
 |
Roland

Helmsman 
Posts: 4190 

 
23929 Gold -

|
Posted: Sun Dec 09, 2012 5:21 am Post subject: |
|
|
I wonder if the Treasure Fleet will run aground on Bermuda now . . . |
|
| Back to top |
|
 |
jlangsdo

Cutthroat 
Posts: 398 

 
11012 Gold -

|
Posted: Sun Dec 16, 2012 12:39 pm Post subject: |
|
|
Going back to the different files:
The graphical files are in two different sizes per island group. The tga files and the _h.bmp and _t.bmp are large, the three *_c*.bmp files are small. The scaling between the two seems to be different per island group.
The b_tga.bhi file I haven't figured out yet... I could use some help brainstorming.
The format is as follows: First 4 bytes: 05 00 00 00, then 9 byte lines. Each 9 byte line starts with a 4 byte address xx 00 00 00, then 5 bytes of data.
The addresses count up from 0, but for the larger files the 9 byte lines are out of order. SMP doesn't appear mind if I rewrite the file with the 9 byte lines sorted by address, and the smallest bhi files do have them in order.
The 5 bytes of data per line each take on only these values: 40 31 30 21 20 11 10 03 02 01 00, and within each line the 5 bytes are strictly decreasing. Therefore this can't really be a map; the information is not fully two dimensional. The line for address 00 is always all 00.
The size of the bhi file is roughly related to the size of the graphics files for the same island group. The 10 coastal bhi files are the largest and they are identical.
So here is the bermuda file:
05 00 00 00
00 00 00 00 00 00 00 00 00
01 00 00 00 03 00 00 00 00
02 00 00 00 03 02 00 00 00
03 00 00 00 02 00 00 00 00
04 00 00 00 03 02 01 00 00
05 00 00 00 02 01 00 00 00
06 00 00 00 01 00 00 00 00
07 00 00 00 31 01 00 00 00
08 00 00 00 31 30 01 00 00
09 00 00 00 31 30 00 00 00
0a 00 00 00 31 02 01 00 00
0b 00 00 00 40 31 30 01 00
0c 00 00 00 40 31 30 00 00
0d 00 00 00 40 30 00 00 00
0e 00 00 00 40 31 01 00 00
0f 00 00 00 40 00 00 00 00
10 00 00 00 31 30 02 01 00
11 00 00 00 31 03 02 01 00
Any guesses? |
|
| Back to top |
|
 |
jlangsdo

Cutthroat 
Posts: 398 

 
11012 Gold -

|
Posted: Sat Dec 22, 2012 1:03 pm Post subject: |
|
|
The *_b.tga.bhi file is an index for the RED bytes in the corresponding *_b.tga file, linking those bytes to the TextureID lines found in landscapehills.ini.
If you look at the tga file in a graphics editor, splitting red from green from blue, the red is very faint, only small numbers are used - corresponding to the small line index numbers in the tga.bhi file
This combination (red bytes + decoding) determines where you can land your ship (probably sand or sandwet). |
|
| Back to top |
|
 |
jlangsdo

Cutthroat 
Posts: 398 

 
11012 Gold -

|
Posted: Fri Jan 11, 2013 12:32 am Post subject: |
|
|
In landscape.ini, the XPos and YPos determine the upper left coordinate of each island group. These two are at 4x scale compared to the standard 462x293 grid.
The XYScale value tells how to scale ${island}_h.bmp to get it onto the same grid.
Using XPos, YPos, and XYScale, as well as the ${island}_h.bmp files, it is possible to reconstruct piratemap.dta, piratemap8.dta, and piratemapz.dta - which are the files which govern treasuremaps, where non-player ships can sail, and where settlements and pirate landmarks are placed.
I think generally a height of 128 is used to for piratemap.dta and piratemap8.dta for setting the treasuremap coastline, but the cutoff has to be higher in piratemapz.dta, otherwise no landmarks are placed. Landmarks seem to land on sites that are 00 00 in piratemapz.dta but are on the coast in piratemap.dta/piratemap8.dta |
|
| Back to top |
|
 |
Liakos

Powder Monkey 
Posts: 5 

 
16 Gold -

|
Posted: Fri Jan 11, 2013 6:20 am Post subject: |
|
|
And all these changes in which file we will apply ? |
|
| Back to top |
|
 |
jlangsdo

Cutthroat 
Posts: 398 

 
11012 Gold -

|
Posted: Sat Jan 12, 2013 12:33 am Post subject: |
|
|
Hi Liakos -
Sorry for being cryptic. I've been posting the little nuggets of information as I figure them out, hoping to make it easier for the next person who goes down this path.
My master plan is to make a huge mod that changes the map entirely to the East Indies. I think that is still at least a month away, maybe two. In a week or two, I may be ready to post my scripts that let you add a new island (or clone an existing one) and then rebuild the full world accordingly.
The 'map' works as follows:
Each island group has several different graphics files. One file sets the height of the land, another manages the texture, another does shading effects, etc. Some of the details are captured above in this thread. The graphics files for each island group come in two sizes; usually _h.bmp is larger than _cc.bmp. All of the files have to be roughly in harmony for your ship to be able to land and for the land to look right as your landing party marches around. If the files don't match up, the land goes transparent, or much too bright, or there are trees in the water, etc.
The islands are placed on the physical world using a text file called landscape.ini; that's the file that has XPos, YPos, and XYScale for each island group.
The sizes of the island group graphics files have to match something in the landscape.ini file, but I don't understand the formula. It works if you copy the entire paragraph in landscape.ini over and copy all of the graphics files accordingly, but I don't know how it determines what sizes are required for the _h.bmp and _cc.bmp files for a particular landscape.ini paragraph.
There are 3 dta files that have important overall function. (dta files are just a grid of bytes, like a graphics file without the header). piratemap.dta or piratemap8.dta (not sure which, they are identical) sets the coastline as seen in treasuremaps. piratemapz.dta sets where non-player ships can sail. The interaction between these files is also needed to set the possible locations for pirate landmarks, which are created uniquely in each game.
The treasuremaps themselves are constructed by taking the relevant part of the coastline from piratemap.dta and using it to place copies of the coast_*.dds files. It reads 4 adjacent squares, and picks one of those dds files if some of the squares are land and others are sea; sea in NW and land in NE, SE, and SW is coast_insideul.dds, for example.
Then we have the world map as seen in the game. caribbeanmap2.bmp, caribbeanmap4.bmp, and caribbeanmap6.bmp are the backgrounds for world map (at 3 different zooms). The cities are drawn on top of that map, and the labels for the cities (size, orientation, color) are determined by maplabel.dta. cityloc.dta determines the locations and orientations of each city. The starting nation of each city, and which years it is active, are stored in the executable. Settlements are sprinkled along the coastlines.
loadsavemap.dds shows a zoomed out picture with a frame around it, that is familiar from the load/save screen. The pirateopedia also has maps - pedia_city_*_map.dds - which look like a beat up version of the carribbeanmap.bmp with an X placed over the city.
When you save a game, it stores the contents of cityloc.dta, piratemap.dta, and piratemapz.dta into the savegame file, along with the locations of all of the settlements, pirate landmarks, shipwrecks, etc. |
|
| Back to top |
|
 |
jlangsdo

Cutthroat 
Posts: 398 

 
11012 Gold -

|
Posted: Tue Jan 15, 2013 2:21 am Post subject: |
|
|
OK, here is a script that can rebuild the world....
island.pl
graphics_formats.pm
smp_fpk_unpack.pl
First you unpack your FPK files with smp_fpk_unpack.pl so it can see what the baseline maps look like. Use a graphics program to convert loadsavemap.dds to loadsavemap.bmp so the script can update that.
Then you create Islands.csv detailing where to place any new islands. You create _h.bmp files for them derived from same size original _h.bmp files.
Then run island.pl, it will read the _h.bmp files to build all of the other island files, then update all of the global files. graphics_formats.pl should live in the same directory as island.pl, it has some generic subroutines for reading/writing bmp and tga files.
The resulting world is not quite as pretty as the original, but it is not bad, and is definitely playable.
Next stop... the spice islands. |
|
| Back to top |
|
 |
jlangsdo

Cutthroat 
Posts: 398 

 
11012 Gold -

|
Posted: Sun Jan 27, 2013 5:34 pm Post subject: |
|
|
One more map: pirateinfobg.dds
This is the background map shown whenever you get a hint about the location of a pirate or evil character. |
|
| Back to top |
|
 |
jlangsdo

Cutthroat 
Posts: 398 

 
11012 Gold -

|
Posted: Tue Jan 29, 2013 12:49 am Post subject: |
|
|
Another surprising bit of information - all land battles happen on Hispanola... a scaled down version, but recognizable. You are looking east across the Dominican Republic:
It's not the island files that matter (haiti_h.bmp), but actually what landmass you have placed in that part of the world map. The terrain painted there (_b.tga) actually affects what the land looks like in the battle scene.
This puts an interesting constraint on a large map mod - any new map has to preserve a large landmass in the right spot, otherwise land battles cause the game to crash. |
|
| Back to top |
|
 |
AdamMil

Cutthroat 
Posts: 279 

 
4759 Gold -

|
Posted: Tue Mar 18, 2014 3:02 pm Post subject: |
|
|
| jlangsdo wrote: | | Another surprising bit of information - all land battles happen on Hispanola... This puts an interesting constraint on a large map mod - any new map has to preserve a large landmass in the right spot, otherwise land battles cause the game to crash. | I believe I've found how to change this. At offset 0x327520 in the PC .exe, there's the following data: 44 01 00 00 8D 00 00 0. This corresponds to the integers 324, 141. Coordinates of the location for land battles, I think! |
|
| Back to top |
|
 |
themodelcitizen

Gunner 
Posts: 903 

 
15615 Gold -

|
Posted: Mon Oct 19, 2020 6:31 am Post subject: |
|
|
Anyone still have island.pl and graphics_formats.pm? That would be huge... |
|
| Back to top |
|
 |
jlangsdo

Cutthroat 
Posts: 398 

 
11012 Gold -

|
Posted: Mon Nov 08, 2021 4:24 pm Post subject: |
|
|
Bumping as I relearn this stuff.
piratemap8.dta and piratemap.dta are not quite identical.
piratemap8.dta rates each spot on the 462x293 with an 8 bit value from 0..255 (or 00 to FF). Open sea is 00, dry land is FF, coastline is in between.
piratemap.dta condenses that number. It takes the binary representation of the 8 bit value from piratemap8, counts the number of ones, and adds one more if the MSB is set, to get a count from 0 to 9. So 0 is open sea, 9 is dry land, and coastline is from 1 to 8.
These files can be approximated from the bhi files and landscape.ini, as they are in the East Indies mod, but my code wasn't getting them exactly right. That's probably why there are problems with dolphins on land in that mod. So the question would be, where exactly do the numbers in piratemap8 come from? |
|
| Back to top |
|
 |
themodelcitizen

Gunner 
Posts: 903 

 
15615 Gold -

|
Posted: Mon Nov 08, 2021 5:47 pm Post subject: |
|
|
I recall being able to land and walk on Bermuda/adjusted Barbados with just a landscape.ini change, not touching the piratemaps. So it may be that once the islands/landmasses are set by those files, then landscape.ini can move them around as landmasses you can still interact with. I realize this may not be entirely helpful, just thinking out loud. Keep up the great work. |
|
| Back to top |
|
 |
jlangsdo

Cutthroat 
Posts: 398 

 
11012 Gold -

|
Posted: Mon Nov 08, 2021 10:41 pm Post subject: |
|
|
A little closer....
piratemap8.dta is encoding a 3x higher resolution map.
Looking at each byte in hex, its 8 bits break down like this (all values in hex):
04 20 --
02 10 80
01 08 40
where a 1 means there is land there, and a zero is sea. The ordering looks a little funny until you remember that dta files are written from bottom to top, left to right - so they are in the exact order one would expect. NE does not contribute (no data is there for that square) but when it is condensed to make the piratemap.dta to decide if it is land/sea on a treasuremap, E is counted twice to make up for that.
The expanded map looks really good - very smooth curves, it's the extra detail that is not there in a low-res treasuremap.
Unfortunately, when I scale and place the *_h.bmp file, it doesn't perfectly match the expanded map. I'm watching a particular shallow puddle in Mexico that is water according to coastal4_h.bmp, but doesn't show up as a puddle in piratemap8.dta. Argh. It is very shallow, so this has something to do with rounding or quantization. I'm not guessing exactly how they do the transformation.
The good news is, I think this means that there are no hidden magical bits or masks hiding in piratemap8.dta or piratemap.dta |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|