// PUNISHER! - Unlimited Ammo

/* CVARS - copy and paste to shconfig.cfg

//Punisher
punisher_level 0
punisher_rldmode 0        // Endless Ammo mode: 0-server default, 1-no reload, 2-reload, 3-drop wpn (Default 1)

*/

#include <superheromod>

// GLOBAL VARIABLES
new gHeroID
new const gHeroName[] = "Punisher"
new bool:gHasPunisher[SH_MAXSLOTS+1]
new pCvarRldMode
//----------------------------------------------------------------------------------------------
public plugin_init()
{
    // Plugin Info
    register_plugin("SUPERHERO Punisher", SH_VERSION_STR, "{HOJ} Batman")

    // DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
    new pcvarLevel = register_cvar("punisher_level", "0")
    pCvarRldMode = register_cvar("punisher_rldmode", "0")

    // FIRE THE EVENT TO CREATE THIS SUPERHERO!
    gHeroID = sh_create_hero(gHeroName, pcvarLevel)
    sh_set_hero_info(gHeroID, "Unlimited Ammo", "Endless Bullets. No Reload! Keep Shooting")

    // REGISTER EVENTS THIS HERO WILL RESPOND TO!
    register_event("CurWeapon", "change_weapon", "be", "1=1")
}
//----------------------------------------------------------------------------------------------
public sh_hero_init(id, heroID, mode)
{
    if ( gHeroID != heroID ) return

    gHasPunisher[id] = mode ? true : false

    sh_debug_message(id, 1, "%s %s", gHeroName, mode ? "ADDED" : "DROPPED")
}
//----------------------------------------------------------------------------------------------
public change_weapon(id)
{
    if ( !sh_is_active() || !gHasPunisher[id] ) return

    //new wpnid = read_data(2)
    new wpnslot = sh_get_weapon_slot(read_data(2))

    if ( wpnslot != 1 && wpnslot != 2 ) return

    //new clip = read_data(3)
    if ( read_data(3) == 0 ) {
        sh_reload_ammo(id, get_pcvar_num(pCvarRldMode))
    }
}
//----------------------------------------------------------------------------------------------