Advertisement
Filiq_

jah

Dec 16th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.90 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <fakemeta_util>
  4. #include <hamsandwich>
  5. #include <cstrike>
  6.  
  7. #define PLUGIN "Balrog-III"
  8. #define VERSION "1.0"
  9. #define AUTHOR "Dias"
  10.  
  11. #define V_MODEL "models/v_balrog3.mdl"
  12. #define P_MODEL "models/p_balrog3.mdl"
  13. #define W_MODEL "models/w_balrog3.mdl"
  14.  
  15. #define DAMAGE 24
  16. #define BPAMMO 240
  17. #define ACTIVE_CLIP 15
  18.  
  19. #define CSW_BALROG3 CSW_MP5NAVY
  20. #define weapon_balrog3 "weapon_mp5navy"
  21.  
  22. #define WEAPON_SECRETCODE 4962
  23. #define WEAPON_EVENT "events/mp5n.sc"
  24. #define OLD_W_MODEL "models/w_mp5.mdl"
  25.  
  26. new const Balrog3_Sounds[6][] =
  27. {
  28. "weapons/balrig3-1.wav",
  29. "weapons/balrig3-2.wav",
  30. "weapons/balrig3_boltpull.wav",
  31. "weapons/balrig3_clipin.wav",
  32. "weapons/balrig3_clipout.wav",
  33. "weapons/balrig3_draw.wav"
  34. }
  35.  
  36. #define EXPLOSE_SPR "sprites/balrog5stack.spr"
  37.  
  38. enum
  39. {
  40. ANIM_IDLE = 0,
  41. ANIM_DRAW,
  42. ANIM_RELOAD,
  43. ANIM_SHOOT_A,
  44. ANIM_SHOOT_B
  45. }
  46.  
  47.  
  48. new g_Had_Balrog3[33], g_Shoot_Special[33], g_Holding_Attack[33], g_Shoot_Count[33], g_Old_Weapon[33], g_Current_Weapon[33]
  49. new g_Exp_SprId, g_balrog3_event, g_ShellId, g_SmokePuff_SprId, pemapa[33]
  50.  
  51. public plugin_init()
  52. {
  53. register_plugin(PLUGIN, VERSION, AUTHOR)
  54.  
  55. register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
  56.  
  57. register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  58. register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
  59. register_forward(FM_SetModel, "fw_SetModel")
  60. register_forward(FM_CmdStart, "fw_CmdStart")
  61.  
  62. RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack")
  63. RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
  64. RegisterHam(Ham_Weapon_PrimaryAttack, weapon_balrog3, "fw_Weapon_PrimaryAttack")
  65. RegisterHam(Ham_Weapon_PrimaryAttack, weapon_balrog3, "fw_Weapon_PrimaryAttack_Post", 1)
  66. RegisterHam(Ham_Item_AddToPlayer, weapon_balrog3, "fw_Item_AddToPlayer_Post", 1)
  67.  
  68. register_clcmd("say /barlog", "Get_Balrog3", ADMIN_LEVEL_H)
  69. }
  70.  
  71. public plugin_precache()
  72. {
  73. engfunc(EngFunc_PrecacheModel, V_MODEL)
  74. engfunc(EngFunc_PrecacheModel, P_MODEL)
  75. engfunc(EngFunc_PrecacheModel, W_MODEL)
  76.  
  77. for(new i = 0; i < sizeof(Balrog3_Sounds); i++)
  78. engfunc(EngFunc_PrecacheSound, Balrog3_Sounds[i])
  79.  
  80. g_Exp_SprId = engfunc(EngFunc_PrecacheModel, EXPLOSE_SPR)
  81. g_SmokePuff_SprId = engfunc(EngFunc_PrecacheModel, "sprites/wall_puff1.spr")
  82. g_ShellId = engfunc(EngFunc_PrecacheModel, "models/pshell.mdl")
  83.  
  84. register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
  85. }
  86.  
  87. public fw_PrecacheEvent_Post(type, const name[])
  88. {
  89. if(equal(WEAPON_EVENT, name))
  90. g_balrog3_event = get_orig_retval()
  91. }
  92.  
  93. public zp_user_infected_post(id) Remove_Balrog3(id)
  94. public Get_Balrog3(id)
  95. {
  96. if(!is_user_alive(id))
  97. return
  98.  
  99. if(pemapa[id] == 2) {
  100. ColorChat(id, "!gAi luat deja aceasta arma de 2 ori.")
  101. return
  102. }
  103.  
  104. g_Had_Balrog3[id] = 1
  105. g_Shoot_Special[id] = 0
  106. g_Holding_Attack[id] = 0
  107. g_Shoot_Count[id] = 0
  108. pemapa[id] ++
  109.  
  110. fm_give_item(id, weapon_balrog3)
  111.  
  112. cs_set_user_bpammo(id, CSW_BALROG3, BPAMMO)
  113. }
  114.  
  115. public Remove_Balrog3(id)
  116. {
  117. if(!is_user_connected(id))
  118. return
  119.  
  120. g_Had_Balrog3[id] = 0
  121. g_Shoot_Special[id] = 0
  122. }
  123.  
  124. public Event_CurWeapon(id)
  125. {
  126. if(!is_user_alive(id))
  127. return
  128.  
  129. if(get_user_weapon(id) != g_Current_Weapon[id]) g_Current_Weapon[id] = get_user_weapon(id)
  130.  
  131. if(get_user_weapon(id) == CSW_BALROG3 && g_Had_Balrog3[id])
  132. {
  133. if(g_Old_Weapon[id] != CSW_BALROG3)
  134. {
  135. set_pev(id, pev_viewmodel2, V_MODEL)
  136. set_pev(id, pev_weaponmodel2, P_MODEL)
  137. }
  138. }
  139.  
  140. g_Old_Weapon[id] = get_user_weapon(id)
  141. }
  142.  
  143. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  144. {
  145. if(!is_user_alive(id) || !is_user_connected(id))
  146. return FMRES_IGNORED
  147. if(get_user_weapon(id) == CSW_BALROG3 && g_Had_Balrog3[id])
  148. set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  149.  
  150. return FMRES_HANDLED
  151. }
  152.  
  153. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  154. {
  155. if (!is_user_connected(invoker))
  156. return FMRES_IGNORED
  157. if(get_user_weapon(invoker) != CSW_BALROG3 || !g_Had_Balrog3[invoker])
  158. return FMRES_IGNORED
  159. if(eventid != g_balrog3_event)
  160. return FMRES_IGNORED
  161.  
  162. engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  163.  
  164. if(!g_Shoot_Special[invoker] && cs_get_user_bpammo(invoker, CSW_BALROG3) > 0)
  165. {
  166. g_Shoot_Count[invoker]++
  167. if(g_Shoot_Count[invoker] >= ACTIVE_CLIP)
  168. {
  169. g_Shoot_Special[invoker] = 1
  170.  
  171. static Ent; Ent = fm_get_user_weapon_entity(invoker, CSW_BALROG3)
  172. if(pev_valid(Ent)) g_Shoot_Count[invoker] = cs_get_weapon_ammo(Ent)
  173. }
  174. } else if(g_Shoot_Special[invoker]) {
  175. cs_set_user_bpammo(invoker, CSW_BALROG3, cs_get_user_bpammo(invoker, CSW_BALROG3) - 1)
  176.  
  177. if(cs_get_user_bpammo(invoker, CSW_BALROG3) <= 0)
  178. {
  179. g_Shoot_Special[invoker] = 0
  180. g_Shoot_Count[invoker] = 0
  181. }
  182. }
  183.  
  184. set_weapon_anim(invoker, g_Shoot_Special[invoker] == 1 ? ANIM_SHOOT_B : ANIM_SHOOT_A)
  185. emit_sound(invoker, CHAN_WEAPON, g_Shoot_Special[invoker] == 1 ? Balrog3_Sounds[1] : Balrog3_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  186.  
  187. Eject_Shell(invoker, g_ShellId, 0.0)
  188.  
  189. return FMRES_SUPERCEDE
  190. }
  191.  
  192. public fw_SetModel(entity, model[])
  193. {
  194. if(!pev_valid(entity))
  195. return FMRES_IGNORED
  196.  
  197. static Classname[32]
  198. pev(entity, pev_classname, Classname, sizeof(Classname))
  199.  
  200. if(!equal(Classname, "weaponbox"))
  201. return FMRES_IGNORED
  202.  
  203. static iOwner
  204. iOwner = pev(entity, pev_owner)
  205.  
  206. if(equal(model, OLD_W_MODEL))
  207. {
  208. static weapon; weapon = fm_find_ent_by_owner(-1, weapon_balrog3, entity)
  209.  
  210. if(!pev_valid(weapon))
  211. return FMRES_IGNORED;
  212.  
  213. if(g_Had_Balrog3[iOwner])
  214. {
  215. Remove_Balrog3(iOwner)
  216.  
  217. set_pev(weapon, pev_impulse, WEAPON_SECRETCODE)
  218. engfunc(EngFunc_SetModel, entity, W_MODEL)
  219.  
  220. return FMRES_SUPERCEDE
  221. }
  222. }
  223.  
  224. return FMRES_IGNORED;
  225. }
  226.  
  227. public fw_CmdStart(id, uc_handle, seed)
  228. {
  229. if(!is_user_alive(id))
  230. return
  231. if(g_Current_Weapon[id] != CSW_BALROG3 || !g_Had_Balrog3[id])
  232. return
  233.  
  234. static NewButton; NewButton = get_uc(uc_handle, UC_Buttons)
  235. static OldButton; OldButton = pev(id, pev_oldbuttons)
  236.  
  237. if(NewButton & IN_ATTACK)
  238. {
  239. if(!g_Holding_Attack[id]) g_Holding_Attack[id] = 1
  240. } else if((NewButton & IN_ATTACK2) && !(OldButton & IN_ATTACK2)) {
  241. if(cs_get_user_zoom(id) == 1) cs_set_user_zoom(id, CS_SET_AUGSG552_ZOOM, 1)
  242. else cs_set_user_zoom(id, CS_SET_NO_ZOOM, 1)
  243. } else {
  244. if(OldButton & IN_ATTACK)
  245. {
  246. if(g_Holding_Attack[id])
  247. {
  248. g_Holding_Attack[id] = 0
  249. g_Shoot_Count[id] = 0
  250. g_Shoot_Special[id] = 0
  251. }
  252. }
  253. }
  254. }
  255.  
  256. public fw_TraceAttack(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
  257. {
  258. if(!is_user_alive(Attacker))
  259. return HAM_IGNORED
  260. if(get_user_weapon(Attacker) != CSW_BALROG3 || !g_Had_Balrog3[Attacker])
  261. return HAM_IGNORED
  262.  
  263. static Float:flEnd[3], Float:vecPlane[3]
  264.  
  265. get_tr2(Ptr, TR_vecEndPos, flEnd)
  266. get_tr2(Ptr, TR_vecPlaneNormal, vecPlane)
  267.  
  268. if(!is_user_alive(Victim))
  269. {
  270. Make_BulletHole(Attacker, flEnd, Damage)
  271. Make_BulletSmoke(Attacker, Ptr)
  272. }
  273.  
  274. if(g_Shoot_Special[Attacker])
  275. {
  276. Make_BalrogEffect(Attacker, Ptr)
  277. radius_damage(Attacker, flEnd, float(DAMAGE), 96.0)
  278. }
  279.  
  280. SetHamParamFloat(3, float(DAMAGE))
  281.  
  282. return HAM_IGNORED
  283. }
  284.  
  285. public fw_Weapon_PrimaryAttack(Ent)
  286. {
  287. if(!pev_valid(Ent))
  288. return
  289. static Id; Id = pev(Ent, pev_owner)
  290. if(!g_Had_Balrog3[Id])
  291. return
  292.  
  293. if(g_Shoot_Special[Id]) set_pdata_float(Ent, 62, 0.4, 4)
  294. else set_pdata_float(Ent, 62, 0.2, 4)
  295. }
  296.  
  297. public fw_Weapon_PrimaryAttack_Post(Ent)
  298. {
  299. if(!pev_valid(Ent))
  300. return
  301. static Id; Id = pev(Ent, pev_owner)
  302. if(!g_Had_Balrog3[Id])
  303. return
  304.  
  305. if(g_Shoot_Special[Id] && cs_get_weapon_ammo(Ent) > 0)
  306. {
  307. cs_set_weapon_ammo(Ent, g_Shoot_Count[Id])
  308. set_pdata_float(Ent, 46, get_pdata_float(Ent, 46, 4) * 0.75, 4)
  309. }
  310. }
  311.  
  312. public fw_Item_AddToPlayer_Post(ent, id)
  313. {
  314. if(!pev_valid(ent))
  315. return HAM_IGNORED
  316.  
  317. if(pev(ent, pev_impulse) == WEAPON_SECRETCODE)
  318. {
  319. g_Had_Balrog3[id] = 1
  320. set_pev(ent, pev_impulse, 0)
  321. }
  322.  
  323. return HAM_HANDLED
  324. }
  325.  
  326. stock Make_BulletHole(id, Float:Origin[3], Float:Damage)
  327. {
  328. // Find target
  329. static Decal; Decal = random_num(41, 45)
  330. static LoopTime;
  331.  
  332. if(Damage > 100.0) LoopTime = 2
  333. else LoopTime = 1
  334.  
  335. for(new i = 0; i < LoopTime; i++)
  336. {
  337. // Put decal on "world" (a wall)
  338. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  339. write_byte(TE_WORLDDECAL)
  340. engfunc(EngFunc_WriteCoord, Origin[0])
  341. engfunc(EngFunc_WriteCoord, Origin[1])
  342. engfunc(EngFunc_WriteCoord, Origin[2])
  343. write_byte(Decal)
  344. message_end()
  345.  
  346. // Show sparcles
  347. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  348. write_byte(TE_GUNSHOTDECAL)
  349. engfunc(EngFunc_WriteCoord, Origin[0])
  350. engfunc(EngFunc_WriteCoord, Origin[1])
  351. engfunc(EngFunc_WriteCoord, Origin[2])
  352. write_short(id)
  353. write_byte(Decal)
  354. message_end()
  355. }
  356. }
  357.  
  358. public Make_BulletSmoke(id, TrResult)
  359. {
  360. static Float:vecSrc[3], Float:vecEnd[3], TE_FLAG
  361.  
  362. get_weapon_attachment(id, vecSrc)
  363. global_get(glb_v_forward, vecEnd)
  364.  
  365. xs_vec_mul_scalar(vecEnd, 8192.0, vecEnd)
  366. xs_vec_add(vecSrc, vecEnd, vecEnd)
  367.  
  368. get_tr2(TrResult, TR_vecEndPos, vecSrc)
  369. get_tr2(TrResult, TR_vecPlaneNormal, vecEnd)
  370.  
  371. xs_vec_mul_scalar(vecEnd, 2.5, vecEnd)
  372. xs_vec_add(vecSrc, vecEnd, vecEnd)
  373.  
  374. TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  375. TE_FLAG |= TE_EXPLFLAG_NOSOUND
  376. TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  377.  
  378. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0)
  379. write_byte(TE_EXPLOSION)
  380. engfunc(EngFunc_WriteCoord, vecEnd[0])
  381. engfunc(EngFunc_WriteCoord, vecEnd[1])
  382. engfunc(EngFunc_WriteCoord, vecEnd[2] - 10.0)
  383. write_short(g_SmokePuff_SprId)
  384. write_byte(2)
  385. write_byte(50)
  386. write_byte(TE_FLAG)
  387. message_end()
  388. }
  389.  
  390. public Make_BalrogEffect(id, TrResult)
  391. {
  392. static Float:vecSrc[3], Float:vecEnd[3], TE_FLAG
  393.  
  394. get_weapon_attachment(id, vecSrc)
  395. global_get(glb_v_forward, vecEnd)
  396.  
  397. xs_vec_mul_scalar(vecEnd, 8192.0, vecEnd)
  398. xs_vec_add(vecSrc, vecEnd, vecEnd)
  399.  
  400. get_tr2(TrResult, TR_vecEndPos, vecSrc)
  401. get_tr2(TrResult, TR_vecPlaneNormal, vecEnd)
  402.  
  403. xs_vec_mul_scalar(vecEnd, 5.0, vecEnd)
  404. xs_vec_add(vecSrc, vecEnd, vecEnd)
  405.  
  406. TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  407. TE_FLAG |= TE_EXPLFLAG_NOSOUND
  408. TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  409.  
  410. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0)
  411. write_byte(TE_EXPLOSION)
  412. engfunc(EngFunc_WriteCoord, vecEnd[0])
  413. engfunc(EngFunc_WriteCoord, vecEnd[1])
  414. engfunc(EngFunc_WriteCoord, vecEnd[2])
  415. write_short(g_Exp_SprId)
  416. write_byte(5)
  417. write_byte(30)
  418. write_byte(TE_FLAG)
  419. message_end()
  420. }
  421.  
  422. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
  423. {
  424. new Float:vfEnd[3], viEnd[3]
  425. get_user_origin(id, viEnd, 3)
  426. IVecFVec(viEnd, vfEnd)
  427.  
  428. new Float:fOrigin[3], Float:fAngle[3]
  429.  
  430. pev(id, pev_origin, fOrigin)
  431. pev(id, pev_view_ofs, fAngle)
  432.  
  433. xs_vec_add(fOrigin, fAngle, fOrigin)
  434.  
  435. new Float:fAttack[3]
  436.  
  437. xs_vec_sub(vfEnd, fOrigin, fAttack)
  438. xs_vec_sub(vfEnd, fOrigin, fAttack)
  439.  
  440. new Float:fRate
  441.  
  442. fRate = fDis / vector_length(fAttack)
  443. xs_vec_mul_scalar(fAttack, fRate, fAttack)
  444.  
  445. xs_vec_add(fOrigin, fAttack, output)
  446. }
  447.  
  448. stock radius_damage(id, Float:Origin[3], Float:Damage, Float:Radius)
  449. {
  450. static Victim; Victim = -1
  451.  
  452. while((Victim = engfunc(EngFunc_FindEntityInSphere, Victim, Origin, Radius)) != 0)
  453. {
  454. if(!is_user_alive(Victim) || id == Victim)
  455. continue
  456.  
  457. ExecuteHamB(Ham_TakeDamage, Victim, fm_get_user_weapon_entity(id, get_user_weapon(id)), id, Damage, DMG_BULLET)
  458. }
  459. }
  460.  
  461. stock Eject_Shell(id, Shell_ModelIndex, Float:Time) // By Dias
  462. {
  463. static Ent; Ent = get_pdata_cbase(id, 373, 5)
  464. if(!pev_valid(Ent))
  465. return
  466.  
  467. set_pdata_int(Ent, 57, Shell_ModelIndex, 4)
  468. set_pdata_float(id, 111, get_gametime() + Time)
  469. }
  470.  
  471. stock set_weapon_anim(id, anim)
  472. {
  473. if(!is_user_alive(id))
  474. return
  475.  
  476. set_pev(id, pev_weaponanim, anim)
  477.  
  478. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
  479. write_byte(anim)
  480. write_byte(pev(id, pev_body))
  481. message_end()
  482. }
  483. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  484. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  485. */
  486.  
  487. stock ColorChat(const id, const input[], any:...) {
  488. new count = 1, players[32]
  489. static msg[320]
  490. vformat(msg, 190, input, 3)
  491. replace_all(msg, 190, "!g", "^4")
  492. replace_all(msg, 190, "!n", "^1")
  493. replace_all(msg, 190, "!t", "^3")
  494. replace_all(msg, 190, "!t2", "^0")
  495.  
  496. if(id) players[0] = id;
  497. else get_players(players, count, "ch")
  498.  
  499. for (new i = 0; i < count; i++) {
  500. if (is_user_connected(players[i])) {
  501. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
  502. write_byte(players[i])
  503. write_string(msg)
  504. message_end()
  505. }
  506. }
  507. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement