Adding new HUD sprite for new weapon Created 8 years ago2016-03-20 16:56:49 UTC by EsprimoP EsprimoP

Created 8 years ago2016-03-20 16:56:49 UTC by EsprimoP EsprimoP

Posted 8 years ago2016-03-20 16:56:49 UTC Post #329481
I created a new weapon in HLSDK and it works just fine, animations, precaches, classname, etc. But I after picking up another weapon I can't switch to it, there's no sprite. I can't find any part of the code in HLSDK where weapon HUD sprites are present. I created the new weapon through this tutorial http://twhl.info/articulator.php?art=31. It is not very accurate but I fixed some issues and made it work. Now, I made a nice sprite in Sprite Explorer for the weapon. But how do I add it? In the sources and headers for existing weapons there are no hud sprite parts.

Ugh.. sorry I'm so confused, I don't know what else to type, tell me what do you think I just said (What you understood).
EsprimoP EsprimoPwEight
Posted 8 years ago2016-03-20 17:18:49 UTC Post #329482
What are the values of "iSlot" and "iPos" in your weapon's "GetItemInfo" method ?

EDIT : sprites are handled by "weapon_myweapon.txt" in the "sprites" folder.
Posted 8 years ago2016-03-20 19:56:03 UTC Post #329486
iSlot = 0
iPos = 0
I did change the crowbar's iPos to 1 so it goes after the new melee weapon.

I never noticed that text file.. I'll check it out.
EsprimoP EsprimoPwEight
Posted 8 years ago2016-03-20 22:58:00 UTC Post #329488
The weapon cpp is not the only place you must change position values. I think there are stuff u need to change in weapons.h as well (if I remember correctly)
Posted 8 years ago2016-03-21 18:57:23 UTC Post #329506
Couldn't make it in weapons.h but I did actually change the new weapon's position to 1, and returned crowbar to default. So now It actually works, but the sprite is not set. I made 2 sprites for the new weapon (When selected and not), made weapon_classname.txt in sprites folder. I copied it from weapon_crowbar.txt and changed it. I still don't know what those numbers means.

4
weapon 320 320hud1 0 0 80 20
weapon_s 320 320hud1 0 20 80 20
weapon 640 640mpipe1 0 0 170 45
weapon_s 640 640mpipe2 0 0 170 45

What does all of this mean?

After starting a map, it crashes with an error GL_Upload16: s&3 and R6025
-pure virtual function call
.

I first compiled hl.dll before adding the sprite and the weapon worked well, I could select it. This error appears after adding the sprite.
EsprimoP EsprimoPwEight
Posted 8 years ago2016-03-21 19:37:17 UTC Post #329508
The first number is the number of lines in this file (in this case 4)
The syntax is the following
<object> <res> <filename> <offset x> <offset y> <size x> <size y>

object = What is this sprite's role ? It can be "weapon" (weapon not selected), "weapon_s" (weapon selected), "crosshair", "zoom", "autoaim", "ammo" and many more, check the other files
<res> = The base resolution (320 or 640), it will use 320 on resolutions lower than 640x480 and 640 on that resolution and higher
<filename> = The SPR file to load
<offset x> = The starting point in the X axis
<offset y> = The starting point in the Y axis
<size x> = The width of the sprite
<size y> = The height of the sprite

As for the crash, make sure that the sprite is in additive mode (if you are using Sprite Explorer), clean and build the solution again.
Posted 8 years ago2016-03-23 17:26:53 UTC Post #329515
Edit: Fixed it.
The width and height were out of bounds and caused the crash.
EsprimoP EsprimoPwEight
You must be logged in to post a response.