Description
This plugin shows a laser beam at the client's head that from green to red based on its HP.
It's similar to my
[L4D1 & L4D2] HP Sprite plugin.
Features- Automatically sets the laser beam color (from green to red) in a gradient way.
- Automatically sets the laser beam 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 laser beam model/alpha/fade/size.
- Allow setting a different laser beam width for Survivor and Infected.
- Allow setting a laser beam that fills the bar.
- Allow setting an outline to the laser beam.
- Allow setting which SI should have a laser beam (except Witch).
- Allow the client to hide/show the laser beam through a menu or command (client preferences).
- Show laser beam for incapacitated survivors.
Preview
Cvars
A configuration file named "
l4d_hp_laser.cfg" will automatically be created for you upon the first run in the "
\cfg\sourcemod\" folder.
PHP Code:
// 0 = Align the laser left-to-right per client eye angles. (lower performance)
// 1 = Align the laser to center. (better performance)
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_hp_laser_align_center "1"
// Alpha of the laser beam HP.
// 0 = Invisible, 255 = Fully Visible.
// -
// Default: "240"
// Minimum: "0.000000"
// Maximum: "255.000000"
l4d_hp_laser_alpha "240"
// Show the laser beam HP 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_laser_attack_delay "0.0"
// Show a laser beam HP in white on "black and white" survivors.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_hp_laser_black_and_white "1"
// Maximum render alpha that a client must be to hide the laser beam HP.
// Useful to hide it on invisible/transparent clients.
// -1 = OFF.
// -
// Default: "0"
// Minimum: "-1.000000"
// Maximum: "255.000000"
l4d_hp_laser_client_alpha_max "0"
// Allow cookies for storing client preferences.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_hp_laser_cookies "1"
// Enable/Disable the plugin.
// 0 = Disable, 1 = Enable.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_hp_laser_enable "1"
// Minimum distance that a client must be from another client to see the laser beam HP.
// 0 = Always visible.
// -
// Default: "0"
// Minimum: "0.000000"
l4d_hp_laser_fade_distance "0"
// Display a laser beam HP to fill the bar.
// Note: Disable this if you intend to show a lot of laser beams HP. The game limits the number of beams rendered at the same time when limit exceeds it may not draw then all.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_hp_laser_fill "1"
// Alpha of the laser beam HP that fills the bar.
// 0 = Invisible, 255 = Fully Visible
// -
// Default: "40"
// Minimum: "0.000000"
// Maximum: "255.000000"
l4d_hp_laser_fill_alpha "40"
// Should the laser beam HP on survivors render in gradient color.
// 0 = OFF. (Game colors: Green 40HP+, Yellow 39HP~25HP, Red 24HP-), 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_laser_gradient_color "0"
// Height of the laser beam HP.
// -
// Default: "2.0"
// Minimum: "0.000000"
l4d_hp_laser_height "2.0"
// Which teams infected can see a laser beam HP.
// 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_laser_infected_team "3"
// Width of the infected laser beam HP.
// -
// Default: "25.0"
// Minimum: "0.000000"
l4d_hp_laser_infected_width "25.0"
// Model of the laser beam HP.
// -
// Default: "vgui/white_additive.vmt"
l4d_hp_laser_model "vgui/white_additive.vmt"
// Which teams should multiply the laser beam HP 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_laser_multiply_alpha_team "2"
// Render type used to draw the laser beams.
// 0 = Timer (0.1 seconds - less expensive), 1 = OnGameFrame (by frame - more expensive).
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_hp_laser_render_frame "0"
// Which special infected should have a laser beam HP.
// 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 laser beam HP for all SI.
// -
// Default: "64"
// Minimum: "0.000000"
// Maximum: "127.000000"
l4d_hp_laser_si "64"
// Show a laser beam HP 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_laser_sight "1"
// How many frames should skip while using l4d_hp_laser_render_type = "1" (OnGameFrame). Frames may vary depending on your tickrate. Using a higher value than 2 becomes slower than with the timer on default tick rate (30)
// -
// Default: "1"
// Minimum: "0.000000"
l4d_hp_laser_skip_frame "1"
// Which teams spectators can see a laser beam HP.
// 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_laser_spectator_team "3"
// Which teams survivors can see a laser beam HP.
// 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_laser_survivor_team "3"
// Width of the survivor laser beam HP.
// -
// Default: "15.0"
// Minimum: "0.000000"
l4d_hp_laser_survivor_width "15.0"
// Which teams should have a laser beam HP.
// 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_laser_team "3"
// Additional Z axis distance of laser beam HP based on client position.
// -
// Default: "85"
// Minimum: "0.000000"
l4d_hp_laser_z_axis "85"
Public Commands
- sm_hplaser => Open a menu to toogle the laser beam HP for the client.
- sm_hidehplaser => Disable laser beam HP for the client.
- sm_showhplaser => Enable laser beam HP for the client.
Admin Commands
- sm_print_cvars_l4d_hp_laser => Print the plugin related cvars and their respective values to the console. (z flag required)
Change Log
Notes
- L4D1 and L4D2 behave differently for some values (e.g: alpha transparency).
- The laser beam may have a blinking effect. Probably there is nothing that can be done.
- There is no different appearance between normal and temporary health.
- I use a TraceRay/TraceHull to determine the laser beam visibility on sight. This may not work in all cases (e.g. transparent windows).
- Every laser beam is drawn using TE_SetupBeamPoints.
- Due to game engine limitations (nothing I can do), the amount of laser beams that can be drawn at the same time is limited to 32, so in case you have many clients some beams may not appear.
- To reduce this issue you can set some cvars (l4d_hp_laser_fill / l4d_hp_laser_outline) to "0".
To Do
- Enable visibility through transparent glasses.
- Add laser beam for Witch.
- Hide from SI when the survivor is in a "hidden" state.
- Add cooldown ability bar.
- Add list with client settings.
Thank you!
- lugui - for helping me and his [Any] Simple HealthBars plugin.
- GsiX - for helping me with some code snippets.
- HarryPotter - for reporting a render bug in L4D1.
- 3aljiyavslgazana - for requesting the laser alpha being based on client render alpha.
- RA - for reporting the bar showing on SIs while in ghost mode and requesting the frame render option.
- LexNBR - for requesting a menu/command to hide/show the laser beam.
- TrueDarkness - for reporting a bug with the Last Boss plugin.
- xZk - for providing the code to center align the laser.
Related Plugins
Post Reply
- Any feedback, bug reports, fixes, improvements, translations or suggestions for the plugin are welcome.
Installation
- Put the "l4d_hp_laser.smx" file (click Get Plugin) in your "\addons\sourcemod\plugins\" folder.