Death notices with custom weapons

For a few months The Battlegrounds 2 was without its own death notices. Upon inspection of the code it was shortly found how to add them to the weapons, and it was quite easy too. Hopefully, this will help those who are looking for a solution to this and can't see it.
First of all, 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 needs to be done is to give the engine something to use for your weapon. So how is that done? Look through the texture find code.
// Try and find the death identifier in the icon list deathMsg.iconDeath = gHUD.GetIcon( fullkilledwith );
So death_* token in the script files needs to be found. 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. Here's something your texture artist would already know, but it's handy for the coder to know also. 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.