Automatically sets the sprite color (from green to red) in a gradient way.
Automatically sets the sprite color to white for black and white survivors.
Allow setting the Z axis based on the client position.
Allow setting the visibility by team.
Allow setting the survivor visibility based on sight and last hit.
Allow setting the sprites visibility/model/alpha/fade/scale.
Allow setting a dead sprite color.
Allow setting which SI should have a sprite (except Witch).
Allow the client to hide/show the sprite through a menu or command. (client preferences).
Show sprite for incapacitated survivors.
Custom sprite.
Preview
Custom Sprite Preview
Note:
This requires the client downloading the custom sprite (.vmt and .vtf) "mart/mart_custombar.vmt" and "mart/mart_custombar.vtf". Search for FastDL for more info.
You must set the cvar l4d_hp_sprite_custom_model to "1"
Cvars
A configuration file named "l4d_hp_sprite.cfg" will automatically be created for you upon the first run in the "\cfg\sourcemod\" folder.
// Model of alive sprite.
// -
// Default: "vgui/healthbar_white.vmt"
l4d_hp_sprite_alive_model "vgui/healthbar_white.vmt"
// Scale of alive sprite (increases both height and width).
// Note: Some range values maintain the same size. (e.g. from 0.0 to 0.38 the size doesn't change).
// -
// Default: "0.25"
// Minimum: "0.000000"
l4d_hp_sprite_alive_scale "0.25"
// Show the alive sprite while client is alive.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_hp_sprite_alive_show "1"
// Show the sprite to the survivor attacker, by this amount of time in seconds, after hitting a special infected.
// 0 = OFF.
// -
// Default: "0.0"
// Minimum: "0.000000"
l4d_hp_sprite_attack_delay "0.0"
// Show the alive sprite in white on "black and white" survivors.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_hp_sprite_black_and_white "1"
// Maximum render alpha that a client must be to hide the sprite.
// Useful to hide it on invisible/transparent clients.
// -1 = OFF.
// -
// Default: "0"
// Minimum: "-1.000000"
// Maximum: "255.000000"
l4d_hp_sprite_client_alpha_max "0"
// Allow cookies for storing client preferences.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_hp_sprite_cookies "1"
// Use a custom sprite for the alive model
// Note: This creates an extra entity for each sprite.
// Note: This requires the client downloading the custom model (.vmt and .vtf) to work.
// Search for FastDL for more info.
// 0 = OFF, 1 = ON.
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_hp_sprite_custom_model "0"
// Color of dead sprite.
// Use three values between 0-255 separated by spaces ("<0-255> <0-255> <0-255>").
// -
// Default: "225 0 0"
l4d_hp_sprite_dead_color "225 0 0"
// Model of dead sprite.
// -
// Default: "sprites/death_icon.vmt"
l4d_hp_sprite_dead_model "sprites/death_icon.vmt"
// Scale of dead sprite (increases both height and width).
// Some range values maintain the size the same.
// -
// Default: "0.25"
// Minimum: "0.000000"
l4d_hp_sprite_dead_scale "0.25"
// Show the dead sprite when a client dies.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_hp_sprite_dead_show "1"
// Minimum distance that a client must be from another client to see the sprite.
// -1 = Always visible.
// -
// Default: "-1"
// Minimum: "-1.000000"
// Maximum: "9999.000000"
l4d_hp_sprite_fade_distance "-1"
// Should the sprite on survivors render in gradient color.
// 0 = OFF. (Vanilla Colors: Green 100HP->40HP, Yellow 39HP->25HP, Red 25HP-), 1 = Gradient Mode.
// Note: The Yellow color is defined by the "survivor_limp_health" game cvar.
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_hp_sprite_gradient_color "0"
// Which teams infected can see the sprite.
// 0 = NONE, 1 = SURVIVOR, 2 = INFECTED, 4 = SPECTATOR, 8 = HOLDOUT.
// Add numbers greater than 0 for multiple options.
// Example: "3", enables for SURVIVOR and INFECTED.
// -
// Default: "3"
// Minimum: "0.000000"
// Maximum: "15.000000"
l4d_hp_sprite_infected_team "3"
// Which teams should multiply the sprite alpha based on the client render alpha.
// 0 = NONE, 1 = SURVIVOR, 2 = INFECTED, 4 = SPECTATOR, 8 = HOLDOUT.
// Add numbers greater than 0 for multiple options.
// Example: "3", enables for SURVIVOR and INFECTED.
// -
// Default: "2"
// Minimum: "0.000000"
// Maximum: "15.000000"
l4d_hp_sprite_multiply_alpha_team "2"
// Which condition should the sprite pulse on survivors.
// 0 = OFF, 1 = Incapacitated, 2 = Black and White, 4 = Low health (24HP-).
// Add numbers greater than 0 for multiple options.
// Example: "3", enables for Incapacitated and Black and White survivors.
// -
// Default: "7"
// Minimum: "0.000000"
// Maximum: "7.000000"
l4d_hp_sprite_pulse "7"
// Removes the blur effect while behind walls.
// Note: This creates an extra entity for each sprite.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_hp_sprite_remove_blur "1"
// Interval in seconds to check the sprite rendering rules. (visibility, color and frame)
// -
// Default: "0.1"
// Minimum: "0.100000"
l4d_hp_sprite_render_interval "0.1"
// Which special infected should have a sprite.
// 1 = SMOKER, 2 = BOOMER, 4 = HUNTER, 8 = SPITTER, 16 = JOCKEY, 32 = CHARGER, 64 = TANK.
// Add numbers greater than 0 for multiple options.
// Example: "127", enables sprite for all SI.
// -
// Default: "64"
// Minimum: "0.000000"
// Maximum: "127.000000"
l4d_hp_sprite_si "64"
// Show the sprite to the survivor only if the special infected is on sight.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_hp_sprite_sight "1"
// Which teams spectators can see the sprite.
// 0 = NONE, 1 = SURVIVOR, 2 = INFECTED, 4 = SPECTATOR, 8 = HOLDOUT.
// Add numbers greater than 0 for multiple options.
// Example: "3", enables for SURVIVOR and INFECTED.
// -
// Default: "3"
// Minimum: "0.000000"
// Maximum: "15.000000"
l4d_hp_sprite_spectator_team "3"
// Which teams survivors can see the sprite.
// 0 = NONE, 1 = SURVIVOR, 2 = INFECTED, 4 = SPECTATOR, 8 = HOLDOUT.
// Add numbers greater than 0 for multiple options.
// Example: "3", enables for SURVIVOR and INFECTED.
// -
// Default: "3"
// Minimum: "0.000000"
// Maximum: "15.000000"
l4d_hp_sprite_survivor_team "3"
// Which teams should the sprite be visible.
// 0 = NONE, 1 = SURVIVOR, 2 = INFECTED, 4 = SPECTATOR, 8 = HOLDOUT.
// Add numbers greater than 0 for multiple options.
// Example: "3", enables for SURVIVOR and INFECTED.
// -
// Default: "3"
// Minimum: "0.000000"
// Maximum: "15.000000"
l4d_hp_sprite_team "3"
// Additional Z axis distance of the sprite based on client position.
// -
// Default: "92"
// Minimum: "0.000000"
l4d_hp_sprite_z_axis "92"
Other sprite models
Spoiler
The plugin has a default sprite for both alive and dead clients.
But if you wanna try some other sprite models, I found these ones that may fit too.
In case you want to check for more sprite models, then you will have to use GCFScape in the pak01_dir.vpk files and extract it from the materials folder.
Note: You can change the model with: sm_cvar l4d_hp_alive_model<model>
The plugin will automatically precache the new model and update the sprite.
HP:
vgui/healthbar_white.vmt
vgui/s_panel_healing_mini_prog.vmt
vgui/white_additive.vmt
vgui/hud/s_healthbar_outline.vmt
vgui/s_panel_background_glow.vmt
Death:
sprites/death_icon.vmt
sprites/skull_icon.vmt
sprites/headshot_icon.vmt
Tank:
vgui/hud/zombieteamimage_tank.vmt
Public Commands
sm_hpsprite => Open a menu to toogle the sprite HP for the client.
sm_hidehpsprite => Disable sprite HP for the client.
sm_showhpsprite => Enable sprite HP for the client.
Admin Commands
sm_print_cvars_l4d_hp_sprite => Print the plugin related cvars and their respective values to the console. (z flag required)
Change Log
Spoiler
1.1.3 (24-July-2021)
- Fixed bar not showing up when the current HP is bigger than max HP.
1.1.2 (03-May-2021)
- Added cvar to control the timer interval for the rendering rules.
1.1.0 (22-February-2021)
- Added cvar to change the gradient color to default game colors on survivors. (Green 40HP+, Yellow 39HP~25HP, Red 24HP-)
- Added menu and commands to hide/show the sprite.
- Added cvar to remove blur effect behind walls. (thanks "KadabraZz" for requesting)
- Added cvar and Fast Wide Pulse FX for survivors when: incapacitated; black and white; low health (24HP-).
1.0.9 (18-February-2021)
- Added cvar to set the maximum alpha that a client must be to hide the sprite.
1.0.8 (18-February-2021)
- Added cvar to multiply the sprite alpha based on client render alpha.
1.0.7 (16-February-2021)
- Plugin renamed.
- Added support to survivors and to all SI.
- Fixed a wrong behaviour when attack delay visibility cvar was enabled.
1.0.6 (12-February-2021)
- Fixed custom model cvar typo. (thanks "weffer" for reporting)
1.0.5 (11-February-2021)
- Fixed a bug not rendering custom sprites right after turning it on.
- Added one more custom sprite option with an alpha background filling the bar.
1.0.3 (08-February-2021)
- Fixed missing client in-game in visibility check. (thanks to "Krufftys Killers" and "Striker black")
1.0.2 (08-February-2021)
- Fixed wrong value on max health calculation.
- Fixed sprite hiding behind tank rocks.
- Fixed sprite hiding while tank throws rocks (ability use).
- Moved visibility logic to timer handle.
1.0.1 (30-January-2021)
- Public release.
1.0.0 (21-April-2019)
- Private version.
Notes
L4D1 and L4D2 behave differently for some values (e.g: alpha transparency).
I use a TraceRay/TraceHull to determine the sprite visibility on sight. This may not work in all cases (e.g. transparent windows).
Custom Sprite Notes
There are two custom sprites in the zip folder. The difference is that the "mart_custombar2.vmt" sprite has an alpha background filling the bar.
The .vtf files must be created in sizes (width x height) of power of 2.
The default alive sprite has a 256x16 size, the custom sprite has 128x4 size.
The size was reduced because even with the minimum scale (0.25) the sprite still was big for some people, so this gives more flexibility.
Since I have to create the width in a power of 2, I cut 14px from left and right (28px in total), remaining 100px, then I aligned to center.
I created 101 images to represent every rounded percent of the hp. So every 1%, the bar will change the width in 1.
To set the sprite frame I had to use an extra entity env_texturetoggle. (thanks to kazya3 - for the tip)
To Do
Enable visibility through transparent glasses.
Add sprite for Witch.
Hide from SI when the survivor is in a "hidden" state.
Add dead sprite for survivors.
Add a sprite to show that the SI is on fire/vomit.
Add cooldown ability bar.
Add list with client settings.
Thank you!
kazya3 - for the custom sprite with frames creation guide.
foxhound27 - for supporting me on the custom sprite creation.
hello im a CN ZEmapper, and i just know how to make boss healthbar sprite in hammer.
First make 5 or more pictures like
1. full-green-heath.png
2. 2/3health-width.png
3. 1/2health-width.png
....
Open the vtfeditor ,import all the pictures in a new one vtf “healthbar”
create a vmt like:
-------------------------
"UnlitGeneric"
{
"$basetexture" "custom/healthbar" //your picture path in the materials folder
"$vertexcolor" "1"
"$vertexalpha" "1"
"$translucent" "1"
"Proxies"
{
"ToggleTexture"
{
"toggleTextureVar" "$baseTexture"
"toggleTextureFrameNumVar" "$frame"
"toggleTextureShouldWrap" "0"
}
}
}
--------------------------------------------------------
Use entity env_sprite"hp_spr" with the vtf you made and setparents to the boss or anything you want
create a entity env_texturetoggle "hp_toggle" set the target brush "hp_spr"(https://developer.valvesoftware.com/..._texturetoggle)
when boss health reduce, entfire hp_toggle SetTextureindex 0 or 1 or 2....to show different health bar in the vtf you made
sorry for my poor english and hope that can help you
Just got this error
L 02/08/2021 - 08:466: SourceMod error session started
L 02/08/2021 - 08:466: Info (map "c6m1_riverbank") (file "C:\servers\kruffty\left4dead2\addons\sourcem od\logs\errors_20210208.log")
L 02/08/2021 - 08:466: [SM] Exception reported: Client 5 is not in game
L 02/08/2021 - 08:466: [SM] Blaming: l4d_tank_hp_sprite.smx
L 02/08/2021 - 08:466: [SM] Call stack trace:
L 02/08/2021 - 08:466: [SM] [0] GetClientTeam
L 02/08/2021 - 08:466: [SM] [1] Line 812, /home/forums/content/files/2/9/0/3/2/7/187113.attach::GetClientTeamFlag
L 02/08/2021 - 08:466: [SM] [2] Line 474, /home/forums/content/files/2/9/0/3/2/7/187113.attach::TimerVisible
L 02/08/2021 - 08:466: [SM] Exception reported: Client 5 is not in game
L 02/08/2021 - 11:49:48: [SM] Blaming: l4d_tank_hp_sprite2.smx
L 02/08/2021 - 11:49:48: [SM] Call stack trace:
L 02/08/2021 - 11:49:48: [SM] [0] GetClientTeam
L 02/08/2021 - 11:49:48: [SM] [1] Line 826, C:\Users\ST\Downloads\source 1.11.0\addons\sourcemod\scripting\l4d_tank_hp_sprite2.sp::GetClientTeamFlag
L 02/08/2021 - 11:49:48: [SM] [2] Line 485, C:\Users\ST\Downloads\source 1.11.0\addons\sourcemod\scripting\l4d_tank_hp_sprite2.sp::TimerVisible
L 02/08/2021 - 11:49:49: [SM] Exception reported: Client 6 is not in game
L 02/08/2021 - 11:49:49: [SM] Blaming: l4d_tank_hp_sprite2.smx
L 02/08/2021 - 11:49:49: [SM] Call stack trace:
L 02/08/2021 - 11:49:49: [SM] [0] GetClientTeam
L 02/08/2021 - 11:49:49: [SM] [1] Line 826, C:\Users\ST\Downloads\source 1.11.0\addons\sourcemod\scripting\l4d_tank_hp_sprite2.sp::GetClientTeamFlag
L 02/08/2021 - 11:49:49: [SM] [2] Line 485, C:\Users\ST\Downloads\source 1.11.0\addons\sourcemod\scripting\l4d_tank_hp_sprite2.sp::TimerVisible
L 02/08/2021 - 11:49:49: [SM] Exception reported: Client 6 is not in game
L 02/08/2021 - 11:49:49: [SM] Blaming: l4d_tank_hp_sprite2.smx
L 02/08/2021 - 11:49:49: [SM] Call stack trace:
L 02/08/2021 - 11:49:49: [SM] [0] GetClientTeam
L 02/08/2021 - 11:49:49: [SM] [1] Line 826, C:\Users\ST\Downloads\source 1.11.0\addons\sourcemod\scripting\l4d_tank_hp_sprite2.sp::GetClientTeamFlag
L 02/08/2021 - 11:49:49: [SM] [2] Line 485, C:\Users\ST\Downloads\source 1.11.0\addons\sourcemod\scripting\l4d_tank_hp_sprite2.sp::TimerVisible
L 02/08/2021 - 11:58:15: [SM] Exception reported: Handle 6393065e is invalid (error 1)
Great to see this isn't dependent on using in game hints. Any possibility to convert the sprite to a HP based where the colors decrease in length according to tank HP?