HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta>
  4. #include <fun>
  5. #include <hamsandwich>
  6. #include <xs>
  7. #include <cstrike>
  8. #include <zombieplague>
  9.  
  10. enum
  11. {
  12. anim_idle,
  13. anim_shoot1,
  14. anim_shoot2,
  15. anim_reload,
  16. anim_draw
  17. }
  18.  
  19. #define ENG_NULLENT -1
  20. #define EV_INT_WEAPONKEY EV_INT_impulse
  21. #define USAS_WEAPONKEY 7
  22. #define MAX_PLAYERS 32
  23. #define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
  24.  
  25. const USE_STOPPED = 0
  26. const OFFSET_ACTIVE_ITEM = 373
  27. const OFFSET_WEAPONOWNER = 41
  28. const OFFSET_LINUX = 5
  29. const OFFSET_LINUX_WEAPONS = 4
  30.  
  31. #define WEAP_LINUX_XTRA_OFF 4
  32. #define m_fKnown 44
  33. #define m_flNextPrimaryAttack 46
  34. #define m_flTimeWeaponIdle 48
  35. #define m_iClip 51
  36. #define m_fInReload 54
  37. #define PLAYER_LINUX_XTRA_OFF 5
  38. #define m_flNextAttack 83
  39. #define write_coord_f(%1) engfunc(EngFunc_WriteCoord,%1)
  40.  
  41. #define USAS_RELOAD_TIME 4.0
  42.  
  43. const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
  44. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
  45. "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
  46. "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  47. "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  48. "weapon_ak47", "weapon_knife", "weapon_p90" }
  49.  
  50.  
  51. new const Fire_Sounds[][] = { "weapons/usas-1.wav" }
  52. new const Sound_Zoom[] = { "weapons/zoom.wav" }
  53. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
  54. new USAS_V_MODEL[64] = "models/zombie/v_usas.mdl"
  55. new USAS_P_MODEL[64] = "models/zombie/p_usas.mdl"
  56. new USAS_W_MODEL[64] = "models/zombie/w_usas.mdl"
  57.  
  58. new g_usas
  59. new g_has_usas[33]
  60. new Trie:g_tClassNames
  61. new g_usas_TmpClip[33]
  62. new g_hamczbots, cvar_botquota
  63. new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]
  64. new g_MaxPlayers, g_orig_event_usas, g_IsInPrimaryAttack, g_clip_ammo[33]
  65. new cvar_dmg_usas, cvar_recoil_usas, cvar_clip_usas, cvar_usas_ammo, cvar_spd_usas
  66.  
  67.  
  68. public plugin_init()
  69. {
  70. register_plugin("[ZP] Extra: Usas", "1.0", "Crock/4yBak001")
  71. register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
  72. register_event("CurWeapon","CurrentWeapon","be","1=1")
  73. RegisterHam(Ham_Item_AddToPlayer, "weapon_xm1014", "fw_USAS_AddToPlayer")
  74. RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
  75. RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
  76. RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
  77. RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
  78. for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
  79. if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
  80. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_xm1014", "fw_USAS_PrimaryAttack")
  81. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_xm1014", "fw_USAS_PrimaryAttack_Post", 1)
  82. RegisterHam(Ham_Item_PostFrame, "weapon_xm1014", "USAS__ItemPostFrame");
  83. RegisterHam(Ham_Weapon_Reload, "weapon_xm1014", "USAS__Reload");
  84. RegisterHam(Ham_Weapon_Reload, "weapon_xm1014", "USAS__Reload_Post", 1);
  85. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  86.  
  87. register_forward(FM_Spawn, "fw_Spawn_Post", 1)
  88. register_forward(FM_SetModel, "fw_SetModel")
  89. register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  90. register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
  91.  
  92. cvar_dmg_usas = register_cvar("zp_usas_dmg", "1.15")
  93. cvar_recoil_usas = register_cvar("zp_usas_recoil", "0.6")
  94. cvar_clip_usas = register_cvar("zp_usas_clip", "20")
  95. cvar_usas_ammo = register_cvar("zp_usas_ammo", "60")
  96. cvar_spd_usas = register_cvar("zp_usas_spd", "0.9")
  97.  
  98. cvar_botquota = get_cvar_pointer("bot_quota")
  99.  
  100. g_usas = zp_register_extra_item("USAS-12", 20, ZP_TEAM_HUMAN)
  101.  
  102. g_MaxPlayers = get_maxplayers()
  103. }
  104.  
  105. public plugin_precache()
  106. {
  107. precache_model(USAS_V_MODEL)
  108. precache_model(USAS_P_MODEL)
  109. precache_model(USAS_W_MODEL)
  110.  
  111. precache_sound(Sound_Zoom)
  112. precache_sound("weapons/usas_draw.wav")
  113. precache_sound("weapons/usas_foley1.wav")
  114. precache_sound("weapons/usas_foley2.wav")
  115. precache_sound("weapons/usas_foley3.wav")
  116. for(new i = 0; i < sizeof Fire_Sounds; i++)
  117. precache_sound(Fire_Sounds[i])
  118. m_iBlood[0] = precache_model("sprites/blood.spr")
  119. m_iBlood[1] = precache_model("sprites/bloodspray.spr")
  120. register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
  121.  
  122. g_tClassNames = TrieCreate()
  123.  
  124. RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
  125. RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
  126. RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
  127. RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
  128. RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
  129. RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
  130. RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
  131.  
  132. TrieSetCell(g_tClassNames, "worldspawn", 1)
  133. TrieSetCell(g_tClassNames, "func_breakable", 1)
  134. TrieSetCell(g_tClassNames, "func_wall", 1)
  135. TrieSetCell(g_tClassNames, "func_door", 1)
  136. TrieSetCell(g_tClassNames, "func_door_rotating", 1)
  137. TrieSetCell(g_tClassNames, "func_plat", 1)
  138. TrieSetCell(g_tClassNames, "func_rotating", 1)
  139.  
  140. }
  141.  
  142. public fwPrecacheEvent_Post(type, const name[])
  143. {
  144. if (equal("events/xm1014.sc", name))
  145. {
  146. g_orig_event_usas = get_orig_retval()
  147. return FMRES_HANDLED
  148. }
  149. return FMRES_IGNORED
  150. }
  151.  
  152. public client_putinserver(id)
  153. {
  154. if(is_user_bot(id) && !g_hamczbots && cvar_botquota) set_task(0.1, "register_ham_czbots", id)
  155. }
  156.  
  157. public register_ham_czbots(id)
  158. {
  159. if (g_hamczbots || !is_user_connected(id) || !get_pcvar_num(cvar_botquota)) return
  160.  
  161. RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage")
  162.  
  163. g_hamczbots = true
  164. }
  165.  
  166. public client_connect(id)
  167. {
  168. g_has_usas[id] = false
  169. }
  170.  
  171. public client_disconnect(id)
  172. {
  173. g_has_usas[id] = false
  174. }
  175.  
  176. public zp_user_infected_post(id)
  177. {
  178. if (zp_get_user_zombie(id))
  179. {
  180. g_has_usas[id] = false
  181. }
  182. }
  183.  
  184. public fw_Spawn_Post(iEnt)
  185. {
  186. if(pev_valid(iEnt))
  187. {
  188. static szClassName[32]
  189. pev(iEnt, pev_classname, szClassName, charsmax(szClassName))
  190. if(!TrieKeyExists(g_tClassNames, szClassName))
  191. {
  192. RegisterHam(Ham_TraceAttack, szClassName, "TraceAttack", 1)
  193. TrieSetCell(g_tClassNames, szClassName, 1)
  194. }
  195. }
  196. }
  197.  
  198. public fw_SetModel(entity, model[])
  199. {
  200. if(!is_valid_ent(entity))
  201. return FMRES_IGNORED;
  202.  
  203. static szClassName[33]
  204. entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  205.  
  206. if(!equal(szClassName, "weaponbox"))
  207. return FMRES_IGNORED;
  208.  
  209. static iOwner
  210.  
  211. iOwner = entity_get_edict(entity, EV_ENT_owner)
  212.  
  213. if(equal(model, "models/w_xm1014.mdl"))
  214. {
  215. static iStoredSVDID
  216.  
  217. iStoredSVDID = find_ent_by_owner(ENG_NULLENT, "weapon_xm1014", entity)
  218.  
  219. if(!is_valid_ent(iStoredSVDID))
  220. return FMRES_IGNORED;
  221.  
  222. if(g_has_usas[iOwner])
  223. {
  224. entity_set_int(iStoredSVDID, EV_INT_WEAPONKEY, USAS_WEAPONKEY)
  225.  
  226. g_has_usas[iOwner] = false
  227.  
  228. entity_set_model(entity, USAS_W_MODEL)
  229.  
  230. return FMRES_SUPERCEDE;
  231. }
  232. }
  233. return FMRES_IGNORED;
  234. }
  235.  
  236. public zp_extra_item_selected(id, itemid)
  237. {
  238. if(itemid == g_usas)
  239. {
  240. drop_weapons(id, 1);
  241. new iWep1 = give_item(id, "weapon_xm1014")
  242. if( iWep1 > 0 )
  243. {
  244. cs_set_weapon_ammo(iWep1, get_pcvar_num(cvar_clip_usas))
  245. cs_set_user_bpammo(id, CSW_XM1014, get_pcvar_num(cvar_usas_ammo))
  246. }
  247. g_has_usas[id] = true;
  248. }
  249. }
  250.  
  251. public fw_USAS_AddToPlayer(USAS, id)
  252. {
  253. if(!is_valid_ent(USAS) || !is_user_connected(id))
  254. return HAM_IGNORED;
  255.  
  256. if(entity_get_int(USAS, EV_INT_WEAPONKEY) == USAS_WEAPONKEY)
  257. {
  258. g_has_usas[id] = true
  259.  
  260. entity_set_int(USAS, EV_INT_WEAPONKEY, 0)
  261.  
  262. return HAM_HANDLED;
  263. }
  264.  
  265. return HAM_IGNORED;
  266. }
  267.  
  268. public fw_UseStationary_Post(entity, caller, activator, use_type)
  269. {
  270. if (use_type == USE_STOPPED && is_user_connected(caller))
  271. replace_weapon_models(caller, get_user_weapon(caller))
  272. }
  273.  
  274. public fw_Item_Deploy_Post(weapon_ent)
  275. {
  276. static owner
  277. owner = fm_cs_get_weapon_ent_owner(weapon_ent)
  278.  
  279. static weaponid
  280. weaponid = cs_get_weapon_id(weapon_ent)
  281.  
  282. replace_weapon_models(owner, weaponid)
  283. }
  284.  
  285. public CurrentWeapon(id)
  286. {
  287. static iWeapon; iWeapon = read_data(2)
  288.  
  289. replace_weapon_models(id, read_data(2))
  290.  
  291. static weapon[32], iEnt
  292. get_weaponname(iWeapon, weapon, 31)
  293. iEnt = find_ent_by_owner(-1, weapon, id)
  294. if(iEnt)
  295. {
  296. static Float:Delay, Float:M_Delay
  297. static Float:iSpeed
  298. iSpeed = 0.0
  299. if(iWeapon == CSW_XM1014 && g_has_usas[id])
  300. iSpeed = get_pcvar_float(cvar_spd_usas)
  301.  
  302. Delay = get_pdata_float(iEnt, 46, 4) * iSpeed
  303. M_Delay = get_pdata_float(iEnt, 47, 4) * iSpeed
  304. if (Delay > 0.0)
  305. {
  306. set_pdata_float(iEnt, 46, Delay, 4)
  307. set_pdata_float(iEnt, 47, M_Delay, 4)
  308. }
  309. }
  310. }
  311.  
  312. replace_weapon_models(id, weaponid)
  313. {
  314. switch (weaponid)
  315. {
  316. case CSW_XM1014:
  317. {
  318. if (zp_get_user_zombie(id) || zp_get_user_survivor(id))
  319. return;
  320.  
  321. if(g_has_usas[id])
  322. {
  323. set_pev(id, pev_viewmodel2, USAS_V_MODEL)
  324. set_pev(id, pev_weaponmodel2, USAS_P_MODEL)
  325. }
  326. }
  327. }
  328. }
  329.  
  330. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  331. {
  332. if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_XM1014) || (get_user_weapon(Player) == CSW_XM1014 && !g_has_usas[Player]))
  333. return FMRES_IGNORED
  334.  
  335. set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  336. return FMRES_HANDLED
  337. }
  338.  
  339. public fw_USAS_PrimaryAttack(Weapon)
  340. {
  341. new Player = get_pdata_cbase(Weapon, 41, 5)
  342.  
  343. if (!g_has_usas[Player])
  344. return;
  345.  
  346. g_IsInPrimaryAttack = 1
  347. pev(Player,pev_punchangle,cl_pushangle[Player])
  348.  
  349. g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
  350. }
  351.  
  352. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  353. {
  354. if ((eventid != g_orig_event_usas && eventid) || !g_IsInPrimaryAttack)
  355. return FMRES_IGNORED
  356. if (!(1 <= invoker <= g_MaxPlayers))
  357. return FMRES_IGNORED
  358.  
  359. playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  360. return FMRES_SUPERCEDE
  361. }
  362.  
  363. public fw_USAS_PrimaryAttack_Post(Weapon)
  364. {
  365. g_IsInPrimaryAttack = 0
  366. new Player = get_pdata_cbase(Weapon, 41, 5)
  367.  
  368. if(g_has_usas[Player])
  369. {
  370. new Float:push[3]
  371. pev(Player,pev_punchangle,push)
  372. xs_vec_sub(push,cl_pushangle[Player],push)
  373.  
  374. xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil_usas),push)
  375. xs_vec_add(push,cl_pushangle[Player],push)
  376. set_pev(Player,pev_punchangle,push)
  377.  
  378. if (!g_clip_ammo[Player])
  379. return
  380.  
  381. emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  382. switch(random_num(1,2))
  383. {
  384. case 1:
  385. UTIL_PlayWeaponAnimation(Player, anim_shoot1)
  386. case 2:
  387. UTIL_PlayWeaponAnimation(Player, anim_shoot2)
  388. }
  389.  
  390. make_blood_and_bulletholes(Player)
  391. }
  392. }
  393.  
  394. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
  395. {
  396. if (victim != attacker && is_user_connected(attacker))
  397. {
  398. if(get_user_weapon(attacker) == CSW_XM1014)
  399. {
  400. if(g_has_usas[attacker])
  401. SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_usas))
  402. }
  403. }
  404. }
  405.  
  406. public message_DeathMsg(msg_id, msg_dest, id)
  407. {
  408. static szTruncatedWeapon[33], iAttacker, iVictim
  409.  
  410. get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  411.  
  412. iAttacker = get_msg_arg_int(1)
  413. iVictim = get_msg_arg_int(2)
  414.  
  415. if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  416. return PLUGIN_CONTINUE
  417.  
  418. if(equal(szTruncatedWeapon, "xm1014") && get_user_weapon(iAttacker) == CSW_XM1014)
  419. {
  420. if(g_has_usas[iAttacker])
  421. set_msg_arg_string(4, "usas")
  422. }
  423.  
  424. return PLUGIN_CONTINUE
  425. }
  426.  
  427. stock fm_cs_get_current_weapon_ent(id)
  428. {
  429. return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
  430. }
  431.  
  432. stock fm_cs_get_weapon_ent_owner(ent)
  433. {
  434. return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS);
  435. }
  436.  
  437. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
  438. {
  439. set_pev(Player, pev_weaponanim, Sequence)
  440.  
  441. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  442. write_byte(Sequence)
  443. write_byte(pev(Player, pev_body))
  444. message_end()
  445. }
  446.  
  447. stock make_blood_and_bulletholes(id)
  448. {
  449. new aimOrigin[3], target, body
  450. get_user_origin(id, aimOrigin, 3)
  451. get_user_aiming(id, target, body)
  452.  
  453. if(target > 0 && target <= g_MaxPlayers && zp_get_user_zombie(target))
  454. {
  455. new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
  456. pev(id, pev_origin, fStart)
  457.  
  458. velocity_by_aim(id, 64, fVel)
  459.  
  460. fStart[0] = float(aimOrigin[0])
  461. fStart[1] = float(aimOrigin[1])
  462. fStart[2] = float(aimOrigin[2])
  463. fEnd[0] = fStart[0]+fVel[0]
  464. fEnd[1] = fStart[1]+fVel[1]
  465. fEnd[2] = fStart[2]+fVel[2]
  466.  
  467. new res
  468. engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
  469. get_tr2(res, TR_vecEndPos, fRes)
  470.  
  471. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  472. write_byte(TE_BLOODSPRITE)
  473. write_coord(floatround(fStart[0]))
  474. write_coord(floatround(fStart[1]))
  475. write_coord(floatround(fStart[2]))
  476. write_short( m_iBlood [ 1 ])
  477. write_short( m_iBlood [ 0 ] )
  478. write_byte(70)
  479. write_byte(random_num(1,2))
  480. message_end()
  481.  
  482.  
  483. }
  484. else if(!is_user_connected(target))
  485. {
  486. if(target)
  487. {
  488. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  489. write_byte(TE_DECAL)
  490. write_coord(aimOrigin[0])
  491. write_coord(aimOrigin[1])
  492. write_coord(aimOrigin[2])
  493. write_byte(GUNSHOT_DECALS[random_num ( 0, sizeof GUNSHOT_DECALS -1 ) ] )
  494. write_short(target)
  495. message_end()
  496. }
  497. else
  498. {
  499. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  500. write_byte(TE_WORLDDECAL)
  501. write_coord(aimOrigin[0])
  502. write_coord(aimOrigin[1])
  503. write_coord(aimOrigin[2])
  504. write_byte(GUNSHOT_DECALS[random_num ( 0, sizeof GUNSHOT_DECALS -1 ) ] )
  505. message_end()
  506. }
  507.  
  508. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  509. write_byte(TE_GUNSHOTDECAL)
  510. write_coord(aimOrigin[0])
  511. write_coord(aimOrigin[1])
  512. write_coord(aimOrigin[2])
  513. write_short(id)
  514. write_byte(GUNSHOT_DECALS[random_num ( 0, sizeof GUNSHOT_DECALS -1 ) ] )
  515. message_end()
  516. }
  517. }
  518.  
  519. public USAS__ItemPostFrame(weapon_entity) {
  520. new id = pev(weapon_entity, pev_owner)
  521. if (!is_user_connected(id))
  522. return HAM_IGNORED;
  523.  
  524. if (!g_has_usas[id])
  525. return HAM_IGNORED;
  526.  
  527. new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)
  528.  
  529. new iBpAmmo = cs_get_user_bpammo(id, CSW_XM1014);
  530. new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  531.  
  532. new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF)
  533.  
  534. if( fInReload && flNextAttack <= 0.0 )
  535. {
  536. new j = min(get_pcvar_num(cvar_clip_usas) - iClip, iBpAmmo)
  537.  
  538. set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
  539. cs_set_user_bpammo(id, CSW_XM1014, iBpAmmo-j);
  540.  
  541. set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
  542. fInReload = 0
  543. }
  544.  
  545. return HAM_IGNORED;
  546. }
  547.  
  548. public USAS__Reload(weapon_entity) {
  549. new id = pev(weapon_entity, pev_owner)
  550. if (!is_user_connected(id))
  551. return HAM_IGNORED;
  552.  
  553. if (!g_has_usas[id])
  554. return HAM_IGNORED;
  555.  
  556. g_usas_TmpClip[id] = -1;
  557.  
  558. new iBpAmmo = cs_get_user_bpammo(id, CSW_XM1014);
  559. new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  560.  
  561. if (iBpAmmo <= 0)
  562. return HAM_SUPERCEDE;
  563.  
  564. if (iClip >= get_pcvar_num(cvar_clip_usas))
  565. return HAM_SUPERCEDE;
  566.  
  567.  
  568. g_usas_TmpClip[id] = iClip;
  569.  
  570. return HAM_IGNORED;
  571. }
  572.  
  573. public USAS__Reload_Post(weapon_entity) {
  574. new id = pev(weapon_entity, pev_owner)
  575. if (!is_user_connected(id))
  576. return HAM_IGNORED;
  577.  
  578. if (!g_has_usas[id])
  579. return HAM_IGNORED;
  580.  
  581. if (g_usas_TmpClip[id] == -1)
  582. return HAM_IGNORED;
  583.  
  584. set_pdata_int(weapon_entity, m_iClip, g_usas_TmpClip[id], WEAP_LINUX_XTRA_OFF)
  585.  
  586. set_pdata_float(weapon_entity, m_flTimeWeaponIdle, USAS_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)
  587.  
  588. set_pdata_float(id, m_flNextAttack, USAS_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)
  589.  
  590. set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)
  591.  
  592. // relaod animation
  593. UTIL_PlayWeaponAnimation(id, 7)
  594.  
  595. return HAM_IGNORED;
  596. }
  597.  
  598. stock drop_weapons(id, dropwhat)
  599. {
  600. static weapons[32], num, i, weaponid
  601. num = 0
  602. get_user_weapons(id, weapons, num)
  603.  
  604. for (i = 0; i < num; i++)
  605. {
  606. weaponid = weapons[i]
  607.  
  608. if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
  609. {
  610. static wname[32]
  611. get_weaponname(weaponid, wname, sizeof wname - 1)
  612. engclient_cmd(id, "drop", wname)
  613. }
  614. }
  615. }
  616.  
  617. public fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  618. {
  619. if(get_user_weapon(iAttacker) != CSW_XM1014) return
  620.  
  621. if((user_has_weapon(iAttacker, CSW_XM1014) && !g_has_usas[iAttacker])) return
  622.  
  623. static Float:flEnd[3]
  624. get_tr2(ptr, TR_vecEndPos, flEnd)
  625.  
  626. if(iEnt)
  627. {
  628. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  629. write_byte(TE_DECAL)
  630. write_coord_f(flEnd[0])
  631. write_coord_f(flEnd[1])
  632. write_coord_f(flEnd[2])
  633. write_byte(GUNSHOT_DECALS[random_num(0, sizeof GUNSHOT_DECALS -1)])
  634. write_short(iEnt)
  635. message_end()
  636. }
  637. else
  638. {
  639. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  640. write_byte(TE_WORLDDECAL)
  641. write_coord_f(flEnd[0])
  642. write_coord_f(flEnd[1])
  643. write_coord_f(flEnd[2])
  644. write_byte(GUNSHOT_DECALS[random_num(0, sizeof GUNSHOT_DECALS -1)])
  645. message_end()
  646. }
  647.  
  648. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  649. write_byte(TE_GUNSHOTDECAL)
  650. write_coord_f(flEnd[0])
  651. write_coord_f(flEnd[1])
  652. write_coord_f(flEnd[2])
  653. write_short(iAttacker)
  654. write_byte(GUNSHOT_DECALS[random_num(0, sizeof GUNSHOT_DECALS -1)])
  655. message_end()
  656. }
  657. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  658. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1066\\ f0\\ fs16 \n\\ par }
  659. */
  660.