首页 > 代码库 > 未完成的ShotgunReload

未完成的ShotgunReload

  1 #include <amxmodx>  2 #include <hamsandwich>  3 #include <fakemeta>  4   5 new const g_szWpnName[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10", "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550", "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249", "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552", "weapon_ak47", "weapon_knife", "weapon_p90" }  6   7 const m_flNextAttack = 83  8   9 const m_pPlayer = 41 10 const m_iId = 43 11  12 const m_flNextPrimaryAttack = 46 13 const m_flTimeWeaponIdle = 48 14 const m_iPrimaryAmmoType = 49 15 const m_iClip = 51 16 const m_fInReload = 54 17 const m_fInSpecialReload = 55 18  19 new const m_rgAmmo[32] = { 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 } // int 20  21 public plugin_precache() 22 { 23     // Register Plugin 24     register_plugin("GameWpn", "1.1", "crsky") 25 } 26  27 public plugin_init() 28 { 29     // ShotGun 30     RegisterHam(Ham_Item_PostFrame, g_szWpnName[CSW_XM1014], "HamF_WpnPostFrame") 31     RegisterHam(Ham_Item_PostFrame, g_szWpnName[CSW_M3], "HamF_WpnPostFrame") 32     RegisterHam(Ham_Weapon_WeaponIdle, g_szWpnName[CSW_XM1014], "HamF_WpnIdle") 33     RegisterHam(Ham_Weapon_WeaponIdle, g_szWpnName[CSW_M3], "HamF_WpnIdle") 34 } 35  36 public HamF_WpnPostFrame(iWpnEnt)  37 { 38     new iPlayer = get_pdata_cbase(iWpnEnt, m_pPlayer) 39      40     new fInReload = get_pdata_int(iWpnEnt, m_fInReload) 41     new iClip = get_pdata_int(iWpnEnt, m_iClip) 42     new iAmmoType = get_pdata_int(iWpnEnt, m_iPrimaryAmmoType) 43     new iBpAmmo = get_pdata_int(iPlayer, m_rgAmmo[iAmmoType]) 44      45     new iButton = pev(iPlayer, pev_button) 46      47     if (iButton & IN_ATTACK && get_pdata_float(iWpnEnt, m_flNextPrimaryAttack) <= 0.0) 48     return 49      50     new iTempClip = get_pdata_int(iWpnEnt, m_iId) == CSW_M3 ? 8 : 7 51      52     if(iButton & IN_RELOAD && !fInReload) 53     { 54         new iClipExtra = 15 55          56         if(iClip >= iClipExtra) 57         { 58             set_pev(iPlayer, pev_button, iButton & ~IN_RELOAD) 59         } 60         else if(iClip == iTempClip && iBpAmmo) 61         { 62             ShotgunReload(iWpnEnt, iClipExtra, iClip, iBpAmmo, iPlayer) 63         } 64     } 65 } 66  67 public HamF_WpnIdle(iWpnEnt) 68 { 69     new iPlayer = get_pdata_cbase(iWpnEnt, m_pPlayer) 70      71     if(get_pdata_float(iWpnEnt, m_flTimeWeaponIdle) > 0.0) 72     return 73      74     new iClip = get_pdata_int(iWpnEnt, m_iClip)  75     new fInSpecReload = get_pdata_int(iWpnEnt, m_fInSpecialReload) 76      77     if(!iClip && !fInSpecReload) return 78  79     if(fInSpecReload) 80     { 81         new iAmmoType = get_pdata_int(iWpnEnt, m_iPrimaryAmmoType) 82         new iBpAmmo = get_pdata_int(iPlayer, m_rgAmmo[iAmmoType]) 83          84         new iClipExtra = 15 85         new iTempClip = get_pdata_int(iWpnEnt, m_iId) == CSW_M3 ? 8 : 7 86          87         Stock_SendWpnAnim(iPlayer, 3) // insert 88          89         if(iClip < iClipExtra && iClip == iTempClip && iBpAmmo) 90         { 91             ShotgunReload(iWpnEnt, iClipExtra, iClip, iBpAmmo, iPlayer) 92             return 93         } 94         if(iClip == iClipExtra && iClip != iTempClip - 1) 95         { 96             Stock_SendWpnAnim(iPlayer, 4) // after_reload 97             set_pdata_int(iWpnEnt, m_fInSpecialReload, 0) 98             set_pdata_float(iWpnEnt, m_flTimeWeaponIdle, 1.8) 99         }100     }101 }102 103 public ShotgunReload(iWpnEnt, iMaxClip, iClip, iBpAmmo, iPlayer)104 {105     if(iBpAmmo <= 0 || iMaxClip == iClip)106     return107     108     if(get_pdata_float(iWpnEnt, m_flNextPrimaryAttack) > 0.0)109     return110     111     switch(get_pdata_int(iWpnEnt, m_fInSpecialReload))112     {113         case 0:114         {115             Stock_SendWpnAnim(iPlayer, 5) // start_reload116             117             set_pdata_int(iWpnEnt, m_fInSpecialReload, 1)118             set_pdata_float(iPlayer, m_flNextAttack, 0.55)119             set_pdata_float(iWpnEnt, m_flNextPrimaryAttack, 0.55)120             set_pdata_float(iWpnEnt, m_flTimeWeaponIdle, 0.55)121             122             return123         }124         case 1:125         {126             if(get_pdata_float(iWpnEnt, m_flTimeWeaponIdle) > 0.0) return127             128             set_pdata_int(iWpnEnt, m_fInSpecialReload, 2)129             set_pdata_float(iWpnEnt, m_flTimeWeaponIdle, 0.45)130         }131         default:132         {133             new iAmmoType = get_pdata_int(iWpnEnt, m_iPrimaryAmmoType)134             135             set_pdata_int(iWpnEnt, m_iClip, iClip + 1)136             set_pdata_int(iPlayer, m_rgAmmo[iAmmoType], iBpAmmo - 1)137             set_pdata_int(iWpnEnt, m_fInSpecialReload, 1)138         }139     }140 }141 142 stock Stock_SendWpnAnim(iPlayer, iAnim)143 {144     set_pev(iPlayer, pev_weaponanim, iAnim)145     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, iPlayer)146     write_byte(iAnim)147     write_byte(pev(iPlayer, pev_body))148     message_end()149 }

 

未完成的ShotgunReload