HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <fakemeta_util>
  4. #include <hamsandwich>
  5. #include <cstrike>
  6.  
  7. //#define USE_FOR_ZOMBIE
  8. //Ha Zombie Plague módhoz szeretnéd használni akkor töröld a "//" jelet a "#define" elejéröl
  9.  
  10. #if defined USE_FOR_ZOMBIE
  11. #include <zp50_items>
  12. #include <zp50_class_survivor>
  13. #endif
  14.  
  15. #define PLUGIN "[CSO] Weapon: JANUS-3"
  16. #define VERSION "1.0"
  17. #define AUTHOR "Dias Pendragon"
  18. #define MODIFIED/FIXED "Dooz"
  19.  
  20. #define V_MODEL "models/v_janus3.mdl"
  21. #define P_MODEL "models/p_janus3.mdl"
  22. #define W_MODEL "models/w_janus3.mdl"
  23.  
  24. #define TASK_CHANGE 42343
  25. #define TASK_CHANGELIMITTIME 54364
  26. #define TASK_USETIME 34647
  27.  
  28. new const Janus3_Sounds[10][] =
  29. {
  30. "weapons/janus3_shoot1.wav",
  31. "weapons/janus3_shoot2.wav",
  32. "weapons/change1_ready.wav",
  33. "weapons/janus3_draw.wav",
  34. "weapons/janus3_clipout.wav",
  35. "weapons/janus3_clipin.wav",
  36. "weapons/janus3_change2.wav",
  37. "weapons/janus3_change1.wav",
  38. "weapons/janus3_boltpull1.wav",
  39. "weapons/janus3_boltpull2.wav"
  40. }
  41.  
  42. new const Janus3_Resources[4][] =
  43. {
  44. "sprites/weapon_janus3.txt",
  45. "sprites/640hud7_2.spr",
  46. "sprites/640hud12_2.spr",
  47. "sprites/640hud109_2.spr"
  48. }
  49.  
  50. enum
  51. {
  52. J3_ANIM_IDLE = 0,
  53. J3_ANIM_RELOAD,
  54. J3_ANIM_DRAW,
  55. J3_ANIM_SHOOT1,
  56. J3_ANIM_SHOOT1_ACTIVE,
  57. J3_ANIM_CHANGE_TO_JANUS,
  58. J3_ANIM_IDLE_JANUS,
  59. J3_ANIM_DRAW_JANUS,
  60. J3_ANIM_SHOOT1_JANUS,
  61. J3_ANIM_SHOOT2_JANUS,
  62. J3_ANIM_SHOOT3_JANUS,
  63. J3_ANIM_CHANGE_TO_BACK,
  64. J3_ANIM_IDLE_ACTIVE,
  65. J3_ANIM_RELOAD_ACTIVE,
  66. J3_ANIM_DRAW_ACTIVE
  67. }
  68.  
  69. enum
  70. {
  71. JANUS3_NORMAL = 0,
  72. JANUS3_ACTIVE,
  73. JANUS3_JANUS
  74. }
  75.  
  76. #define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
  77. #define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
  78. #define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))
  79.  
  80. new g_Cvars[9], g_HasGun, g_Janus3_Mode[33], g_Janus3_Clip[33], g_BulletCount[33], g_ChangingMode, Float:g_Recoil[33][3]
  81. new g_Event_Janus3, g_SmokePuff_SprId, g_RifleShell_Id
  82.  
  83. #if defined USE_FOR_ZOMBIE
  84. new g_Item;
  85. #define Item_Price 20
  86. #endif
  87.  
  88. public plugin_init()
  89. {
  90. register_plugin(PLUGIN, VERSION, AUTHOR)
  91.  
  92. #if defined USE_FOR_ZOMBIE
  93. g_Item = zp_items_register("Janus-3", Item_Price);
  94. #else
  95. register_clcmd("say /get_janus3", "Get_Janus3")
  96. #endif
  97. register_clcmd("weapon_janus3", "Hook_Weapon")
  98.  
  99. g_Cvars[0] = register_cvar("jn3_damage", "35");
  100. g_Cvars[1] = register_cvar("jn3_damage_charged", "70");
  101. g_Cvars[2] = register_cvar("jn3_charge_ammo", "20");
  102. g_Cvars[3] = register_cvar("jn3_charge_limittime", "7");
  103. g_Cvars[4] = register_cvar("jn3_charge_time", "7");
  104. g_Cvars[5] = register_cvar("jn3_clip", "50");
  105. g_Cvars[6] = register_cvar("jn3_bpammo", "250");
  106. g_Cvars[7] = register_cvar("jn3_change_time", "2.0");
  107. g_Cvars[8] = register_cvar("jn3_chargeshoot_recoil", "0.25");
  108.  
  109. register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
  110.  
  111. register_forward(FM_UpdateClientData,"fw_UpdateClientData_Post", 1)
  112. register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
  113. register_forward(FM_SetModel, "fw_SetModel")
  114. register_forward(FM_CmdStart, "fw_CmdStart")
  115.  
  116. RegisterHam(Ham_Weapon_WeaponIdle, "weapon_ump45", "fw_Weapon_WeaponIdle_Post", 1)
  117. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_Weapon_PrimaryAttack")
  118. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_Weapon_PrimaryAttack_Post", 1)
  119. RegisterHam(Ham_Item_Deploy, "weapon_ump45", "fw_Item_Deploy_Post", 1)
  120. RegisterHam(Ham_Item_AddToPlayer, "weapon_ump45", "fw_Item_AddToPlayer_Post", 1)
  121. RegisterHam(Ham_Item_PostFrame, "weapon_ump45", "fw_Item_PostFrame")
  122. RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Weapon_Reload")
  123. RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Weapon_Reload_Post", 1)
  124.  
  125. RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
  126.  
  127. RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_World")
  128. RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack_Player")
  129.  
  130. register_message(get_user_msgid("DeathMsg"), "message_DeathMsg");
  131. }
  132.  
  133. public plugin_precache()
  134. {
  135. engfunc(EngFunc_PrecacheModel, V_MODEL)
  136. engfunc(EngFunc_PrecacheModel, P_MODEL)
  137. engfunc(EngFunc_PrecacheModel, W_MODEL)
  138.  
  139. new i
  140. for(i = 0; i < sizeof(Janus3_Sounds); i++)
  141. engfunc(EngFunc_PrecacheSound, Janus3_Sounds[i])
  142.  
  143. for(i = 0; i < sizeof(Janus3_Resources); i++)
  144. {
  145. if(i == 0) engfunc(EngFunc_PrecacheGeneric, Janus3_Resources[i])
  146. else engfunc(EngFunc_PrecacheModel, Janus3_Resources[i])
  147. }
  148.  
  149. g_RifleShell_Id = engfunc(EngFunc_PrecacheModel, "models/rshell.mdl")
  150. g_SmokePuff_SprId = engfunc(EngFunc_PrecacheModel, "sprites/wall_puff1.spr")
  151.  
  152. register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
  153. }
  154.  
  155. public fwHamPlayerSpawnPost(id) {
  156. if (!is_user_alive(id) && !Get_BitVar(g_HasGun, id))
  157. return;
  158.  
  159. if(get_user_weapon(id) == CSW_UMP45)
  160. set_weapon_anim(id, J3_ANIM_IDLE)
  161.  
  162. remove_task(id+TASK_CHANGE)
  163. remove_task(id+TASK_CHANGELIMITTIME)
  164. remove_task(id+TASK_USETIME)
  165.  
  166. g_Janus3_Mode[id] = JANUS3_NORMAL
  167. g_BulletCount[id] = 0
  168.  
  169. UnSet_BitVar(g_ChangingMode, id)
  170.  
  171. static Ent; Ent = fm_get_user_weapon_entity(id, CSW_UMP45)
  172. if(!pev_valid(Ent)) return
  173.  
  174. new Clip = get_pcvar_num(g_Cvars[5]), BPAmmo = get_pcvar_num(g_Cvars[6])
  175.  
  176. cs_set_weapon_ammo(Ent, Clip)
  177. cs_set_user_bpammo(id, CSW_UMP45, BPAmmo)
  178.  
  179. Update_AmmoHud(id, CSW_UMP45, Clip, BPAmmo)
  180. }
  181.  
  182. public Hook_Weapon(id)
  183. {
  184. engclient_cmd(id, "weapon_ump45")
  185. return PLUGIN_HANDLED
  186. }
  187.  
  188. public fw_PrecacheEvent_Post(type, const name[])
  189. {
  190. if(equal("events/ump45.sc", name)) g_Event_Janus3 = get_orig_retval()
  191. }
  192.  
  193. public client_putinserver(id)
  194. {
  195. UnSet_BitVar(g_HasGun, id);
  196. UnSet_BitVar(g_ChangingMode, id);
  197. g_Janus3_Mode[id] = JANUS3_NORMAL;
  198. g_BulletCount[id] = 0;
  199. }
  200.  
  201. #if defined USE_FOR_ZOMBIE
  202. public zp_fw_items_select_pre(id, itemid, ignorecost){
  203.  
  204. if(itemid == g_Item){
  205. if(zp_core_is_zombie(id) || zp_class_survivor_get(id))
  206. return ZP_ITEM_DONT_SHOW;
  207. }
  208.  
  209. return ZP_ITEM_AVAILABLE;
  210. }
  211.  
  212. public zp_fw_items_select_post(id, itemid, ignorecost){
  213.  
  214. if (itemid == g_Item)
  215. Get_Janus3(id)
  216.  
  217. return ZP_ITEM_AVAILABLE;
  218. }
  219. #endif
  220.  
  221. public Get_Janus3(id)
  222. {
  223. if(!is_user_alive(id))
  224. return
  225.  
  226. Drop_Weapon(id, 1)
  227.  
  228. g_Janus3_Mode[id] = JANUS3_NORMAL
  229. g_BulletCount[id] = 0
  230.  
  231. Set_BitVar(g_HasGun, id)
  232. UnSet_BitVar(g_ChangingMode, id)
  233. fm_give_item(id, "weapon_ump45")
  234.  
  235. // Set Weapon
  236. engclient_cmd(id, "weapon_ump45")
  237.  
  238. set_pev(id, pev_viewmodel2, V_MODEL)
  239. set_pev(id, pev_weaponmodel2, P_MODEL)
  240.  
  241. // Set Weapon Base
  242. static Ent; Ent = fm_get_user_weapon_entity(id, CSW_UMP45)
  243. if(!pev_valid(Ent)) return
  244.  
  245. new Clip = get_pcvar_num(g_Cvars[5]), BPAmmo = get_pcvar_num(g_Cvars[6])
  246.  
  247. cs_set_weapon_ammo(Ent, Clip)
  248. cs_set_user_bpammo(id, CSW_UMP45, BPAmmo)
  249.  
  250. Update_AmmoHud(id, CSW_UMP45, Clip, BPAmmo)
  251. }
  252.  
  253. public Update_AmmoHud(id, CSWID, Ammo, BpAmmo)
  254. {
  255. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("CurWeapon"), _, id)
  256. write_byte(1)
  257. write_byte(CSWID)
  258. write_byte(Ammo)
  259. message_end()
  260.  
  261. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("AmmoX"), _, id)
  262. write_byte(10)
  263. write_byte(BpAmmo)
  264. message_end()
  265. }
  266.  
  267. public Remove_Janus3(id)
  268. {
  269. g_Janus3_Mode[id] = JANUS3_NORMAL
  270. g_BulletCount[id] = 0
  271.  
  272. UnSet_BitVar(g_HasGun, id)
  273. UnSet_BitVar(g_ChangingMode, id)
  274.  
  275. remove_task(id+TASK_CHANGE)
  276. remove_task(id+TASK_CHANGELIMITTIME)
  277. remove_task(id+TASK_USETIME)
  278. }
  279.  
  280. public Event_CurWeapon(id)
  281. {
  282. if(!Get_BitVar(g_HasGun, id))
  283. return
  284. if(g_Janus3_Mode[id] != JANUS3_JANUS)
  285. return
  286.  
  287. static Float:Delay, Float:Delay2
  288. static Ent; Ent = fm_get_user_weapon_entity(id, CSW_UMP45)
  289. if(!pev_valid(Ent)) return
  290.  
  291. Delay = get_pdata_float(Ent, 46, 4) * 0.75
  292. Delay2 = get_pdata_float(Ent, 47, 4) * 0.75
  293.  
  294. if(Delay > 0.0)
  295. {
  296. set_pdata_float(Ent, 46, Delay, 4)
  297. set_pdata_float(Ent, 47, Delay2, 4)
  298. }
  299. }
  300.  
  301. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  302. {
  303. if(!is_user_alive(id) || !is_user_connected(id))
  304. return FMRES_IGNORED
  305. if(get_user_weapon(id) == CSW_UMP45 && Get_BitVar(g_HasGun, id))
  306. set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  307.  
  308. return FMRES_HANDLED
  309. }
  310.  
  311. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  312. {
  313. if (!is_user_connected(invoker))
  314. return FMRES_IGNORED
  315. if(get_user_weapon(invoker) != CSW_UMP45 || !Get_BitVar(g_HasGun, invoker))
  316. return FMRES_IGNORED
  317. if(eventid != g_Event_Janus3)
  318. return FMRES_IGNORED
  319.  
  320. engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  321.  
  322. if(g_Janus3_Mode[invoker] == JANUS3_NORMAL) set_weapon_anim(invoker, J3_ANIM_SHOOT1)
  323. else if(g_Janus3_Mode[invoker] == JANUS3_ACTIVE) set_weapon_anim(invoker, J3_ANIM_SHOOT1_ACTIVE)
  324. else if(g_Janus3_Mode[invoker] == JANUS3_JANUS) set_weapon_anim(invoker, random_num(J3_ANIM_SHOOT1_JANUS, J3_ANIM_SHOOT3_JANUS))
  325.  
  326. emit_sound(invoker, CHAN_WEAPON, g_Janus3_Mode[invoker] == JANUS3_JANUS ? Janus3_Sounds[1] : Janus3_Sounds[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
  327. Eject_Shell(invoker, g_RifleShell_Id, 0.01)
  328.  
  329. static Ent; Ent = fm_find_ent_by_owner(-1, "weapon_ump45", invoker)
  330. if(pev_valid(Ent) && g_Janus3_Mode[invoker] == JANUS3_JANUS) cs_set_weapon_ammo(Ent, cs_get_weapon_ammo(Ent) + 1)
  331.  
  332. return FMRES_IGNORED
  333. }
  334.  
  335. public fw_SetModel(entity, model[])
  336. {
  337. if(!pev_valid(entity))
  338. return FMRES_IGNORED
  339.  
  340. static Classname[32]
  341. pev(entity, pev_classname, Classname, sizeof(Classname))
  342.  
  343. if(!equal(Classname, "weaponbox"))
  344. return FMRES_IGNORED
  345.  
  346. static iOwner
  347. iOwner = pev(entity, pev_owner)
  348.  
  349. if(equal(model, "models/w_ump45.mdl"))
  350. {
  351. static weapon; weapon = fm_find_ent_by_owner(-1, "weapon_ump45", entity)
  352.  
  353. if(!pev_valid(weapon))
  354. return FMRES_IGNORED;
  355.  
  356. if(Get_BitVar(g_HasGun, iOwner))
  357. {
  358. Remove_Janus3(iOwner)
  359.  
  360. set_pev(weapon, pev_impulse, 31122013)
  361. engfunc(EngFunc_SetModel, entity, W_MODEL)
  362.  
  363. return FMRES_SUPERCEDE
  364. }
  365. }
  366.  
  367. return FMRES_IGNORED;
  368. }
  369.  
  370. public fw_CmdStart(id, uc_handle, seed)
  371. {
  372. if(!is_user_alive(id))
  373. return FMRES_IGNORED
  374.  
  375. if(!Get_BitVar(g_HasGun, id) || get_user_weapon(id) != CSW_UMP45)
  376. return FMRES_IGNORED
  377.  
  378. static PressButton; PressButton = get_uc(uc_handle, UC_Buttons)
  379.  
  380. if((PressButton & IN_RELOAD) && g_Janus3_Mode[id] == JANUS3_JANUS)
  381. return FMRES_SUPERCEDE
  382.  
  383. if((PressButton & IN_ATTACK2))
  384. {
  385. PressButton &= ~IN_ATTACK2
  386. set_uc(uc_handle, UC_Buttons, PressButton)
  387.  
  388. if((pev(id, pev_oldbuttons) & IN_ATTACK2))
  389. return FMRES_IGNORED
  390. if(g_Janus3_Mode[id] != JANUS3_ACTIVE)
  391. return FMRES_IGNORED
  392. if(get_pdata_float(id, 83, 5) > 0.0)
  393. return FMRES_IGNORED
  394.  
  395. remove_task(id+TASK_CHANGELIMITTIME)
  396.  
  397. Set_BitVar(g_ChangingMode, id)
  398. Set_Player_NextAttack(id, CSW_UMP45, get_pcvar_float(g_Cvars[7]))
  399.  
  400. set_weapon_anim(id, J3_ANIM_CHANGE_TO_JANUS)
  401. set_task(get_pcvar_float(g_Cvars[7]), "ChangeTo_JanusTransform", id+TASK_CHANGE)
  402. }
  403.  
  404. return FMRES_IGNORED
  405. }
  406.  
  407. public ChangeTo_JanusTransform(id)
  408. {
  409. id -= TASK_CHANGE
  410.  
  411. if(!is_user_alive(id))
  412. return
  413.  
  414. if(get_user_weapon(id) != CSW_UMP45 || !Get_BitVar(g_HasGun, id))
  415. return
  416.  
  417. if(!Get_BitVar(g_ChangingMode, id))
  418. return
  419.  
  420. UnSet_BitVar(g_ChangingMode, id)
  421. g_Janus3_Mode[id] = JANUS3_JANUS
  422.  
  423. set_weapon_anim(id, J3_ANIM_IDLE_JANUS)
  424.  
  425. remove_task(id+TASK_USETIME)
  426. set_task(float(get_pcvar_num(g_Cvars[4])), "TurnOff_JTS2", id+TASK_USETIME)
  427. }
  428.  
  429. public TurnOff_JTS2(id)
  430. {
  431. id -= TASK_USETIME
  432.  
  433. if(!is_user_alive(id))
  434. return
  435.  
  436. if(get_user_weapon(id) != CSW_UMP45 || !Get_BitVar(g_HasGun, id))
  437. return
  438.  
  439. if(g_Janus3_Mode[id] != JANUS3_JANUS)
  440. return
  441.  
  442. Set_BitVar(g_ChangingMode, id)
  443. Set_Player_NextAttack(id, CSW_UMP45, get_pcvar_num(g_Cvars[7]) - 1.0)
  444.  
  445. set_weapon_anim(id, J3_ANIM_CHANGE_TO_BACK)
  446.  
  447. set_task(get_pcvar_num(g_Cvars[7]) - 1.0, "ChangeTo_Back", id+TASK_CHANGE)
  448. }
  449.  
  450. public ChangeTo_Back(id)
  451. {
  452. id -= TASK_CHANGE
  453.  
  454. if(!is_user_alive(id))
  455. return
  456.  
  457. if(get_user_weapon(id) != CSW_UMP45 || !Get_BitVar(g_HasGun, id))
  458. return
  459.  
  460. if(g_Janus3_Mode[id] != JANUS3_JANUS)
  461. return
  462.  
  463. g_Janus3_Mode[id] = JANUS3_NORMAL
  464. }
  465.  
  466. public fw_Weapon_PrimaryAttack(Ent)
  467. {
  468. static id; id = pev(Ent, pev_owner)
  469. pev(id, pev_punchangle, g_Recoil[id])
  470.  
  471. return HAM_IGNORED
  472. }
  473.  
  474. public fw_Weapon_PrimaryAttack_Post(Ent)
  475. {
  476. static id; id = pev(Ent, pev_owner)
  477.  
  478. if(Get_BitVar(g_HasGun, id) && g_Janus3_Mode[id] == JANUS3_JANUS)
  479. {
  480. static Float:Push[3]
  481. pev(id, pev_punchangle, Push)
  482. xs_vec_sub(Push, g_Recoil[id], Push)
  483.  
  484. xs_vec_mul_scalar(Push, get_pcvar_float(g_Cvars[8]), Push)
  485. xs_vec_add(Push, g_Recoil[id], Push)
  486. set_pev(id, pev_punchangle, Push)
  487.  
  488. Event_CurWeapon(id)
  489. }
  490. }
  491.  
  492. public fw_Weapon_WeaponIdle_Post(Ent)
  493. {
  494. if(pev_valid(Ent) != 2)
  495. return HAM_IGNORED
  496. static Id; Id = get_pdata_cbase(Ent, 41, 4)
  497. if(get_pdata_cbase(Id, 373) != Ent)
  498. return HAM_IGNORED
  499. if(!Get_BitVar(g_HasGun, Id))
  500. return HAM_IGNORED
  501.  
  502. if(get_pdata_float(Ent, 48, 4) <= 0.1)
  503. {
  504. if(g_Janus3_Mode[Id] == JANUS3_NORMAL) set_weapon_anim(Id, J3_ANIM_IDLE)
  505. else if(g_Janus3_Mode[Id] == JANUS3_ACTIVE) set_weapon_anim(Id, J3_ANIM_IDLE_ACTIVE)
  506. else if(g_Janus3_Mode[Id] == JANUS3_JANUS) set_weapon_anim(Id, J3_ANIM_IDLE_JANUS)
  507.  
  508. set_pdata_float(Ent, 48, 20.0, 4)
  509. set_pdata_string(Id, (492) * 4, "carbine", -1 , 20)
  510. }
  511.  
  512. return HAM_IGNORED
  513. }
  514.  
  515. public fw_Item_Deploy_Post(Ent)
  516. {
  517. if(pev_valid(Ent) != 2)
  518. return
  519. static Id; Id = get_pdata_cbase(Ent, 41, 4)
  520. if(get_pdata_cbase(Id, 373) != Ent)
  521. return
  522. if(!Get_BitVar(g_HasGun, Id))
  523. return
  524.  
  525. set_pev(Id, pev_viewmodel2, V_MODEL)
  526. set_pev(Id, pev_weaponmodel2, P_MODEL)
  527.  
  528. if(g_Janus3_Mode[Id] == JANUS3_NORMAL) set_weapon_anim(Id, J3_ANIM_DRAW)
  529. else if(g_Janus3_Mode[Id] == JANUS3_ACTIVE) set_weapon_anim(Id, J3_ANIM_DRAW_ACTIVE)
  530. else if(g_Janus3_Mode[Id] == JANUS3_JANUS) set_weapon_anim(Id, J3_ANIM_DRAW_JANUS)
  531. }
  532.  
  533. public fw_Item_AddToPlayer_Post(Ent, id)
  534. {
  535. if(!pev_valid(Ent))
  536. return HAM_IGNORED
  537.  
  538. if(pev(Ent, pev_impulse) == 31122013)
  539. {
  540. Set_BitVar(g_HasGun, id)
  541. set_pev(Ent, pev_impulse, 0)
  542. }
  543.  
  544. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("WeaponList"), .player = id)
  545. write_string(Get_BitVar(g_HasGun, id) ? "weapon_janus3" : "weapon_ump45")
  546. write_byte(6) // PrimaryAmmoID
  547. write_byte(100) // PrimaryAmmoMaxAmount
  548. write_byte(-1) // SecondaryAmmoID
  549. write_byte(-1) // SecondaryAmmoMaxAmount
  550. write_byte(0) // SlotID (0...N)
  551. write_byte(15) // NumberInSlot (1...N)
  552. write_byte(CSW_UMP45) // WeaponID
  553. write_byte(0) // Flags
  554. message_end()
  555.  
  556. return HAM_HANDLED
  557. }
  558.  
  559. public fw_Item_PostFrame(ent)
  560. {
  561. static id; id = pev(ent, pev_owner)
  562. if(!is_user_alive(id))
  563. return HAM_IGNORED
  564. if(!Get_BitVar(g_HasGun, id))
  565. return HAM_IGNORED
  566.  
  567. static Float:flNextAttack; flNextAttack = get_pdata_float(id, 83, 5)
  568. static bpammo; bpammo = cs_get_user_bpammo(id, CSW_UMP45)
  569.  
  570. static iClip; iClip = get_pdata_int(ent, 51, 4)
  571. static fInReload; fInReload = get_pdata_int(ent, 54, 4)
  572.  
  573. if(fInReload && flNextAttack <= 0.0)
  574. {
  575. static temp1
  576. temp1 = min(get_pcvar_num(g_Cvars[5]) - iClip, bpammo)
  577.  
  578. set_pdata_int(ent, 51, iClip + temp1, 4)
  579. cs_set_user_bpammo(id, CSW_UMP45, bpammo - temp1)
  580.  
  581. set_pdata_int(ent, 54, 0, 4)
  582.  
  583. fInReload = 0
  584. }
  585.  
  586. return HAM_IGNORED
  587. }
  588.  
  589. public fw_Weapon_Reload(ent)
  590. {
  591. static id; id = pev(ent, pev_owner)
  592.  
  593. if(!is_user_alive(id))
  594. return HAM_IGNORED
  595.  
  596. if(!Get_BitVar(g_HasGun, id))
  597. return HAM_IGNORED
  598.  
  599. if(g_Janus3_Mode[id] == JANUS3_JANUS)
  600. return HAM_SUPERCEDE
  601.  
  602. g_Janus3_Clip[id] = -1
  603.  
  604. static BPAmmo; BPAmmo = cs_get_user_bpammo(id, CSW_UMP45)
  605. static iClip; iClip = get_pdata_int(ent, 51, 4)
  606.  
  607. if(BPAmmo <= 0)
  608. return HAM_SUPERCEDE
  609. if(iClip >= get_pcvar_num(g_Cvars[5]))
  610. return HAM_SUPERCEDE
  611.  
  612. g_Janus3_Clip[id] = iClip
  613.  
  614. return HAM_HANDLED
  615. }
  616.  
  617. public fw_Weapon_Reload_Post(ent)
  618. {
  619. static id; id = pev(ent, pev_owner)
  620. if(!is_user_alive(id))
  621. return HAM_IGNORED
  622. if(!Get_BitVar(g_HasGun, id))
  623. return HAM_IGNORED
  624.  
  625. if(g_Janus3_Mode[id] == JANUS3_JANUS)
  626. return HAM_SUPERCEDE
  627.  
  628. if((get_pdata_int(ent, 54, 4) == 1))
  629. {
  630. if(g_Janus3_Clip[id] == -1)
  631. return HAM_IGNORED
  632.  
  633. set_pdata_int(ent, 51, g_Janus3_Clip[id], 4)
  634.  
  635. if(g_Janus3_Mode[id] == JANUS3_NORMAL) set_weapon_anim(id, J3_ANIM_RELOAD)
  636. else if(g_Janus3_Mode[id] == JANUS3_ACTIVE) set_weapon_anim(id, J3_ANIM_RELOAD_ACTIVE)
  637.  
  638. }
  639.  
  640. return HAM_HANDLED
  641. }
  642.  
  643. public fw_TraceAttack_World(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
  644. {
  645. if(!is_user_connected(Attacker))
  646. return HAM_IGNORED
  647. if(get_user_weapon(Attacker) != CSW_UMP45 || !Get_BitVar(g_HasGun, Attacker))
  648. return HAM_IGNORED
  649.  
  650. static Float:flEnd[3], Float:vecPlane[3]
  651.  
  652. get_tr2(Ptr, TR_vecEndPos, flEnd)
  653. get_tr2(Ptr, TR_vecPlaneNormal, vecPlane)
  654.  
  655. Make_BulletHole(Attacker, flEnd, Damage)
  656. Make_BulletSmoke(Attacker, Ptr)
  657.  
  658. SetHamParamFloat(3, g_Janus3_Mode[Attacker] == JANUS3_JANUS ? float(get_pcvar_num(g_Cvars[1])) : float(get_pcvar_num(g_Cvars[0])))
  659.  
  660. if(g_Janus3_Mode[Attacker] == JANUS3_NORMAL)
  661. {
  662. g_BulletCount[Attacker]++
  663. CheckCharge(Attacker)
  664. }
  665.  
  666. return HAM_IGNORED
  667. }
  668.  
  669. public fw_TraceAttack_Player(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
  670. {
  671. if(!is_user_connected(Attacker))
  672. return HAM_IGNORED
  673. if(get_user_weapon(Attacker) != CSW_UMP45 || !Get_BitVar(g_HasGun, Attacker))
  674. return HAM_IGNORED
  675.  
  676. SetHamParamFloat(3, g_Janus3_Mode[Attacker] == JANUS3_JANUS ? float(get_pcvar_num(g_Cvars[1])) : float(get_pcvar_num(g_Cvars[0])))
  677. if(cs_get_user_team(Attacker) != cs_get_user_team(Victim) && g_Janus3_Mode[Attacker] == JANUS3_NORMAL)
  678. {
  679. g_BulletCount[Attacker]++
  680. CheckCharge(Attacker)
  681. }
  682.  
  683. return HAM_IGNORED
  684. }
  685.  
  686. public CheckCharge(id)
  687. {
  688. if(g_BulletCount[id] >= get_pcvar_num(g_Cvars[2]))
  689. {
  690. g_Janus3_Mode[id] = JANUS3_ACTIVE
  691.  
  692. set_weapon_anim(id, J3_ANIM_IDLE_ACTIVE)
  693.  
  694. emit_sound(id, CHAN_VOICE, Janus3_Sounds[2], 1.0, ATTN_NORM, 0, PITCH_NORM)
  695.  
  696. g_BulletCount[id] = 0
  697.  
  698. remove_task(id+TASK_CHANGELIMITTIME)
  699. set_task(float(get_pcvar_num(g_Cvars[3])), "TurnOff_JTS", id+TASK_CHANGELIMITTIME)
  700. }
  701. }
  702.  
  703. public TurnOff_JTS(id)
  704. {
  705. id -= TASK_CHANGELIMITTIME
  706. if(!is_user_alive(id))
  707. return
  708.  
  709. g_Janus3_Mode[id] = JANUS3_NORMAL
  710. g_BulletCount[id] = 0
  711.  
  712. set_weapon_anim(id, J3_ANIM_IDLE)
  713. }
  714.  
  715. public message_DeathMsg(msg_id, msg_dest, id)
  716. {
  717. static szTruncatedWeapon[33], iAttacker, iVictim;
  718. get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  719.  
  720. iAttacker = get_msg_arg_int(1);
  721. iVictim = get_msg_arg_int(2);
  722.  
  723. if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  724. return PLUGIN_CONTINUE;
  725.  
  726. if(equal(szTruncatedWeapon, "ump45") && get_user_weapon(iAttacker) == CSW_UMP45)
  727. if(Get_BitVar(g_HasGun, iAttacker))
  728. set_msg_arg_string(4, "Janus-3");
  729.  
  730. return PLUGIN_CONTINUE;
  731. }
  732.  
  733. stock Eject_Shell(id, Shell_ModelIndex, Float:Time) // By Dias
  734. {
  735. static Ent; Ent = get_pdata_cbase(id, 373, 5)
  736. if(!pev_valid(Ent))
  737. return
  738.  
  739. set_pdata_int(Ent, 57, Shell_ModelIndex, 4)
  740. set_pdata_float(id, 111, get_gametime() + Time)
  741. }
  742.  
  743. stock Drop_Weapon(id, slot)
  744. {
  745. if(!(1 <= slot <= 2))
  746. return 0;
  747.  
  748. static iCount; iCount = 0;
  749. static iEntity; iEntity = get_pdata_cbase(id, (367 + slot), 5);
  750.  
  751. if(iEntity > 0)
  752. {
  753. static iNext;
  754. static szWeaponName[32];
  755.  
  756. do {
  757. iNext = get_pdata_cbase(iEntity, 42, 4);
  758.  
  759. if(get_weaponname(cs_get_weapon_id(iEntity), szWeaponName, charsmax(szWeaponName)))
  760. {
  761. engclient_cmd(id, "drop", szWeaponName);
  762. iCount++;
  763. }
  764. }
  765.  
  766. while(( iEntity = iNext) > 0);
  767. }
  768.  
  769. return iCount;
  770. }
  771.  
  772. stock set_weapon_anim(id, anim)
  773. {
  774. set_pev(id, pev_weaponanim, anim)
  775.  
  776. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
  777. write_byte(anim)
  778. write_byte(pev(id, pev_body))
  779. message_end()
  780. }
  781.  
  782. stock Make_BulletHole(id, Float:Origin[3], Float:Damage)
  783. {
  784. // Find target
  785. static Decal; Decal = random_num(41, 45)
  786. static LoopTime;
  787.  
  788. if(Damage > 100.0) LoopTime = 2
  789. else LoopTime = 1
  790.  
  791. for(new i = 0; i < LoopTime; i++)
  792. {
  793. // Put decal on "world" (a wall)
  794. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  795. write_byte(TE_WORLDDECAL)
  796. engfunc(EngFunc_WriteCoord, Origin[0])
  797. engfunc(EngFunc_WriteCoord, Origin[1])
  798. engfunc(EngFunc_WriteCoord, Origin[2])
  799. write_byte(Decal)
  800. message_end()
  801.  
  802. // Show sparcles
  803. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  804. write_byte(TE_GUNSHOTDECAL)
  805. engfunc(EngFunc_WriteCoord, Origin[0])
  806. engfunc(EngFunc_WriteCoord, Origin[1])
  807. engfunc(EngFunc_WriteCoord, Origin[2])
  808. write_short(id)
  809. write_byte(Decal)
  810. message_end()
  811. }
  812. }
  813.  
  814. stock Make_BulletSmoke(id, TrResult)
  815. {
  816. static Float:vecSrc[3], Float:vecEnd[3], TE_FLAG
  817.  
  818. get_weapon_attachment(id, vecSrc)
  819. global_get(glb_v_forward, vecEnd)
  820.  
  821. xs_vec_mul_scalar(vecEnd, 8192.0, vecEnd)
  822. xs_vec_add(vecSrc, vecEnd, vecEnd)
  823.  
  824. get_tr2(TrResult, TR_vecEndPos, vecSrc)
  825. get_tr2(TrResult, TR_vecPlaneNormal, vecEnd)
  826.  
  827. xs_vec_mul_scalar(vecEnd, 2.5, vecEnd)
  828. xs_vec_add(vecSrc, vecEnd, vecEnd)
  829.  
  830. TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  831. TE_FLAG |= TE_EXPLFLAG_NOSOUND
  832. TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  833.  
  834. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0)
  835. write_byte(TE_EXPLOSION)
  836. engfunc(EngFunc_WriteCoord, vecEnd[0])
  837. engfunc(EngFunc_WriteCoord, vecEnd[1])
  838. engfunc(EngFunc_WriteCoord, vecEnd[2] - 10.0)
  839. write_short(g_SmokePuff_SprId)
  840. write_byte(2)
  841. write_byte(50)
  842. write_byte(TE_FLAG)
  843. message_end()
  844. }
  845.  
  846. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
  847. {
  848. static Float:vfEnd[3], viEnd[3]
  849. get_user_origin(id, viEnd, 3)
  850. IVecFVec(viEnd, vfEnd)
  851.  
  852. static Float:fOrigin[3], Float:fAngle[3]
  853.  
  854. pev(id, pev_origin, fOrigin)
  855. pev(id, pev_view_ofs, fAngle)
  856.  
  857. xs_vec_add(fOrigin, fAngle, fOrigin)
  858.  
  859. static Float:fAttack[3]
  860.  
  861. xs_vec_sub(vfEnd, fOrigin, fAttack)
  862. xs_vec_sub(vfEnd, fOrigin, fAttack)
  863.  
  864. static Float:fRate
  865.  
  866. fRate = fDis / vector_length(fAttack)
  867. xs_vec_mul_scalar(fAttack, fRate, fAttack)
  868.  
  869. xs_vec_add(fOrigin, fAttack, output)
  870. }
  871.  
  872. stock Set_Player_NextAttack(id, CSWID, Float:NextTime)
  873. {
  874. static Ent; Ent = fm_get_user_weapon_entity(id, CSWID)
  875. if(!pev_valid(Ent)) return
  876.  
  877. set_pdata_float(id, 83, NextTime, 5)
  878.  
  879. set_pdata_float(Ent, 46 , NextTime, 4)
  880. set_pdata_float(Ent, 47, NextTime, 4)
  881. set_pdata_float(Ent, 48, NextTime, 4)
  882. }
  883.