Wavelength Logo
tl.jpg (2351 bytes) blank.gif (837 bytes) tr.jpg (2446 bytes)
blank.gif (837 bytes)
Advanced Sprite Editing by Spider
blank.gif (837 bytes)

This article details the information in the sprite text files in the Half-Life pak0.pak file so you can add your own sprites to the HUD. This is closely associated with editing code but I'll leave that to programmers and just explain the text files. This does not explain how to move sprites around in the game HUD, but rather to modify these text files to accommodate your new sprites. This is necessary if you're adding new weapons or if trying to replace existing sprites is too restricting. For a mod, you need to include any edited or new text files in your own pak file.

To edit sprites, see my sprite tutorial. It gives information about the types of sprites, as does Valve's Sprite Tutorial.


Here is a listing of the sprites involved and the list of text files, all in the sprites folder of the pak file. I'll give the details for Hud.txt and one of the weapons, Weapon_9mmar.txt.

320hud1.spr
320hud2.spr
320hud3.spr
320hud4.spr
640hud1.spr
640hud2.spr
640hud3.spr
640hud4.spr
640hud5.spr
640hud6.spr
640hud7.spr
640hud8.spr
640hud9.spr
crosshairs.spr
Hud.txt
Weapon_357.txt
Weapon_9mmar.txt
Weapon_9mmhandgun.txt
Weapon_crossbow.txt
Weapon_crowbar.txt
Weapon_egon.txt
Weapon_gauss.txt
Weapon_handgrenade.txt
Weapon_hornetgun.txt
Weapon_question.txt
Weapon_rpg.txt
Weapon_satchel.txt
Weapon_shotgun.txt
Weapon_snark.txt
Weapon_tripmine.txt



Hud.txt
Below is a sampling of the many sprites in hud.txt. It includes important things such as the health numbers, damage icons and weapon icons that appear when you pick up a weapon. Here's a listing of the sprite parameters:

Sprite Index 320
or
640
.spr
filename
top left
X
top left
Y
width height


The first number (121) is how many sprites there are in this text file. Then it starts listing the sprites. First is the sprite Index or name that it's called in the code. Then either 320 or 640 is chosen. 320 is for screen resolutions less than 640x480, and 640 is for 640x480 and above. The sprites are organized to list the 320 ones first, then the 640 sprites. Next is the actual sprite filename without the .spr extension. Then comes the top left X coordinate and the top left Y coordinate in that file. Next is the width and height to designate a rectangle which includes the image you'd like to use for that sprite.

121            
selection 320 320hud1 160 160 80 20
bucket1 320 320hud2 108 16 12 12
bucket2 320 320hud2 108 28 12 12
...            
dmg_bio 320 320hud4 0 0 32 32
dmg_poison 320 320hud4 0 0 32 32
...            
number_0 320 320hud2 0 0 12 16
number_1 320 320hud2 12 0 12 16
...            
divider 320 320hud2 120 0 1 20
...            
title_half 320 320hud3 0 48 128 16
title_life 320 320hud3 128 48 116 16
d_crowbar 320 320hud1 0 208 48 16
d_9mmhandgun 320 320hud1 0 224 32 16
...            
selection 640 640hud3 0 180 170 45
bucket1 640 640hud7 168 72 20 20
...            


To find out more about changing the HUD in Half-Life's source code, see cl_dll\hud.cpp.


Weapon_9mmar.txt
Below are the sprites in weapon_9mmar.txt. It includes when you select a weapon to use, it's ammo and crosshairs. Here's a listing of the sprite parameters:

Sprite Index 320
or
640
.spr
filename
top left
X
top left
Y
width height


The first number (12) is how many sprites there are in this text file. Then it starts listing the weapon's sprites. First is the sprite Index or name that it's called in the code. The Sprite Index choices are: ammo, ammo2, autoaim, crosshair, weapon, weapon_s, zoom and zoom_autoaim. Ammo and ammo2 are primary and secondary ammo sprites for when you pick them up. Weapon_s is it's selected state in the HUD, and weapon is not selected, plus it will change color when the weapon is out of ammo. The colors are listed in cl_dll\hud.h as RGB_YELLOWISH, RGB_REDISH and RGB_GREENISH, which can be changed. Then either 320 or 640 is chosen for screen resolutions. Next is the actual sprite filename without the .spr extension. Then comes the top left X coordinate and the top left Y coordinate in that file. Next is the width and height to designate a rectangle which includes the image you'd like to use for that sprite.

// mp5            
12            
weapon 320 320hud1 0 120 80 20
weapon_s 320 320hud1 0 140 80 20
ammo 320 320hud2 0 16 18 18
ammo2 320 320hud2 36 16 18 18
crosshair 320 crosshairs 0 48 24 24
autoaim 320 crosshairs 48 72 24 24
weapon 640 640hud1 0 135 170 45
weapon_s 640 640hud4 0 135 170 45
ammo 640 640hud7 0 72 24 24
ammo2 640 640hud7 48 72 24 24
crosshair 640 crosshairs 0 48 24 24
autoaim 640 crosshairs 48 72 24 24


To find out more about weapon sprites in Half-Life's source code, see cl_dll\ammo.cpp.


Conclusion
If you're replacing existing sprites and they're not the same size, you can simply change the coordinates in these files. If you want to add new sprite files to the HUD, just add them in to hud.txt and set it's number appropriately. You can create your own text files for new weapons but you'll need to add code to load in the text files.


blank.gif (837 bytes)
bl.jpg (2471 bytes) blank.gif (837 bytes) br.jpg (2132 bytes)