Fandom

Vault-Tec Labs

Automated Tile making

403pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Automated Tile makingEdit

by dude_obj

In order to make tiles, a large graphic needs to be sliced into overlapping rectangles, then a mask image can be overlayed onto each rectangle, making the outside transparent.

A mask file must be overlayed onto rectangles cut from the large graphic:

F2tilemask80x36

  • This can be overlayed onto a 80x36 piece using this ImageMagick command:
composite mask.gif tile.gif tile.gif
  • All gifs in a directory can be done like this:
for %i in (*.gif) do composite mask.gif %i
  • After the mask is overlayed, the pink (fuchsia/magenta R=255 G=0 B=255) 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
  • Use 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.

This method gives you exactly the same image you started with but sliced into fallout tiles.

script sourceEdit

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 a 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)

Also on Fandom

Random Wiki