Fallout Tile Geometry

dude_obj

Vault Senior Citizen
Moderator
TileGeometry.gif


In order to make tiles, the large graphic would have to be sliced into overlapping rectangles as shown above, then a mask image could be overlayed onto each rectangle, making the outside transparent. I've been looking at ImageMagick command line capabilities, and I think it might be possible to write a script to do exactly that.

http://www.imagemagick.org/
http://www.cit.gu.edu.au/~anthony/graphics/imagick6/

Cropping and Masking
http://www.cit.gu.edu.au/~anthony/graphics/imagick6/crop/#crop
http://www.cit.gu.edu.au/~anthony/graphics/imagick6/channels/


EDIT: Cool! It is definitely possible to make fallout tiles with ImageMagick.
I made a mask file that gets overlayed onto rectangles cut from the large graphic:

mask.gif


This can be overlayed onto a 80x36 slice using this ImageMagick command:
composite mask.gif tile.gif tile.gif
And I can do all gifs in a directory like this:
for %i in (*.gif) do composite mask.gif %i

After the mask is overlayed, the pink (fuchsia) outer edge can be made transparent using these commands:
convert -transparent fuchsia tile.gif tile.gif or
for %i in (*.gif) do convert -transparent fuchsia %i

Don't use fuchsia in your tiles, okay? :lol:

And the gif2frm to make the fallout compatible image
for %i in (*.gif) do gif2frm %i

The hard part is cropping the large image into rectangles that when masked will still fit together. As you can see in the above digram the rectangles are not continguous, they overlap. But I figured out the math for this. I can crop the first tile like this:

convert bigfile.gif -crop 80x36+0+0 +repage tile01.gif

If you look at the diagram, you can see that the next tile in the SE direction is 24 pixels south and 32 pixels east. So adding these offsets to the above command crops that rectangle:

convert bigfile.gif -crop 80x36+32+24 +repage tile02.gif

Keep adding 32 to x offset and 24 to the y offset and you're cropping the full row. I did two rows of a large image to make sure it works (it does!) and then I started writing a Lua script that automates the whole process. It still needs some work but soon I will have a program that can make fallout tiles out of a large image with one command. The output will be FRM and it will even generate the lines for tiles.lst.

Here's some tiles that were generated by the Lua script:

tlc01r01.gif
tlc01r02.gif
tlc01r03.gif
tlc01r04.gif
tlc01r05.gif
tlc01r06.gif
tlc01r07.gif
tlc01r08.gif
tlc01r09.gif
tlc01r10.gif


These tiles all fit together in a SE direction.
tiletest.jpg

These are tiles from the screenshot of the troika PA game.

This method doesn't alter the image in any way like the rotation described here: http://www.nma-fallout.com/forum/viewtopic.php?t=11984
The end result there is "flattened" because it's rotated. This method gives you exactly the same image you started with but sliced into fallout tiles. You can then make a painting of a background and scan it, and we can take tilesets and images from other games and many different places....

Nice thing about this, all the tools are free. And Lua is the scripting language for IanOut. I can see why they chose Lua, it's excellent. I will finally have new tiles for completely new areas soon :)

EDIT: A bit more info ... here is the pattern that repeats along the vertical and horizontal axes:

TilePattern.jpg
 
The tile making script is still very rough, but it was able to generate tiles from this 1280x480 panorama that I found in \art\interface. Here's a screen shot with that as background. You see the player in environmental armor and wielding a pulse rifle prototype. You also see a gila monster lizard (new critter).

newtileshot.jpg


Here's one more test of tile creation.

tilenew2.gif


Unfortuntaley it appears that we can only have 4096 tile FRMs altogether. I started working on a 3rd set and bumped into the maximum limit. In the mapper, the FRMs show up right until the 4096th spot, where it says "reserved" and nothing works after there. That's a familiar number, and it means they didn't allow much FID (file ID) addressing expansion for tiles :( Perhaps some of the old spots could be reused. FO2 has 3101 tiles. So only approx 1000 more can be added. That sounds like a lot but really it isn't. The panorama image above (1280x480) ended up being over 500 tiles.

Anyways I have a script that has worked now on 1280x480, 1024x768, and 800x600 images. Will upload it a bit later after I clean things up a little.
 
You could almost use a image like that for making a 'mini-game' that the player could coudl access via a computer terminal. I'm not sure how hard it would be to scritp but it woudl be cool to have a Fallout Spacie machine that the player could access in one of the town bars.

maybe make a small 'tank' sprite that drives around to shoot the enemy tanks. You could use a script to load the 'tank' armour for the game then load the players inverntory back once he ends the game.
 
In case anyone is anxious to make new tiles, I'll post the script source below. You need a lua binary, imagemagick, and gif2frm to run this. These also have to be in your system path so they are found. You also need this mask file.

One other note: you need to change the top lines in the script to configure the location of your patch, the image file name you are slicing into tiles, and the size of the image. This was a quick hack so don't expect it to be a refined utility, but it does work for me ...

-- Change these configuration values
infile = "large.gif"
width = 1024
height = 768
tileprefix = "AC"
patchdir = "F:\\Fallout2\\FO2XP.SRC\\Data"

-- Save original tiles.lst file
print "Saving original tiles.lst"
tilepath = patchdir .. "\\art\\tiles\\"
oscmd = "copy " .. tilepath .. "tiles.lst " .. tilepath .. "tiles.bak"
os.execute(oscmd)

-- Delete old tiles in working directory
print "Deleting Old Tiles"
oscmd = "erase "..tileprefix.."*"
os.execute(oscmd)

-- Add border to outside of image
print("Adding border to original image")
oscmd = "convert "..infile.." -bordercolor fuchsia -border 80x36 cropimage.gif"
os.execute(oscmd)

-- Crop input image into 80x36 tiles
print " "
print "Cropping input image into tiles"

cropwidth = width + 160
cropheight = height + 72
tilecol=0
tilerow=0
oddxstart=0
oddystart=0
evenxstart=0
evenystart=0
oddflag=true
inheight=true

-- Pass One: Crop left side of image
oddystart = -96
evenystart = -60
while inheight do
tilerow = 0
tilecol = tilecol + 1

if oddflag then
oddxstart = 12
xcoord = oddxstart
oddystart = oddystart + 96
ycoord = oddystart
end
if not oddflag then
evenxstart = 0
xcoord = evenxstart
evenystart = evenystart + 96
ycoord = evenystart
end
if oddflag then
oddflag = false
elseif not oddflag then
oddflag = true
end
inheight=true

while (ycoord + 36) < cropheight do
if (xcoord) < cropwidth then
if (ycoord + 32) < cropheight then
tilerow = tilerow + 1
rowid = tilerow
if string.len(rowid) < 2 then rowid = "0"..tilerow end
colid = tilecol
if string.len(colid) < 2 then colid = "0"..tilecol end
tilename = tileprefix.."L"..colid.."R"..rowid..".gif"
print("cropping column "..colid.. " row "..rowid.. " x="..xcoord.." y="..ycoord.." "..tilename)
oscmd = "convert cropimage.gif -crop 80x36+"..xcoord.."+"..ycoord.." +repage "..tilename
os.execute (oscmd)
end
end
xcoord = xcoord + 32
ycoord = ycoord + 24
if (oddystart + 96) > cropheight then
inheight=false
end
if (evenystart + 96) > cropheight then
inheight=false
end
end
end

-- Pass Two: Crop right side of image
oddxstart = 0
evenxstart = -12
tilecol=0
inwidth=true
while inwidth do
evenxstart.." evenxstart="..evenxstart)
tilerow = 0
tilecol = tilecol + 1

if oddflag then
oddxstart = oddxstart + 128
xcoord = oddxstart
oddystart = 0
ycoord = oddystart
end
if not oddflag then
evenxstart = oddxstart + 128
xcoord = evenxstart
evenystart = 36
ycoord = evenystart
end
if oddflag then
oddflag = false
elseif not oddflag then
oddflag = true
end
inheight=true

if oddxstart > cropwidth then
inwidth=false
end
if evenxstart > cropwidth then
inwidth=false
end

while (xcoord + 36) < cropwidth do
if (ycoord) < cropheight then
if (xcoord + 32) < cropwidth then
tilerow = tilerow + 1
rowid = tilerow
if string.len(rowid) < 2 then rowid = "0"..tilerow end
colid = tilecol
if string.len(colid) < 2 then colid = "0"..tilecol end
tilename = tileprefix.."T"..colid.."R"..rowid..".gif"
print("cropping column "..colid.. " row "..rowid.. " x="..xcoord.." y="..ycoord.." "..tilename)
oscmd = "convert cropimage.gif -crop 80x36+"..xcoord.."+"..ycoord.." +repage "..tilename
os.execute (oscmd)
end
end
xcoord = xcoord + 32
ycoord = ycoord + 24
end
end


-- Combine fallout tile mask to each tile
print " "
print "Masking tiles for transparency"
oscmd = "for %i in ("..tileprefix.."*.gif) do composite mask.gif %i %i"
os.execute (oscmd)

-- Convert tile edges to be transparent
print " "
print "Converting tile for transparency"
oscmd = "for %i in ("..tileprefix.."*.gif) do convert -transparent fuchsia %i %i"
os.execute (oscmd)

-- Convert tiles to fallout FRM format
print " "
print "Converting tiles to FRM format"
oscmd = "for %i in ("..tileprefix.."*.gif) do gif2frm %i"
os.execute (oscmd)

-- Delete temporary files
os.execute("erase cropimage.gif")
oscmd = "erase "..tileprefix.."*.gif"
os.execute(oscmd)

-- Generate fallout tiles.lst file
print " "
print "Building new tiles.lst"
tilepath = patchdir.."\\art\\tiles\\"
os.execute("dir /b *.frm > tiles.txt")
oscmd = "copy /b "..tilepath.."tiles.lst + tiles.txt " tiles.lst"
os.execute(oscmd)

-- Copy tiles to fallout patch directory
print " "
print "Copying new tiles to patch directory"
oscmd = "copy "..tileprefix.."*.frm "..tilepath
os.execute(oscmd)
 
Back
Top