// SUPERMAN! - Yeah - well not all of his powers or it'd be unfair...

/* CVARS - copy and paste to shconfig.cfg

//Superman
superman_level 0
superman_gravity 0.35			//Gravity
superman_health 150				//Starting health
superman_armor 150				//STarting armor

*/

#include <amxmod>
#include <superheromod>

// VARIABLES
new gHeroName[]="Superman"
new gHasSuperPower[SH_MAXSLOTS+1]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
	// Plugin Info
	register_plugin("SUPERHERO Superman","1.18","{HOJ} Batman")

	// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
	register_cvar("superman_level", "0" )
	register_cvar("superman_gravity", "0.35" )
	register_cvar("superman_armor", "150")
	register_cvar("superman_health", "150")

	// FIRE THE EVENT TO CREATE THIS SUPERHERO!
	shCreateHero(gHeroName, "Health/Armor/Gravity", "More Health/Free Armor/Reduced Gravity", false, "superman_level" )

	// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
	// INIT
	register_srvcmd("superman_init", "superman_init")
	shRegHeroInit(gHeroName, "superman_init")

	// Let Server know about Supermans Variable
	// It is possible that another hero has more hps, less gravity, or more armor
	// so rather than just setting these - let the superhero module decide each round
	shSetMaxHealth(gHeroName, "superman_health" )
	shSetMinGravity(gHeroName, "superman_gravity" )
	shSetMaxArmor(gHeroName, "superman_armor" )
}
//----------------------------------------------------------------------------------------------
public superman_init()
{
	// First Argument is an id
	new temp[6]
	read_argv(1,temp,5)
	new id = str_to_num(temp)

	// 2nd Argument is 0 or 1 depending on whether the id has flash
	read_argv(2,temp,5)
	new hasPowers = str_to_num(temp)

	//Got to remove powers from a Superman that lost his powers...
	//This gets run if they had the power but don't anymore
	if ( !hasPowers && gHasSuperPower[id] && is_user_alive(id) ) {
		shRemHealthPower(id)
		shRemGravityPower(id)
		shRemArmorPower(id)
	}

	//Sets this variable to the current status
	gHasSuperPower[id] = (hasPowers != 0)
}
//----------------------------------------------------------------------------------------------