/* Plugin generated by AMXX-Studio */

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

#define DMG_BULLET (1<<1)

new bool:ma_klase[33];
new Float:ostatni_skok[33];

new const nazwa[] = "Komandos";
new const opis[] = "Natychmiastowe zabicie z noza (PPM), Modul Odrzutowy (Uzycie: E)";
new const bronie = 1<<CSW_DEAGLE;
new const zdrowie = 10;
new const kondycja = 60;
new const inteligencja = 5;
new const wytrzymalosc = 0;

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)
	ma_klase[id] = true;

	
public cod_class_disabled(id)
	ma_klase[id] = false;
	
public cod_class_skill_used(id)
{
	new flags = pev(id, pev_flags);
	
	if(ostatni_skok[id] + 4.0 > get_gametime())
	{
		client_print(id, print_center, "Modulu mozesz uzywac co 4 sekundy");
		return PLUGIN_CONTINUE;
	}
	
	if(flags & FL_ONGROUND)
	{
		ostatni_skok[id] = get_gametime();
		new Float:velocity[3];
		velocity_by_aim(id, 666+cod_get_user_intelligence(id), velocity);
		velocity[2] = random_float(265.0,285.0);
		set_pev(id, pev_velocity, velocity);
	}
	return PLUGIN_CONTINUE;
}
public TakeDamage(this, idinflictor, idattacker, Float:damage, damagebits)
{
	if(!is_user_connected(idattacker))
		return HAM_IGNORED;
	
	if(!ma_klase[idattacker])
		return HAM_IGNORED;
	
	if(get_user_team(this) != get_user_team(idattacker) && get_user_weapon(idattacker) == CSW_KNIFE && damagebits & DMG_BULLET && damage > 20)
		cod_inflict_damage(idattacker, this, float(get_user_health(this))-damage+1.0, 0.0, idinflictor, damagebits);
	
	return HAM_IGNORED;
}
