Before getting started with this tutorial, check out the custom HUD
tutorial. It gives you the basics on how to take one
of the game's original sprites and edit it as you please. This section will go into
some more detail about how Half-Life and TF 1.5 handle sprites with text files, including
the control of crosshairs. I'll be glancing over the actual sprite creation, as it is
explained in more detail in the HUD section.
Tools you will need:
Pak Explorer
SprView
SprWiz
A Paint program
Notepad
Everything aside from the paint program (and Notepad) can be found at the files section
of the extremely helpful site known as Wavelength.
Files to back up before starting:
None. Your original sprites are in a .pak file. You won't be moving or destroying them.
Let's start with a quick recap of what we did to make the custom HUD sprite. We found
the sprite we wanted in PakExplorer, exported it to the Sierra\Half-Life\sprites folder,
opened it in SprView, and then saved a .bmp image file from the sprite. Next we opened up
our trusty paint program, edited the .bmp, then used SprWiz to turn our creation back into
a functioning sprite. The sprite itself had lots of separate image sections: a health cross,
armor indicator, numerals, etc. So how does the game know what to do with each section
of the sprite? The short answer is that it uses a handy text file as a road map.
The text file that controls the HUD is cleverly named hud.txt. It can be found in
the pak0.pak file in Sierra\Half-Life\tfc. Use PakExplorer to extract hud.txt to your
tfc\sprites folder, then open it up in Notepad and have a look. As you'll no doubt remember,
the HUD file we worked with earlier was named 640hud7.spr. A look through hud.txt
shows how the game knows what to do with the sprite. Let's take a look at one line:
number_0 640 640hud7 0 0 20 24
Naturally a pretty basic line, but it helps illustrate what's going on. number_0 refers to,
well, zero. Arguments about whether or not zero is a number will not be considered here.
The game uses this line to determine where to look for a sprite when it
needs to represent a zero on the HUD. The rest of the line is translated as follows:
640: all resolutions of 640x480 or above will use these directions. Lower resolutions use the 320 instructions.
640hud7: the name of the sprite that is to be used
0: X-coordinate on the sprite where the game image should begin
0: Y-coordinate on the sprite where the game image should begin
20: Width of the sprite that should be used, in pixels
24: Height of the sprite that should be used, in pixels
So, to make a zero the game is told to look at sprite 640hud7.spr and start at
coordinates 0,0 (top left hand corner of sprite). It makes an image from the sprite that
is 20 pixels wide by 24 pixels tall, beginning at those coordinates. Looking back at our
bitmap of the sprite, it's no surprise to see a big zero in the upper left-hand corner:
A quick look through the rest of hud.txt turns up instructions for the rest of the
HUD features. The "buckets" are the small numerals, cross is the health icon, suit_full
and suit_empty are the armor icons, etc.
What you will also notice while looking through hud.txt is that the names of quite
a few other sprites appear. There's tfc_dmsg (death icons), tfchud01 (flag icons), and many more.
As you might have guessed by now, you can edit most of these sprites to your liking. A word
of caution: it's best to simply edit an actual sprite bitmap directly over the original sprite
in most cases. It is fully possible to make a completely new sprite for something (as we'll see), or to edit
hud.txt so that a certain sprite is larger or smaller. There are a few problems with this. Results
are hard to predict when you change the size of a sprite. Editing the hud.txt also means
that you have to share that hud.txt with anyone who wants to use your sprite. A good example
is the popular TF death icons available at PlanetFortress. They come with an edited
hud.txt and many people use them. If you create a new hud.txt and give it to someone
who uses these sprites, their death icons would basically become borked. Recap: try not to change
hud.txt if you don't have to.
That said, there's plenty of fun to be had editing the original sprites. Let's say you became
bored seeing the same old dizzy man every time you dropped a conc. Looking through hud.txt you
find a line about dmg_concuss, which uses a sprite called tfchud05. Extract that sprite
to Sierra\Half-Life\tfc\sprites with PakExplorer (refer to the HUD tutorial
if you need a refresher). Save the .bmp in SprView, then open up your paint program and have a look:
You see the representations of some weapons, as well as the familiar conc, hallucination,
and tranq indicators. Using the trusty paint program, let's make a few changes to alleviate
the tedium. As in the HUD tutorial, we can edit the palette and add a little
color (remember colors other than red and green usually look terrible). I've made hallucination-man's
trials a little more colorful and changed conc-man to indicate that he is dizzy from drinking,
um, poison:
Save the bitmap and then use SprWiz to make it into a sprite. Remember to choose the default
"additive" type of sprite. Save your new sprite as tfchud05.spr in Sierra\Half-Life\tfc\sprites.
Next, go out and find a game of 2fort so you can get gassed and conc'ed constantly
for testing purposes:
Click image for larger version.
That brings us to the consideration of crosshairs. Like the images on the HUD, crosshairs
are sprites that you can edit. I'm not going to go into a ton of detail here, because
there are plenty of crosshair tutorials floating around. I will give a quick explanation
of how you can create crosshairs that are larger and more intricate than the defaults,
as this is handy for high-res players.
Just like the HUD, crosshair sprites contain instructions in text files. These files
are located in the sprites folder inside the file pak0.pak in Sierra\Half-Life\tfc. Let's
look at one weapon in particular by extracting it's text file with PakExplorer (find it in the sprites folder). We'll
consider the rocket launcher and extract tf_weapon_rpg.txt to look at. The text files
for all of the other weapons are named accordingly. Here's what we find in tf_weapon_rpg.txt:
The instructions start with the number of designations (8), then list specific
sprite locations for rendering a image of the weapon (weapon), an image of the weapon
when it has been selected (weapon_s), ammo for the weapon, and the crosshair for the weapon.
Some of the text files contain more entries due to different features (sniper rifle, etc.)
One thing remains constant: the crosshairs are always found on the sprite crosshairs.spr,
which can be found in the sprites folder inside the pak0.pak file in Sierra\Half-Life\valve.
There is no different crosshair sprite file in the Half-Life\tfc folder, as the game uses
the original Half-Life crosshairs. Here's a quick look at crosshairs.spr (slightly enlarged):
The green circle has been added to show the rpg crosshair. As indicated in the text file,
it begins at position 24,48 and is 24x24 pixels. When you're playing the game at a high
resolution, 24x24 isn't much to work with. Those orangey crosshairs can get lost on a lot of
maps as well. Given the way that the text files work, it's possible to create entirely
new sprites to use as crosshairs.
Open your paint program and create a new image that is a 256-color bitmap (.bmp). For this
example, I created one that is 80x80 pixels and has a grey background. I then paint away, using
some brighter colors and adjusting the crosshair slightly down and to the right (ever
notice they're a little off?). Here's what I came up with (enlarged here):
Before turning the new crosshair .bmp into a sprite, you must make sure that the palette
is configured correctly for transparency. The last color in the palette (number 255) is the color
that will be transparent. Here I make sure I have the grey background color in the proper
position in Paint Shop Pro:
Next, I start up SprWiz and turn the bitmap into a sprite. This time there is one change in the procedure:
during the SprWiz process you must choose to create an "alphatest" sprite (rather than
"additive"). I will call my finished sprite rpg.spr. It should be saved in Sierra\Half-Life\tfc\sprites.
Now, it's time to make some changes to tf_weapon_rpg.txt so that the game will use the new sprite.
Here's the changes:
The game is now told to use the new sprite, rpg, to start at position 0,0 as
it will use the whole sprite, and that the sprite is 80x80. This process can
be repeated for every weapon in the game, allowing you to do just about anything
you wish with your crosshairs. I made some more crosshairs to go with this one; you can download them
at the end of this tutorial. I only play in 800x600 so they're reasonably small. I encourage
you to make your own and look around, as there are plenty of high-quality crosshair
sets around. Here's how it looks in the game:
Click for larger image.
Download the sprites featured in this tutorial here. Read the enclosed readme.txt for instructions.
I made lame sprites. How do I get the originals back?
Delete the new sprites you made from Sierral\Half-Life\tfc\sprites. The originals,
which are in the .pak files, will be used after you delete them. If you want to get rid
of a custom crosshair set, delete the tf_weapon_xxx.txt files as well as the sprites.