Half-Life Full Crosshair Tutorial.
02-09-2000, By: BBR.
Written for: Crosshair Central.

This Tutorial will explain all aspects of Xhair Factory v1.2, its usage, and making custom crosshairs.

I Assume you already have Paint Shop Pro 6.x or something similar, and know how to use it.
Also i will assume you have Half-Life installed on your hard-disk.
 
Before reading the rest of this tutorial, download the following file to save yourself waiting time later on.
Xhair Factory v1.2 Which contains several crosshair packs for example usage, Pakexplorer, Sprite Generator,
the 2 earlier tutorials, several color palettes, Sprite Viewer and a set of weapon text files.
(Check Download area for newer version)

Chapters:
1: Getting started
2: Xhair Factory v1.2 Contents
2.1: PakExplorer Usage
2.2: Sprite Generator Usage
2.3: Sprite Viewer Usage
3: A Simple Crosshair
3.1: Implementing a Simple Crosshair, into Half-Life
3.1.1: The Contents of a Qc file
3.1.2: Troubleshooting
3.2: Other crosshairs in the default pack
4: Variable size crosshairs
4.1: Variable size crosshair packs
4.2: Single file crosshairs


1: Getting Started

Things you need to do when Xhair Factory has been downloaded:
Make a directory on your hard-disk to unpack it in, c:\gameprogs  Usually does the trick.
(Ms-Dos users must unpack with the -d option)

Run Pakexplorer once, and set all preferred options.
Run SpriteViewer once, and/or make sure it is linked to the .Spr file-type.
you can link it to opening .Spr files by double-clicking on a Spr file, and then selecting the Sprite Viewer from a list, or finding it on your hard-disk manually.
Now grab all *.Pal files form the palette directory and place them in your PaintShopPro\palettes  directory. (You don't have to, but it might save you time later.)


2: Xhair Factory v1.2 Contents.

Xhair Factory v1.2
- Ready to use Crosshair Packs, for instant action.
- Ready to use Crosshair Palettes, for easier crosshair customization.
- PakExplorer 1.2, for opening and extracting .PAK files.
- Sprite Generator, uses a .Qc and a .Bmp to create an .Spr file.
- Sprite Viewer, can view and extract .Qc and .Bmp files from a .Spr file
- A set of tutorials on how to make crosshairs and sprites. (Kinda useless if you have this Html file... ;-)


2.1: PakExplorer Usage

When Opening a .Pak file a Windows-Explorer environment will be started.
While PakExplorer was Originally make for Quake 2 editing usage, it supports Half-Life .Pak files as well.

Quake 2 does not read images from its baseq2 directory therefore any crosshairs must be placed within an existing .Pak or in a newly created pak9.pak (or whatever isn't used yet)

Pakexplorer can be used with Half-Life using the same functions as are available for Quake2, with the exeption that
you cannot safely add file to the .Pak, it might be possible, but beware that HalfLife is based on the Quake 1 engine, not Quake 2!!

Pakexplorer can load file from the pak into a temporary directory so that all files known to your system can be started
by their default editors. Bmp, Pcx and Gif images with PaintShopPro. Textfiles with notepad, and so on.
Pakexplorer allows you to listen to wav files from within the pak by using its build-in sound engine. (Ofcourse you will need a soundcard DUH!)

The main function of Pakexplorer will be to Extract Files for editing or viewing with Sprite Viewer.
Simply right-click on a file or directory and select extract-to, and select the directory where the files are to be extracted.


2.2: Sprite Generator Usage

Xh Factory Version 1.2 and above comes with a Compile-All.bat added in the Sprite Generator directory.
This file will scan current directory for known bmp files and give SprGen.exe the order to compile a Sprite file for each file set found.
If for example you place the file "laserdot.bmp" in the same directory as Compile-All.bat , and then run compile-all, the batfile will then be able to find your laserdot.bmp and send it to SprGen.exe which will make a laserdot.spr , in turn Compile-all
will then present you with this file so that you can place it in the halflife directory, or open it with Sprite Viewer.
Required files for Sprite file:
- Bmp, can be created with an image editor, or converted from a Gif image.
- Qc, This is a Textfile which contains compiling data for SprGen, it can be edited with notepad.


2.3: Sprite Viewer Usage

Double-click on any Sprite-file to open it, or select "File -> Open" (Ctrl-O) from within Sprite Viewer.
You will then see the seleted Sprite, animating when possible.
Its now possible to save a single frame from the sprite as a Bmp file, or save a sequence of files including the QC file.
Sprite Viewer also allows you to take a closer look at the sprite, by zooming in or out, and give additional information about the file.


3: A Simple Crosshair

Now that you know how to use the tools, lets create a simple crosshair, and replace the current pistol crosshair.

Firstly, start PSP 5, or 6, whatever you use.
Select: File > New > Width 24, Height 24. 256 Colors 8 Bit.
 
Second you'll need an easy to use palette.
Load one from the Xhfact directory, or extract it from one of these:
To extract a palette Right click on one of the images, and select "save image as"
put it anywhere in the My-Documents folder or something.
Open it in PSP and Select: Colors > Save palette.
You can save it as "HL-crosshairs.pal" or something in that direction.
Now open your new image, and select: Colors > Load palette. (So far, so good eh?)

Now you should have an empty 24x24 sized image with a pretty cool palette,
and probably a black background like i have right now.

Lets flood-fill the image with color: 77,77,77. which is the grey color in the bottom right corner.
This should be the final palette entry, which is used by HalfLife as transparency color.
When that is done put a red, blue or green dot, at position 11,11 on the image.
 
You should have something like this:
on your screen now.
Note that this is the exact center of your crosshair. and almost all HalfLife weapons fire exactly
at this location. Exept the hornet gun and sniper ofcourse.

Now to keep this tutorial simple we shall make a big + for a crosshair. Act with me,
 
Make a line from:  11,9 to 11,1
a line from:  9,11 to 1,11
from:  11,13 to 11,21
and finally:  13,11 to 21,11

There you have it,, a basic crosshair. It doesn't get any easier.
Notice that the un-used strokes at the bottom and right side of the image are slightly larger than the
top and left. This is simply because these 2 small strokes are NOT used, so don't put anyhing in there ok?
After all, you don't want to end up with an A-symetrical crosshair?


3.1: Implementing a Simple Crosshair, into Half-Life

Now i suppose you'll want to see how it'll look in HalfLife right?

To reduce the time of making a full crosshair sprite, we'll just grap the standard one and replace the pistol crosshair.
 
Grab this one the same
way you did earlyer,
or extract it from
valve\sprites\crosshairs.spr
located within valve\pak0.pak
Open it with PsP and
carefully place your
cross one over the
pistol crosshair, like so:
Don't bother about the other crosshairs yet, i'll get to that in a minute.

Now make sure you save it as a "Windows or os/2 Bitmap *.BMP", and place it in the file Generator directory.
delete any older versions, and name it crosshairs.bmp.

Run: "Compile-all.bat"

Once "Compile-all.bat" Has completed its task you will find a new sprite file in the current directory.
Place the crosshairs.spr in the: Half-Life\valve\sprites\
directory, and run Half-Life... your pistol should now have your very own crosshair on it.


3.1.1: The Contents of a Qc file
 
Note: This info is inside the essentials\crosshairs.qc
// Half-Life Sprites
//
// Added $texture, valid types are:
// "additive"   - full color texture, to be blended with additive transparency
// "indexalpha" - full color, palette index is alpha
// "alphatest"  - full color, 255 is a hole
// "normal"     - same as additive in practice, full color, no blending or holes

$spritename     crosshairs
$type           vp_parallel
$texture alphatest
$load  crosshairs.bmp
$frame  0   0   128   128

Lines with // are skipped during compile process.
- Spritename: Name of output Sprite file.
- Type: vp_parallel is visible to user.
- Texture: Additive is transparent, like the Rpg Laserdot.
- Texture: Alphatest is opaque, exept for the final palette entry.
- Load: Filename to be loaded.
- Frame: Compile start at position " x wide, x high " , and "y to the right, y down"
Since "y" is relative, it tells the dimentions of the field to be compiled.


3.1.2: Troubleshooting

What if your crosshair doesn't show up?
1: Select the pistol.
2: If no crosshair is shown "At All" when you have selected the pistol.
  Make sure you allow the crosshairs to be shown. Activate it with: crosshair "1"
3: If you see your old crosshair, not the new one: backtrack the following:
 -Did you indeed save the "new" Crosshair pack?
 -Did the compiler, Compile the "new" Crosshair pack?
 -Was the file you placed in: \halflife\valve\sprites\    . called: "crosshairs.spr"  ?
4: If it still doesn't work just recompile it, and overwrite the crosshairs.spr
5: Persistant problem? Uninstall Windows and throw your pc out of the window.


3.2: Other crosshairs in the default pack.

By now you should have gains some knowledge on how to make a croshair, and im sure you can't wait to modify the other crosshairs by now.
 
In this:
Image, (standard
crosshairs) the
following locations
represent these
weapons.

(From left to right)
Unused*, Pistol, Magnum, sniper, Magnum-Zoomed
Shotgun, Hornet-gun
Mk-5, Rpg, Gauss, Gluon(O2)
A-Pistol, A-Magnum, A-Mk-5, A-Shotgun.
A-Sniper, Sniper-Zoomed
A-Sniper-Zoomed.
* : First crosshair is not used, and editing it will not provide you with a new crosshair in-game.
A : Weapon with activated Autoaim.

Note that all but the zoomed-in sniper crosshairs are: 24x24 pixels in size.
The Zoomed Snipers are: 104 wide, and 16 high.

You can alter all crosshairs the same way you made the "blue" cross for the pistol, add a touch of another color for the autoaim crosshairs, and you got another custom crosshair pack. Just be creative.
Well, i guess that should get you going for now.
Onto the next subject.


4: Variable size crosshairs

As you probably guessed by now, its indeed possible to make bigger crosshairs, and crosshair packs.
And as long as you keep to a few simple rules, it can be very worthwhile

Each dimention "must" be a multiple of 8. So 8, 16, 24, 32, 64, 96, 128 and such.
Maximum size of a sprite can be 256x256 pixels. Keep this in mind when making a crosshair pack as well, coz if you make each independant crosshair too big, the pack might grow over 256x256 pixels, and will ned to be seperated.
But even that, isn't a problem.

So here's the scoop:
Each crosshair used in the game, is defined in a so called TextFile.
In the halflife\valve\pak0.pak  (use pakexplorer)
there are a bunch of these TextFiles in the "sprites" directory, these TextFiles tell HL how big each
crosshair is, in which spritefile to find it, and the location (dimensions) of the sprite to be used.
 
Here's an example of: weapon_crossbow.txt
14 // < Number
     //of sprites
//Resolution
//Used at
//Spritefile
//name
//Start,
//Width
//Start,
//Height
//Dimension
//Width
//Dimension
//Height
weapon 320 320hud1 80 0 80 20
weapon_s 320 320hud1 80 20 80 20
ammo 320 320hud2 72 16 18 18
crosshair 320 crosshairs 72 0 24 24
autoaim 320 crosshairs 0 96 24 24
zoom 320 crosshairs 24 96 104 16
zoom_autoaim 320 crosshairs 24 112 104 16
weapon 640 640hud2 0 0 170 45
weapon_s 640 640hud5 0 0 170 45
ammo 640 640hud7 96 72 24 24
crosshair 640 crosshairs 72 0 24 24
autoaim 640 crosshairs 0 96 24 24
zoom 640 crosshairs 24 96 104 16
zoom_autoaim 640 crosshairs 24 112 104 16
Lines with // are skipped during compile process.
Text in red are comments.

Number of sprites: This is the number of sprite entries this texfile calls upon.
Resolution used at: This shows whether this is a sprite for 320, or 640 based resolution.
Spritefile name: This is the full name of the SPR file. (without the .spr extension.)
Start: This is the Width and Height specific location of there the first pixel of the sprite is located.
Dimension: This is the full size of the sprite / crosshair.

There are in total 16 of these textfiles. (Including the HUD)
And all these are also supplied with Xhair Factory 1.2.
Also be adviced that, in order for these things to work, you cannot change the name of those textfiles.

Now say you'd want to use a bigger crosshair for the zoomed sniper, and you don't use Autoaim, then you
could make use of the space that is used by the autoaim crosshair for making your normal crosshair bigger.
You could also make use uf the black areas on the default crosshair pack, but ill get to that later.

Here's an example:
14
crosshair 320 crosshairs 72 0 24 24
autoaim 320 crosshairs 0 96 24 24
zoom 320 crosshairs 24 96 104 16
zoom_autoaim 320 crosshairs 24 112 104 16
crosshair 640 crosshairs 72 0 24 24
autoaim 640 crosshairs 0 96 24 24
zoom 640 crosshairs 24 96 104 16
zoom_autoaim 640 crosshairs 24 112 104 16
//Before: I marked the values that will be changed.
14
crosshair 320 crosshairs 72 0 24 24
autoaim 320 crosshairs 0 96 24 24
zoom 320 crosshairs 24 96 104 32
zoom_autoaim 320 crosshairs 24 96 104 32
crosshair 640 crosshairs 72 0 24 24
autoaim 640 crosshairs 0 96 24 24
zoom 640 crosshairs 24 96 104 32
zoom_autoaim 640 crosshairs 24 96 104 32
After: New value added for both resolutions.
The result of this change will cause halflife to use the same coordinates for the zoomed sniper, as well as the a_zoomed sniper. In effect, the space that was used by the a_zoomed sniper is now being used by both.
By setting the autoaim position to the same as the zoom position, the autoaim crosshair is no longer used.
After that i take this unused space and add it to both crosshairs by increasing the height of both to 32.
Try it out.


4.1: Variable size crosshair packs

This is what it's all about.
You should remember this,
Ugly, Big, hard to see,
Crappy selection of default
Crosshairs, made by some
punk at Valve.
(no offence though)

As you probably noted, those big black areas on the palette are totally unused, and eat up memory
(less than 3K, but heck, its the thought that counts.)
 
With the knowledge you got from Par 4 you
should be able to redesign the crosshairs.spr
Make it use less diskspace (as if 3K matters.)
or give more detail to your crosshairs. (Finally!)
Or even give each crosshair its own Sprite-File.

Here is my very first attempt at reduction.
And you can use <These (3K)> textfiles with it.
Note that only 9 weapons use a crosshair.


A difference of 3K
with the origonal
Valve Crosshairs.

Ofcourse this is not nearly perfect, right?
You can still see a lot of black, and unused space.
So, lets remake the crosshairs.spr again, this time a bit more severe.
Since the crosshair at position: "0,0 size 24x24" is not used by any of the weapons, this one can be deleted,
thus leaving a black space. This way we can make the image even smaller, and while we are at it,
it would be nice to sort this thing out a bit.
 
From left to right: 
Pistol, A-Pistol, Magnum, A-Magnum, Zoomed Magnum.
Mk-5, A-Mk-5, Shotgun, A-Shotgun, Rpg.
Sniper, A-Sniper, Gauss, Gluon, Hornet.
Sniper-Zoomed.
A-Sniper-Zoomed.
I moved all crosshairs to different locations, and placed the Autoaim next to each non-autoaim crosshair.
This is as small as i could get it, without changing the crosshair sizes.
Ofcourse i know that with this pack the sniper could be made a bit more wide, but thats not the point of this current tutorial.
The textfiles i used for this one are also included in XhairFactory 1.2, its named "reduced-pack".


4.2: Single file crosshairs 

Now onto the main thing: Single file crosshairs.

I'm sure you wondered why the hell those crosshairs were all located in the same file, right?
Yes you were! you used to play quake, quake 2, and games like that. and they all had seperate files for each crosshair. Valve did gave it a good thought, coz a single spr file takes less space than 18 seperate sprites, instead of 18 start and end flags, you only need 1 start and ending flag for the file. (Im not gonna explain that, just take it from me ok?)

I'll now show you how to make single file crosshairs, for the good old days sake,
or for making a all-round crosshair.
 
Unlike the all in 1, crosshair file, you can make
each crosshair have its own sprite file.
This enables easyer editing / replacing crosshairs.
And it saves you the trouble of having to make
a complete crosshair pack, each time you get
tired of your old ones.
Each crosshair will thus need to be given its own
QC-file, and BMP-file. then each one needs to
be compiled to a SPR-file, and in the TXT-file
you will finally have to tell halflife what you did.
Sounds difficult?
Well, its not. It just takes up a bit of your time for preparation.
But once you complete it, you can easily change each crosshair shape,
size, and EVEN the palette of "Each" available crosshair.
Its worth a considderation.

This is how to make one: (Note that this TextFile is just an example)
4 //Spritename
crosshair 320 320_shotgun 0 0 24 24
autoaim 320 320_a_shotgun 0 0 24 24
crosshair 640 640_shotgun 0 0 48 48
autoaim 640 640_a_shotgun 0 0 48 48
This way you can use a different sprite with the same or bigger dimensions for each different weapon crosshair.
Check out Xhair Factory again for the Pro-Pack, it uses seperate 24x24 crosshairs with different sprites.

You could also Use the same Sprite for each weapon, that way some TFC people wont need to make
an entire pack filled with the exact same crosshair 18 times. Seems kinda pointless to me.

Again, another example:
4 //Spritename
crosshair 320 TfcCrosshair1 0 0 24 24
autoaim 320 TfcCrosshair1 0 0 24 24
crosshair 640 TfcCrosshair1 0 0 24 24
autoaim 640 TfcCrosshair1 0 0 24 24

Behold the QC file that this single file crosshair would need to use:
$spritename TfcCrosshair1
$type vp_parallel
$texture alphatest
$load TfcCrosshair1.bmp
$frame 0  0  24  24

Ofcourse instead of 24x24 you could easily make it 48x48,
96x96 or any multiple of 8 smaller or equal than 256x256.

I guess that just about rounds up this tutorial, go on and make yourself proud!

If you make anything worthwhile, just let me know.