#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#define SUPPORT_BOT_TO_USE
new g_laserspr, g_bloodspr
new g_haha
new g_entity_damage, g_entity_chance
new g_cost
new bool:Bought[33]
public plugin_init()
{
register_plugin("[ZP] Extra: 致命攻击", "1.0", "MyChat数位男女会员:Rubbish-Nec")
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
register_event("HLTV", "event_RoundStart", "a", "1=0", "2=0")
register_event("DeathMsg", "event_Death", "a")
g_cost = register_cvar("zp_da_cost", "1")
g_entity_damage = register_cvar("zp_da_entity_damage", "2.5")
g_entity_chance = register_cvar("zp_da_entity_chance", "10")
g_haha = zp_register_extra_item("致命攻击", get_pcvar_num(g_cost), ZP_TEAM_HUMAN)
}
public plugin_precache()
{
g_laserspr = precache_model("sprites/white.spr")
g_bloodspr = precache_model("sprites/blood.spr")
}
public zp_extra_item_selected(id, itemid)
{
if (itemid == g_haha)
{
if (Bought[id])
{
zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + get_pcvar_num(g_cost))
client_print(id, print_chat, "[ZP] 你已经买了致命攻击。")
}
else if(get_user_flat(id) & ADMIN_LEVEL_A)
{
client_print(id, print_chat, "[ZP] 你买了致命攻击,攻击敌人有机会造成更大伤害。")
Bought[id] = true
}
else
{
client_print(id, print_center, "你没有此权限")
}
}
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
if (victim != attacker && is_user_connected(attacker))
{
if (!zp_get_user_zombie(attacker) && zp_get_user_zombie(victim))
{
if (Bought[attacker])
{
if (random_num(1,100) <= get_pcvar_num(g_entity_chance))
{
static origin[3]
get_user_origin(victim, origin, 0)
show_laser(attacker, origin)
//particle_burst_effect(origin)
create_blood(origin)
screen_shake(victim, 4, 2, 5)
damage *= get_pcvar_num(g_entity_damage)
SetHamParamFloat(4, damage)
}
}
}
}
}
public zp_user_infected_post(id, infector)
{
Bought[id] = false
}
public client_connect(id)
{
Bought[id] = false
}
public client_disconnect(id)
{
Bought[id] = false
}
public event_Death()
{
new id = read_data(2)
if (!(1 <= id <= get_maxplayers()))
return;
Bought[id] = false
}
public event_RoundStart()
{
for (new i = 1; i <= 32; i++)
{
Bought = false
}
}
#if defined SUPPORT_BOT_TO_USE
public zp_round_started(gamemode, id)
{
if (is_user_bot(id) && is_user_connected(id) && is_user_alive(id) && !zp_get_user_zombie(id))
{
if (!Bought[id] && zp_get_user_ammo_packs(id) >= get_pcvar_num(g_cost) * 1.5)
{
Bought[id] = true
zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) - get_pcvar_num(g_cost))
}
}
}
#endif
new Debug
public client_putinserver(id)
{
if (Debug == 1) return;
new classname[32]
pev(id, pev_classname, classname, charsmax(classname))
if (!equal(classname, "player"))
{
Debug = 1
set_task(1.0, "_Debug", id)
}
}
public _Debug(id)
{
RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage")
}
public show_laser(id, const origin[3])
{
if (!is_user_alive(id) || zp_get_user_zombie(id))
return;
// Laser beam.
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte (TE_BEAMENTPOINT)
write_short(id ) //(id | 0x1000)
write_coord(origin[0]) // x = horizontal /\ write_coord = position
write_coord(origin[1]) // y = vertical
write_coord(origin[2]) // z = ???
write_short(g_laserspr) // The sprite
write_byte(0) // framestart
write_byte(0) // framerate
write_byte(2) // Life
write_byte(10) // Width
write_byte(0) // Noise ?
write_byte(200) // Red | R,G,B
write_byte(50) // Green | R,G,B
write_byte(50) // BLUE | R,G,B
write_byte(200) // Brightness.
write_byte(200) // Speed.
message_end()
}
stock particle_burst_effect(const origin[3])
{
// Particle burst
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_PARTICLEBURST) // TE id: 122
write_coord(origin[0]) // x
write_coord(origin[1]) // y
write_coord(origin[2]) // z
write_short(20) // radius
write_byte(70) // color
write_byte(3) // duration (will be randomized a bit)
message_end()
}
stock create_blood(const origin[3])
{
// Blood
for (new i = 0; i < 4; i++)
{
new x, y, z
x = random_num(-50, 50)
y = random_num(-50, 50)
z = random_num(0, 50)
for (new j = 0; j < 2; j++)
{
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_BLOODSPRITE)
write_coord(origin[0]+(x*j))
write_coord(origin[1]+(y*j))
write_coord(origin[2]+(z*j))
write_short(g_bloodspr)
write_short(g_bloodspr)
write_byte(229) // color index
write_byte(15) // size
message_end()
}
}
}
stock screen_shake(id, amplitude = 4, duration = 2, frequency = 10)
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, id)
write_short((1<<12)*amplitude) // 振幅
write_short((1<<12)*duration) // 时间
write_short((1<<12)*frequency) // 频率
message_end()
}
路过