// FROGGER! - From the arcade game. You know, the frog that jumps around to avoid traffic or aligators.

/* CVARS - copy and paste to shconfig.cfg

//Frogger
frogger_level 0

*/

/*
* v1.2 - vittu - 8/20/08
*       - Updated to be SH 1.2.0 compliant.
*
* v1.1 - vittu - 6/2/07
*      - Fixed issue to remove jumppack when hero is removed. Thanks to VEN's fakemeta_util.
*
* v1.0 - vittu - 6/1/05
*      - Only issue is jumppack only removed on death.
*/

//---------- User Changeable Defines --------//

// Comment out to not display the longjump module icon
#define SHOW_ICON

//------- Do not edit below this point ------//


#include <superheromod>

// GLOBAL VARIABLES
new gHeroID
new bool:gHasFogger[SH_MAXSLOTS+1]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
	// Plugin Info
	register_plugin("SUPERHERO Frogger", "1.2", "vittu")

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

	// FIRE THE EVENT TO CREATE THIS SUPERHERO!
	gHeroID = sh_create_hero("Frogger", pcvarLevel)
	sh_set_hero_info(gHeroID, "Longjump", "Get a Half-Life Longjump pack. While moving forward, press duck and jump.")
}
//----------------------------------------------------------------------------------------------
public sh_hero_init(id, heroID, mode)
{
	if ( gHeroID != heroID ) return

	switch(mode) {
		case SH_HERO_ADD: {
			gHasFogger[id] = true
			frogger_giveitem(id)
		}
		case SH_HERO_DROP: {
			gHasFogger[id] = false
			if ( is_user_alive(id) )
				engfunc(EngFunc_SetPhysicsKeyValue, id, "slj", "0")
		}
	}
}
//----------------------------------------------------------------------------------------------
public sh_client_spawn(id)
{
	if ( sh_is_active() && is_user_alive(id) && gHasFogger[id] )
		frogger_giveitem(id)
}
//----------------------------------------------------------------------------------------------
frogger_giveitem(id)
{
	if ( is_user_alive(id) )
	{
		engfunc(EngFunc_SetPhysicsKeyValue, id, "slj", "1")

#if defined SHOW_ICON
			static msgid_itempickup
			if ( !msgid_itempickup )
				msgid_itempickup = get_user_msgid("ItemPickup")

			message_begin(MSG_ONE_UNRELIABLE, msgid_itempickup, _, id)
			write_string("item_longjump")
			message_end()
#endif
	}
}
//----------------------------------------------------------------------------------------------