#include <amxmodx>
#include <amxmisc>
#include <codmod>
#include <engine>
#include <cstrike>
#include <hamsandwich>
#include <fakemeta>
#include <fun>
#define DMG_BULLET (1<<1)
new const nazwa[] = "Invisible";
new const opis[] = "1hp na stale, niewidzialny, 1 rakieta 1/1 z PPM";
new const bronie = 0;
new const zdrowie = 0;
new const kondycja = 150;
new const inteligencja = 0;
new const wytrzymalosc = 0;
new sprite_blast;
new ilosc_rakiet_gracza[33];
new poprzednia_rakieta_gracza[33];
new ma_klase[33];
public plugin_init()
{
register_plugin(nazwa, "1.0", "amxx.pl");
cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc);
RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
register_touch("rocket", "*" , "DotykRakiety");
RegisterHam(Ham_Spawn, "player", "fwSpawn_Rakiety", 1);
RegisterHam(Ham_AddPlayerItem, "player", "fwAddPlayerItem");
register_event("Health", "Health", "be")
}
public plugin_precache()
{
sprite_blast = precache_model("sprites/dexplo.spr");
precache_model("models/rpgrocket.mdl");
}
public client_disconnect(id)
{
new entRakiety = find_ent_by_class(0, "rocket");
while(entRakiety > 0)
{
if(entity_get_edict(entRakiety, EV_ENT_owner) == id)
remove_entity(entRakiety);
entRakiety = find_ent_by_class(entRakiety, "rocket");
}
}
public cod_class_enabled(id)
{
if(!(get_user_flags(id) & ADMIN_LEVEL_F))
{
client_print(id, print_chat, "[Invisible] Nie masz uprawnien, aby uzywac tej klasy.")
return COD_STOP;
}
new iWeapons[32], iNum;
set_rendering(id,kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 0);
ilosc_rakiet_gracza[id] = 1;
ma_klase[id] = true;
set_user_health(id, 1);
get_user_weapons(id, iWeapons, iNum);
for(new i = 0; i < iNum; i++)
if(iWeapons[i] != CSW_KNIFE && iWeapons[i] != CSW_C4)
ham_strip_user_weapon(id, iWeapons[i]);
return COD_CONTINUE;
}
public cod_class_disabled(id)
{
set_rendering(id,kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 255);
ma_klase[id] = false;
}
public fwAddPlayerItem(id, iWeaponEnt)
{
if(!is_user_alive(id) || !ma_klase[id])
return HAM_IGNORED;
new iWeaponId = cs_get_weapon_id(iWeaponEnt);
if(iWeaponId != CSW_KNIFE && iWeaponId != CSW_C4)
return HAM_SUPERCEDE;
return HAM_IGNORED;
}
public cod_class_skill_used(id)
{
if (!ilosc_rakiet_gracza[id])
{
client_print(id, print_center, "Wykorzystales juz wszystkie rakiety!");
}
else
{
if(poprzednia_rakieta_gracza[id] + 2.0 > get_gametime())
{
client_print(id, print_center, "Rakiet mozesz uzywac co 2 sekundy!");
}
else
{
if (is_user_alive(id))
{
poprzednia_rakieta_gracza[id] = floatround(get_gametime());
ilosc_rakiet_gracza[id]--;
new Float: Origin[3], Float: vAngle[3], Float: Velocity[3];
entity_get_vector(id, EV_VEC_v_angle, vAngle);
entity_get_vector(id, EV_VEC_origin , Origin);
new Ent = create_entity("info_target");
entity_set_string(Ent, EV_SZ_classname, "rocket");
entity_set_model(Ent, "models/rpgrocket.mdl");
vAngle[0] *= -1.0;
entity_set_origin(Ent, Origin);
entity_set_vector(Ent, EV_VEC_angles, vAngle);
entity_set_int(Ent, EV_INT_effects, 2);
entity_set_int(Ent, EV_INT_solid, SOLID_BBOX);
entity_set_int(Ent, EV_INT_movetype, MOVETYPE_FLY);
entity_set_edict(Ent, EV_ENT_owner, id);
VelocityByAim(id, 1000 , Velocity);
entity_set_vector(Ent, EV_VEC_velocity ,Velocity);
}
}
}
}
public fwSpawn_Rakiety(id)
{
if(!is_user_alive(id) || !ma_klase[id])
return HAM_IGNORED;
ilosc_rakiet_gracza[id] = 1;
strip_user_weapons(id);
give_item(id, "weapon_knife");
return HAM_IGNORED;
}
public DotykRakiety(ent)
{
if (!is_valid_ent(ent))
return;
new attacker = entity_get_edict(ent, EV_ENT_owner);
new Float:fOrigin[3];
entity_get_vector(ent, EV_VEC_origin, fOrigin);
new iOrigin[3];
for(new i=0;i<3;i++)
iOrigin[i] = floatround(fOrigin[i]);
message_begin(MSG_BROADCAST,SVC_TEMPENTITY, iOrigin);
write_byte(TE_EXPLOSION);
write_coord(iOrigin[0]);
write_coord(iOrigin[1]);
write_coord(iOrigin[2]);
write_short(sprite_blast);
write_byte(32);
write_byte(20);
write_byte(0);
message_end();
new entlist[33];
new numfound = find_sphere_class(ent, "player", 190.0, entlist, 32);
for (new i=0; i < numfound; i++)
{
new pid = entlist[i];
if (!is_user_alive(pid) || get_user_team(attacker) == get_user_team(pid))
continue;
cod_inflict_damage(attacker, pid, 55.0, 0.9, ent, (1<<24));
}
remove_entity(ent);
}
public TakeDamage(this, idinflictor, idattacker, Float:damage, damagebits)
{
if(!is_user_connected(idattacker))
return HAM_IGNORED;
if(!ma_klase[idattacker])
return HAM_IGNORED;
if(damagebits & DMG_BULLET)
{
new weapon = get_user_weapon(idattacker);
if(weapon == CSW_KNIFE && damage > 20.0 && random_num(1,1) == 1)
cod_inflict_damage(idattacker, this, float(get_user_health(this))-damage+1.0, 0.0, idinflictor, damagebits);
}
return HAM_IGNORED;
}
public Health(id)
{
if(is_user_alive(id) && ma_klase[id])
{
set_user_health(id, 1);
}
}
stock ham_strip_user_weapon(id, iCswId, iSlot = 0, bool:bSwitchIfActive = true)
{
new iWeapon;
if(!iSlot)
{
static const iWeaponsSlots[] = {
-1,
2, //CSW_P228
-1,
1, //CSW_SCOUT
4, //CSW_HEGRENADE
1, //CSW_XM1014
5, //CSW_C4
1, //CSW_MAC10
1, //CSW_AUG
4, //CSW_SMOKEGRENADE
2, //CSW_ELITE
2, //CSW_FIVESEVEN
1, //CSW_UMP45
1, //CSW_SG550
1, //CSW_GALIL
1, //CSW_FAMAS
2, //CSW_USP
2, //CSW_GLOCK18
1, //CSW_AWP
1, //CSW_MP5NAVY
1, //CSW_M249
1, //CSW_M3
1, //CSW_M4A1
1, //CSW_TMP
1, //CSW_G3SG1
4, //CSW_FLASHBANG
2, //CSW_DEAGLE
1, //CSW_SG552
1, //CSW_AK47
3, //CSW_KNIFE
1 //CSW_P90
}
iSlot = iWeaponsSlots[iCswId];
}
const XTRA_OFS_PLAYER = 5;
const m_rgpPlayerItems_Slot0 = 367;
iWeapon = get_pdata_cbase(id, m_rgpPlayerItems_Slot0 + iSlot, XTRA_OFS_PLAYER);
const XTRA_OFS_WEAPON = 4;
const m_pNext = 42;
const m_iId = 43;
while(iWeapon > 0)
{
if(get_pdata_int(iWeapon, m_iId, XTRA_OFS_WEAPON) == iCswId)
{
break;
}
iWeapon = get_pdata_cbase(iWeapon, m_pNext, XTRA_OFS_WEAPON);
}
if(iWeapon > 0)
{
const m_pActiveItem = 373;
if(bSwitchIfActive && get_pdata_cbase(id, m_pActiveItem, XTRA_OFS_PLAYER) == iWeapon)
{
ExecuteHamB(Ham_Weapon_RetireWeapon, iWeapon);
}
if(ExecuteHamB(Ham_RemovePlayerItem, id, iWeapon))
{
user_has_weapon(id, iCswId, 0);
ExecuteHamB(Ham_Item_Kill, iWeapon);
return 1;
}
}
return 0;
}