Raised This Month: $51 Target: $400
 12% 

[L4D1 & L4D2] HP Sprite [v1.1.3 | 24-July-2021]


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Plugin ID:
7483
Plugin Version:
1.1.3
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
    11 
    Plugin Description:
    Shows a sprite at the client head based on its HP
    Old 01-31-2021 , 11:20   [L4D1 & L4D2] HP Sprite [v1.1.3 | 24-July-2021]
    Reply With Quote #1

    Description

    This plugin shows a sprite at the client's head that from green to red based on its HP.

    It's similar to my [L4D1 & L4D2] HP Laser plugin.

    Features
    • 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.

    PHP Code:
    // Alpha of alive sprite.
    // 0 = Invisible, 255 = Fully Visible.
    // -
    // Default: "200"
    // Minimum: "0.000000"
    // Maximum: "255.000000"
    l4d_hp_sprite_alive_alpha "200"

    // 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"

    // Custom sprite VMT path.
    // -
    // Default: "mart/mart_custombar.vmt"
    l4d_hp_sprite_custom_model_vmt "mart/mart_custombar.vmt"

    // Custom sprite VTF path.
    // -
    // Default: "mart/mart_custombar.vtf"
    l4d_hp_sprite_custom_model_vtf "mart/mart_custombar.vtf"

    // Alpha of dead sprite.
    // 0 = Invisible, 255 = Fully Visible
    // -
    // Default: "200"
    // Minimum: "0.000000"
    // Maximum: "255.000000"
    l4d_hp_sprite_dead_alpha "200"

    // 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"

    // Enable/Disable the plugin.
    // 0 = Disable, 1 = Enable.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_hp_sprite_enable "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


    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


    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!

    Related Plugins

    Post Reply
    • Any feedback, bug reports, fixes, improvements, translations or suggestions for the plugin are welcome.

    Installation
    • Put the "l4d_hp_sprite.smx" file (click Get Plugin) in your "\addons\sourcemod\plugins\" folder.

    If you want to use the custom sprite bar then:
    • Download the "mart_custombar.zip" file.
    • Extract it to the "left4dead2\materials" folder. (in the end your file must have that path: "left4dead2\materials\mart\mart_custombar.vmt")
    • Don't forget to the set the "AddFileToDownloadsTable" if you use a different path.
    • If you still don't see the custom sprite, search for FastDL, I won't teach it here.
    Attached Files
    File Type: zip mart_custombar.zip (81.9 KB, 918 views)
    File Type: sp Get Plugin or Get Source (l4d_hp_sprite.sp - 620 views - 60.4 KB)
    __________________

    Last edited by Marttt; 02-19-2023 at 21:53.
    Marttt is offline
    Tank Rush
    Senior Member
    Join Date: May 2019
    Location: Argentina
    Old 01-31-2021 , 11:40   Re: [L4D1 & L4D2] Tank HP Sprite [v1.0.1 | 31-January-2021]
    Reply With Quote #2

    This looks great!
    __________________
    Sorry i don't speak english very well

    --->My name is Source and I'm on Steam<---
    Discord: Source#9382
    Tank Rush is offline
    kazya3
    Member
    Join Date: Aug 2019
    Location: CN
    Old 02-03-2021 , 10:36   Re: [L4D1 & L4D2] Tank HP Sprite [v1.0.1 | 31-January-2021]
    Reply With Quote #3

    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
    kazya3 is offline
    ZBzibing
    Senior Member
    Join Date: Dec 2012
    Old 02-03-2021 , 22:37   Re: [L4D1 & L4D2] Tank HP Sprite [v1.0.1 | 31-January-2021]
    Reply With Quote #4

    这是一个非常COOL的插件
    これはとてもクールなプラグインです
    This is a very cool plugin
    ZBzibing is offline
    HarryPotter
    Veteran Member
    Join Date: Sep 2017
    Location: Taiwan, Asia
    Old 02-03-2021 , 23:02   Re: [L4D1 & L4D2] Tank HP Sprite [v1.0.1 | 31-January-2021]
    Reply With Quote #5

    Quote:
    I did this plugin as a private request back in 2019, but "somehow" the code got "leaked".
    Great Job, marttt
    I must apologize, since I got the code from my friend in 2019, and I didn't know the original author is you
    __________________
    HarryPotter is offline
    Striker black
    Member
    Join Date: Apr 2013
    Old 02-08-2021 , 02:08   Re: [L4D1 & L4D2] Tank HP Sprite [v1.0.1 | 31-January-2021]
    Reply With Quote #6

    Quote:
    Originally Posted by Marttt View Post
    Hey don't worry is not your fault.

    The real problem here was the first guy sharing it with no info and other people trying to sell it (much worse).

    No problem in sharing for free.
    It is not the first time he has done this kind of thing, his nickname here is "aya supay" and in steam it is https://steamcommunity.com/id/joshegatito

    I affirm that this user was selling this plugin and the topskeet published by harry. Lol
    __________________
    --------------------------------------

    Last edited by Striker black; 02-08-2021 at 02:16.
    Striker black is offline
    Striker black
    Member
    Join Date: Apr 2013
    Old 02-08-2021 , 02:22   Re: [L4D1 & L4D2] Tank HP Sprite [v1.0.1 | 31-January-2021]
    Reply With Quote #7

    Beautiful Work Mart, thank you for sharing it.

    I'm going to try it on my server
    __________________
    --------------------------------------
    Striker black is offline
    Krufftys Killers
    Senior Member
    Join Date: Jan 2014
    Old 02-08-2021 , 13:52   Re: [L4D1 & L4D2] Tank HP Sprite [v1.0.2 | 08-February-2021]
    Reply With Quote #8

    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
    Krufftys Killers is offline
    Striker black
    Member
    Join Date: Apr 2013
    Old 02-08-2021 , 14:08   Re: [L4D1 & L4D2] Tank HP Sprite [v1.0.2 | 08-February-2021]
    Reply With Quote #9

    I have this spawn in LOGS.

    Code:
    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)
    __________________
    --------------------------------------
    Striker black is offline
    Mr. Man
    Veteran Member
    Join Date: Mar 2011
    Location: Huh?
    Old 02-09-2021 , 00:00   Re: [L4D1 & L4D2] Tank HP Sprite [v1.0.3 | 08-February-2021]
    Reply With Quote #10

    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?
    __________________
    Mr. Man is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 05:02.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode