Death notices with custom weapons

From Valve Developer Community
Revision as of 10:36, 25 September 2005 by Draco (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

For a few months The Battlegrounds 2 was without its own death notices. Upon inspection of the code I found how to support our weapons, and it was quite easy too. I hope that this helps those who are looking for a solution to this and can't see it.

First of all lets take a look at the player death event handler function of the HL2DM death notices element.

char fullkilledwith[128];
if ( killedwith && *killedwith )
{
	Q_snprintf( fullkilledwith, sizeof(fullkilledwith), "death_%s", killedwith );
}
else
{
	fullkilledwith[0] = 0;
}

and if that fails...

// Try and find the death identifier in the icon list
deathMsg.iconDeath = gHUD.GetIcon( fullkilledwith );
if ( !deathMsg.iconDeath || deathMsg.iSuicide )
{
	// Can't find it, so use the default skull & crossbones icon
	deathMsg.iconDeath = m_iconD_skull;
}

so what we need to do is give the engine something to use for your weapon. So how is that done? Let's look through the texture find code.

// Try and find the death identifier in the icon list
deathMsg.iconDeath = gHUD.GetIcon( fullkilledwith );

so we need to find a death_* token in the script files. The one you need should be obvious, it's mod_textures.txt

oh look at the first token!

"death_357"
{
	"font"		"HL2MPTypeDeath"
	"character"	"."
}

So, if you can make your textures into a font file, use that as a template, but unfortunately I don't have one, so I decided to load standard materials.

"death_brownbess"
{
	"file"		"hud/death_brownbess"
	"x"		"0"
	"y"		"0"
	"width"		"150"
	"height"	"25"
}
"death_charleville"
{
	"file"		"hud/death_charleville"
	"x"		"0"
	"y"		"0"
	 "width"		"160"
	"height"	"25"
}

simply make a death_ entry for each weapon, using their entity name with death_ instead of weapon_.

Ok, so now you can load a material and crop it using the 4 other values there, great! But now you need to create those materials. Heres something your texture artist would already know, but I'll show you anyway. Your VMT should have these entries on them to have transparencies and work correctly on the HUD.

"Unlitgeneric"
{
	"$baseTexture" "hud/death_pennsylvania"
	"$translucent" 1
	"$alphatest" 1
	"$ignorez"	1
}

Ok, so now you should be able to get those cool weapons showing properly.

Deathnoticeexample.jpg

--Draco 03:36, 25 Sep 2005 (PDT)