/* Plugin generated by AMXX-Studio */

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

#define DMG_BULLET (1<<1)

new const perk_name[] = "Bron Z Przemytu";
new const perk_desc[] = "Zadajesz 50% wiecej obrazen z AK47 / M4A1";

new ma_perk[33];

public plugin_init() 
{
	register_plugin(perk_name, "1.0", "Play");
	
	cod_register_perk(perk_name, perk_desc);
	
	RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
	
}
public cod_perk_enabled(id)
{
	cod_give_weapon(id, CSW_AK47);
	cod_give_weapon(id, CSW_M4A1);
	ma_perk[id] = true;
}
public cod_perk_disabled(id)
{
	cod_take_weapon(id, CSW_AK47);
	cod_take_weapon(id, CSW_M4A1);
	ma_perk[id] = false;
}
public TakeDamage(this, idinflictor, idattacker, Float:damage, damagebits)
{
	if(!is_user_connected(idattacker))
		return HAM_IGNORED;
	
	if(!ma_perk[idattacker])
		return HAM_IGNORED;
	
	if(damagebits & DMG_BULLET)
	{
		new weapon = get_user_weapon(idattacker);
		
		if(weapon == CSW_AK47)
			cod_inflict_damage(idattacker, this, damage*0.5, 0.0, idinflictor, damagebits);
			
		if(weapon == CSW_M4A1)
			cod_inflict_damage(idattacker, this, damage*0.5, 0.0, idinflictor, damagebits);
	}
	
	return HAM_IGNORED;
}
