// WOLVERINE!
/* CVARS - copy and paste to shconfig.cfg
//Wolverine
wolv_level 0
wolv_healpoints 3 //The # of HP healed per second
wolv_knifespeed 290 //Speed of wolveine when holding knife
wolv_knifemult 1.35 //Multiplier for knife damage
*/
// v1.17 - JTP - fixed runtime error on damage event if user is already dead
// v1.17.5 - JTP - Added code to allow you to regen to your max heatlh
//---------- User Changeable Defines --------//
// Comment out to force not using the model, will result in a very small reduction in code/checks
// Note: If you change anything here from default setting you must recompile the plugin
#define USE_WEAPON_MODEL
//------- Do not edit below this point ------//
#include <superheromod>
// GLOBAL VARIABLES
new gHeroID
new const gHeroName[] = "Wolverine"
new bool:gHasWolverine[SH_MAXSLOTS+1]
new gPcvarHealPoints
#if defined USE_WEAPON_MODEL
new const gModelKnife[] = "models/shmod/wolv_knife.mdl"
new bool:gModelLoaded
#endif
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO Wolverine", SH_VERSION_STR, "{HOJ}Batman/JTP10181")
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
new pcvarLevel = register_cvar("wolv_level", "0")
new pcvarSpeed = register_cvar("wolv_knifespeed", "290")
new pcvarKnifeMult = register_cvar("wolv_knifemult", "1.35")
gPcvarHealPoints = register_cvar("wolv_healpoints", "3")
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
gHeroID = sh_create_hero(gHeroName, pcvarLevel)
sh_set_hero_info(gHeroID, "Auto-Heal & Claws", "Auto-Heal, Extra Knife Damage and Speed Boost")
sh_set_hero_speed(gHeroID, pcvarSpeed, {CSW_KNIFE})
sh_set_hero_dmgmult(gHeroID, pcvarKnifeMult, CSW_KNIFE)
#if defined USE_WEAPON_MODEL
// REGISTER EVENTS THIS HERO WILL RESPOND TO!
if ( gModelLoaded ) {
register_event("CurWeapon", "weapon_change", "be", "1=1")
}
#endif
// HEAL LOOP
set_task(1.0, "wolv_loop", _, _, _, "b")
}
//----------------------------------------------------------------------------------------------
#if defined USE_WEAPON_MODEL
public plugin_precache()
{
// Method servers 2 purposes, moron check and optional way to not use the model
if ( file_exists(gModelKnife) ) {
precache_model(gModelKnife)
gModelLoaded = true
}
else {
sh_debug_message(0, 0, "Aborted loading ^"%s^", file does not exist on server", gModelKnife)
gModelLoaded = false
}
}
#endif
//----------------------------------------------------------------------------------------------
public sh_hero_init(id, heroID, mode)
{
if ( gHeroID != heroID ) return
switch(mode) {
case SH_HERO_ADD: {
gHasWolverine[id] = true
#if defined USE_WEAPON_MODEL
if ( gModelLoaded ) {
switch_model(id)
}
#endif
}
case SH_HERO_DROP: {
gHasWolverine[id] = false
}
}
sh_debug_message(id, 1, "%s %s", gHeroName, mode ? "ADDED" : "DROPPED")
}
//----------------------------------------------------------------------------------------------
public wolv_loop()
{
if ( !sh_is_active() ) return
static players[SH_MAXSLOTS], playerCount, player, i
get_players(players, playerCount, "ah")
for ( i = 0; i < playerCount; i++ ) {
player = players[i]
if ( gHasWolverine[player] ) {
sh_add_hp(player, get_pcvar_num(gPcvarHealPoints))
}
}
}
//----------------------------------------------------------------------------------------------
#if defined USE_WEAPON_MODEL
public weapon_change(id)
{
if ( !sh_is_active() || !gHasWolverine[id] ) return
if ( read_data(2) == CSW_KNIFE ) switch_model(id)
}
//----------------------------------------------------------------------------------------------
switch_model(id)
{
if ( !sh_is_active() || !is_user_alive(id) || !gHasWolverine[id] ) return
// If user has a shield do not change model, since we don't have one with a shield
if ( cs_get_user_shield(id) ) return
if ( get_user_weapon(id) == CSW_KNIFE ) {
set_pev(id, pev_viewmodel2, gModelKnife)
}
}
//----------------------------------------------------------------------------------------------
#endif