标签:
1 #include <amxmodx> 2 #include <hamsandwich> 3 #include <fakemeta> 4 5 stock m_flNextAttack = 83; 6 stock m_rgAmmo[] = { 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407 }; 7 stock m_pPlayer = 41; 8 stock m_flNextPrimaryAttack = 46; 9 stock m_flNextSecondaryAttack = 47; 10 stock m_flTimeWeaponIdle = 48; 11 stock m_iPrimaryAmmoType = 49; 12 stock m_iClip = 51; 13 stock m_fInSpecialReload = 55; 14 stock m_flNextReload = 75; 15 16 enum xm1014_e 17 { 18 XM1014_IDLE, 19 XM1014_FIRE1, 20 XM1014_FIRE2, 21 XM1014_RELOAD, 22 XM1014_PUMP, 23 XM1014_START_RELOAD, 24 XM1014_DRAW 25 } 26 27 #define MAX_CLIP 15 28 29 public plugin_init() 30 { 31 register_plugin("XM1014", "1.0", "crsky123003"); 32 33 RegisterHam(Ham_Weapon_WeaponIdle, "weapon_xm1014", "HamF_Weapon_WeaponIdle"); 34 RegisterHam(Ham_Weapon_Reload, "weapon_xm1014", "HamF_Weapon_Reload"); 35 } 36 37 public HamF_Weapon_WeaponIdle(this) 38 { 39 new id = get_pdata_cbase(this, m_pPlayer); 40 new iAmmoType = get_pdata_int(this, m_iPrimaryAmmoType); 41 new iClip = get_pdata_int(this, m_iClip); 42 new iBpAmmo = get_pdata_int(id, m_rgAmmo[iAmmoType]); 43 44 if(get_pdata_float(this, m_flTimeWeaponIdle) <= 0.0) 45 { 46 if(iClip == 0 && get_pdata_int(this, m_fInSpecialReload) == 0 && iBpAmmo) 47 { 48 Reload(this); 49 } 50 else if(get_pdata_int(this, m_fInSpecialReload) != 0) 51 { 52 if(iClip != MAX_CLIP && iBpAmmo) 53 { 54 Reload(this); 55 } 56 else 57 { 58 SendWeaponAnim(id, XM1014_PUMP); 59 60 // 装弹结束 61 set_pdata_int(this, m_fInSpecialReload, 0); 62 set_pdata_float(this, m_flTimeWeaponIdle, 1.5); 63 } 64 } 65 else 66 SendWeaponAnim(id, XM1014_IDLE); 67 68 return HAM_SUPERCEDE; 69 } 70 71 return HAM_IGNORED; 72 } 73 74 public HamF_Weapon_Reload(this) 75 { 76 Reload(this); 77 return HAM_SUPERCEDE; 78 } 79 80 public Reload(this) 81 { 82 new id = get_pdata_cbase(this, m_pPlayer); 83 new iAmmoType = get_pdata_int(this, m_iPrimaryAmmoType); 84 new iClip = get_pdata_int(this, m_iClip); 85 new iBpAmmo = get_pdata_int(id, m_rgAmmo[iAmmoType]); 86 87 if(iBpAmmo <= 0 || iClip == MAX_CLIP) 88 return; 89 90 if(get_pdata_float(this, m_flNextPrimaryAttack) > 0.0) 91 return; 92 93 if(!get_pdata_int(this, m_fInSpecialReload)) 94 { 95 SendWeaponAnim(id, XM1014_START_RELOAD); 96 set_pdata_int(this, m_fInSpecialReload, 1); 97 98 // 开始装弹的时间 99 set_pdata_float(id, m_flNextAttack, 0.55); 100 set_pdata_float(this, m_flTimeWeaponIdle, 0.55); 101 set_pdata_float(this, m_flNextPrimaryAttack, 0.55); 102 set_pdata_float(this, m_flNextSecondaryAttack, 0.55); 103 } 104 else if(get_pdata_int(this, m_fInSpecialReload) == 1) 105 { 106 if(get_pdata_float(this, m_flTimeWeaponIdle) > 0.0) 107 return; 108 109 set_pdata_int(this, m_fInSpecialReload, 2); 110 111 if(random_num(0, 1)) 112 emit_sound(id, CHAN_ITEM, "weapons/reload1.wav", VOL_NORM, ATTN_NORM, 0, 85 + random_num(0, 31)); 113 else 114 emit_sound(id, CHAN_ITEM, "weapons/reload2.wav", VOL_NORM, ATTN_NORM, 0, 85 + random_num(0, 31)); 115 116 SendWeaponAnim(id, XM1014_RELOAD); 117 118 // 装弹间隔时间 119 set_pdata_float(this, m_flNextReload, 0.3); 120 set_pdata_float(this, m_flTimeWeaponIdle, 0.3); 121 } 122 else 123 { 124 set_pdata_int(this, m_iClip, iClip + 1); 125 set_pdata_int(this, m_rgAmmo[iAmmoType], iBpAmmo - 1); 126 set_pdata_int(this, m_fInSpecialReload, 1); 127 } 128 } 129 130 stock SendWeaponAnim(id, iAnim) 131 { 132 set_pev(id, pev_weaponanim, iAnim); 133 message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id); 134 write_byte(iAnim); 135 write_byte(pev(id, pev_body)); 136 message_end(); 137 }
标签:
原文地址:http://www.cnblogs.com/crsky/p/4292448.html