Код
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <zombieplague>
new beam,redflare,blueflare;
new g_itemid_candle;
new g_CandleAmmo[33] = 0;
new const g_item_name[] = { "Candle bomb (+1)" };
const g_item_cost = 2;
public plugin_init()
{
register_plugin("CandleBomb","0.2","Enigmaya");
g_itemid_candle = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN);
register_forward(FM_PlayerPreThink, "Forward_PlayerPreThink")
register_event("ResetHUD", "AddCandleBomb", "b")
register_touch("", "", "entity_touch")
}
public plugin_precache()
{
precache_sound("weapons/rocketfire1.wav");
precache_model("models/rpgrocket.mdl")
beam = precache_model("sprites/laserbeam.spr")
blueflare = precache_model("sprites/blueflare2.spr")
redflare = precache_model("sprites/redflare2.spr")
precache_sound("debris/beamstart15.wav")
}
public client_connect(id)
{
g_CandleAmmo[id]=0;
}
public client_disconnect(id)
{
g_CandleAmmo[id]=0;
}
public entity_touch(pToucher,pTouched)
{
new classn[32];
if( pToucher )
entity_get_string(pToucher,EV_SZ_classname,classn,31);
if ( equal(classn,"candleB") )
{
new Float:FlashOrigin[3];
entity_get_vector(pToucher,EV_VEC_origin,FlashOrigin);
remove_entity(pToucher);
new spr;
if(random_num(0,1))
spr=blueflare;
else spr=redflare;
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte( 4 );
write_coord( floatround(FlashOrigin[0]) );
write_coord( floatround(FlashOrigin[1]) );
write_coord( floatround(FlashOrigin[2]) );
message_end();
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(15)
write_coord( floatround(FlashOrigin[0]) )
write_coord( floatround(FlashOrigin[1]) )
write_coord( floatround(FlashOrigin[2])-5 )
write_coord( floatround(FlashOrigin[0]) )
write_coord( floatround(FlashOrigin[1]) )
write_coord( floatround(FlashOrigin[2]) )
write_short(spr) // (sprite index)
write_byte(2) // (count)
write_byte(55) // (life in 0.1's)
write_byte(100) // byte (scale in 0.1's)
write_byte(0) // (velocity along vector in 10's)
write_byte(0) // (randomness of velocity in 10's)
message_end()
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(27);
write_coord( floatround(FlashOrigin[0]) );
write_coord( floatround(FlashOrigin[1]) );
write_coord( floatround(FlashOrigin[2]) );
write_byte(200);
write_byte(230);
write_byte(230);
write_byte(230);
write_byte(100);
write_byte(10); // decay rate
message_end();
}
else if( equal(classn,"slowLight") )
{
remove_entity(pToucher);
}
}
public Forward_PlayerPreThink(id)
{
if(pev( id, pev_button ) & IN_ATTACK2 && !(pev( id, pev_oldbuttons ) & IN_ATTACK2 ) & !is_user_bot(id))
InitCandleBomb(id)
return PLUGIN_CONTINUE
}
public AddCandleBomb(id)
{
if(!is_user_alive(id) || zp_get_user_zombie(id))
return PLUGIN_HANDLED;
g_CandleAmmo[id]=1
return PLUGIN_HANDLED;
}
/*
public event_infect2(id)
{
g_CandleAmmo[id]=0
}
*/
public InitCandleBomb(id)
{
if (!is_user_alive(id) || zp_get_user_zombie(id) || !g_CandleAmmo[id])
{
return PLUGIN_HANDLED;
}
if(get_user_weapon(id) == CSW_C4 || get_user_weapon(id) == CSW_FLASHBANG || get_user_weapon(id) == CSW_HEGRENADE || get_user_weapon(id) == CSW_KNIFE || get_user_weapon(id) == CSW_SMOKEGRENADE)
return PLUGIN_HANDLED
entity_set_int(id,EV_INT_effects,2);
entity_set_int(id,EV_INT_light_level,4);
new Float:angle[3],origin[3],Float:PlayerOrigin[3],Float:PlayerVelocity[3];
entity_get_vector(id,EV_VEC_origin,PlayerOrigin);
get_user_origin(id,origin,1);
velocity_by_aim(id, 16, PlayerVelocity)
origin[0] += floatround( PlayerVelocity[0] )
origin[1] += floatround( PlayerVelocity[1] )
origin[2] += floatround( PlayerVelocity[2] )
shootFire(origin)
if( ViewContents(id)==CONTENTS_SKY )
{
new candle = create_entity("info_target");
entity_set_string(candle,EV_SZ_classname,"candleB");
entity_set_model(candle,"models/rpgrocket.mdl");
entity_set_origin(candle,PlayerOrigin);
entity_set_int(candle,EV_INT_solid,2);
entity_set_edict(candle,EV_ENT_owner,id);
entity_set_int(candle,EV_INT_movetype,5);
entity_set_int(candle,EV_INT_effects,4);
VelocityByAim(id,600,PlayerVelocity);
vector_to_angle(PlayerVelocity,angle);
entity_set_vector(candle,EV_VEC_angles,angle);
entity_set_vector(candle,EV_VEC_velocity,PlayerVelocity);
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(22)
write_short(candle)
write_short(beam)
write_byte(5)
write_byte(5)
write_byte(230)
write_byte(230)
write_byte(230)
write_byte(128)
message_end()
emit_sound(id,CHAN_BODY,"weapons/rocketfire1.wav",1.0,ATTN_NORM,0,PITCH_NORM);
}
else
{
new slowLight = create_entity("info_target");
entity_set_string(slowLight,EV_SZ_classname,"slowLight");
entity_set_model(slowLight,"models/rpgrocket.mdl");
entity_set_origin(slowLight,PlayerOrigin);
entity_set_int(slowLight,EV_INT_solid,2);
entity_set_edict(slowLight,EV_ENT_owner,id);
entity_set_int(slowLight,EV_INT_movetype,5);
entity_set_int(slowLight,EV_INT_effects,4);
VelocityByAim(id,200,PlayerVelocity);
if( PlayerVelocity[2]<=-100.0 )
RemoveEntity(slowLight);
PlayerVelocity[2]=0.0;
vector_to_angle(PlayerVelocity,angle);
entity_set_vector(slowLight,EV_VEC_angles,angle);
entity_set_vector(slowLight,EV_VEC_velocity,PlayerVelocity);
emit_sound(id,CHAN_BODY,"debris/beamstart15.wav",1.0,ATTN_NORM,0,PITCH_NORM);
set_task(20.0,"RemoveEntity",slowLight);
}
g_CandleAmmo[id]=0;
return PLUGIN_HANDLED;
}
shootFire(origin[3])
{
origin[0]+=10;
origin[1]+=10;
Msg(origin)
origin[0]-=10;
origin[1]-=10;
Msg(origin)
origin[0]+=10;
origin[1]-=10;
Msg(origin)
origin[0]-=10;
origin[1]+=10;
Msg(origin)
}
Msg(origin[3])
{
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte( 9 );
write_coord( origin[0] );
write_coord( origin[1] );
write_coord( origin[2] );
message_end();
}
public RemoveEntity(entid)
{
remove_entity(entid);
return PLUGIN_CONTINUE;
}
public zp_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_candle){
}
g_CandleAmmo[player] += 1;
client_print(player, print_chat,"[ZP] Now you have candle bomb , press attack2 to see it.");
}
public EVENT_round_start()
{
for (new id; id <= 32; id++) g_CandleAmmo[id] = false;
}
public zp_user_infected_post(id, infector)
{
if (g_CandleAmmo[id])
{
g_CandleAmmo[id] = false
}
}