Death notices with custom weapons
HL2MP-Based Mods
By default, mods based on Half-Life 2: Deathmatch will only have death icons for the weapons included in Half-Life 2. If an icon is not found, it will fall back to an icon of a skull. Half-Life 2 Deathmatch's icons come from a font file called HL2MP.ttf, found in the resource folder of your mod.
Explanation
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 );
Adding Icons
From above, it shows that it searches for a death_* token (where * is the weapon entity name minus "weapon") in scripts/mod_textures.txt.
"death_357" { "font" "HL2MPTypeDeath" "character" "." }
This is the first token, for the 357, this is using fonts for the death message. You can define your custom icons this way if you are using font-based icons for your death messages. Simply make a death_ entry for each weapon, using their entity name with death_ instead of weapon_.
You can also use textures.
"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" }
The "file" property is the filepath for the texture, minus "materials/" and an extension. These entries also use a region of the texture, rather than all of it, so "x" and "y" are the origin of the icon from the top-left, and "width" and "height" should be fairly self-explanatory.
Material Creation
The creation of these textures is fairly simple and can be done through tools such as VTFEdit. Once you have created your VTF, 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 }
"UnlitGeneric" is important, as otherwise it'll use the world lighting on the texture.
Result
Mod Template
The mod template is different to using the HL2DM template as it uses the death notices from Team Fortress 2, the death notices work in similar fashion to the HL2DM deathnotices, however this is just a slight difference.
"d_skull" { "file" "HUD/d_images" "x" "116" "y" "288" "width" "52" "height" "32" }
This is defined in the template, d_images contains all the death icons from TF2 whilse the x, y, width, height are specifying a region on that material file.
Contrary to what the comment in the default mod_textures.txt, death notices can use font-based icons.
"d_weapon_enfield" // NB: i've removed the code to remove the weapon_ prefix { "font" "DeathIcons" // define this in your SourceScheme "character" "E" }
Negative Icons
You will also see entries for "dneg_" icons, these are used when the local player (you) gets the kill, you may want to invert the icons, if your icons use a bright colour and then add a entry using "dneg_" instead of "d_".