/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <codmod>
#include <hamsandwich>

#define DMG_BULLET (1<<1)
#define DMG_HEGRENADE (1<<24)

new const nazwa[] = "InVoKeR [P]";
new const opis[] = "15 procent obrazen z AK47 i M4A1, dodatkowe 1/3 z HE";
new const bronie = 1<<CSW_AK47 |1<<CSW_M4A1 | 1<<CSW_HEGRENADE;
new const zdrowie = 10;
new const kondycja = 10;
new const inteligencja = 10;
new const wytrzymalosc = 10;

new bool:ma_klase[33];

public plugin_init() 
{
	register_plugin(nazwa, "1.0", "Play");
	
	cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc);
	
	RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
}

public cod_class_enabled(id)
{
	if(!(get_user_flags(id) & ADMIN_LEVEL_D))
	{
		client_print(id, print_center, "[%s], Nie masz uprawnien, aby uzywac tej klasy.", nazwa);
		return COD_STOP;
	}
	ma_klase[id] = true;
	return COD_CONTINUE;
}
	
public cod_class_disabled(id)
{
	ma_klase[id] = false;
}

public TakeDamage(this, idinflictor, idattacker, Float:damage, damagebits)
{
	if(!is_user_connected(idattacker))
		return HAM_IGNORED;
	
	if(!ma_klase[idattacker])
		return HAM_IGNORED;
		
	new weapon = get_user_weapon(idattacker);
		
	if(weapon == CSW_AK47 && CSW_M4A1)
		cod_inflict_damage(idattacker, this, 15.0, 0.2, idinflictor, damagebits);
		
	if(damagebits & DMG_HEGRENADE && random_num(1, 3) == 1)
	{	
		cod_inflict_damage(idattacker, this, float(get_user_health(this))-damage+1.0, 0.0, idinflictor, damagebits);
	}
		
	return HAM_IGNORED;
}
