HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2.   Fordította: BBk - Death of Legend
  3. */
  4.  
  5. #include <amxmodx>
  6. #include <engine>
  7. #include <fakemeta_util>
  8. #include <cstrike>
  9. #include <hamsandwich>
  10. #include <amxmisc>
  11. #include <fun>
  12.  
  13. #define MAX_PLAYERS 32
  14. #define MAX_BLOOD_DISTANCE 64
  15. #define LOADUP_TIME 0.75
  16. #define SHUTDOWN_TIME 1.7
  17. #define SHAKE_FORCE -5.0 //(must be negative value)
  18. new const GUNSHOT_DECALS[] = {41, 42, 43, 44, 45} // Gunshot decal list
  19. // Plugin information
  20. new const PLUGIN[] = "WPN Minigun"
  21. new const VERSION[] = "1.65"
  22. new const AUTHOR[] = "CLLlAgOB"
  23. // other
  24. new bool:has_minigun[33], m249, bool:atk2[33], bool:atk1[33],
  25. bool:delay[33], clipp[33],clipstart,g_fwid,bool:delayhud[33],bool:beackup[33],
  26. mcost,msg[128],bool:frstCLIP[33],g_MaxPlayers,g_guns_eventids_bitsum,bool:haswhpnnmg[33],
  27. Float:g_lastShot[33], Float:g_nextSound[33], g_plAction[33],bool:g_fix_punchangle[33],
  28. bool:canfire[33],oneround,only_adminCB,MsgSayText,g_normal_trace[33],DMGMG,bool:user_bot[33],
  29. bool:is_alive[33],bool:is_connected[33]
  30. // Blood
  31. new g_blood
  32. new g_bloodspray
  33. // CS Player PData Offsets (win32)
  34. const OFFSET_CSTEAMS = 114
  35. // Linux diff's
  36. const OFFSET_LINUX = 5 // offsets 5 higher in Linux builds
  37. // Models
  38. new P_MODEL[] = "models/wpnmod/m134/p_minigun.mdl"
  39. new V_MODEL[] = "models/wpnmod/m134/v_minigun.mdl"
  40. new W_MODEL[] = "models/wpnmod/m134/w_minigun.mdl"
  41. // Sounds
  42. new m_SOUND[][] = {"wpnmod/minigun/hw_shoot1.wav", "wpnmod/minigun/hw_spin.wav", "wpnmod/minigun/hw_spinup.wav", "wpnmod/minigun/hw_spindown.wav"}
  43. new g_noammo_sounds[][] = {"weapons/dryfire_rifle.wav"}
  44. //no recoil
  45. new const g_guns_events[][] = {"events/m249.sc"}
  46. //connect
  47. #define is_user_valid_connected(%1) (1 <= %1 <= g_MaxPlayers && is_connected[%1])
  48. enum {
  49. anim_idle,
  50. anim_idle2,
  51. anim_gentleidle,
  52. anim_stillidle,
  53. anim_draw,
  54. anim_holster,
  55. anim_spinup,
  56. anim_spindown,
  57. anim_spinidle,
  58. anim_spinfire,
  59. anim_spinidledown
  60. }
  61.  
  62. // Types
  63. enum {
  64. act_none,
  65. act_load_up,
  66. act_run
  67. }
  68. public plugin_precache() {
  69. precache_model(P_MODEL)
  70. precache_model(V_MODEL)
  71. precache_model(W_MODEL)
  72. precache_sound(m_SOUND[0])
  73. precache_sound(m_SOUND[1])
  74. precache_sound(m_SOUND[2])
  75. precache_sound(m_SOUND[3])
  76. g_blood = precache_model("sprites/blood.spr")
  77. g_bloodspray = precache_model("sprites/bloodspray.spr")
  78. g_fwid = register_forward(FM_PrecacheEvent, "fwPrecacheEvent", 1)
  79. }
  80.  
  81. public plugin_init() {
  82. register_plugin(PLUGIN, VERSION, AUTHOR)
  83. register_dictionary("minigun.txt")
  84. MsgSayText = get_user_msgid("SayText")
  85. clipstart = register_cvar("amx_ammo_mini","600")
  86. m249 = register_cvar("amx_speed_mini","0.9")
  87. DMGMG = register_cvar("amx_minigun_damage","1.2")
  88. oneround = register_cvar("amx_oneround","0")
  89. mcost = register_cvar("amx_cost_mini","10000")
  90. only_adminCB = register_cvar("amx_only_adm_buy","0")
  91. register_event("CurWeapon","event_curweapon","be", "1=1")
  92. register_event("DeathMsg","unminigun","a")
  93. register_forward(FM_ClientDisconnect, "fw_ClientDisconnect")
  94. register_forward(FM_CmdStart, "fwd_CmdStart")
  95. register_forward(FM_EmitSound,"fwd_emitsound")
  96. register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
  97. register_forward(FM_PlayerPostThink, "fwPlayerPostThink", 1)
  98. register_forward(FM_StartFrame, "fwd_StartFrame")
  99. register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
  100. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  101. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  102. RegisterHam(Ham_TakeDamage, "player", "player_TakeDamage")
  103. register_clcmd("say /minigun","buymini")
  104. register_concmd("amx_minigun_give", "cmdMinigun_give", ADMIN_LEVEL_A, "<@all or name/id> <ammo>")
  105. register_clcmd("drop","dropcmd")
  106. //events
  107. // Get Max Players
  108. g_MaxPlayers = global_get(glb_maxClients)
  109. register_logevent("event_start", 2, "1=Round_Start")
  110. register_event("TextMsg", "fwEvGameWillRestartIn", "a", "2=#Game_will_restart_in")
  111. register_event("HLTV", "event_start_freezetime", "a", "1=0", "2=0")
  112. unregister_forward(FM_PrecacheEvent, g_fwid, 1)
  113. }
  114.  
  115. // Client joins the game
  116. public client_putinserver(id)
  117. {
  118. // Player joined
  119. is_connected[id] = true
  120. }
  121. // Client leaving
  122. public fw_ClientDisconnect(id)
  123. {
  124. is_connected[id] = false
  125. is_alive[id] = false
  126. }
  127. public fw_PlayerSpawn_Post(id)
  128. {
  129. // Not alive or didn't join a team yet
  130. if (!is_user_alive(id) || !fm_cs_get_user_team(id))
  131. return;
  132. // Player spawned
  133. is_alive[id] = true
  134. }
  135. public fw_PlayerKilled(victim, attacker, shouldgib)
  136. {
  137. //player die
  138. is_alive[victim] = false
  139. }
  140. public unminigun(){
  141. new id = read_data(2)
  142. if(has_minigun[id] && !is_alive[id]) {
  143. new Float:Aim[3],Float:origin[3]
  144. VelocityByAim(id, 64, Aim)
  145. entity_get_vector(id,EV_VEC_origin,origin)
  146.  
  147. origin[0] += Aim[0]
  148. origin[1] += Aim[1]
  149.  
  150. new minigun = create_entity("info_target")
  151. entity_set_string(minigun,EV_SZ_classname,"minigun")
  152. entity_set_model(minigun,W_MODEL)
  153.  
  154. entity_set_size(minigun,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
  155. entity_set_int(minigun,EV_INT_solid,1)
  156.  
  157. entity_set_int(minigun,EV_INT_movetype,6)
  158. entity_set_int(minigun, EV_INT_iuser1, clipp[id])
  159. entity_set_vector(minigun,EV_VEC_origin,origin)
  160. has_minigun[id] = false
  161. remowegun(id)
  162. return PLUGIN_HANDLED
  163. }
  164. return PLUGIN_CONTINUE
  165. }
  166.  
  167. //damage lvl
  168. public player_TakeDamage(victim, inflictor, attacker, Float:damage, damagetype) {
  169. if(damagetype & DMG_BULLET && haswhpnnmg[attacker] && has_minigun[attacker] == true && attacker!=victim)
  170. {
  171. damage = damage*get_pcvar_float(DMGMG)
  172. SetHamParamFloat(4, damage)
  173. return HAM_IGNORED
  174. }
  175. return HAM_IGNORED
  176. }
  177.  
  178. public cmdMinigun_give(id, level, cid) {
  179. if (!cmd_access(id, level, cid, 3)) {
  180. return PLUGIN_HANDLED
  181. }
  182.  
  183. new arg[32], arg2[8], name2[32], argument2
  184. read_argv(1,arg,31)
  185. read_argv(2,arg2,7)
  186. argument2 = str_to_num(arg2)
  187. if ( equali(arg,"@all") ){
  188. new plist[32],pnum
  189. get_players(plist,pnum,"a")
  190. if (pnum==0)
  191. {
  192. console_print(id,"[Minigun] This client is invalid")
  193. return PLUGIN_HANDLED
  194. }
  195. for (new i=0; i<pnum; i++)
  196. {
  197. give_weapon(plist[i], argument2, 1)
  198. client_print(plist[i], print_chat, "[Minigun] %L", LANG_PLAYER, "MINIGUN_ADMIN_GIVE_ALL",argument2)
  199. }
  200. }
  201. else
  202. {
  203. get_user_name(id,name2,31)
  204. new player = cmd_target(id,arg,7)
  205. if (!player)
  206. {
  207. console_print(id,"[Minigun] Give Minigun Failed")
  208. return PLUGIN_HANDLED
  209. }
  210. new name[32]
  211. get_user_name(player,name,31)
  212. give_weapon(player, argument2, 1)
  213. client_print(0, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_ADMIN_GIVE",name,argument2)
  214. return PLUGIN_HANDLED
  215. }
  216. return PLUGIN_HANDLED
  217. }
  218.  
  219. public buymini(id) {
  220. if ((!(get_user_flags(id) & ADMIN_IMMUNITY) || !(get_user_flags(id) & ADMIN_RESERVATION)) && get_pcvar_num(only_adminCB)) {
  221. format(msg,256,"[Minigun] %L", LANG_PLAYER,"MINIGUN_ADMIN_BUY")
  222. message_begin(MSG_ONE,MsgSayText,{0,0,0},id)
  223. write_byte(id)
  224. write_string(msg)
  225. message_end()
  226. return PLUGIN_HANDLED
  227. }
  228. new money = cs_get_user_money(id)
  229. new price = get_pcvar_num(mcost)
  230. if(!is_alive[id])
  231. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_ALIVE")
  232. else if(has_minigun[id])
  233. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_ALREADY")
  234. else if(money < price)
  235. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_NO_MONEY")
  236. else{
  237. cs_set_user_money(id, money - price)
  238. give_weapon(id, 0, 1)
  239. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_BUY",price)
  240. }
  241. return PLUGIN_HANDLED
  242. }
  243.  
  244. public dropcmd(id) {
  245. if(has_minigun[id] && haswhpnnmg[id] && is_alive[id]) {
  246. new Float:Aim[3],Float:origin[3]
  247. VelocityByAim(id, 64, Aim)
  248. entity_get_vector(id,EV_VEC_origin,origin)
  249.  
  250. origin[0] += Aim[0]
  251. origin[1] += Aim[1]
  252.  
  253. new minigun = create_entity("info_target")
  254. entity_set_string(minigun,EV_SZ_classname,"minigun")
  255. entity_set_model(minigun,W_MODEL)
  256.  
  257. entity_set_size(minigun,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
  258. entity_set_int(minigun,EV_INT_solid,1)
  259.  
  260. entity_set_int(minigun,EV_INT_movetype,6)
  261. entity_set_int(minigun, EV_INT_iuser1, clipp[id])
  262. entity_set_vector(minigun,EV_VEC_origin,origin)
  263. has_minigun[id] = false
  264. canfire[id] = false
  265. remowegun(id)
  266. g_plAction[id] = false
  267. return PLUGIN_HANDLED
  268. }
  269. return PLUGIN_CONTINUE
  270. }
  271.  
  272. public pfn_touch(ptr, ptd) {
  273. if(is_valid_ent(ptr)) {
  274. new classname[32]
  275. entity_get_string(ptr,EV_SZ_classname,classname,31)
  276.  
  277. if(equal(classname, "minigun")) {
  278. if(is_valid_ent(ptd)) {
  279. new id = ptd
  280. if(id > 0 && id < 34) {
  281. if(!has_minigun[id] && is_alive[id]) {
  282. give_weapon(id,entity_get_int(ptr, EV_INT_iuser1), 0)
  283. canfire[id] = true
  284. remove_entity(ptr)
  285. }
  286. }
  287. }
  288. }
  289. }
  290. }
  291.  
  292. public remove_miniguns() {
  293. new nextitem = find_ent_by_class(-1,"minigun")
  294. while(nextitem) {
  295. remove_entity(nextitem)
  296. nextitem = find_ent_by_class(-1,"minigun")
  297. }
  298. return PLUGIN_CONTINUE
  299. }
  300. public event_start_freezetime(){
  301. remove_miniguns()
  302. static iPlayers[32], iPlayersNum, i
  303. get_players(iPlayers, iPlayersNum, "a")
  304.  
  305. if(!get_pcvar_num(only_adminCB)){
  306. for (i = 0; i <= iPlayersNum; ++i){
  307. if(!has_minigun[iPlayers[i]]){
  308. set_task(random_float(0.1,1.0),"msghelp",iPlayers[i])
  309. }
  310. }
  311. }
  312. if(get_pcvar_num(oneround)){
  313. for (i = 0; i <= iPlayersNum; ++i){
  314. if(has_minigun[iPlayers[i]]){
  315. has_minigun[iPlayers[i]] = false
  316. remowegun(iPlayers[i])
  317. }
  318. }
  319. } else {
  320. for (i = 0; i <= iPlayersNum; ++i){
  321. g_plAction[iPlayers[i]] = false
  322. canfire[iPlayers[i]] = false
  323. frstCLIP[iPlayers[i]] = true
  324. }
  325. }
  326. }
  327. // remove gun and save all guns
  328. public remowegun(id) {
  329. new wpnList[32]
  330. new number
  331. get_user_weapons(id,wpnList,number)
  332. for (new i = 0;i < number ;i++) {
  333. if (wpnList[i] == CSW_M249) {
  334. fm_strip_user_gun(id, wpnList[i])
  335. }
  336. }
  337. }
  338.  
  339. public msghelp(id){
  340. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_FOR_BUY")
  341. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_PRICE",get_pcvar_num(mcost))
  342. }
  343.  
  344. public event_start(){
  345. static iPlayers[32], iPlayersNum, i
  346. get_players(iPlayers, iPlayersNum, "a")
  347. for (i = 0; i <= iPlayersNum; ++i)
  348. canfire[iPlayers[i]] = true
  349. }
  350.  
  351.  
  352.  
  353. public fwEvGameWillRestartIn() {
  354. static iPlayers[32], iPlayersNum, i
  355. get_players(iPlayers, iPlayersNum, "a")
  356. for (i = 0; i <= iPlayersNum; ++i)
  357. has_minigun[iPlayers[i]] = false
  358. }
  359. public client_connect(id){
  360. canfire[id]= false
  361. has_minigun[id] = false
  362. g_normal_trace[id] = 0
  363. if(is_user_bot(id)) user_bot[id] = true
  364. else user_bot[id] = false
  365. }
  366.  
  367. //block sound no ammo in atack
  368. public fwd_emitsound(id, channel, sample[], Float:volume, Float:attn, flag, pitch)
  369. {
  370. if (!is_user_valid_connected(id) || !has_minigun[id])
  371. return FMRES_IGNORED;
  372. else if((equal(sample, g_noammo_sounds[0])) && has_minigun[id] && haswhpnnmg[id])
  373. {
  374. return FMRES_SUPERCEDE
  375. }
  376. return FMRES_IGNORED
  377. }
  378.  
  379. //give wpn
  380. public give_weapon(id, ammo, frst){
  381. has_minigun[id] = true
  382. give_item(id,"weapon_m249")
  383. canfire[id] = true
  384. clipp[id] = ammo
  385. if(frst) frstCLIP[id] = true
  386. else beackup[id] = true
  387.  
  388. }
  389.  
  390.  
  391. //play anim
  392. public native_playanim(player,anim)
  393. {
  394. set_pev(player, pev_weaponanim, anim)
  395. message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
  396. write_byte(anim)
  397. write_byte(pev(player, pev_body))
  398. message_end()
  399. }
  400.  
  401.  
  402. public fwd_CmdStart(id, uc_handle, seed)
  403. {
  404.  
  405.  
  406. if(!is_alive[id] || !canfire[id] || !has_minigun[id]) return FMRES_HANDLED
  407.  
  408. if(haswhpnnmg[id])
  409. {
  410. static buttons
  411. buttons = get_uc(uc_handle, UC_Buttons)
  412. if(buttons & IN_ATTACK)
  413. {
  414. atk1[id] = true
  415. atk2[id] = false
  416.  
  417.  
  418. }
  419. else if(buttons & IN_ATTACK2)
  420. {
  421. atk2[id] = true
  422. atk1[id] = false
  423. }
  424. if(atk1[id] && !atk2[id] && (g_plAction[id] == act_none || g_plAction[id] == act_load_up) && clipp[id]>0){
  425. buttons &= ~IN_ATTACK
  426. buttons &= ~IN_ATTACK2
  427. set_uc(uc_handle, UC_Buttons, buttons)
  428. fire_mode(id,0)
  429. } else if(atk2[id] || atk1[id] && clipp[id]==0){
  430. fire_mode(id,1)
  431. }
  432.  
  433. }
  434. return FMRES_IGNORED
  435. }
  436.  
  437. // in fire
  438. fire_mode(id, type) {
  439. static Float:gtime
  440. gtime = get_gametime()
  441. g_lastShot[id] = gtime
  442.  
  443. if(g_nextSound[id] <= gtime && canfire[id]) {
  444. switch(g_plAction[id]) {
  445. case act_none: {
  446. native_playanim(id, anim_spinup)
  447. emit_sound(id, CHAN_WEAPON, m_SOUND[2], 1.0, ATTN_NORM, 0, PITCH_NORM)
  448. g_nextSound[id] = gtime + LOADUP_TIME
  449. g_plAction[id] = act_load_up
  450. }
  451. case act_load_up: {
  452. g_nextSound[id] = gtime
  453. g_plAction[id] = act_run
  454. }
  455. }
  456. }
  457.  
  458. if(g_plAction[id] == act_run) {
  459. if(type == 0 && clipp[id]>0 && atk1[id]){
  460. emit_sound(id, CHAN_WEAPON, m_SOUND[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
  461. testbulet(id)
  462. if(!delay[id]) {
  463. native_playanim(id, anim_spinfire)
  464. ammo_hud(id)
  465. set_task(0.2,"delayanim",id)
  466. delay[id] = true
  467. }
  468. }
  469. else {
  470. if(!delay[id]) {
  471. ammo_hud(id)
  472. emit_sound(id, CHAN_WEAPON, m_SOUND[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
  473. native_playanim(id, anim_spinidle)
  474. set_task(0.2,"delayanim",id)
  475. delay[id] = true
  476. }
  477. }
  478. }
  479. atk1[id] = false
  480. atk2[id] = false
  481. }
  482.  
  483. public delayanim(id){
  484. delay[id] = false
  485. }
  486.  
  487. //set models
  488. public event_curweapon(id){
  489. if(!is_alive[id] || !is_connected[id] || user_bot[id]) return;
  490. new clip, ammo, weapon = get_user_weapon(id, clip, ammo)
  491. if((has_minigun[id]) && (weapon == CSW_M249)){
  492. if(g_plAction[id] != act_run && frstCLIP[id]){
  493. new ent = get_weapon_ent(id,weapon)
  494. if(clipp[id] < get_pcvar_num(clipstart)) clipp[id] = get_pcvar_num(clipstart)
  495. cs_set_weapon_ammo(ent, clipp[id])
  496. frstCLIP[id] = false
  497. }
  498. if(g_plAction[id] != act_run && beackup[id]){
  499. new ent = get_weapon_ent(id,weapon)
  500. cs_set_weapon_ammo(ent, clipp[id])
  501. beackup[id] = false
  502. }
  503. if(clipp[id] == 0){
  504. new ent = get_weapon_ent(id,weapon)
  505. cs_set_weapon_ammo(ent, clipp[id])
  506. }
  507. if(g_plAction[id] == act_run){
  508. clipp[id] = clip
  509. }
  510. message_begin(MSG_ONE, get_user_msgid("CurWeapon"), {0,0,0}, id)
  511. write_byte(1)
  512. write_byte(CSW_KNIFE)
  513. write_byte(0)
  514. message_end()
  515. if(!haswhpnnmg[id]){
  516. entity_set_string(id,EV_SZ_viewmodel,V_MODEL)
  517. entity_set_string(id,EV_SZ_weaponmodel,P_MODEL)
  518. haswhpnnmg[id] = true
  519. }
  520. new Ent = get_weapon_ent(id,weapon)
  521. new Float:N_Speed
  522. if(Ent)
  523. {
  524. N_Speed = get_pcvar_float(m249)
  525. new Float:Delay = get_pdata_float( Ent, 46, 4) * N_Speed
  526. if (Delay > 0.0){
  527. set_pdata_float( Ent, 46, Delay, 4)
  528. }
  529. }
  530. ammo_hud(id)
  531. if(atk1[id]){
  532. fire_mode(id, 0)
  533. }
  534. if(atk2[id]){
  535. fire_mode(id, 1)
  536. }
  537. }
  538. if(weapon != CSW_M249) haswhpnnmg[id] = false
  539. if((has_minigun[id]) && (!haswhpnnmg[id])) g_plAction[id] = act_none
  540. return;
  541. }
  542.  
  543. //sound and anim
  544. public fwd_StartFrame() {
  545. static Float:gtime, id
  546.  
  547. gtime = get_gametime()
  548.  
  549. for(id = 0; id <= g_MaxPlayers; id++) {
  550. if(g_plAction[id] != act_none) {
  551.  
  552. if(!(pev(id, pev_button) & IN_ATTACK) && !(pev(id, pev_button) & IN_ATTACK2) && g_lastShot[id] + 0.2 < gtime) {
  553. native_playanim(id, anim_spinidledown)
  554. emit_sound(id, CHAN_WEAPON, m_SOUND[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
  555. g_nextSound[id] = gtime + SHUTDOWN_TIME
  556. g_plAction[id] = act_none
  557. }
  558. }
  559. }
  560. }
  561.  
  562. //marks on hit
  563. public native_gi_get_gunshot_decal()
  564. {
  565. return GUNSHOT_DECALS[random_num(0, sizeof(GUNSHOT_DECALS) - 1)]
  566. }
  567.  
  568. //hit bulet
  569. public testbulet(id){
  570. // Find target
  571. new aimOrigin[3], target, body
  572. get_user_origin(id, aimOrigin, 3)
  573. get_user_aiming(id, target, body)
  574.  
  575. if(target > 0 && target <= g_MaxPlayers)
  576. {
  577. new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
  578. pev(id, pev_origin, fStart)
  579.  
  580. // Get ids view direction
  581. velocity_by_aim(id, MAX_BLOOD_DISTANCE, fVel)
  582.  
  583. // Calculate position where blood should be displayed
  584. fStart[0] = float(aimOrigin[0])
  585. fStart[1] = float(aimOrigin[1])
  586. fStart[2] = float(aimOrigin[2])
  587. fEnd[0] = fStart[0]+fVel[0]
  588. fEnd[1] = fStart[1]+fVel[1]
  589. fEnd[2] = fStart[2]+fVel[2]
  590.  
  591. // Draw traceline from victims origin into ids view direction to find
  592. // the location on the wall to put some blood on there
  593. new res
  594. engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
  595. get_tr2(res, TR_vecEndPos, fRes)
  596.  
  597. // Show some blood :)
  598. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  599. write_byte(TE_BLOODSPRITE)
  600. write_coord(floatround(fStart[0]))
  601. write_coord(floatround(fStart[1]))
  602. write_coord(floatround(fStart[2]))
  603. write_short(g_bloodspray)
  604. write_short(g_blood)
  605. write_byte(70)
  606. write_byte(random_num(1,2))
  607. message_end()
  608.  
  609.  
  610. } else {
  611. new decal = native_gi_get_gunshot_decal()
  612.  
  613. // Check if the wall hit is an entity
  614. if(target)
  615. {
  616. // Put decal on an entity
  617. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  618. write_byte(TE_DECAL)
  619. write_coord(aimOrigin[0])
  620. write_coord(aimOrigin[1])
  621. write_coord(aimOrigin[2])
  622. write_byte(decal)
  623. write_short(target)
  624. message_end()
  625. } else {
  626. // Put decal on "world" (a wall)
  627. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  628. write_byte(TE_WORLDDECAL)
  629. write_coord(aimOrigin[0])
  630. write_coord(aimOrigin[1])
  631. write_coord(aimOrigin[2])
  632. write_byte(decal)
  633. message_end()
  634. }
  635.  
  636. // Show sparcles
  637. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  638. write_byte(TE_GUNSHOTDECAL)
  639. write_coord(aimOrigin[0])
  640. write_coord(aimOrigin[1])
  641. write_coord(aimOrigin[2])
  642. write_short(id)
  643. write_byte(decal)
  644. message_end()
  645. }
  646. }
  647.  
  648.  
  649. //block anim standart wpn
  650. public UpdateClientData_Post( id, sendweapons, cd_handle ){
  651. if ( !is_alive[id] ) return FMRES_IGNORED;
  652. if(haswhpnnmg[id] && has_minigun[id]) set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001 );
  653. return FMRES_HANDLED;
  654. }
  655.  
  656.  
  657.  
  658. // No recoil stuff
  659.  
  660. public fwPrecacheEvent(type, const name[]) {
  661. for (new i = 0; i < sizeof g_guns_events; ++i) {
  662. if (equal(g_guns_events[i], name)) {
  663. g_guns_eventids_bitsum |= (1<<get_orig_retval())
  664. return FMRES_HANDLED
  665. }
  666. }
  667.  
  668. return FMRES_IGNORED
  669. }
  670. public fwPlaybackEvent(flags, invoker, eventid) {
  671. if (!(g_guns_eventids_bitsum & (1<<eventid)) || !(1 <= invoker <= g_MaxPlayers)|| !haswhpnnmg[invoker] || !has_minigun[invoker])
  672. return FMRES_IGNORED
  673.  
  674. g_fix_punchangle[invoker] = true
  675.  
  676. return FMRES_HANDLED
  677. }
  678.  
  679. public fwPlayerPostThink(id) {
  680. if (g_fix_punchangle[id]) {
  681. g_fix_punchangle[id] = false
  682. set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0})
  683. return FMRES_HANDLED
  684. }
  685.  
  686. return FMRES_IGNORED
  687. }
  688.  
  689. public fwTraceLine(const Float:start[3], const Float:dest[3], ignore_monsters, id, ptr) {
  690. if (!(1 <= id <= g_MaxPlayers))
  691. return FMRES_IGNORED
  692.  
  693. if (!g_normal_trace[id]) {
  694. g_normal_trace[id] = ptr
  695. return FMRES_HANDLED
  696. }
  697. if (ptr == g_normal_trace[id] || ignore_monsters != DONT_IGNORE_MONSTERS || !haswhpnnmg[id] || !has_minigun[id] || !is_alive[id])
  698. return FMRES_IGNORED
  699.  
  700. fix_recoil_trace(id, start, ptr)
  701.  
  702. return FMRES_SUPERCEDE
  703. }
  704. // show ammo clip
  705. public ammo_hud(id) {
  706. if(!delayhud[id]) {
  707. delayhud[id] = true
  708. new AmmoHud[65]
  709. new clip = clipp[id]
  710. format(AmmoHud, 64, "Ammo: %i", clip)
  711. set_hudmessage(200, 100, 0, 1.0 , 1.0, 0, 0.1, 0.1,0.1)
  712. show_hudmessage(id,"%s",AmmoHud)
  713. set_task(0.2,"delayhutmsg",id)
  714. }
  715. }
  716.  
  717. public delayhutmsg(id){
  718. delayhud[id]= false
  719. }
  720.  
  721. //get weapon id
  722. stock get_weapon_ent(id,wpnid=0,wpnName[]="")
  723. {
  724. // who knows what wpnName will be
  725. static newName[24];
  726.  
  727. // need to find the name
  728. if(wpnid) get_weaponname(wpnid,newName,23);
  729.  
  730. // go with what we were told
  731. else formatex(newName,23,"%s",wpnName);
  732.  
  733. // prefix it if we need to
  734. if(!equal(newName,"weapon_",7))
  735. format(newName,23,"weapon_%s",newName);
  736.  
  737. return fm_find_ent_by_owner(get_maxplayers(),newName,id);
  738. }
  739.  
  740. fix_recoil_trace(id, const Float:start[], ptr) {
  741. static Float:dest[3]
  742. pev(id, pev_v_angle, dest)
  743. engfunc(EngFunc_MakeVectors, dest)
  744. global_get(glb_v_forward, dest)
  745. xs_vec_mul_scalar(dest, 9999.0, dest)
  746. xs_vec_add(start, dest, dest)
  747. engfunc(EngFunc_TraceLine, start, dest, DONT_IGNORE_MONSTERS, id, ptr)
  748. }
  749. // Get User Team
  750. stock fm_cs_get_user_team(id)
  751. {
  752. return get_pdata_int(id, OFFSET_CSTEAMS, OFFSET_LINUX);
  753. }