View Full Version : Hud weapons pics
berzerker8x
03-21-2003, 08:03 PM
Hi,
I noticed that the images for the weapons in the hud is all composed from one picture, what i don't understand is how does the game recognize where the picture is and what the picture is for which weapon.. Can anyone help me out. like, just set me in the right direction. I'm sure I can figure it out once I get a little assistance, thanks in advance
thanks
Akari
03-21-2003, 10:44 PM
</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> [ActiveWeapon]
{
[WeaponSpecific]
id = WEAPONID_BERETTA;
LowAmmunition = LOWAMMO_ALWAYS_VISIBLE;
UnlimitedAmmoText = "-";
[Sprite]
ReferencePoint = DOWNRIGHT;
Position = WEAPON_POSITION ;
Width = WEAPON_WIDTH ;
Height = WEAPON_HEIGHT ;
Filename = "bitmaps\weapons\beretta.jpg";
AlphaFilename = "bitmaps\weapons\beretta_alpha.pcx";
DefaultVertexAlpha = WEAPON_ALPHA ;
} [/code]</blockquote><font size="2" face="Verdana, Arial">found in HUD.txt
Akari
03-21-2003, 10:52 PM
Oh sh*t! Sorry. I thought you meant something else! Well it finds it cause in the source
code it tells it which rows are for which slots.
</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> #define SLOTID_EMPTY 10
#define SLOTID_LEADPIPE 0
#define SLOTID_BASEBALLBAT 10
#define SLOTID_BERETTA 1
#define SLOTID_BERETTADUAL 1
#define SLOTID_DESERTEAGLE 1
#define SLOTID_SAWEDSHOTGUN 2
#define SLOTID_PUMPSHOTGUN 2
#define SLOTID_JACKHAMMER 2
#define SLOTID_INGRAM 3
#define SLOTID_INGRAMDUAL 3
#define SLOTID_MP5 3
#define SLOTID_MOLOTOV 4
#define SLOTID_GRENADE 4
#define SLOTID_M79 4
#define SLOTID_SNIPER 5
#define SLOTID_PAINKILLER 10
#define SLOTID_KUNGFU 0
#define SLOTID_LEVEL1 10
#define SLOTID_LEVEL2 10
#define SLOTID_LEVEL3 10
#define SLOTID_LEVEL1_PRINT 10
#define SLOTID_LEVEL2_PRINT 10
#define SLOTID_LEVEL3_PRINT 10
#define SLOTID_STICK 0[/code]</blockquote><font size="2" face="Verdana, Arial">from KF3/ The stick weapon which is near the lead pipe ingame has the same thing as the SLOT_ID_STICK .... 0
Notice the numbers? Also notice how that the baseball bat and the leadpipe are on the
same row in the weapons hud image? That's because there numbers are in the same area.
Make sense? Sorta huh? So if you want to add a new weapon in the WH file and want it
near the melee weaps then make the weapon slot number to 1 2 or 3
LJHalfbreed
03-21-2003, 11:04 PM
Uh... WTF are you talking about akari????? You need to stop smoking crack. Please read the question before you post some weird craziness...
The following is found in the hud.txt file in your data folder (if you correctly decompile/decompress your x_data.ras and x_english.ras files correctly)....
</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> // offsets to find weapons in combination map
#define U_0xOFFSET 0.0
#define U_1xOFFSET 0.333333
#define U_2xOFFSET 0.666666
#define U_3xOFFSET 1.0
#define V_0xOFFSET 0.0
#define V_1xOFFSET 0.166666
#define V_2xOFFSET 0.333333
#define V_3xOFFSET 0.5
#define V_4xOFFSET 0.666666
#define V_5xOFFSET 0.833333
#define V_6xOFFSET 1.0
// sprite sizes in 640x480 space
#define SLOTNUMBER_WIDTH 12
#define SLOTNUMBER_HEIGHT 12
#define SLOTWEAPON_WIDTH 60
#define SLOTWEAPON_HEIGHT 20
// positions in 640x480 space
#define SLOT1_NUMBERPOSITION ( 170, 15, 0 )
#define SLOT2_NUMBERPOSITION ( 230, 15, 0 )
#define SLOT3_NUMBERPOSITION ( 290, 15, 0 )
#define SLOT4_NUMBERPOSITION ( 350, 15, 0 )
#define SLOT5_NUMBERPOSITION ( 410, 15, 0 )
#define SLOT6_NUMBERPOSITION ( 470, 15, 0 )
#define SLOT1_WEAPONPOSITION ( 170, 40, 0 )
#define SLOT2_WEAPONPOSITION ( 230, 40, 0 )
#define SLOT3_WEAPONPOSITION ( 290, 40, 0 )
#define SLOT4_WEAPONPOSITION ( 350, 40, 0 )
#define SLOT5_WEAPONPOSITION ( 410, 40, 0 )
#define SLOT6_WEAPONPOSITION ( 470, 40, 0 )[/code]</blockquote><font size="2" face="Verdana, Arial">AND THEN!!!
</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> [Slot]
{
[SlotNumberSpriteWindow]
ReferencePoint = CENTER;
Position = SLOT1_NUMBERPOSITION;
Width = SLOTNUMBER_WIDTH;
Height = SLOTNUMBER_HEIGHT;
UVUpperLeft = ( 0.676666, 0.00 , 0);
UVLowerRight = ( 0.732222, 0.10 , 0);
[SlotWeapon]
{
[WeaponSpecific]
ID = WEAPONID_BASEBALLBAT ****(or whatever the ID of your particular weapon is);
[SpriteWindow]
ReferencePoint = CENTER;
Position = SLOT1_WEAPONPOSITION;
Width = SLOTWEAPON_WIDTH;
Height = SLOTWEAPON_HEIGHT;
UVUpperLeft = ( U_1xOFFSET , V_0xOFFSET , 0); **** This references those values defined above
UVLowerRight = ( U_2xOFFSET , V_1xOFFSET , 0); **** Ditto... references those values defined above
}[/code]</blockquote><font size="2" face="Verdana, Arial">Okay... you see how the remarks call for some graphic to be 640x480? That's that graphic that has all the weapon pix on it... more commonly known as " Data\hud\bitmaps\weaponhud.pcx ".
Basically, all those offsets and numbers refer to pixel columns, widths, and measurements within that particular pcx file.
If you get bored (like me) you can fool around and either make a bigger pcx file, or make the icons in that current pcx file smaller... then you can have silhouettes of whatever weapon you want.
Keep in mind that this is a rather involved and lengthy process. If you look at this part of the text in the hud.txt file, and then open up the pcx with a decent image viewer/editor, you'll see how the game knows in which section a weapon outline is found, and then is later 'referenced' in that same hud.txt . Also, after you do all the drop-down scrolly hud stuff, within the actual active weapon texts you'll have to edit the graphic that shows in the lower right-hand corner... it usually has the weapon name and a 'plus' sign above it.
Good luck, and hopefully this explained your situation and how to fix it better than other people's crazy crack-smoking ideas.
images/icons/tongue.gif
-LJ
Akari
03-21-2003, 11:10 PM
... What's really sad is that I don't smoke anything at all! LOL
LJHalfbreed
03-21-2003, 11:13 PM
PS. The slot ID numbers are to tell the game which 'slot' the pictures should show up in the HUD.
Also, you can have weapons share ammo by configuring ID's in that same file that the slot ID's are to be the same number...
For example:
(WARNING: This is taken from an incomplete version of a weapons test for a mod I'm working on.)
</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> // Max Payne WEAPONID list
//DE REPLACED BY REVOLVER
#define WEAPONID_EMPTY 0
#define WEAPONID_LEADPIPE 1
#define WEAPONID_BASEBALLBAT 2
#define WEAPONID_BERETTA 3
#define WEAPONID_BERETTADUAL 4
#define WEAPONID_DESERTEAGLE 5
#define WEAPONID_SAWEDSHOTGUN 6
#define WEAPONID_PUMPSHOTGUN 7
#define WEAPONID_INGRAM 8
#define WEAPONID_INGRAMDUAL 9
#define WEAPONID_MP5 10
#define WEAPONID_JACKHAMMER 11
#define WEAPONID_MOLOTOV 12
#define WEAPONID_GRENADE 13
#define WEAPONID_M79 14
#define WEAPONID_SNIPER 15
#define WEAPONID_PAINKILLER 16
#define WEAPONID_STAKEGUN 17
#define WEAPONID_REVOLVER 18
#define WEAPONID_CROSSBOW 19
#define WEAPONID_DBMG 20
#define INVENTORYID_EMPTY 0
#define INVENTORYID_LEADPIPE 1
#define INVENTORYID_BASEBALLBAT 2
#define INVENTORYID_BERETTA 3
#define INVENTORYID_DESERTEAGLE 4
#define INVENTORYID_SAWEDSHOTGUN 5
#define INVENTORYID_PUMPSHOTGUN 5
#define INVENTORYID_INGRAM 6
#define INVENTORYID_SNIPER 7
#define INVENTORYID_MP5 8
#define INVENTORYID_JACKHAMMER 9
#define INVENTORYID_GRENADE 10
#define INVENTORYID_MOLOTOV 11
#define INVENTORYID_M79 12
#define INVENTORYID_PAINKILLER 13
#define INVENTORYID_STAKEGUN 14
#define INVENTORYID_REVOLVER 4
#define INVENTORYID_CROSSBOW 15
#define INVENTORYID_DBMG 16
#define SLOTID_EMPTY 10
#define SLOTID_LEADPIPE 0
#define SLOTID_BASEBALLBAT 0
#define SLOTID_BERETTA 1
#define SLOTID_BERETTADUAL 1
#define SLOTID_DESERTEAGLE 10
#define SLOTID_SAWEDSHOTGUN 2
#define SLOTID_PUMPSHOTGUN 2
#define SLOTID_JACKHAMMER 2
#define SLOTID_STAKEGUN 2
#define SLOTID_INGRAM 3
#define SLOTID_INGRAMDUAL 3
#define SLOTID_MP5 3
#define SLOTID_MOLOTOV 4
#define SLOTID_GRENADE 4
#define SLOTID_M79 4
#define SLOTID_SNIPER 5
#define SLOTID_PAINKILLER 10
#define SLOTID_REVOLVER 1
#define SLOTID_CROSSBOW 5
#define SLOTID_DBMG 3
[/code]</blockquote><font size="2" face="Verdana, Arial">Slot 10 is an 'empty' slot, meaning you can't select or 'mousewheel' over to that slot.
InventoryID's tell the engine where to find the 'bullets' for each weapon. If a weapon shares bullets (such as the pump shotgun and the sawed-off shotgun), then all inventory ID's of 'shared bullet pool' weapons will have the same exact number.
Each weapon ***MUST*** have a UNIQUE weaponID. If you have any that have the same ID, you might run into problems unless you're replacing kf2's and not weapon scripts.
The InventoryID tells the engine which weapons share bullets, like I talked about above.
The SlotID helps explain to the hud on where weapons should show up in the hud slots. You know how each of the slots has a number above it? That's where this comes into play. Please don't confuse this with the weaponpriority.txt . The weaponpriority file just tells the engine which weapons to switch to... so technically you could have two totally different slotted weapons set as 1 and 2 priorities, and then have different groups WITHIN the slots be part of the previous weapon/next weapon cycling command.
Just trying to help and eliminate any wrong information.
-LJ
Akari
03-21-2003, 11:22 PM
Just trying to help and eliminate any wrong information. <font size="2" face="Verdana, Arial">Every buddy says Im dumb but look whos laughing now! HAHAH HAHA HAHHAHAH..HA..ha...umm...wait a minute...I made a mistake....
berzerker8x
03-21-2003, 11:48 PM
Hey guys, I appreciate the replies man, it's ok Akari, everyonem akes mistakes sometimes images/icons/smile.gif
I know the slot stuff, just didn't understand how the little imagte is taken from the single picture to make up the images on the huds..
huh.... it looks very extensively time consuming and confusing... I looked at it early but I din't know what it was, kinda had a vague idea of how I have to select a certain section of it... ugh.... Thanks for the reply, I'll be investigating it hehe.
LJHalfbreed
03-22-2003, 12:19 AM
Heh.. its really not that hard if you start thinking about it...
The one part of code talks about the 'offsets' of the various axes.
On a 2d plane, such as the .pcx the txt file is referencing, you'll have 2 different dimensions to work with, x and y. Because artists are weird, they like to mess with stuff and change the variable names to 'UV' instead of 'XY'. (No, that's not the real reason, but it will help you sleep at night... images/icons/smile.gif )
The X axis goes left to right. The Y axis goes up and down. All those offsets do is explain to the engine on how to divvy up that pic into different sections.
If you look at the weaponhud.pcx, you'll see how things are kinda separated into 3 columns (up and down) of 6 rows (left to right). (Also, there are two 'sniper' rifle pix that you can use if you're only adding 2 new weapon scripts).
The offsets tell the game which 'parts' of the pcx to look at. Since the X (column) offset is divided by three (the number of columns), the final 'offset' is decimal equivalents of 1/3, and that's why it says:
</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> #define U_0xOFFSET 0.0
#define U_1xOFFSET 0.333333
#define U_2xOFFSET 0.666666
#define U_3xOFFSET 1.0 [/code]</blockquote><font size="2" face="Verdana, Arial">So, if you wanted to make more columns, you'd basically divide the thing by fourths, and come up with:
</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> #define U_0xOFFSET 0.0
#define U_1xOFFSET 0.25
#define U_2xOFFSET 0.50
#define U_3xOFFSET 0.75
#define U_4xOFFSET 1.00[/code]</blockquote><font size="2" face="Verdana, Arial">And then you'd decrease that 'integer' accordingly... 5 columns would give you 0.0, 0.20, 0.40, 0.60, 0.80, 1.00. And so on..
You'd do the same thing for the y axis... if you want more rows, add them, and then adjust the V_xOFFSET integers to fit the decimal/integer equivalent of whatever fractions you're doing.
I will offer a word of advice. The current 'squares' of picture that are used for the hud pix are approximately 85x42 or so. Try to keep your weapons about that size to keep them from being too big, or even 'overlapped'. Even though the pcx is 256x256, you can make a new one that's larger. I recommend keeping it at a 'square' value, so you don't have to worry about any weird problems. Plus, 3d games like square textures a bunch... images/icons/smile.gif
Just try to look at it from the angle of a math problem, and you should be okay!
Unless you suck at maths.... images/icons/grin.gif
-LJ
berzerker8x
03-22-2003, 10:56 AM
I suck at math images/icons/grin.gif
but once I getstarted and have everything layed out ít should be alright... It doesn't sound that hard, as long as I get my calculations right and coded properly, i think ehehe... Thanks for the great tutorial. I'll be working on this for awhile hehe.
LJHalfbreed
03-22-2003, 11:20 AM
NP man. Glad I could help.
-LJ
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.