Death notices with custom weapons

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.