Advertisement
macquid123560

Top Jailbreak | Days | Sgdrill

Mar 23rd, 2016
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 35.51 KB | None | 0 0
  1. /*
  2. ***********************************************************************
  3. ************************** WWW.ZOMBIE-MOD.RU **************************
  4. ***********************************************************************
  5. ****** The Plugins Is Made Indonesia :) || Sorry For Bad Coding *******
  6. ** My Group Community: Counter:Strike Zombie Plague Modder Indonesia **
  7. ***********************************************************************
  8. Tracer Color Const || Configuration In Cvar "sgdrill_trace_color"
  9. White = 0
  10. Red = 1
  11. Green = 2
  12. Yellow = 3
  13. Blue = 4
  14. Orange = 5
  15. Pink = 6
  16. */
  17.  
  18. #include <amxmodx>
  19. #include <engine>
  20. #include <fakemeta>
  21. #include <fakemeta_util>
  22. #include <hamsandwich>
  23. #include <cstrike>
  24. #include <xs>
  25.  
  26. #define PLUGIN "[CSO] SG-DRILL || Magnum Drill"
  27. #define VERSION "1.0"
  28. #define AUTHOR "AsepKhairulAnam@CS:ZPMI || -RequiemID- || Facebook.com/asepdwa11"
  29.  
  30. // CONFIGURATION WEAPON
  31. #define system_name     "sgdrill"
  32. #define system_base     "xm1014"
  33.  
  34. #define DRAW_TIME       1.0
  35. #define RELOAD_TIME     2.7
  36.  
  37. #define SLASH_TIME      0.7
  38. #define SLASH_DELAY_TIME    1.8
  39. #define SLASH_RADIUS        150
  40. #define SLASH_DAMAGE        500
  41. #define SLASH_KNOCKBACK_POWER   800
  42.  
  43. #define CSW_BASE        CSW_XM1014
  44. #define WEAPON_KEY      11092002
  45.  
  46. #define ANIMEXT         "m249"
  47. #define ANIMEXT_SLASH       "knife"
  48.  
  49. // ALL MACRO
  50. #define ENG_NULLENT     -1
  51. #define EV_INT_WEAPONKEY    EV_INT_impulse
  52.  
  53. #define USE_STOPPED         0
  54. #define OFFSET_LINUX_WEAPONS    4
  55. #define OFFSET_LINUX        5
  56. #define OFFSET_WEAPONOWNER  41
  57. #define OFFSET_ACTIVE_ITEM  373
  58.  
  59. #define m_fKnown        44
  60. #define m_flNextPrimaryAttack   46
  61. #define m_flTimeWeaponIdle  48
  62. #define m_iClip         51
  63. #define m_fInReload     54
  64. #define m_flNextAttack      83
  65.  
  66. // ALL ANIM
  67. #define ANIM_SHOOT1     1
  68. #define ANIM_SHOOT2     1
  69. #define ANIM_SHOOT3     1
  70. #define ANIM_SLASH      2
  71. #define ANIM_RELOAD     3
  72. #define ANIM_DRAW       4
  73.  
  74. #define TASK_SLASH      4412482
  75. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
  76.  
  77. native is_day();
  78. native get_running_day_sgdrill();
  79.  
  80. // All Models Of The Weapon
  81. new V_MODEL[64] = "models/Top/JB/Days/v_sgdrill.mdl"
  82. new W_MODEL[64] = "models/Top/JB/Days/w_sgdrill.mdl"
  83. new P_MODEL[64] = "models/Top/JB/Days/p_sgdrill.mdl"
  84. new P_MODEL_SLASH[64] = "models/Top/JB/Days/p_sgdrill_slash.mdl"
  85.  
  86. // You Can Add Fire Sound Here
  87. new const Fire_Sounds[][] = { "weapons/sgdrill-1.wav", "weapons/sgdrill_slash.wav" }
  88.  
  89. // All Vars Here
  90. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
  91. new cvar_dmg, cvar_recoil, cvar_clip, cvar_spd, cvar_ammo, cvar_color_trace
  92. new g_MaxPlayers, g_orig_event, g_IsInPrimaryAttack, g_attack_type[33], Float:cl_pushangle[33][3], g_temp_slash_attack[33]
  93. new g_has_weapon[33], g_clip_ammo[33], g_weapon_TmpClip[33], oldweap[33], g_InTempingAttack[33]
  94.  
  95. // Macros Again :v
  96. new weapon_name_buffer[512]
  97. new weapon_base_buffer[512]
  98.        
  99. const PRIMARY_WEAPONS_BIT_SUM =
  100. (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<<
  101. 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)
  102. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
  103.             "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
  104.             "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  105.             "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  106.             "weapon_ak47", "weapon_knife", "weapon_p90" }
  107.  
  108. // START TO CREATE PLUGINS || AMXMODX FORWARD
  109. public plugin_init()
  110. {
  111.     formatex(weapon_name_buffer, sizeof(weapon_name_buffer), "weapon_%s_asep", system_name)
  112.     formatex(weapon_base_buffer, sizeof(weapon_base_buffer), "weapon_%s", system_base)
  113.    
  114.     register_plugin(PLUGIN, VERSION, AUTHOR)
  115.    
  116.     // Event And Message
  117.     register_event("CurWeapon", "Forward_CurrentWeapon", "be", "1=1")
  118.     register_message(get_user_msgid("DeathMsg"), "Forward_DeathMsg")
  119.    
  120.     // Ham Forward (Entity) || Ham_Use
  121.     RegisterHam(Ham_Use, "func_tank", "Forward_UseStationary_Post", 1)
  122.     RegisterHam(Ham_Use, "func_tankmortar", "Forward_UseStationary_Post", 1)
  123.     RegisterHam(Ham_Use, "func_tankrocket", "Forward_UseStationary_Post", 1)
  124.     RegisterHam(Ham_Use, "func_tanklaser", "Forward_UseStationary_Post", 1)
  125.    
  126.     // Ham Forward (Entity) || Ham_TraceAttack
  127.     RegisterHam(Ham_TraceAttack, "func_door", "Forward_TraceAttack", 1)
  128.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "Forward_TraceAttack", 1)
  129.     RegisterHam(Ham_TraceAttack, "func_plat", "Forward_TraceAttack", 1)
  130.     RegisterHam(Ham_TraceAttack, "func_rotating", "Forward_TraceAttack", 1)
  131.     RegisterHam(Ham_TraceAttack, "func_breakable", "Forward_TraceAttack", 1)
  132.     RegisterHam(Ham_TraceAttack, "func_wall", "Forward_TraceAttack", 1)
  133.     RegisterHam(Ham_TraceAttack, "worldspawn", "Forward_TraceAttack", 1)
  134.    
  135.     // Ham Forward (Weapon)
  136.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_base_buffer, "Weapon_PrimaryAttack")
  137.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_base_buffer, "Weapon_PrimaryAttack_Post", 1)
  138.     RegisterHam(Ham_Item_PostFrame, weapon_base_buffer, "Weapon_ItemPostFrame")
  139.     RegisterHam(Ham_Weapon_Reload, weapon_base_buffer, "Weapon_Reload")
  140.     RegisterHam(Ham_Weapon_Reload, weapon_base_buffer, "Weapon_Reload_Post", 1)
  141.     RegisterHam(Ham_Item_AddToPlayer, weapon_base_buffer, "Weapon_AddToPlayer")
  142.    
  143.     for(new i = 1; i < sizeof WEAPONENTNAMES; i++)
  144.         if(WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "Weapon_Deploy_Post", 1)
  145.        
  146.     // Ham Forward (Player)
  147.     RegisterHam(Ham_TakeDamage, "player", "Forward_TakeDamage")
  148.     RegisterHam(Ham_TakeDamage, "func_breakable", "Forward_TakeDamage")
  149.     RegisterHam(Ham_Killed, "player", "Forward_PlayerKilled")
  150.    
  151.     // Fakemeta Forward
  152.     register_forward(FM_SetModel, "Forward_SetModel")
  153.     register_forward(FM_UpdateClientData, "Forward_UpdateClientData_Post", 1)
  154.     register_forward(FM_PlaybackEvent, "Forward_PlaybackEvent")
  155.     register_forward(FM_EmitSound, "Forward_Emitsound")
  156.     register_forward(FM_TraceLine, "Forward_Traceline")
  157.     register_forward(FM_TraceHull, "Forward_Tracehull")
  158.    
  159.     // All Some Cvar
  160.     cvar_clip = register_cvar("sgdrill_clip", "35")
  161.     cvar_spd = register_cvar("sgdrill_speed", "0.8")
  162.     cvar_ammo = register_cvar("sgdrill_ammo", "254")
  163.     cvar_dmg = register_cvar("sgdrill_damage", "1.5")
  164.     cvar_recoil = register_cvar("sgdrill_recoil", "1.0")
  165.     cvar_color_trace = register_cvar("sgdrill_trace_color", "5")
  166.    
  167.     g_MaxPlayers = get_maxplayers()
  168. }
  169.  
  170. public plugin_precache()
  171. {
  172.     formatex(weapon_name_buffer, sizeof(weapon_name_buffer), "weapon_%s_asep", system_name)
  173.     formatex(weapon_base_buffer, sizeof(weapon_base_buffer), "weapon_%s", system_base)
  174.    
  175.     new Buffer[512]
  176.     precache_model(V_MODEL)                                                                                
  177.     precache_model(P_MODEL)
  178.     precache_model(W_MODEL)
  179.     precache_model(P_MODEL_SLASH)
  180.    
  181.     formatex(Buffer, sizeof(Buffer), "sprites/%s.txt", weapon_name_buffer)
  182.     precache_generic(Buffer) // EG: Output "sprites/weapon_sgdrill_asep.txt"
  183.    
  184.     precache_model("sprites/640hud140.spr")
  185.     precache_model("sprites/640hud17.spr")
  186.    
  187.     for(new i = 0; i < sizeof Fire_Sounds; i++)
  188.         precache_sound(Fire_Sounds[i]) 
  189.    
  190.     precache_viewmodel_sound(V_MODEL)
  191.    
  192.     formatex(Buffer, sizeof(Buffer), "test_%s", system_name)
  193.     register_clcmd(Buffer, "give_item") // EG: Output "test_sgdrill"
  194.     register_clcmd(weapon_name_buffer, "weapon_hook")
  195.    
  196.     register_forward(FM_PrecacheEvent, "Forward_PrecacheEvent_Post", 1)
  197. }
  198.  
  199. public plugin_natives()
  200. {
  201.     new Buffer[512]
  202.     formatex(Buffer, sizeof(Buffer), "give_item")
  203.     register_native(Buffer, "give_item", 1) // EG: Output "give_item"
  204.     formatex(Buffer, sizeof(Buffer), "remove_item")
  205.     register_native(Buffer, "remove_item", 1) // EG: Output "remove_item"
  206.     register_native( "give_sgdrill", "_give_sgdrill" );
  207.     register_native( "remove_sgdrill", "_remove_sgdrill" );
  208. }
  209.  
  210. // Reset Bitvar (Fix Bug) If You Connect Or Disconnect Server
  211. public client_connect(id) remove_item(id)
  212. public client_disconnect(id) remove_item(id)
  213. /* ========= START OF REGISTER HAM TO SUPPORT BOTS FUNC ========= */
  214. new g_HamBot
  215. public client_putinserver(id)
  216. {
  217.     if(!g_HamBot && is_user_bot(id))
  218.     {
  219.         g_HamBot = 1
  220.         set_task(0.1, "Do_RegisterHam", id)
  221.     }
  222. }
  223.  
  224. public _give_sgdrill( plugin, params )
  225. {
  226.     new client = get_param( 1 );
  227.    
  228.     if( is_day() && get_running_day_sgdrill() )
  229.         give_item( client )
  230. }
  231.  
  232. public _remove_sgdrill( plugin, params )
  233.     return remove_item( get_param( 1 ) );
  234.  
  235. public Do_RegisterHam(id)
  236. {
  237.     RegisterHamFromEntity(Ham_TakeDamage, id, "Forward_TakeDamage")
  238.     RegisterHamFromEntity(Ham_Killed, id, "Forward_PlayerKilled")  
  239. }
  240. /* ======== END OF REGISTER HAM TO SUPPORT BOTS FUNC ============= */
  241. /* ============ START OF ALL FORWARD (FAKEMETA) ================== */
  242. public Forward_PrecacheEvent_Post(type, const name[])
  243. {
  244.     new Buffer[512]
  245.     formatex(Buffer, sizeof(Buffer), "events/%s.sc", system_base)
  246.     if(equal(Buffer, name, 0))
  247.     {
  248.         g_orig_event = get_orig_retval()
  249.         return FMRES_HANDLED
  250.     }
  251.     return FMRES_IGNORED
  252. }
  253.  
  254. public Forward_SetModel(entity, model[])
  255. {
  256.     if(!is_valid_ent(entity))
  257.         return FMRES_IGNORED
  258.    
  259.     static szClassName[33]
  260.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  261.        
  262.     if(!equal(szClassName, "weaponbox"))
  263.         return FMRES_IGNORED
  264.    
  265.     static iOwner
  266.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  267.    
  268.     new Buffer[512]
  269.     formatex(Buffer, sizeof(Buffer), "models/w_%s.mdl", system_base)
  270.    
  271.     if(equal(model, Buffer))
  272.     {
  273.         static iStoredAugID
  274.        
  275.         iStoredAugID = find_ent_by_owner(ENG_NULLENT, weapon_base_buffer, entity)
  276.    
  277.         if(!is_valid_ent(iStoredAugID))
  278.             return FMRES_IGNORED
  279.    
  280.         if(g_has_weapon[iOwner])
  281.         {
  282.             entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, WEAPON_KEY)
  283.             remove_item(iOwner)
  284.             entity_set_model(entity, W_MODEL)
  285.            
  286.             return FMRES_SUPERCEDE
  287.         }
  288.     }
  289.     return FMRES_IGNORED
  290. }
  291.  
  292. public Forward_UseStationary_Post(entity, caller, activator, use_type)
  293. {
  294.     if(use_type == USE_STOPPED && is_user_connected(caller))
  295.         replace_weapon_models(caller, get_user_weapon(caller))
  296. }
  297.  
  298. public Forward_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  299. {
  300.     if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_BASE || !g_has_weapon[Player]))
  301.         return FMRES_IGNORED
  302.    
  303.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  304.     return FMRES_HANDLED
  305. }
  306.  
  307. public Forward_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  308. {
  309.     if ((eventid != g_orig_event) || !g_IsInPrimaryAttack)
  310.         return FMRES_IGNORED
  311.     if (!(1 <= invoker <= g_MaxPlayers))
  312.         return FMRES_IGNORED
  313.  
  314.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  315.     return FMRES_SUPERCEDE
  316. }
  317.  
  318. public Forward_TakeDamage(victim, inflictor, attacker, Float:damage)
  319. {
  320.     if(victim != attacker && is_user_connected(attacker))
  321.     {
  322.         if(get_user_weapon(attacker) == CSW_BASE)
  323.         {
  324.             if(g_has_weapon[attacker])
  325.             {
  326.                 SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg))
  327.                 set_hudmessage(255, 0, 0, -1.0, 0.46, 0, 0.2, 0.2)
  328.                 show_hudmessage(attacker, "\        /^n^n/         \")
  329.                        
  330.                 // Effect Like CSO || I Think Haha..
  331.                 // \           /    (Like This)
  332.                 //   +       (Crosshair Default)
  333.                 // /            \   (If Enemy TakeDamage Or Entity To BreakAble)
  334.             }
  335.         }
  336.     }
  337. }
  338.  
  339. public Forward_Emitsound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
  340. {
  341.     if(!is_user_alive(id) || !is_user_connected(id))
  342.         return FMRES_IGNORED
  343.     if(!g_has_weapon[id] || !g_InTempingAttack[id])
  344.         return FMRES_IGNORED
  345.        
  346.     if(sample[8] == 'k' && sample[9] == 'n' && sample[10] == 'i')
  347.     {
  348.         if(sample[14] == 's' && sample[15] == 'l' && sample[16] == 'a')
  349.             return FMRES_SUPERCEDE
  350.         if (sample[14] == 'h' && sample[15] == 'i' && sample[16] == 't')
  351.         {
  352.             if (sample[17] == 'w')  return FMRES_SUPERCEDE
  353.             else  return FMRES_SUPERCEDE
  354.         }
  355.         if (sample[14] == 's' && sample[15] == 't' && sample[16] == 'a')
  356.             return FMRES_SUPERCEDE;
  357.     }
  358.    
  359.     return FMRES_IGNORED
  360. }
  361.  
  362. public Forward_Traceline(Float:vector_start[3], Float:vector_end[3], ignored_monster, id, handle)
  363. {
  364.     if(!is_user_alive(id) || !is_user_connected(id))
  365.         return FMRES_IGNORED
  366.     if(!g_InTempingAttack[id])
  367.         return FMRES_IGNORED
  368.    
  369.     static Float:vecStart[3], Float:vecEnd[3], Float:v_angle[3], Float:v_forward[3], Float:view_ofs[3], Float:fOrigin[3]
  370.    
  371.     pev(id, pev_origin, fOrigin)
  372.     pev(id, pev_view_ofs, view_ofs)
  373.     xs_vec_add(fOrigin, view_ofs, vecStart)
  374.     pev(id, pev_v_angle, v_angle)
  375.    
  376.     engfunc(EngFunc_MakeVectors, v_angle)
  377.     get_global_vector(GL_v_forward, v_forward)
  378.  
  379.     xs_vec_mul_scalar(v_forward, 0.0, v_forward)
  380.     xs_vec_add(vecStart, v_forward, vecEnd)
  381.    
  382.     engfunc(EngFunc_TraceLine, vecStart, vecEnd, ignored_monster, id, handle)
  383.    
  384.     return FMRES_SUPERCEDE
  385. }
  386.  
  387. public Forward_Tracehull(Float:vector_start[3], Float:vector_end[3], ignored_monster, hull, id, handle)
  388. {
  389.     if(!is_user_alive(id) || !is_user_connected(id))
  390.         return FMRES_IGNORED
  391.     if(!g_InTempingAttack[id])
  392.         return FMRES_IGNORED
  393.    
  394.     static Float:vecStart[3], Float:vecEnd[3], Float:v_angle[3], Float:v_forward[3], Float:view_ofs[3], Float:fOrigin[3]
  395.    
  396.     pev(id, pev_origin, fOrigin)
  397.     pev(id, pev_view_ofs, view_ofs)
  398.     xs_vec_add(fOrigin, view_ofs, vecStart)
  399.     pev(id, pev_v_angle, v_angle)
  400.    
  401.     engfunc(EngFunc_MakeVectors, v_angle)
  402.     get_global_vector(GL_v_forward, v_forward)
  403.    
  404.     xs_vec_mul_scalar(v_forward, 0.0, v_forward)
  405.     xs_vec_add(vecStart, v_forward, vecEnd)
  406.    
  407.     engfunc(EngFunc_TraceHull, vecStart, vecEnd, ignored_monster, hull, id, handle)
  408.    
  409.     return FMRES_SUPERCEDE
  410. }
  411. /* ================= END OF ALL FAKEMETA FORWARD ================= */
  412. /* ================= START OF ALL MESSAGE FORWARD ================ */
  413. public Forward_CurrentWeapon(id)
  414. {
  415.     replace_weapon_models(id, read_data(2))
  416.    
  417.     if(!is_user_alive(id))
  418.         return
  419.    
  420.     if(read_data(2) != CSW_BASE || !g_has_weapon[id])
  421.         return
  422.    
  423.     static Float:Speed
  424.     if(g_has_weapon[id] && !cs_get_user_zoom(id))
  425.         Speed = get_pcvar_float(cvar_spd)
  426.     else if(g_has_weapon[id] && cs_get_user_zoom(id))
  427.         Speed = get_pcvar_float(cvar_spd)*2
  428.        
  429.     static weapon[32], Ent
  430.     get_weaponname(read_data(2), weapon, 31)
  431.     Ent = find_ent_by_owner(-1, weapon, id)
  432.     if(pev_valid(Ent))
  433.     {
  434.         static Float:Delay
  435.         Delay = get_pdata_float(Ent, 46, 4) * Speed
  436.         if(Delay > 0.0) set_pdata_float(Ent, 46, Delay, 4)
  437.     }
  438. }
  439. /* ================== END OF ALL MESSAGE FORWARD ================ */
  440. /* ================== START OF ALL EVENT FORWARD ================ */
  441. public Forward_DeathMsg(msg_id, msg_dest, id)
  442. {
  443.     static szTruncatedWeapon[33], iAttacker, iVictim
  444.    
  445.     get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  446.    
  447.     iAttacker = get_msg_arg_int(1)
  448.     iVictim = get_msg_arg_int(2)
  449.    
  450.     if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  451.         return PLUGIN_CONTINUE
  452.    
  453.     if(equal(szTruncatedWeapon, system_base) || equal(szTruncatedWeapon, "knife") && get_user_weapon(iAttacker) == CSW_BASE)
  454.     {
  455.         if(g_has_weapon[iAttacker])
  456.             set_msg_arg_string(4, system_name)
  457.     }
  458.     return PLUGIN_CONTINUE
  459. }
  460. /* ================== END OF ALL EVENT FORWARD =================== */
  461. /* ================== START OF ALL HAM FORWARD ============== */
  462. public Forward_PlayerKilled(id) remove_item(id)
  463. public Forward_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  464. {
  465.     if(!is_user_alive(iAttacker))
  466.         return
  467.        
  468.     new g_currentweapon = get_user_weapon(iAttacker)
  469.     if(g_currentweapon != CSW_BASE || !g_has_weapon[iAttacker])
  470.         return
  471.  
  472.     static Float:flEnd[3], Float:WallVector[3]
  473.     get_tr2(ptr, TR_vecEndPos, flEnd)
  474.     get_tr2(ptr, TR_vecPlaneNormal, WallVector)
  475.    
  476.     if(iEnt)
  477.     {
  478.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  479.         write_byte(TE_DECAL)
  480.         write_coord_f(flEnd[0])
  481.         write_coord_f(flEnd[1])
  482.         write_coord_f(flEnd[2])
  483.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  484.         write_short(iEnt)
  485.         message_end()
  486.     }
  487.     else
  488.     {
  489.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  490.         write_byte(TE_WORLDDECAL)
  491.         write_coord_f(flEnd[0])
  492.         write_coord_f(flEnd[1])
  493.         write_coord_f(flEnd[2])
  494.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  495.         message_end()
  496.     }
  497.    
  498.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  499.     write_byte(TE_GUNSHOTDECAL)
  500.     write_coord_f(flEnd[0])
  501.     write_coord_f(flEnd[1])
  502.     write_coord_f(flEnd[2])
  503.     write_short(iAttacker)
  504.     write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  505.     message_end()
  506.  
  507.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  508.     write_byte(TE_STREAK_SPLASH)
  509.     engfunc(EngFunc_WriteCoord, flEnd[0])
  510.     engfunc(EngFunc_WriteCoord, flEnd[1])
  511.     engfunc(EngFunc_WriteCoord, flEnd[2])
  512.     engfunc(EngFunc_WriteCoord, WallVector[0] * random_float(25.0,30.0))
  513.     engfunc(EngFunc_WriteCoord, WallVector[1] * random_float(25.0,30.0))
  514.     engfunc(EngFunc_WriteCoord, WallVector[2] * random_float(25.0,30.0))
  515.     write_byte(get_pcvar_num(cvar_color_trace))
  516.     write_short(12)
  517.     write_short(3)
  518.     write_short(75)
  519.     message_end()
  520. }
  521.  
  522. public Weapon_Deploy_Post(weapon_entity)
  523. {
  524.     static owner
  525.     owner = fm_cs_get_weapon_ent_owner(weapon_entity)
  526.    
  527.     static weaponid
  528.     weaponid = cs_get_weapon_id(weapon_entity)
  529.    
  530.     replace_weapon_models(owner, weaponid)
  531. }
  532.  
  533. public Weapon_AddToPlayer(weapon_entity, id)
  534. {
  535.     if(!is_valid_ent(weapon_entity) || !is_user_connected(id))
  536.         return HAM_IGNORED
  537.    
  538.     if(entity_get_int(weapon_entity, EV_INT_WEAPONKEY) == WEAPON_KEY)
  539.     {
  540.         g_has_weapon[id] = true
  541.         entity_set_int(weapon_entity, EV_INT_WEAPONKEY, 0)
  542.         set_weapon_list(id, weapon_name_buffer, CSW_BASE)
  543.        
  544.         return HAM_HANDLED
  545.     }
  546.     else
  547.     {
  548.         set_weapon_list(id, weapon_base_buffer, CSW_BASE)
  549.     }
  550.    
  551.     return HAM_IGNORED
  552. }
  553.  
  554. public Weapon_PrimaryAttack(weapon_entity)
  555. {
  556.     new Player = get_pdata_cbase(weapon_entity, 41, 4)
  557.    
  558.     if(!g_has_weapon[Player])
  559.         return
  560.    
  561.     g_IsInPrimaryAttack = 1
  562.     pev(Player,pev_punchangle,cl_pushangle[Player])
  563.    
  564.     g_clip_ammo[Player] = cs_get_weapon_ammo(weapon_entity)
  565. }
  566.  
  567. public Weapon_PrimaryAttack_Post(weapon_entity)
  568. {
  569.     g_IsInPrimaryAttack = 0
  570.     new Player = get_pdata_cbase(weapon_entity, 41, 4)
  571.    
  572.     new szClip, szAmmo
  573.     get_user_weapon(Player, szClip, szAmmo)
  574.    
  575.     if(!is_user_alive(Player))
  576.         return
  577.        
  578.     if(g_has_weapon[Player])
  579.     {
  580.         if(!g_clip_ammo[Player])
  581.             return
  582.  
  583.         new Float:push[3]
  584.         pev(Player,pev_punchangle,push)
  585.         xs_vec_sub(push,cl_pushangle[Player],push)
  586.         xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil),push)
  587.        
  588.         xs_vec_add(push,cl_pushangle[Player],push)
  589.         set_pev(Player,pev_punchangle,push)
  590.        
  591.         emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  592.         if(!g_attack_type[Player])
  593.         {
  594.             static random_number
  595.             random_number = random_num(0,1)
  596.             if(!random_number) set_weapon_anim(Player, ANIM_SHOOT1)
  597.             else set_weapon_anim(Player, ANIM_SHOOT3)
  598.            
  599.             g_attack_type[Player] = 1
  600.         }
  601.         else
  602.         {
  603.             set_weapon_anim(Player, ANIM_SHOOT2)
  604.             g_attack_type[Player] = 0
  605.         }
  606.     }
  607. }
  608.  
  609. public Weapon_ItemPostFrame(weapon_entity)
  610. {
  611.     new id = pev(weapon_entity, pev_owner)
  612.     if(!is_user_connected(id))
  613.         return HAM_IGNORED
  614.  
  615.     if(!g_has_weapon[id])
  616.         return HAM_IGNORED
  617.  
  618.     static iClipExtra
  619.    
  620.     iClipExtra = get_pcvar_num(cvar_clip)
  621.     new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX)
  622.  
  623.     new iBpAmmo = cs_get_user_bpammo(id, CSW_BASE)
  624.     new iClip = get_pdata_int(weapon_entity, m_iClip, OFFSET_LINUX_WEAPONS)
  625.  
  626.     new fInReload = get_pdata_int(weapon_entity, m_fInReload, OFFSET_LINUX_WEAPONS)
  627.     if(fInReload && flNextAttack <= 0.0)
  628.     {
  629.         new j = min(iClipExtra - iClip, iBpAmmo)
  630.    
  631.         set_pdata_int(weapon_entity, m_iClip, iClip + j, OFFSET_LINUX_WEAPONS)
  632.         cs_set_user_bpammo(id, CSW_BASE, iBpAmmo-j)
  633.        
  634.         set_pdata_int(weapon_entity, m_fInReload, 0, OFFSET_LINUX_WEAPONS)
  635.         fInReload = 0
  636.     }
  637.     else if(!fInReload && !get_pdata_int(weapon_entity, 74, 4))
  638.     {
  639.         if(get_pdata_float(weapon_entity, 47, 4) <= 0.0 || get_pdata_float(weapon_entity, 48, 4) <= 8.066)
  640.         {
  641.             if(pev(id, pev_button) & IN_ATTACK2 && !g_temp_slash_attack[id])
  642.             {
  643.                 remove_task(id+TASK_SLASH)
  644.                 g_temp_slash_attack[id] = 1
  645.                
  646.                 create_fake_attack(id)
  647.                 set_weapon_anim(id, ANIM_SLASH)
  648.                 emit_sound(id, CHAN_WEAPON, Fire_Sounds[1], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  649.                
  650.                 set_pev(id, pev_weaponmodel2, P_MODEL_SLASH)
  651.                 set_task(SLASH_TIME, "Slash_Attack", id+TASK_SLASH)
  652.                
  653.                 set_player_nextattackx(id, SLASH_DELAY_TIME)
  654.                 set_weapons_timeidle(id, CSW_BASE, SLASH_DELAY_TIME)
  655.             }
  656.         }
  657.     }
  658.    
  659.     return HAM_IGNORED
  660. }
  661.  
  662. public Weapon_Reload(weapon_entity)
  663. {
  664.     new id = pev(weapon_entity, pev_owner)
  665.     if(!is_user_connected(id))
  666.         return HAM_IGNORED
  667.     if(!g_has_weapon[id])
  668.         return HAM_IGNORED
  669.  
  670.     static iClipExtra
  671.     if(g_has_weapon[id])
  672.         iClipExtra = get_pcvar_num(cvar_clip)
  673.  
  674.     g_weapon_TmpClip[id] = -1
  675.  
  676.     new iBpAmmo = cs_get_user_bpammo(id, CSW_BASE)
  677.     new iClip = get_pdata_int(weapon_entity, m_iClip, OFFSET_LINUX_WEAPONS)
  678.  
  679.     if(iBpAmmo <= 0)
  680.         return HAM_SUPERCEDE
  681.  
  682.     if(iClip >= iClipExtra)
  683.         return HAM_SUPERCEDE
  684.  
  685.     g_weapon_TmpClip[id] = iClip
  686.  
  687.     return HAM_IGNORED
  688. }
  689.  
  690. public Weapon_Reload_Post(weapon_entity)
  691. {
  692.     new id = pev(weapon_entity, pev_owner)
  693.     if (!is_user_connected(id))
  694.         return HAM_IGNORED
  695.  
  696.     if(!g_has_weapon[id])
  697.         return HAM_IGNORED
  698.     if(g_weapon_TmpClip[id] == -1)
  699.         return HAM_IGNORED
  700.    
  701.     remove_task(id+TASK_SLASH)
  702.     g_temp_slash_attack[id] = 0
  703.    
  704.     set_pdata_int(weapon_entity, m_iClip, g_weapon_TmpClip[id], OFFSET_LINUX_WEAPONS)
  705.     set_pdata_float(weapon_entity, m_flTimeWeaponIdle, RELOAD_TIME, OFFSET_LINUX_WEAPONS)
  706.     set_pdata_float(id, m_flNextAttack, RELOAD_TIME, OFFSET_LINUX)
  707.     set_pdata_int(weapon_entity, m_fInReload, 1, OFFSET_LINUX_WEAPONS)
  708.    
  709.     set_weapon_anim(id, ANIM_RELOAD)
  710.     set_pdata_string(id, (492) * 4, ANIMEXT, -1 , 20)
  711.    
  712.     return HAM_IGNORED
  713. }
  714.  
  715. /* ===================== END OF ALL HAM FORWARD ====================== */
  716. /* ================= START OF OTHER PUBLIC FUNCTION  ================= */
  717. public give_item(id)
  718. {  
  719.     drop_weapons(id, 1)
  720.     new iWeapon = fm_give_item(id, weapon_base_buffer)
  721.     if(iWeapon > 0)
  722.     {
  723.         cs_set_weapon_ammo(iWeapon, get_pcvar_num(cvar_clip))
  724.         cs_set_user_bpammo(id, CSW_BASE, get_pcvar_num(cvar_ammo))
  725.         emit_sound(id, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM,0,PITCH_NORM)
  726.        
  727.         set_weapon_anim(id, ANIM_DRAW)
  728.         set_pdata_float(id, m_flNextAttack, DRAW_TIME, OFFSET_LINUX)
  729.  
  730.         set_weapon_list(id, weapon_name_buffer, CSW_BASE)
  731.         set_pdata_string(id, (492) * 4, ANIMEXT, -1 , 20)
  732.     }
  733.    
  734.     g_has_weapon[id] = true
  735.     g_attack_type[id] = 0
  736.     g_temp_slash_attack[id] = 0
  737. }
  738.  
  739. public remove_item(id)
  740. {
  741.     g_has_weapon[id] = false
  742.     g_attack_type[id] = 0
  743.     g_temp_slash_attack[id] = 0
  744.    
  745.     return 0;
  746. }
  747.  
  748. public weapon_hook(id)
  749. {
  750.     engclient_cmd(id, weapon_base_buffer)
  751.     return PLUGIN_HANDLED
  752. }
  753.  
  754. public Slash_Attack(id)
  755. {
  756.     id -= TASK_SLASH
  757.    
  758.     if(!is_user_alive(id) || !is_user_connected(id))
  759.         return
  760.     if(!g_temp_slash_attack[id])
  761.         return
  762.        
  763.     for(new Target = 0; Target < get_maxplayers(); Target++)
  764.     {
  765.         if(!is_user_alive(Target))
  766.             continue
  767.        
  768.         // Shake Screen :v
  769.         message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, id)
  770.         write_short((1<<12) * 4)
  771.         write_short((1<<12) * 1)
  772.         write_short((1<<12) * 4)
  773.         message_end()
  774.        
  775.         if(cs_get_user_team(Target) == cs_get_user_team(id))
  776.             continue
  777.         if(id == Target)
  778.             continue
  779.         if(entity_range(id, Target) > float(SLASH_RADIUS))
  780.             continue
  781.        
  782.         new Float:VicOrigin[3], Float:MyOrigin[3]
  783.         pev(Target, pev_origin, VicOrigin)
  784.         pev(id, pev_origin, MyOrigin)
  785.        
  786.         if(!is_in_viewcone(id, VicOrigin, 1))
  787.             continue
  788.         if(is_wall_between_points(MyOrigin, VicOrigin, id))
  789.             continue
  790.        
  791.         do_attack(id, Target, 0, float(SLASH_DAMAGE))
  792.         set_hook_entity(Target, MyOrigin, float(SLASH_KNOCKBACK_POWER), 2)
  793.     }
  794.    
  795.     set_pev(id, pev_weaponmodel2, P_MODEL)
  796.     set_pdata_string(id, (492) * 4, ANIMEXT, -1 , 20)
  797.    
  798.     g_temp_slash_attack[id] = 0
  799. }
  800.  
  801. public create_fake_attack(id)
  802. {
  803.     static Ent
  804.     Ent = fm_get_user_weapon_entity(id, CSW_KNIFE)
  805.    
  806.     if(!pev_valid(Ent))
  807.         return
  808.    
  809.     g_InTempingAttack[id] = 1
  810.     ExecuteHamB(Ham_Weapon_PrimaryAttack, Ent)
  811.    
  812.     static iAnimDesired,  szAnimation[64]
  813.     formatex(szAnimation, charsmax(szAnimation), (pev(id, pev_flags) & FL_DUCKING) ? "crouch_shoot_%s" : "ref_shoot_%s", ANIMEXT_SLASH)
  814.     if((iAnimDesired = lookup_sequence(id, szAnimation)) == -1)
  815.         iAnimDesired = 0
  816.        
  817.     set_pev(id, pev_sequence, iAnimDesired)
  818.     g_InTempingAttack[id] = 0
  819. }
  820.  
  821. public replace_weapon_models(id, weaponid)
  822. {
  823.     remove_task(id+TASK_SLASH)
  824.     g_temp_slash_attack[id] = 0
  825.    
  826.     switch(weaponid)
  827.     {
  828.         case CSW_BASE:
  829.         {
  830.             if(g_has_weapon[id])
  831.             {
  832.                 set_pev(id, pev_viewmodel2, V_MODEL)
  833.                 set_pev(id, pev_weaponmodel2, P_MODEL)
  834.                
  835.                 if(oldweap[id] != CSW_BASE)
  836.                 {
  837.                     set_weapon_anim(id, ANIM_DRAW)
  838.                     set_player_nextattackx(id, DRAW_TIME)
  839.                     set_weapons_timeidle(id, CSW_BASE, DRAW_TIME)
  840.                     set_weapon_list(id, weapon_name_buffer, CSW_BASE)
  841.                    
  842.                     set_pdata_string(id, (492) * 4, ANIMEXT, -1 , 20)
  843.                 }
  844.             }
  845.         }
  846.     }
  847.    
  848.     oldweap[id] = weaponid
  849. }
  850.  
  851. /* ============= END OF OTHER PUBLIC FUNCTION (Weapon) ============= */
  852. /* ================= START OF ALL STOCK TO MACROS ================== */
  853. stock set_weapon_list(id, const weapon_namee[], const CSW_NAMEE)
  854. {
  855.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0,0,0}, id)
  856.     write_string(weapon_namee)
  857.     write_byte(5)
  858.     write_byte(32)
  859.     write_byte(-1)
  860.     write_byte(-1)
  861.     write_byte(0)
  862.     write_byte(12)
  863.     write_byte(CSW_NAMEE)
  864.     write_byte(0)
  865.     message_end()
  866. }
  867.  
  868. stock set_hook_entity(ent, Float:VicOrigin[3], Float:speed, type)
  869. {
  870.     static Float:fl_Velocity[3]
  871.     static Float:EntOrigin[3]
  872.    
  873.     pev(ent, pev_origin, EntOrigin)
  874.     static Float:distance_f
  875.     distance_f = get_distance_f(EntOrigin, VicOrigin)
  876.    
  877.     new Float:fl_Time = distance_f / speed
  878.    
  879.     if(type == 1)
  880.     {
  881.         fl_Velocity[0] = ((VicOrigin[0] - EntOrigin[0]) / fl_Time)
  882.         fl_Velocity[1] = ((VicOrigin[1] - EntOrigin[1]) / fl_Time)
  883.         fl_Velocity[2] = ((VicOrigin[2] - EntOrigin[2]) / fl_Time) + random_float(200.0, 300.0)
  884.     } else if(type == 2) {
  885.         fl_Velocity[0] = ((EntOrigin[0] - VicOrigin[0]) / fl_Time)
  886.         fl_Velocity[1] = ((EntOrigin[1] - VicOrigin[1]) / fl_Time)
  887.         fl_Velocity[2] = ((EntOrigin[2] - VicOrigin[2]) / fl_Time) + random_float(200.0, 300.0)
  888.     }
  889.  
  890.     set_pev(ent, pev_velocity, fl_Velocity)
  891. }
  892.  
  893. stock drop_weapons(id, dropwhat)
  894. {
  895.     static weapons[32], num = 0, i, weaponid
  896.     get_user_weapons(id, weapons, num)
  897.    
  898.     for (i = 0; i < num; i++)
  899.     {
  900.         weaponid = weapons[i]
  901.          
  902.         if(dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
  903.         {
  904.             static wname[32]
  905.             get_weaponname(weaponid, wname, sizeof wname - 1)
  906.             engclient_cmd(id, "drop", wname)
  907.         }
  908.     }
  909. }
  910. stock set_player_nextattackx(id, Float:nexttime)
  911. {
  912.     if(!is_user_alive(id))
  913.         return
  914.        
  915.     set_pdata_float(id, m_flNextAttack, nexttime, 5)
  916. }
  917.  
  918. stock set_weapons_timeidle(id, WeaponId ,Float:TimeIdle)
  919. {
  920.     if(!is_user_alive(id))
  921.         return
  922.        
  923.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
  924.     if(!pev_valid(entwpn))
  925.         return
  926.        
  927.     set_pdata_float(entwpn, 46, TimeIdle, OFFSET_LINUX_WEAPONS)
  928.     set_pdata_float(entwpn, 47, TimeIdle, OFFSET_LINUX_WEAPONS)
  929.     set_pdata_float(entwpn, 48, TimeIdle + 1.0, OFFSET_LINUX_WEAPONS)
  930. }
  931.  
  932. stock set_weapons_timeidlex(id, Float:TimeIdle, Float:Idle)
  933. {
  934.     new entwpn = fm_get_user_weapon_entity(id, CSW_BASE)
  935.     if(!pev_valid(entwpn))
  936.         return
  937.    
  938.     set_pdata_float(entwpn, 46, TimeIdle, 4)
  939.     set_pdata_float(entwpn, 47, TimeIdle, 4)
  940.     set_pdata_float(entwpn, 48, Idle, 4)
  941. }
  942.  
  943. stock set_weapon_anim(const Player, const Sequence)
  944. {
  945.     set_pev(Player, pev_weaponanim, Sequence)
  946.    
  947.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  948.     write_byte(Sequence)
  949.     write_byte(pev(Player, pev_body))
  950.     message_end()
  951. }
  952.  
  953. stock precache_viewmodel_sound(const model[]) // I Get This From BTE
  954. {
  955.     new file, i, k
  956.     if((file = fopen(model, "rt")))
  957.     {
  958.         new szsoundpath[64], NumSeq, SeqID, Event, NumEvents, EventID
  959.         fseek(file, 164, SEEK_SET)
  960.         fread(file, NumSeq, BLOCK_INT)
  961.         fread(file, SeqID, BLOCK_INT)
  962.        
  963.         for(i = 0; i < NumSeq; i++)
  964.         {
  965.             fseek(file, SeqID + 48 + 176 * i, SEEK_SET)
  966.             fread(file, NumEvents, BLOCK_INT)
  967.             fread(file, EventID, BLOCK_INT)
  968.             fseek(file, EventID + 176 * i, SEEK_SET)
  969.            
  970.             // The Output Is All Sound To Precache In ViewModels (GREAT :V)
  971.             for(k = 0; k < NumEvents; k++)
  972.             {
  973.                 fseek(file, EventID + 4 + 76 * k, SEEK_SET)
  974.                 fread(file, Event, BLOCK_INT)
  975.                 fseek(file, 4, SEEK_CUR)
  976.                
  977.                 if(Event != 5004)
  978.                     continue
  979.                
  980.                 fread_blocks(file, szsoundpath, 64, BLOCK_CHAR)
  981.                
  982.                 if(strlen(szsoundpath))
  983.                 {
  984.                     strtolower(szsoundpath)
  985.                     engfunc(EngFunc_PrecacheSound, szsoundpath)
  986.                 }
  987.             }
  988.         }
  989.     }
  990.     fclose(file)
  991. }
  992.  
  993. stock fm_cs_get_weapon_ent_owner(ent)
  994. {
  995.     return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
  996. }
  997.  
  998. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
  999. {
  1000.     static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  1001.    
  1002.     pev(id, pev_origin, vOrigin)
  1003.     pev(id, pev_view_ofs, vUp) //for player
  1004.     xs_vec_add(vOrigin, vUp, vOrigin)
  1005.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
  1006.    
  1007.     angle_vector(vAngle, ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
  1008.     angle_vector(vAngle, ANGLEVECTOR_RIGHT, vRight)
  1009.     angle_vector(vAngle, ANGLEVECTOR_UP, vUp)
  1010.    
  1011.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  1012.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  1013.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  1014. }
  1015.  
  1016. stock do_attack(Attacker, Victim, Inflictor, Float:fDamage)
  1017. {
  1018.     fake_player_trace_attack(Attacker, Victim, fDamage)
  1019.     fake_take_damage(Attacker, Victim, fDamage, Inflictor)
  1020. }
  1021.  
  1022. stock fake_player_trace_attack(iAttacker, iVictim, &Float:fDamage)
  1023. {
  1024.     // get fDirection
  1025.     new Float:fAngles[3], Float:fDirection[3]
  1026.     pev(iAttacker, pev_angles, fAngles)
  1027.     angle_vector(fAngles, ANGLEVECTOR_FORWARD, fDirection)
  1028.    
  1029.     // get fStart
  1030.     new Float:fStart[3], Float:fViewOfs[3]
  1031.     pev(iAttacker, pev_origin, fStart)
  1032.     pev(iAttacker, pev_view_ofs, fViewOfs)
  1033.     xs_vec_add(fViewOfs, fStart, fStart)
  1034.    
  1035.     // get aimOrigin
  1036.     new iAimOrigin[3], Float:fAimOrigin[3]
  1037.     get_user_origin(iAttacker, iAimOrigin, 3)
  1038.     IVecFVec(iAimOrigin, fAimOrigin)
  1039.    
  1040.     // TraceLine from fStart to AimOrigin
  1041.     new ptr = create_tr2()
  1042.     engfunc(EngFunc_TraceLine, fStart, fAimOrigin, DONT_IGNORE_MONSTERS, iAttacker, ptr)
  1043.     new pHit = get_tr2(ptr, TR_pHit)
  1044.     new iHitgroup = get_tr2(ptr, TR_iHitgroup)
  1045.     new Float:fEndPos[3]
  1046.     get_tr2(ptr, TR_vecEndPos, fEndPos)
  1047.  
  1048.     // get target & body at aiming
  1049.     new iTarget, iBody
  1050.     get_user_aiming(iAttacker, iTarget, iBody)
  1051.    
  1052.     // if aiming find target is iVictim then update iHitgroup
  1053.     if(iTarget == iVictim)
  1054.         iHitgroup = iBody
  1055.    
  1056.     // if ptr find target not is iVictim
  1057.     else if (pHit != iVictim)
  1058.     {
  1059.         // get AimOrigin in iVictim
  1060.         new Float:fVicOrigin[3], Float:fVicViewOfs[3], Float:fAimInVictim[3]
  1061.         pev(iVictim, pev_origin, fVicOrigin)
  1062.         pev(iVictim, pev_view_ofs, fVicViewOfs)
  1063.         xs_vec_add(fVicViewOfs, fVicOrigin, fAimInVictim)
  1064.         fAimInVictim[2] = fStart[2]
  1065.         fAimInVictim[2] += get_distance_f(fStart, fAimInVictim) * floattan( fAngles[0] * 2.0, degrees )
  1066.        
  1067.         // check aim in size of iVictim
  1068.         new iAngleToVictim = get_angle_to_target(iAttacker, fVicOrigin)
  1069.         iAngleToVictim = abs(iAngleToVictim)
  1070.         new Float:fDis = 2.0 * get_distance_f(fStart, fAimInVictim) * floatsin( float(iAngleToVictim) * 0.5, degrees )
  1071.         new Float:fVicSize[3]
  1072.         pev(iVictim, pev_size , fVicSize)
  1073.         if ( fDis <= fVicSize[0] * 0.5 )
  1074.         {
  1075.             // TraceLine from fStart to aimOrigin in iVictim
  1076.             new ptr2 = create_tr2()
  1077.             engfunc(EngFunc_TraceLine, fStart, fAimInVictim, DONT_IGNORE_MONSTERS, iAttacker, ptr2)
  1078.             new pHit2 = get_tr2(ptr2, TR_pHit)
  1079.             new iHitgroup2 = get_tr2(ptr2, TR_iHitgroup)
  1080.            
  1081.             // if ptr2 find target is iVictim
  1082.             if ( pHit2 == iVictim && (iHitgroup2 != HIT_HEAD || fDis <= fVicSize[0] * 0.25) )
  1083.             {
  1084.                 pHit = iVictim
  1085.                 iHitgroup = iHitgroup2
  1086.                 get_tr2(ptr2, TR_vecEndPos, fEndPos)
  1087.             }
  1088.            
  1089.             free_tr2(ptr2)
  1090.         }
  1091.        
  1092.         // if pHit still not is iVictim then set default HitGroup
  1093.         if (pHit != iVictim)
  1094.         {
  1095.             // set default iHitgroup
  1096.             iHitgroup = HIT_GENERIC
  1097.            
  1098.             new ptr3 = create_tr2()
  1099.             engfunc(EngFunc_TraceLine, fStart, fVicOrigin, DONT_IGNORE_MONSTERS, iAttacker, ptr3)
  1100.             get_tr2(ptr3, TR_vecEndPos, fEndPos)
  1101.            
  1102.             // free ptr3
  1103.             free_tr2(ptr3)
  1104.         }
  1105.     }
  1106.    
  1107.     // set new Hit & Hitgroup & EndPos
  1108.     set_tr2(ptr, TR_pHit, iVictim)
  1109.     set_tr2(ptr, TR_iHitgroup, iHitgroup)
  1110.     set_tr2(ptr, TR_vecEndPos, fEndPos)
  1111.    
  1112.     // hitgroup multi fDamage
  1113.     new Float:fMultifDamage
  1114.     switch(iHitgroup)
  1115.     {
  1116.         case HIT_HEAD: fMultifDamage  = 4.0
  1117.         case HIT_STOMACH: fMultifDamage  = 1.25
  1118.         case HIT_LEFTLEG: fMultifDamage  = 0.75
  1119.         case HIT_RIGHTLEG: fMultifDamage  = 0.75
  1120.         default: fMultifDamage  = 1.0
  1121.     }
  1122.    
  1123.     fDamage *= fMultifDamage
  1124.    
  1125.     // ExecuteHam
  1126.     fake_trake_attack(iAttacker, iVictim, fDamage, fDirection, ptr)
  1127.    
  1128.     // free ptr
  1129.     free_tr2(ptr)
  1130. }
  1131.  
  1132. stock fake_trake_attack(iAttacker, iVictim, Float:fDamage, Float:fDirection[3], iTraceHandle, iDamageBit = (DMG_NEVERGIB | DMG_BULLET))
  1133. {
  1134.     ExecuteHamB(Ham_TraceAttack, iVictim, iAttacker, fDamage, fDirection, iTraceHandle, iDamageBit)
  1135. }
  1136.  
  1137. stock fake_take_damage(iAttacker, iVictim, Float:fDamage, iInflictor = 0, iDamageBit = (DMG_NEVERGIB | DMG_BULLET))
  1138. {
  1139.     iInflictor = (!iInflictor) ? iAttacker : iInflictor
  1140.     ExecuteHamB(Ham_TakeDamage, iVictim, iInflictor, iAttacker, fDamage, iDamageBit)
  1141. }
  1142.  
  1143. stock is_wall_between_points(Float:start[3], Float:end[3], ignore_ent)
  1144. {
  1145.     static ptr
  1146.     ptr = create_tr2()
  1147.  
  1148.     engfunc(EngFunc_TraceLine, start, end, IGNORE_MONSTERS, ignore_ent, ptr)
  1149.    
  1150.     static Float:EndPos[3]
  1151.     get_tr2(ptr, TR_vecEndPos, EndPos)
  1152.  
  1153.     free_tr2(ptr)
  1154.     return floatround(get_distance_f(end, EndPos))
  1155. }
  1156.  
  1157. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
  1158. {
  1159.     static Float:vfEnd[3], viEnd[3]
  1160.     get_user_origin(id, viEnd, 3)  
  1161.     IVecFVec(viEnd, vfEnd)
  1162.    
  1163.     static Float:fOrigin[3], Float:fAngle[3]
  1164.    
  1165.     pev(id, pev_origin, fOrigin)
  1166.     pev(id, pev_view_ofs, fAngle)
  1167.    
  1168.     xs_vec_add(fOrigin, fAngle, fOrigin)
  1169.    
  1170.     static Float:fAttack[3]
  1171.    
  1172.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  1173.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  1174.    
  1175.     static Float:fRate
  1176.    
  1177.     fRate = fDis / vector_length(fAttack)
  1178.     xs_vec_mul_scalar(fAttack, fRate, fAttack)
  1179.    
  1180.     xs_vec_add(fOrigin, fAttack, output)
  1181. }
  1182.  
  1183. stock get_angle_to_target(id, const Float:fTarget[3], Float:TargetSize = 0.0)
  1184. {
  1185.     static Float:fOrigin[3], iAimOrigin[3], Float:fAimOrigin[3], Float:fV1[3]
  1186.     pev(id, pev_origin, fOrigin)
  1187.     get_user_origin(id, iAimOrigin, 3) // end position from eyes
  1188.     IVecFVec(iAimOrigin, fAimOrigin)
  1189.     xs_vec_sub(fAimOrigin, fOrigin, fV1)
  1190.    
  1191.     static Float:fV2[3]
  1192.     xs_vec_sub(fTarget, fOrigin, fV2)
  1193.    
  1194.     static iResult; iResult = get_angle_between_vectors(fV1, fV2)
  1195.    
  1196.     if (TargetSize > 0.0)
  1197.     {
  1198.         static Float:fTan; fTan = TargetSize / get_distance_f(fOrigin, fTarget)
  1199.         static fAngleToTargetSize; fAngleToTargetSize = floatround( floatatan(fTan, degrees) )
  1200.         iResult -= (iResult > 0) ? fAngleToTargetSize : -fAngleToTargetSize
  1201.     }
  1202.    
  1203.     return iResult
  1204. }
  1205.  
  1206. stock get_angle_between_vectors(const Float:fV1[3], const Float:fV2[3])
  1207. {
  1208.     static Float:fA1[3], Float:fA2[3]
  1209.     engfunc(EngFunc_VecToAngles, fV1, fA1)
  1210.     engfunc(EngFunc_VecToAngles, fV2, fA2)
  1211.    
  1212.     static iResult; iResult = floatround(fA1[1] - fA2[1])
  1213.     iResult = iResult % 360
  1214.     iResult = (iResult > 180) ? (iResult - 360) : iResult
  1215.    
  1216.     return iResult
  1217. }
  1218.  
  1219. /* ================= END OF ALL STOCK AND PLUGINS CREATED ================== */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement