/*
* This code has been compiled (in the old sense of the word)
* by gncuster and [SYCO]Tactical_Jack.
* Some of the code is his as well.
* Ideas, algorithems, and chucks of code have been liberaly
* cut and paste from a varity of sources.
* contact: gncuster at
* nsc@tacticaljack.com
* contact TJ at:
* tj@tacticaljack.com
*/
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
 
#define ACCESS_CONSOLE 131072
#define FLAG_CHEAT_ACCESS 255
 
 
/* This sets how much additional damage to deal. It is the
 * inverse of the percent extra. ie 50%(1/2) == 2, 33%(1/3) == 3
 */
 
#define EXTRA_DAMAGE_FACTOR 2
 
new STRING_VERSION[MAX_DATA_LENGTH]= "v0.1";
 
 
public grenade_enhance(HLCommand,HLData,HLUserName,UserIndex){
	new s_id1[MAX_NUMBER_LENGTH];
	new s_id2[MAX_NUMBER_LENGTH];
	new weapon[MAX_NAME_LENGTH];
	new data[MAX_DATA_LENGTH];
	new s_ope_health[MAX_DATA_LENGTH];
	new s_null[MAX_DATA_LENGTH];
	new name[MAX_NAME_LENGTH];
 
	convert_string(HLData, data, MAX_DATA_LENGTH);
 
	strsplit(data, " ", s_id1, MAX_NUMBER_LENGTH, s_id2, MAX_NUMBER_LENGTH, weapon, MAX_NAME_LENGTH, s_null, MAX_DATA_LENGTH, s_null, MAX_DATA_LENGTH, s_ope_health, MAX_DATA_LENGTH);
 
	new i_id2 = strtonum( s_id2 );
 
	if( !playerinfo(i_id2,name,MAX_NAME_LENGTH) )
		return PLUGIN_FAILURE;
 
	log(name);
 
	if( strcmp( weapon, "grenade") == 0 ) {
  		new i_damage = strtonum( s_ope_health );
	  	i_damage = i_damage / (5 * EXTRA_DAMAGE_FACTOR);
 
  		if( i_damage == 0)
  			i_damage = 1;
 
		for( new x = 0;x < i_damage;x++ ){
    		slap( name );
	  	}
	}
	return PLUGIN_HANDLED;
}
 
public plugin_init() {
	plugin_registerinfo("Grenade Enhancer","Adds extra damage to grenades.",STRING_VERSION);
	plugin_registercmd("grenade_enhance", "grenade_enhance", ACCESS_CONSOLE, "");
	exec( "logd_reg 57 admin_command rgrenade_enhance" );
	exec( "logd_reg 58 admin_command grenade_enhance" );
	return PLUGIN_CONTINUE;
}