// GOHAN! - from Dragon Ball Z, Goku and Chi Chi's first son.

/* CVARS - copy and paste to shconfig.cfg

//Gohan
gohan_level 10
gohan_health 150		//default 150
gohan_gravity 0.40		//default 0.40 = low gravity
gohan_speed 800		//How fast he is with all weapons
gohan_healpoints 10		//The # of HP healed per second
gohan_healmax 400		//Max # HP gohan can heal to

*/

/*
* v1.2 - vittu - 6/19/05
*      - Minor code clean up.
*
* v1.1 - vittu - 3/13/05
*      - recoded from ArtofDrowning07 cleaned up code
*      - new cvar from ArtofDrowning07, gohan_healmax, you
*         can choose how much goten will heal to now
*/

#include <amxmod>
#include <superheromod>

// GLOBAL VARIABLES
new gHeroName[]="Gohan"
new bool:ghasGohanPowers[SH_MAXSLOTS+1]
new gHealPoints, gHealAmount
//----------------------------------------------------------------------------------------------
public plugin_init()
{
	// Plugin Info
	register_plugin("SUPERHERO Gohan", "1.2", "sharky")

	// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
	register_cvar("gohan_level", "10")
	register_cvar("gohan_health", "150")
	register_cvar("gohan_gravity", "0.40")
	register_cvar("gohan_speed", "800")
	register_cvar("gohan_healpoints", "10")
	register_cvar("gohan_healmax", "400")

	// FIRE THE EVENT TO CREATE THIS SUPERHERO!
	shCreateHero(gHeroName, "Super Power-Up", "Start with more HP, gain even more each second. Also, has Ultra Speed and Low Gravity!", false, "gohan_level")

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

	// HEAL LOOP
	set_task(1.0, "gohan_loop", 0, "", 0, "b")

	// Let Server know about Gohan's Variables
	shSetMaxHealth(gHeroName, "gohan_health")
	shSetMinGravity(gHeroName, "gohan_gravity")
	shSetMaxSpeed(gHeroName, "gohan_speed", "[0]")

	//Set Varibles when plugin loads
	gHealPoints = get_cvar_num("gohan_healpoints")
	gHealAmount = get_cvar_num("gohan_healmax")
}
//----------------------------------------------------------------------------------------------
public gohan_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 the hero
	read_argv(2,temp,5)
	new hasPowers = str_to_num(temp)

	//This gets run if they had the power but don't anymore
	if ( !hasPowers && ghasGohanPowers[id] && is_user_alive(id) ) {
		shRemHealthPower(id)
		shRemGravityPower(id)
		shRemSpeedPower(id)
	}

	//Sets this variable to the current status
	ghasGohanPowers[id] = (hasPowers != 0)
}
//----------------------------------------------------------------------------------------------
public gohan_loop()
{
	if ( !shModActive() || !hasRoundStarted() ) return

	for ( new id = 1; id <= SH_MAXSLOTS; id++ ) {
		if ( ghasGohanPowers[id] && is_user_alive(id) ) {
			// Let the server add the hps back since the # of max hps is controlled by it
			// I.E. Superman has more than 100 hps etc.
			shAddHPs(id, gHealPoints, gHealAmount)
		}
	}
}
//----------------------------------------------------------------------------------------------
