今天找大神写了个m4右键攻击的源码,但是不会用,有的地方也没有补充完,希望各位大大帮帮忙,要求威力能一刀死,动作延迟是雷神或者黑骑士,希望大大做成amxx插件,谢谢了
代码如下:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define WPNSTATE_M4A1_SILENCED (1<<2)
// CBasePlayerItem
stock m_pPlayer = 41 // CBasePlayer *
stock m_flNextPrimaryAttack = 46 // float
stock m_flNextSecondaryAttack = 47 // float
stock m_flTimeWeaponIdle = 48 // float
stock m_iWeaponState = 74 // int
//---------------------- Init
public plugin_init()
{
RegisterHam( Ham_Weapon_SecondaryAttack, "weapon_m4a1", "Ham_Weapon_SecondaryAttack_Post", 1)
}
// ------------------ HAM
public Ham_Weapon_SecondaryAttack_Post( iEnt )
{
new iWpnState = get_pdata_int( iEnt, m_iWeaponState );
iWpnState &= ~WPNSTATE_M4A1_SILENCED;
set_pdata_int( iEnt, m_iWeaponState , iWpnState );
new Float:flAttackTime = 刀攻击时间
set_pdata_float( iEnt, m_flTimeWeaponIdle, flAttackTime );
set_pdata_float( iEnt, m_flNextSecondaryAttack, flAttackTime );
set_pdata_float( iEnt, m_flNextPrimaryAttack, flAttackTime );
new id = get_pdata_cbase( iEnt, m_pPlayer );
SendWeaponAnim ( id, 刀击动作序列 );
new iTarget, iBody;
get_user_aiming( id, iTarget, iBody, 刀击的攻击距离 );
if( pev( iTarget, pev_takedamage ) )
{
ExecuteHamB( Ham_TakeDamage, iTarget, id, id, float(伤害值), DMG_CLUB);
}
}
// ------------------ Private
stock SendWeaponAnim ( id, iAnim )
{
set_pev( id, pev_weaponanim, iAnim);
message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, id);
write_byte(iAnim);
write_byte(0);
message_end();
}