Advertisement
Guest User

Gatling

a guest
Aug 6th, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.39 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <fakemeta_util>
  4. #include <hamsandwich>
  5. #include <cstrike>
  6. #include <zombieplague>
  7.  
  8. #define PLUGIN "Gatling (Volcano)"
  9. #define VERSION "1.0"
  10. #define AUTHOR "Dias"
  11.  
  12. #define CSW_GATLING CSW_M3
  13. #define weapon_gatling "weapon_m3"
  14. #define WEAPON_ANIMEXT "m249"
  15. #define DEFAULT_W_MODEL "models/w_m3.mdl"
  16. #define WEAPON_SECRET_CODE 1942
  17. #define old_event "events/m3.sc"
  18.  
  19. #define DAMAGE 48
  20. #define SPEED 0.25
  21. #define RECOIL 0.5
  22. #define RELOAD_TIME 4.5
  23. #define DEFAULT_CLIP 40
  24. #define DEFAULT_BPAMMO 180
  25.  
  26. new const WeaponModel[3][] =
  27. {
  28. "models/v_gatling.mdl", // V
  29. "models/p_gatling.mdl", // P
  30. "models/w_gatling.mdl" // W
  31. }
  32.  
  33. new const WeaponSound[7][] =
  34. {
  35. "weapons/gatling-1.wav",
  36. "weapons/gatling_boltpull.wav",
  37. "weapons/gatling_clipin1.wav",
  38. "weapons/gatling_clipin2.wav",
  39. "weapons/gatling_clipout1.wav",
  40. "weapons/gatling_clipout2.wav",
  41. "weapons/usas_draw.wav"
  42. }
  43.  
  44. new const WeaponResource[4][] =
  45. {
  46. "sprites/weapon_gatling.txt",
  47. "sprites/640hud7_2.spr",
  48. "sprites/640hud55_2.spr",
  49. "sprites/640hud56_2.spr"
  50. }
  51.  
  52. enum
  53. {
  54. GATLING_ANIM_IDLE = 0,
  55. GATLING_ANIM_SHOOT1,
  56. GATLING_ANIM_SHOOT2,
  57. GATLING_ANIM_RELOAD,
  58. GATLING_ANIM_DRAW
  59. }
  60.  
  61. const PDATA_SAFE = 2
  62. const OFFSET_LINUX_WEAPONS = 4
  63. const OFFSET_LINUX_PLAYER = 5
  64. const OFFSET_WEAPONOWNER = 41
  65. const m_iClip = 51
  66. const m_fInReload = 54
  67. const m_flNextAttack = 83
  68. const m_szAnimExtention = 492
  69.  
  70. new g_gatling
  71. new g_had_gatling[33], Float:g_punchangles[33][3], g_gatling_event, g_smokepuff_id, m_iBlood[2], g_ham_bot
  72.  
  73. public plugin_init()
  74. {
  75. register_plugin(PLUGIN, VERSION, AUTHOR)
  76.  
  77. register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
  78.  
  79. register_forward(FM_CmdStart, "fw_CmdStart")
  80. register_forward(FM_SetModel, "fw_SetModel")
  81. register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  82. register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
  83.  
  84. RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack")
  85. RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
  86.  
  87. RegisterHam(Ham_Item_Deploy, weapon_gatling, "fw_Item_Deploy_Post", 1)
  88. RegisterHam(Ham_Weapon_Reload, weapon_gatling, "fw_Weapon_Reload_Post", 1)
  89. RegisterHam(Ham_Item_PostFrame, weapon_gatling, "fw_Item_PostFrame")
  90. RegisterHam(Ham_Item_AddToPlayer, weapon_gatling, "fw_Item_AddToPlayer_Post", 1)
  91. RegisterHam(Ham_Weapon_PrimaryAttack, weapon_gatling, "fw_Weapon_PrimaryAttack")
  92. RegisterHam(Ham_Weapon_PrimaryAttack, weapon_gatling, "fw_Weapon_PrimaryAttack_Post", 1)
  93.  
  94. register_clcmd("weapon_gatling", "hook_weapon")
  95. register_clcmd("admin_get_gatling", "get_gatling", ADMIN_BAN)
  96. }
  97.  
  98. public plugin_precache()
  99. {
  100. new i
  101.  
  102. for(i = 0; i < sizeof(WeaponModel); i++)
  103. engfunc(EngFunc_PrecacheModel, WeaponModel[i])
  104. for(i = 0; i < sizeof(WeaponSound); i++)
  105. engfunc(EngFunc_PrecacheSound, WeaponSound[i])
  106. for(new i = 0; i < sizeof(WeaponResource); i++)
  107. {
  108. if(i == 0) engfunc(EngFunc_PrecacheGeneric, WeaponResource[i])
  109. else engfunc(EngFunc_PrecacheModel, WeaponResource[i])
  110. }
  111.  
  112. g_smokepuff_id = engfunc(EngFunc_PrecacheModel, "sprites/wall_puff1.spr")
  113. m_iBlood[0] = engfunc(EngFunc_PrecacheModel, "sprites/blood.spr")
  114. m_iBlood[1] = engfunc(EngFunc_PrecacheModel, "sprites/bloodspray.spr")
  115.  
  116. register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
  117. g_gatling = zp_register_extra_item("Gatling (Volcano)", 20, ZP_TEAM_HUMAN)
  118. }
  119.  
  120. public fw_PrecacheEvent_Post(type, const name[])
  121. {
  122. if(equal(old_event, name))
  123. g_gatling_event = get_orig_retval()
  124. }
  125.  
  126. public client_putinserver(id)
  127. {
  128. if(is_user_bot(id) && !g_ham_bot)
  129. {
  130. g_ham_bot = 1
  131. set_task(0.1, "Do_Register_Ham", id)
  132. }
  133. }
  134.  
  135. public Do_Register_Ham(id)
  136. {
  137. RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
  138. }
  139.  
  140. public zp_extra_item_selected(id, itemid)
  141. {
  142. if(itemid == g_gatling) get_gatling(id)
  143. }
  144.  
  145. public zp_user_infected_post(id)
  146. {
  147. remove_gatling(id)
  148. }
  149.  
  150. public zp_user_humanized_post(id)
  151. {
  152. remove_gatling(id)
  153. }
  154.  
  155. public zp_round_ended()
  156. {
  157. for(new i = 0; i < get_maxplayers(); i++)
  158. {
  159. if(!is_user_connected(i))
  160. continue
  161.  
  162. remove_gatling(i)
  163. }
  164. }
  165.  
  166. public get_gatling(id)
  167. {
  168. if(!is_user_alive(id))
  169. return
  170.  
  171. drop_weapons(id, 1)
  172.  
  173. g_had_gatling[id] = 1
  174. fm_give_item(id, weapon_gatling)
  175.  
  176. // Set Clip
  177. static ent; ent = fm_get_user_weapon_entity(id, CSW_GATLING)
  178. if(pev_valid(ent)) cs_set_weapon_ammo(ent, DEFAULT_CLIP)
  179.  
  180. // Set BpAmmo
  181. cs_set_user_bpammo(id, CSW_GATLING, DEFAULT_BPAMMO)
  182.  
  183. // Update Ammo
  184. update_ammo(id, CSW_GATLING, DEFAULT_CLIP, DEFAULT_BPAMMO)
  185. }
  186.  
  187. public remove_gatling(id)
  188. {
  189. g_had_gatling[id] = 0
  190. }
  191.  
  192. public hook_weapon(id)
  193. {
  194. client_cmd(id, weapon_gatling)
  195. return PLUGIN_HANDLED
  196. }
  197.  
  198. public Event_CurWeapon(id)
  199. {
  200. if(!is_user_alive(id))
  201. return
  202. if(get_user_weapon(id) != CSW_GATLING || !g_had_gatling[id])
  203. return
  204.  
  205. // Speed
  206. static ent; ent = fm_get_user_weapon_entity(id, CSW_GATLING)
  207. if(!pev_valid(ent))
  208. return
  209.  
  210. set_pdata_float(ent, 46, get_pdata_float(ent, 46, OFFSET_LINUX_WEAPONS) * SPEED, OFFSET_LINUX_WEAPONS)
  211. }
  212.  
  213. public fw_CmdStart(id, uc_handle, seed)
  214. {
  215. if(!is_user_alive(id))
  216. return
  217. if(get_user_weapon(id) != CSW_GATLING || !g_had_gatling[id])
  218. return
  219.  
  220. static CurButton; CurButton = get_uc(uc_handle, UC_Buttons)
  221.  
  222. if(CurButton & IN_RELOAD)
  223. {
  224. CurButton &= ~IN_RELOAD
  225. set_uc(uc_handle, UC_Buttons, CurButton)
  226.  
  227. static ent; ent = fm_get_user_weapon_entity(id, CSW_GATLING)
  228. if(!pev_valid(ent)) return
  229.  
  230. static fInReload; fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)
  231. static Float:flNextAttack; flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX_PLAYER)
  232.  
  233. if (flNextAttack > 0.0)
  234. return
  235.  
  236. if (fInReload)
  237. {
  238. set_weapon_anim(id, GATLING_ANIM_IDLE)
  239. return
  240. }
  241.  
  242. if(cs_get_weapon_ammo(ent) >= DEFAULT_CLIP)
  243. {
  244. set_weapon_anim(id, GATLING_ANIM_IDLE)
  245. return
  246. }
  247.  
  248. fw_Weapon_Reload_Post(ent)
  249. }
  250. }
  251.  
  252. public fw_SetModel(entity, model[])
  253. {
  254. if(!pev_valid(entity))
  255. return FMRES_IGNORED
  256.  
  257. static szClassName[33]
  258. pev(entity, pev_classname, szClassName, charsmax(szClassName))
  259.  
  260. if(!equal(szClassName, "weaponbox"))
  261. return FMRES_IGNORED
  262.  
  263. static id
  264. id = pev(entity, pev_owner)
  265.  
  266. if(equal(model, DEFAULT_W_MODEL))
  267. {
  268. static weapon
  269. weapon = fm_find_ent_by_owner(-1, weapon_gatling, entity)
  270.  
  271. if(!pev_valid(weapon))
  272. return FMRES_IGNORED
  273.  
  274. if(g_had_gatling[id])
  275. {
  276. set_pev(weapon, pev_impulse, WEAPON_SECRET_CODE)
  277. engfunc(EngFunc_SetModel, entity, WeaponModel[2])
  278.  
  279. remove_gatling(id)
  280.  
  281. return FMRES_SUPERCEDE
  282. }
  283. }
  284.  
  285. return FMRES_IGNORED
  286. }
  287.  
  288. public fw_TraceAttack(ent, attacker, Float:Damage, Float:fDir[3], ptr, iDamageType)
  289. {
  290. if(!is_user_alive(attacker))
  291. return HAM_IGNORED
  292. if(get_user_weapon(attacker) != CSW_GATLING || !g_had_gatling[attacker])
  293. return HAM_IGNORED
  294.  
  295. if(!is_user_alive(ent))
  296. {
  297. static Float:flEnd[3], Float:vecPlane[3]
  298.  
  299. get_tr2(ptr, TR_vecEndPos, flEnd)
  300. get_tr2(ptr, TR_vecPlaneNormal, vecPlane)
  301.  
  302. make_bullet(attacker, flEnd)
  303. fake_smoke(attacker, ptr)
  304. }
  305.  
  306. SetHamParamFloat(3, float(DAMAGE) / random_float(1.5, 2.5))
  307.  
  308. return HAM_HANDLED
  309. }
  310.  
  311. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  312. {
  313. if(!is_user_alive(id) || !is_user_connected(id))
  314. return FMRES_IGNORED
  315. if(get_user_weapon(id) != CSW_GATLING || !g_had_gatling[id])
  316. return FMRES_IGNORED
  317.  
  318. set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  319.  
  320. return FMRES_HANDLED
  321. }
  322.  
  323. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  324. {
  325. if(!is_user_connected(invoker))
  326. return FMRES_IGNORED
  327.  
  328. if(get_user_weapon(invoker) == CSW_GATLING && g_had_gatling[invoker] && eventid == g_gatling_event)
  329. {
  330. engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  331. Event_Gatling_Shoot(invoker)
  332.  
  333. return FMRES_SUPERCEDE
  334. }
  335.  
  336. return FMRES_HANDLED
  337. }
  338.  
  339. public fw_Item_Deploy_Post(ent)
  340. {
  341. static id; id = fm_cs_get_weapon_ent_owner(ent)
  342. if (!pev_valid(id))
  343. return
  344.  
  345. static weaponid
  346. weaponid = cs_get_weapon_id(ent)
  347.  
  348. if(weaponid != CSW_GATLING)
  349. return
  350. if(!g_had_gatling[id])
  351. return
  352.  
  353. set_pev(id, pev_viewmodel2, WeaponModel[0])
  354. set_pev(id, pev_weaponmodel2, WeaponModel[1])
  355.  
  356. set_weapon_anim(id, GATLING_ANIM_DRAW)
  357. set_pdata_string(id, m_szAnimExtention * 4, WEAPON_ANIMEXT, -1 , 20)
  358. }
  359.  
  360. public fw_Weapon_Reload_Post(ent)
  361. {
  362. static id; id = pev(ent, pev_owner)
  363.  
  364. if(g_had_gatling[id])
  365. {
  366. static CurBpAmmo; CurBpAmmo = cs_get_user_bpammo(id, CSW_GATLING)
  367.  
  368. if(CurBpAmmo <= 0)
  369. return HAM_IGNORED
  370.  
  371. set_pdata_int(ent, 55, 0, OFFSET_LINUX_WEAPONS)
  372. set_pdata_float(id, 83, RELOAD_TIME, OFFSET_LINUX_PLAYER)
  373. set_pdata_float(ent, 48, RELOAD_TIME + 0.5, OFFSET_LINUX_WEAPONS)
  374. set_pdata_float(ent, 46, RELOAD_TIME + 0.25, OFFSET_LINUX_WEAPONS)
  375. set_pdata_float(ent, 47, RELOAD_TIME + 0.25, OFFSET_LINUX_WEAPONS)
  376. set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS)
  377.  
  378. set_weapon_anim(id, GATLING_ANIM_RELOAD)
  379.  
  380. return HAM_HANDLED
  381. }
  382.  
  383. return HAM_IGNORED
  384. }
  385.  
  386. public fw_Item_PostFrame(ent)
  387. {
  388. static id; id = pev(ent, pev_owner)
  389. if(!g_had_gatling[id]) return
  390.  
  391. static iBpAmmo ; iBpAmmo = get_pdata_int(id, 381, OFFSET_LINUX_PLAYER)
  392. static iClip ; iClip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS)
  393. static iMaxClip ; iMaxClip = DEFAULT_CLIP
  394.  
  395. if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS) && get_pdata_float(id, m_flNextAttack, OFFSET_LINUX_PLAYER) <= 0.0)
  396. {
  397. static j; j = min(iMaxClip - iClip, iBpAmmo)
  398. set_pdata_int(ent, m_iClip, iClip + j, OFFSET_LINUX_WEAPONS)
  399. set_pdata_int(id, 381, iBpAmmo-j, OFFSET_LINUX_PLAYER)
  400.  
  401. set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS)
  402. cs_set_weapon_ammo(ent, DEFAULT_CLIP)
  403.  
  404. update_ammo(id, CSW_GATLING, cs_get_weapon_ammo(ent), cs_get_user_bpammo(id, CSW_GATLING))
  405.  
  406. return
  407. }
  408. }
  409.  
  410. public fw_Item_AddToPlayer_Post(ent, id)
  411. {
  412. if(!pev_valid(ent))
  413. return HAM_IGNORED
  414.  
  415. if(pev(ent, pev_impulse) == WEAPON_SECRET_CODE)
  416. {
  417. remove_gatling(id)
  418. g_had_gatling[id] = 1
  419.  
  420. update_ammo(id, CSW_GATLING, cs_get_weapon_ammo(ent), cs_get_user_bpammo(id, CSW_GATLING))
  421. }
  422.  
  423. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("WeaponList"), _, id)
  424. write_string(g_had_gatling[id] == 1 ? "weapon_gatling" : "weapon_m3")
  425. write_byte(5)
  426. write_byte(200)
  427. write_byte(-1)
  428. write_byte(-1)
  429. write_byte(0)
  430. write_byte(5)
  431. write_byte(g_had_gatling[id] == 1 ? CSW_GATLING : CSW_M3)
  432. write_byte(0)
  433. message_end()
  434.  
  435. return HAM_IGNORED
  436. }
  437.  
  438. public fw_Weapon_PrimaryAttack(ent)
  439. {
  440. static id; id = pev(ent, pev_owner)
  441. if(!g_had_gatling[id])
  442. return
  443.  
  444. pev(id, pev_punchangle, g_punchangles[id])
  445. }
  446.  
  447. public fw_Weapon_PrimaryAttack_Post(ent)
  448. {
  449. static id; id = pev(ent, pev_owner)
  450. if(!g_had_gatling[id])
  451. return
  452.  
  453. static Float:push[3]
  454. pev(id, pev_punchangle, push)
  455. xs_vec_sub(push, g_punchangles[id], push)
  456.  
  457. xs_vec_mul_scalar(push, RECOIL, push)
  458. xs_vec_add(push, g_punchangles[id], push)
  459. set_pev(id, pev_punchangle, push)
  460. }
  461.  
  462. public update_ammo(id, csw_id, clip, bpammo)
  463. {
  464. if(!is_user_alive(id))
  465. return
  466.  
  467. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("CurWeapon"), _, id)
  468. write_byte(1)
  469. write_byte(csw_id)
  470. write_byte(clip)
  471. message_end()
  472.  
  473. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("AmmoX"), _, id)
  474. write_byte(3)
  475. write_byte(bpammo)
  476. message_end()
  477. }
  478.  
  479. public Event_Gatling_Shoot(id)
  480. {
  481. set_weapon_anim(id, random_num(GATLING_ANIM_SHOOT1, GATLING_ANIM_SHOOT2))
  482. emit_sound(id, CHAN_WEAPON, WeaponSound[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
  483. }
  484.  
  485. stock fm_cs_get_weapon_ent_owner(ent)
  486. {
  487. if (pev_valid(ent) != PDATA_SAFE)
  488. return -1
  489.  
  490. return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
  491. }
  492.  
  493. stock set_weapon_anim(id, anim)
  494. {
  495. if(!is_user_alive(id))
  496. return
  497.  
  498. set_pev(id, pev_weaponanim, anim)
  499.  
  500. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id)
  501. write_byte(anim)
  502. write_byte(0)
  503. message_end()
  504. }
  505.  
  506. stock drop_weapons(id, dropwhat)
  507. {
  508. static weapons[32], num, i, weaponid
  509. num = 0
  510. get_user_weapons(id, weapons, num)
  511.  
  512. const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_MAC10)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_MAC10)|(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)
  513.  
  514. for (i = 0; i < num; i++)
  515. {
  516. weaponid = weapons[i]
  517.  
  518. if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
  519. {
  520. static wname[32]
  521. get_weaponname(weaponid, wname, sizeof wname - 1)
  522. engclient_cmd(id, "drop", wname)
  523. }
  524. }
  525. }
  526.  
  527.  
  528. stock make_bullet(id, Float:Origin[3])
  529. {
  530. // Find target
  531. new decal = random_num(41, 45)
  532. const loop_time = 2
  533.  
  534. static Body, Target
  535. get_user_aiming(id, Target, Body, 999999)
  536.  
  537. if(is_user_connected(Target))
  538. return
  539.  
  540. for(new i = 0; i < loop_time; i++)
  541. {
  542. // Put decal on "world" (a wall)
  543. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  544. write_byte(TE_WORLDDECAL)
  545. engfunc(EngFunc_WriteCoord, Origin[0])
  546. engfunc(EngFunc_WriteCoord, Origin[1])
  547. engfunc(EngFunc_WriteCoord, Origin[2])
  548. write_byte(decal)
  549. message_end()
  550.  
  551. // Show sparcles
  552. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  553. write_byte(TE_GUNSHOTDECAL)
  554. engfunc(EngFunc_WriteCoord, Origin[0])
  555. engfunc(EngFunc_WriteCoord, Origin[1])
  556. engfunc(EngFunc_WriteCoord, Origin[2])
  557. write_short(id)
  558. write_byte(decal)
  559. message_end()
  560. }
  561. }
  562.  
  563. public fake_smoke(id, trace_result)
  564. {
  565. static Float:vecSrc[3], Float:vecEnd[3], TE_FLAG
  566.  
  567. get_weapon_attachment(id, vecSrc)
  568. global_get(glb_v_forward, vecEnd)
  569.  
  570. xs_vec_mul_scalar(vecEnd, 8192.0, vecEnd)
  571. xs_vec_add(vecSrc, vecEnd, vecEnd)
  572.  
  573. get_tr2(trace_result, TR_vecEndPos, vecSrc)
  574. get_tr2(trace_result, TR_vecPlaneNormal, vecEnd)
  575.  
  576. xs_vec_mul_scalar(vecEnd, 2.5, vecEnd)
  577. xs_vec_add(vecSrc, vecEnd, vecEnd)
  578.  
  579. TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  580. TE_FLAG |= TE_EXPLFLAG_NOSOUND
  581. TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  582.  
  583. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0)
  584. write_byte(TE_EXPLOSION)
  585. engfunc(EngFunc_WriteCoord, vecEnd[0])
  586. engfunc(EngFunc_WriteCoord, vecEnd[1])
  587. engfunc(EngFunc_WriteCoord, vecEnd[2] - 10.0)
  588. write_short(g_smokepuff_id)
  589. write_byte(2)
  590. write_byte(50)
  591. write_byte(TE_FLAG)
  592. message_end()
  593. }
  594.  
  595. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
  596. {
  597. new Float:vfEnd[3], viEnd[3]
  598. get_user_origin(id, viEnd, 3)
  599. IVecFVec(viEnd, vfEnd)
  600.  
  601. new Float:fOrigin[3], Float:fAngle[3]
  602.  
  603. pev(id, pev_origin, fOrigin)
  604. pev(id, pev_view_ofs, fAngle)
  605.  
  606. xs_vec_add(fOrigin, fAngle, fOrigin)
  607.  
  608. new Float:fAttack[3]
  609.  
  610. xs_vec_sub(vfEnd, fOrigin, fAttack)
  611. xs_vec_sub(vfEnd, fOrigin, fAttack)
  612.  
  613. new Float:fRate
  614.  
  615. fRate = fDis / vector_length(fAttack)
  616. xs_vec_mul_scalar(fAttack, fRate, fAttack)
  617.  
  618. xs_vec_add(fOrigin, fAttack, output)
  619. }
  620.  
  621. stock create_blood(const Float:origin[3])
  622. {
  623. // Show some blood :)
  624. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  625. write_byte(TE_BLOODSPRITE)
  626. engfunc(EngFunc_WriteCoord, origin[0])
  627. engfunc(EngFunc_WriteCoord, origin[1])
  628. engfunc(EngFunc_WriteCoord, origin[2])
  629. write_short(m_iBlood[1])
  630. write_short(m_iBlood[0])
  631. write_byte(75)
  632. write_byte(5)
  633. message_end()
  634. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement