码迷,mamicode.com
首页 > 其他好文 > 详细

修改CS武器属性(部分)

时间:2014-12-20 00:47:53      阅读:431      评论:0      收藏:0      [点我收藏+]

标签:

  1 #include <amxmodx>
  2 #include <hamsandwich>
  3 #include <fakemeta>
  4 #include <xs>
  5 
  6 #define WEAPON        "weapon_m4a1"
  7 #define MAX_CLIP    35
  8 
  9 const m_flNextAttack = 83
 10 const m_pPlayer = 41
 11 const m_iClip = 51
 12 const m_fInReload = 54
 13 const m_iPrimaryAmmoType = 49
 14 const m_iWeaponState = 74
 15 const m_flNextPrimaryAttack = 46
 16 const m_flNextSecondaryAttack = 47
 17 const m_pActiveItem = 373
 18 const m_iId = 43
 19 
 20 const MAX_AMMO_SLOTS = 32
 21 stock m_rgAmmo[MAX_AMMO_SLOTS] = { 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
 22 
 23 // PunchAngle Save
 24 new Float:g_vecPunchangle[33][3]
 25 
 26 public plugin_init()
 27 {
 28     register_plugin("my m4a1", "1.0", "crsky")
 29     
 30     // Ham Forward
 31     RegisterHam(Ham_Item_Deploy, WEAPON, "fw_Item_Deploy_Post", 1)
 32     RegisterHam(Ham_Item_PostFrame, WEAPON, "fw_Item_PostFrame")
 33     RegisterHam(Ham_Item_PostFrame, WEAPON, "fw_Item_PostFrame_Post", 1)
 34     RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON, "fw_Weapon_PirmaryAttack")
 35     RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON, "fw_Weapon_PirmaryAttack_Post", 1)
 36     RegisterHam(Ham_Weapon_SecondaryAttack, WEAPON, "fw_Weapon_SecondaryAttack_Post", 1)
 37     RegisterHam(Ham_Spawn, WEAPON, "fw_Spawn_Post", 1)
 38     
 39     // Fakemeta Forward
 40     register_forward(FM_PlayerPostThink, "fw_PlayerPostThink", 1)
 41 }
 42 
 43 public fw_Item_Deploy_Post(iWeapon)
 44 {
 45     new iPlayer = get_pdata_cbase(iWeapon, m_pPlayer)
 46     
 47     // Deploy Time (切枪时间)
 48     set_pdata_float(iPlayer, m_flNextAttack, 5.0)
 49 }
 50 
 51 public fw_Item_PostFrame(iWeapon)
 52 {
 53     new iPlayer = get_pdata_cbase(iWeapon, m_pPlayer)
 54     new iButton = pev(iPlayer, pev_button)
 55     
 56     if(iButton & IN_RELOAD)
 57     {
 58         new iClip = get_pdata_int(iWeapon, m_iClip)
 59         
 60         if(iClip >= MAX_CLIP)
 61             set_pev(iPlayer, pev_button, iButton & ~IN_RELOAD)
 62     }
 63     
 64     if(get_pdata_int(iWeapon, m_fInReload))
 65     {
 66         new iClip = get_pdata_int(iWeapon, m_iClip)
 67         new iAmmoType = get_pdata_int(iWeapon, m_iPrimaryAmmoType)
 68         new iBpAmmo = get_pdata_int(iPlayer, m_rgAmmo[iAmmoType])
 69         
 70         new j = MAX_CLIP - iClip
 71         
 72         j = min(j, iBpAmmo)
 73         
 74         set_pdata_int(iWeapon, m_iClip, iClip + j)
 75         set_pdata_int(iPlayer, m_rgAmmo[iAmmoType], iBpAmmo - j)
 76         
 77         set_pdata_int(iWeapon, m_fInReload, 0)
 78     }
 79 }
 80 
 81 public fw_Item_PostFrame_Post(iWeapon)
 82 {
 83     new iPlayer = get_pdata_cbase(iWeapon, m_pPlayer)
 84     new iButton = pev(iPlayer, pev_button)
 85     
 86     if(iButton & IN_RELOAD)
 87     {
 88         new iClip = get_pdata_int(iWeapon, m_iClip)
 89         set_pdata_int(iWeapon, m_fInReload, (iClip < MAX_CLIP) ? 1 : 0)
 90     }
 91     
 92     if(get_pdata_int(iWeapon, m_fInReload))
 93     {
 94         // Reload Time (换弹时间)
 95         set_pdata_float(iPlayer, m_flNextAttack, 5.0)
 96         
 97         // 当m_iWeaponState为0时, M4没有装消音器, 当m_iWeaponState为4时, M4已经装上了消音器
 98         new iState = get_pdata_int(iWeapon, m_iWeaponState)
 99         SendWeaponAnim(iPlayer, iState ? 4 : 11)
100     }
101 }
102 
103 // 播放武器动作
104 stock SendWeaponAnim(iPlayer, iAnim)
105 {
106     set_pev(iPlayer, pev_weaponanim, iAnim)
107     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, iPlayer)
108     write_byte(iAnim)
109     write_byte(pev(iPlayer, pev_body))
110     message_end()
111 }
112 
113 public fw_Weapon_PirmaryAttack(iWeapon)
114 {
115     new iPlayer = get_pdata_cbase(iWeapon, m_pPlayer)
116     pev(iPlayer, pev_punchangle, g_vecPunchangle[iPlayer])
117 }
118 
119 public fw_Weapon_PirmaryAttack_Post(iWeapon)
120 {
121     new iPlayer = get_pdata_cbase(iWeapon, m_pPlayer)
122     
123     // Attack Interval (开枪间隔时间)
124     set_pdata_float(iWeapon, m_flNextPrimaryAttack, 0.07)
125     
126     // 设置后坐力(冲击角度)
127     new Float:push[3]
128     pev(iPlayer, pev_punchangle, push)
129     
130     xs_vec_sub(push, g_vecPunchangle[iPlayer], push)
131     xs_vec_mul_scalar(push, 0.2 /*后坐力倍数, 0.8 就是80% */, push)
132     xs_vec_add(push, g_vecPunchangle[iPlayer], push)
133     
134     set_pev(iPlayer, pev_punchangle, push)
135     
136 }
137 
138 public fw_Weapon_SecondaryAttack_Post(iWeapon)
139 {
140     // SecondaryAttack Interval (特殊功能间隔时间, 按鼠标右键触发的武器功能, 例如开镜, 上消音器, 切换三连发, 刀子重击等功能的间隔时间)
141     set_pdata_float(iWeapon, m_flNextSecondaryAttack, 3.0)
142     
143     // 设置装消音器所需要等待的时间
144     set_pdata_float(iWeapon, m_flNextPrimaryAttack, 1.0)
145 }
146 
147 public fw_Spawn_Post(iWeapon)
148 {
149     // 设置默认子弹数
150     set_pdata_int(iWeapon, m_iClip, MAX_CLIP)
151 }
152 
153 public fw_PlayerPostThink(iPlayer)
154 {
155     new iWeapon = get_pdata_cbase(iPlayer, m_pActiveItem)
156     
157     if(!pev_valid(iWeapon))
158         return
159     
160     if(get_pdata_int(iWeapon, m_iId) == CSW_M4A1)
161     {
162         set_pev(iPlayer, pev_maxspeed, 180.0 /*正常速度是250*/)
163     }
164 }

 

修改CS武器属性(部分)

标签:

原文地址:http://www.cnblogs.com/crsky/p/4174938.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!