Thread: HpRegeneration
View Single Post
Author Message
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 01-24-2008 , 17:08   HpRegeneration
Reply With Quote #1

HpRegeneration
When a player gets hurt, they regenerate 'x' amount of life every 'y' seconds until they reach 'z' health.

Commands:

sm_hpregeneration_enable <0/1> - Enables the HpRegeneration plugin.
sm_hpregeneration_amount <amount> - Amount of life to heal per regeneration tick.
sm_hpregeneration_health <amount> - Health to regenerate to, based on the control mode.
sm_hpregeneration_tickrate <time> - Time, in seconds, between each regeneration tick.
sm_hpregeneration_respawn <0/1> - Enables healing through respawns.
sm_hpregeneration_bots <0/1> - Enables bots regenerating their life.
sm_hpregeneration_mode <1/2> - Controls the regeneration mode (see the "control modes" section for more info).

Note: Take a look at the commented section in the plugin's source for examples on how the CVars are to be used.

Installation:
  • Download hpregeneration.smx to your ~/addons/sourcemod/plugins folder.
  • Change the map, manually load the plugin, or restart the server to use the plugin.
  • Edit the cvars for the plugin in the created config file (~/cfg/sourcemod/plugin.hpregeneration.cfg).
Control Modes:

Note: This section describes the purpose and uses of the sm_hpregeneration_mode cvar.

The mode cvar is pretty simple, but can be confusing unless you know what it does. The cvar has two modes; 1 and 2.
  1. The first mode will make it so a player will regenerate life until they reach the amount set by the health cvar.
  2. The second mode will make it so that the player will regenerate life until they reach their default max health plus the amount specified by the health cvar.
Here's an example of mode #2:
Player A spawns with 200 life (soldier in TF2) and the health cvar is set to 350. Player A takes damage, and begins to regenerate life. Player A regenerates life up up 550 and then stops.

As you can see, this mode differs from mode #1, but not by much. I mainly added this for multi-class use in TF2. If you are unsure on which mode to use, here's some simple directions: If you're using this plugin for TF2, use mode #2. If you're using it for any other mod, use mode #1.

Note: If the mod is TF2 and you use an amount above the player's default max life, their max life will then change to accomodate what they're regenerating to. So instead of draining back down to their default max life, they will retain the new max until they die or take damage again.


Changelog:
  • 1.0.0
    • Initial release.
  • 1.0.1
    • Added CVar 'sm_hpregeneration_respawn'.
  • 1.0.2
    • Fixed health regeneration stopping when the respawn cvar is enabled and a player spawns in late.
    • Regeneration is now halted on all players when the enable cvar is set to disable.
    • Added a check for the respawn cvar for when the enable cvar is enabled any time after startup.
  • 1.0.3
    • Fixed a problem with the respawn cvar check where it would cause an error if the event wasn't hooked, but the plugin tried to unhook it anyways.
  • 1.0.4
    • Bots can no longer regenerate life due to errors.
  • 1.0.5
    • Closes regeneration timers on clients who have disconnected from the server.
  • 1.0.5b
    • Too many bug fixes in one day can get to you. I forgot to include the 'public' keyword on the OnClientDisconnect(); function.
  • 1.0.6
    • Readded bot support and created a new cvar to control whether or not they will receive the HpRegeneration bonus (sm_hpregeneration_bots - see commands section).
    • Changed the way checking the major cvars are handled. They no longer hook/unhook the events, but control whether or not the events do anything. I did this to prevent lots of confusion and unnecessary coding on my part.
    • Cleaned up the coding a bit so there aren't so many unneeded brackets.
    • All timers are closed upon map end.
    • Added a few log messages for when the Enable & Respawn cvars are changed.
  • 1.1.0
    • Added a new cvar, sm_hpregeneration_mode to control what the clients' health should regenerate to. See the "control modes" section for more info.
    • Added a check for a change in tickrate.
      • If a client had an active regeneration timer, their timer will continue with the new tickrate. If they didn't, they will still not have a timer.
    • The maxhealth cvar has been renamed to sm_hpregeneration_health to avoid confusion with the mode cvar.
    • A config file is automatically created in the /cfg/sourcemod/ directory. Use that from now on for this plugin's cvars.
  • 1.1.1
    • Fixed a few bugs with the max health not being set properly.
    • Changed around the way health is set on the coding side (you won't notice a difference while in-game).
    • Cleaned up the coding a bit by merging a few functions.
Attached Files
File Type: sp Get Plugin or Get Source (hpregeneration.sp - 7715 views - 9.1 KB)

Last edited by bl4nk; 02-28-2008 at 13:49.
bl4nk is offline