这是源码,
//几秒后真正造成伤害
set_task(0.1, "knife_melee", id+TASK_STABDELAY)//0.1秒后伤害
set_pdata_float(id, m_flNextAttack, 9999.0, OFFSET_LINUX)
set_pdata_int(wpnent, m_fInReload, 1, OFFSET_LINUX_WEAPONS)
set_pdata_float(wpnent, m_flTimeWeaponIdle, 9999.0, OFFSET_LINUX_WEAPONS)
}
public knife_melee(taskid)
{
static id
if (taskid > g_maxplayers) id = ID_STABDELAY
else id = taskid
new Float:target_origin[3]
get_user_startpos(id, 50.0, 0.0, 0.0, target_origin)//攻击距离(32.0)
new wpnent = fm_get_wpnentity(id, CSW_KNIFE)
set_pdata_float(wpnent, m_flNextPrimaryAttack, 0.5, OFFSET_LINUX)//攻击间隔
set_pdata_float(wpnent, m_flNextSecondaryAttack, 0.5, OFFSET_LINUX)//攻击间隔
new target, num=0
while ((target = engfunc(EngFunc_FindEntityInSphere, any:target, any:target_origin, any:50.0)) != 0)
{
if (pev(target, pev_health)<=0) continue
if (get_user_team(target) == get_user_team(id)) continue
if (entity_range(id, target) > 50.0) continue
if (num > 0) continue
num ++
new Float:origin[3]
pev(target, pev_origin, any:origin)
FX_Blood(origin)
origin[2]+=16.0
FX_Blood(origin)
ExecuteHamB(Ham_TakeDamage, any:target, any:wpnent, any:id, any:53.0, any:DMG_SLASH)//伤害53.0
emit_sound(id, CHAN_WEAPON, "weapons/knife_hit1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)//声音
}
new tg, bd, class[32]
get_user_aiming(id, tg, bd, 50)
pev(tg, pev_classname, any:class, any:31)
if (equal(class, "player")) emit_sound(id, CHAN_WEAPON, "weapons/knife_hit1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)//声音
else emit_sound(id, CHAN_WEAPON, "weapons/knife_hitwall1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)//声音
[ 此帖被泪如火灬在2013-02-16 11:00重新编辑 ]