Advertisement
macquid123560

Top Jailbreak | Days | Throwing Knifes

Mar 23rd, 2016
844
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 23.17 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta>
  4. #include <fakemeta_util>
  5. #include <hamsandwich>
  6. #include <cstrike>
  7. #include <fun>
  8.  
  9. #define PLUGIN "Tactical Knife"
  10. #define VERSION "1.0"
  11. #define AUTHOR "m4m3ts"
  12.  
  13. #define CSW_TACT CSW_P228
  14. #define weapon_tact "weapon_p228"
  15. #define old_event "events/p228.sc"
  16. #define old_w_model "models/w_p228.mdl"
  17. #define WEAPON_SECRETCODE 4234238
  18.  
  19.  
  20. #define TASK_STABING    999999999999999
  21. #define RELOAD_TIME 0.435
  22. #define STAB_TIME 1.1
  23. #define ATTACK_TIME 1.0
  24. #define SYSTEM_CLASSNAME "Triple Tactical Knife"
  25. #define SYSTEM_CLASSNAME2 "Triple Tactical Knife2"
  26. #define WEAPON_ANIMEXT "grenade"
  27.  
  28. const PDATA_SAFE = 2
  29. const OFFSET_LINUX_WEAPONS = 4
  30. const OFFSET_WEAPONOWNER = 41
  31. const m_flNextAttack = 83
  32. const m_szAnimExtention = 492
  33.  
  34. new const v_model[] = "models/Top/JB/Days/v_tknifeex2.mdl"
  35. new const p_model[] = "models/Top/JB/Days/p_tknifeex2.mdl"
  36. new const w_model[] = "models/Top/JB/Days/w_tknifeex2.mdl"
  37. new const ARROW_MODEL[] = "models/Top/JB/Days/tknifeb.mdl"
  38. new const tact_wall[][] = {"weapons/tknife_stone11.wav", "weapons/tknife_stone21.wav"}
  39. new const weapon_sound[6][] =
  40. {
  41.     "weapons/tknife_shoot11.wav",
  42.     "weapons/tknifeex2_shoot11.wav",
  43.     "weapons/tknifeex2_draw1.wav",
  44.     "weapons/tact_hit1.wav",
  45.     "weapons/knife_hit21.wav",
  46.     "weapons/knife_hit31.wav"
  47. }
  48.  
  49.  
  50. new const WeaponResource[4][] =
  51. {
  52.     "sprites/weapon_tknifeex2.txt",
  53.     "sprites/640hud12.spr",
  54.     "sprites/640hud96.spr",
  55.     "sprites/640hud97.spr"
  56. }
  57.  
  58. enum
  59. {
  60.     ANIM_IDLE = 0,
  61.     ANIM_SHOOT,
  62.     ANIM_DRAW,
  63.     ANIM_SHOOT2
  64. }
  65.  
  66. new g_MsgDeathMsg
  67.  
  68. new g_had_tact[33], g_tact_ammo[33], g_Shoot_Count[33]
  69. new g_old_weapon[33], m_iBlood[2]
  70. new sTrail, cvar_dmg_slash_tact, cvar_dmg_stab_tact, cvar_ammo_tactical
  71.  
  72. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
  73.  
  74.  
  75. native is_day();
  76. native get_running_day_throwing_knifes();
  77.  
  78. native is_lr_active();
  79. native is_user_lr( index );
  80.  
  81.  
  82. public plugin_init()
  83. {
  84.     register_plugin(PLUGIN, VERSION, AUTHOR)
  85.     register_cvar("tact_version", "m4m3ts", FCVAR_SERVER|FCVAR_SPONLY)
  86.     register_forward(FM_CmdStart, "fw_CmdStart")
  87.     register_forward(FM_SetModel, "fw_SetModel")
  88.     register_think(SYSTEM_CLASSNAME, "fw_Think")
  89.     register_think(SYSTEM_CLASSNAME2, "fw_Think")
  90.     register_touch(SYSTEM_CLASSNAME, "*", "fw_touch")
  91.     register_touch(SYSTEM_CLASSNAME2, "*", "fw_touch2")
  92.     register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
  93.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)   
  94.     RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  95.     RegisterHam(Ham_Item_AddToPlayer, weapon_tact, "fw_AddToPlayer_Post", 1)
  96.     register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
  97.    
  98.     register_clcmd("weapon_tknifeex2", "hook_weapon")
  99.    
  100.     cvar_dmg_slash_tact = register_cvar( "tactical_dmg_slash", "45.0" )
  101.     cvar_dmg_stab_tact = register_cvar( "tactical_dmg_stab", "100.0" )
  102.     cvar_ammo_tactical = register_cvar( "tactical_ammo", "255")
  103.    
  104.     g_MsgDeathMsg = get_user_msgid("DeathMsg")
  105. }
  106.  
  107.  
  108. public plugin_natives()
  109. {
  110.     register_native( "give_tactical", "_give_tact" );
  111.     register_native( "remove_tactical", "remove_tact_native" );
  112. }
  113.  
  114. public _give_tact( plugin, params )
  115. {
  116.     new client = get_param( 1 );
  117.    
  118.     if( is_day() && get_running_day_throwing_knifes() || is_lr_active() && is_user_lr( client ) )
  119.         get_tact( client );
  120. }
  121.  
  122. public remove_tact_native( plugin, params )
  123.     return remove_tact( get_param( 1 ) );
  124.  
  125.    
  126. public plugin_precache()
  127. {
  128.     precache_model(v_model)
  129.     precache_model(p_model)
  130.     precache_model(w_model)
  131.     precache_model(ARROW_MODEL)
  132.    
  133.     for(new i = 0; i < sizeof(weapon_sound); i++)
  134.         precache_sound(weapon_sound[i])
  135.    
  136.     for(new i = 0; i < sizeof(tact_wall); i++)
  137.         precache_sound(tact_wall[i])
  138.    
  139.     precache_generic(WeaponResource[0])
  140.     for(new i = 1; i < sizeof(WeaponResource); i++)
  141.         precache_model(WeaponResource[i])
  142.    
  143.     m_iBlood[0] = precache_model("sprites/blood.spr")
  144.     m_iBlood[1] = precache_model("sprites/bloodspray.spr")
  145.     sTrail = precache_model("sprites/laserbeam.spr")
  146. }
  147.  
  148. public fw_PlayerKilled(id)
  149. {
  150.     remove_tact(id)
  151. }
  152.  
  153. public hook_weapon(id)
  154. {
  155.     engclient_cmd(id, weapon_tact)
  156.     return
  157. }
  158.  
  159. public get_tact(id)
  160. {
  161.     if(!is_user_alive(id))
  162.         return
  163.     remove_task(id+TASK_STABING)
  164.     drop_weapons(id, 1)
  165.     g_had_tact[id] = 1
  166.     g_tact_ammo[id] = get_pcvar_num(cvar_ammo_tactical)
  167.    
  168.     give_item(id, weapon_tact)
  169.    
  170.     static weapon_ent; weapon_ent = fm_find_ent_by_owner(-1, weapon_tact, id)
  171.     if(pev_valid(weapon_ent)) cs_set_weapon_ammo(weapon_ent, 1)
  172. }
  173.  
  174. public remove_tact(id)
  175. {
  176.     remove_task(id+TASK_STABING)
  177.     g_had_tact[id] = 0
  178.     g_tact_ammo[id] = 0
  179.    
  180.     return 0;
  181. }
  182.    
  183. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  184. {
  185.     if(!is_user_alive(id) || !is_user_connected(id))
  186.         return FMRES_IGNORED   
  187.     if(get_user_weapon(id) == CSW_TACT && g_had_tact[id])
  188.         set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  189.    
  190.     return FMRES_HANDLED
  191. }
  192.  
  193. public Event_CurWeapon(id)
  194. {
  195.     if(!is_user_alive(id))
  196.         return
  197.        
  198.     if(get_user_weapon(id) == CSW_TACT && g_had_tact[id])
  199.     {
  200.         set_pev(id, pev_viewmodel2, v_model)
  201.         set_pev(id, pev_weaponmodel2, p_model)
  202.         set_pdata_string(id, m_szAnimExtention * 4, WEAPON_ANIMEXT, -1 , 20)
  203.         set_weapon_anim(id, ANIM_DRAW)
  204.         update_ammo(id)
  205.     }
  206.    
  207.     g_old_weapon[id] = get_user_weapon(id)
  208. }
  209.  
  210. public fw_CmdStart(id, uc_handle, seed)
  211. {
  212.     if(!is_user_alive(id) || !is_user_connected(id))
  213.         return
  214.     if(get_user_weapon(id) != CSW_TACT || !g_had_tact[id])
  215.         return
  216.    
  217.     static ent; ent = fm_get_user_weapon_entity(id, CSW_TACT)
  218.     if(!pev_valid(ent))
  219.         return
  220.     if(get_pdata_float(ent, 46, OFFSET_LINUX_WEAPONS) > 0.0 || get_pdata_float(ent, 47, OFFSET_LINUX_WEAPONS) > 0.0)
  221.         return
  222.    
  223.     static CurButton
  224.     CurButton = get_uc(uc_handle, UC_Buttons)
  225.    
  226.     if(CurButton & IN_ATTACK)
  227.     {
  228.         CurButton &= ~IN_ATTACK
  229.         set_uc(uc_handle, UC_Buttons, CurButton)
  230.        
  231.         if(g_tact_ammo[id] == 0)
  232.             return
  233.         if(get_pdata_float(id, 83, 5) <= 0.0)
  234.         {
  235.             g_tact_ammo[id]--
  236.             g_Shoot_Count[id] = 0
  237.             update_ammo(id)
  238.             set_task(0.2, "throw_knife", id)
  239.             set_weapon_anim(id, ANIM_SHOOT)
  240.             set_weapons_timeidle(id, CSW_TACT, ATTACK_TIME)
  241.             set_player_nextattackx(id, ATTACK_TIME)
  242.         }
  243.     }
  244.     else if(CurButton & IN_ATTACK2)
  245.     {
  246.         if(get_pdata_float(id, 83, 5) <= 0.0)
  247.         {
  248.             set_weapon_anim(id, ANIM_SHOOT2)
  249.             FireArrow_Charge(id)
  250.             emit_sound(id, CHAN_VOICE, weapon_sound[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
  251.             set_weapons_timeidle(id, CSW_TACT, STAB_TIME)
  252.             set_player_nextattackx(id, STAB_TIME)
  253.         }
  254.     }
  255. }
  256.  
  257. public throw_knife(id)
  258. {
  259.     FireArrow1(id)
  260.     FireArrow2(id)
  261.     FireArrow3(id)
  262. }
  263.  
  264. public FireArrow1(id)
  265. {
  266.     static Float:StartOrigin[3], Float:TargetOrigin[3], Float:angles[3], Float:anglestrue[3]
  267.     get_position(id, 2.0, 4.0, -3.0, StartOrigin)
  268.  
  269.     pev(id,pev_v_angle,angles)
  270.     static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  271.     if(!pev_valid(Ent)) return
  272.     anglestrue[0] = 180.0 - angles[0]
  273.     anglestrue[1] = angles[1]
  274.     anglestrue[2] = angles[2]
  275.    
  276.     // Set info for ent
  277.     set_pev(Ent, pev_movetype, MOVETYPE_TOSS)
  278.     set_pev(Ent, pev_owner, id) // Better than pev_owner
  279.     set_pev(Ent, pev_fuser1, get_gametime() + 4.0)
  280.     set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
  281.    
  282.     entity_set_string(Ent, EV_SZ_classname, SYSTEM_CLASSNAME)
  283.     engfunc(EngFunc_SetModel, Ent, ARROW_MODEL)
  284.     set_pev(Ent, pev_mins, Float:{-0.1, -0.1, -0.1})
  285.     set_pev(Ent, pev_maxs, Float:{0.1, 0.1, 0.1})
  286.     set_pev(Ent, pev_origin, StartOrigin)
  287.     set_pev(Ent, pev_angles, anglestrue)
  288.     set_pev(Ent, pev_gravity, 0.5)
  289.     set_pev(Ent, pev_solid, SOLID_BBOX)
  290.     set_pev(Ent, pev_frame, 0.0)
  291.    
  292.     static Float:Velocity[3]
  293.     get_position(id, 1024.0, 12.0, -12.0, TargetOrigin)
  294.     get_speed_vector(StartOrigin, TargetOrigin, 2300.0, Velocity)
  295.     set_pev(Ent, pev_velocity, Velocity)
  296.  
  297.    
  298.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  299.     write_byte(TE_BEAMFOLLOW) // Temporary entity ID
  300.     write_short(Ent) // Entity
  301.     write_short(sTrail) // Sprite index
  302.     write_byte(7) // Life
  303.     write_byte(1) // Line width
  304.     write_byte(255) // Red
  305.     write_byte(255) // Green
  306.     write_byte(255) // Blue
  307.     write_byte(65) // Alpha
  308.     message_end()
  309. }
  310.  
  311. public FireArrow2(id)
  312. {
  313.     static Float:StartOrigin[3], Float:TargetOrigin[3], Float:angles[3], Float:anglestrue[3]
  314.     get_position(id, 2.0, -4.0, -2.0, StartOrigin)
  315.  
  316.     pev(id,pev_v_angle,angles)
  317.     static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  318.     if(!pev_valid(Ent)) return
  319.     anglestrue[0] = 180.0 - angles[0]
  320.     anglestrue[1] = angles[1]
  321.     anglestrue[2] = angles[2]
  322.    
  323.     // Set info for ent
  324.     set_pev(Ent, pev_movetype, MOVETYPE_TOSS)
  325.     set_pev(Ent, pev_owner, id) // Better than pev_owner
  326.     set_pev(Ent, pev_fuser1, get_gametime() + 4.0)
  327.     set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
  328.    
  329.     entity_set_string(Ent, EV_SZ_classname, SYSTEM_CLASSNAME)
  330.     engfunc(EngFunc_SetModel, Ent, ARROW_MODEL)
  331.     set_pev(Ent, pev_mins, Float:{-0.1, -0.1, -0.1})
  332.     set_pev(Ent, pev_maxs, Float:{0.1, 0.1, 0.1})
  333.     set_pev(Ent, pev_origin, StartOrigin)
  334.     set_pev(Ent, pev_angles, anglestrue)
  335.     set_pev(Ent, pev_gravity, 0.5)
  336.     set_pev(Ent, pev_solid, SOLID_BBOX)
  337.     set_pev(Ent, pev_frame, 0.0)
  338.    
  339.     static Float:Velocity[3]
  340.     get_position(id, 1024.0, -12.0, -12.0, TargetOrigin)
  341.     get_speed_vector(StartOrigin, TargetOrigin, 2300.0, Velocity)
  342.     set_pev(Ent, pev_velocity, Velocity)
  343.  
  344.    
  345.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  346.     write_byte(TE_BEAMFOLLOW) // Temporary entity ID
  347.     write_short(Ent) // Entity
  348.     write_short(sTrail) // Sprite index
  349.     write_byte(7) // Life
  350.     write_byte(1) // Line width
  351.     write_byte(255) // Red
  352.     write_byte(255) // Green
  353.     write_byte(255) // Blue
  354.     write_byte(65) // Alpha
  355.     message_end()
  356. }
  357.  
  358. public FireArrow3(id)
  359. {
  360.     static Float:StartOrigin[3], Float:TargetOrigin[3], Float:angles[3], Float:anglestrue[3]
  361.     get_position(id, 2.0, 2.0, 4.0, StartOrigin)
  362.  
  363.     pev(id,pev_v_angle,angles)
  364.     static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  365.     if(!pev_valid(Ent)) return
  366.     anglestrue[0] = 180.0 - angles[0]
  367.     anglestrue[1] = angles[1]
  368.     anglestrue[2] = angles[2]
  369.    
  370.     // Set info for ent
  371.     set_pev(Ent, pev_movetype, MOVETYPE_TOSS)
  372.     set_pev(Ent, pev_owner, id) // Better than pev_owner
  373.     set_pev(Ent, pev_fuser1, get_gametime() + 4.0)
  374.     set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
  375.    
  376.     entity_set_string(Ent, EV_SZ_classname, SYSTEM_CLASSNAME)
  377.     engfunc(EngFunc_SetModel, Ent, ARROW_MODEL)
  378.     set_pev(Ent, pev_mins, Float:{-0.1, -0.1, -0.1})
  379.     set_pev(Ent, pev_maxs, Float:{0.1, 0.1, 0.1})
  380.     set_pev(Ent, pev_origin, StartOrigin)
  381.     set_pev(Ent, pev_angles, anglestrue)
  382.     set_pev(Ent, pev_gravity, 0.5)
  383.     set_pev(Ent, pev_solid, SOLID_BBOX)
  384.     set_pev(Ent, pev_frame, 0.0)
  385.    
  386.     static Float:Velocity[3]
  387.     get_position(id, 1024.0, 12.0, 12.0, TargetOrigin)
  388.     get_speed_vector(StartOrigin, TargetOrigin, 2300.0, Velocity)
  389.     set_pev(Ent, pev_velocity, Velocity)
  390.  
  391.    
  392.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  393.     write_byte(TE_BEAMFOLLOW) // Temporary entity ID
  394.     write_short(Ent) // Entity
  395.     write_short(sTrail) // Sprite index
  396.     write_byte(7) // Life
  397.     write_byte(1) // Line width
  398.     write_byte(255) // Red
  399.     write_byte(255) // Green
  400.     write_byte(255) // Blue
  401.     write_byte(65) // Alpha
  402.     message_end()
  403. }
  404.  
  405. public FireArrow_Charge(id)
  406. {
  407.     static Float:StartOrigin[3], Float:TargetOrigin[3], Float:angles[3]
  408.     get_position(id, 2.0, 0.0, 0.0, StartOrigin)
  409.  
  410.     pev(id,pev_angles,angles)
  411.     static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  412.     if(!pev_valid(Ent)) return
  413.    
  414.     // Set info for ent
  415.     set_pev(Ent, pev_movetype, MOVETYPE_FLY)
  416.     set_pev(Ent, pev_owner, id) // Better than pev_owner
  417.     set_pev(Ent, pev_rendermode, kRenderTransAdd)
  418.     set_pev(Ent, pev_renderamt, 1.0)
  419.     set_pev(Ent, pev_fuser1, get_gametime() + 0.1)
  420.     set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
  421.    
  422.     entity_set_string(Ent, EV_SZ_classname, SYSTEM_CLASSNAME2)
  423.     engfunc(EngFunc_SetModel, Ent, ARROW_MODEL)
  424.     set_pev(Ent, pev_mins, Float:{-0.1, -0.1, -0.1})
  425.     set_pev(Ent, pev_maxs, Float:{0.1, 0.1, 0.1})
  426.     set_pev(Ent, pev_origin, StartOrigin)
  427.     set_pev(Ent, pev_angles, angles)
  428.     set_pev(Ent, pev_gravity, 0.01)
  429.     set_pev(Ent, pev_solid, SOLID_BBOX)
  430.     set_pev(Ent, pev_frame, 0.0)
  431.    
  432.     static Float:Velocity[3]
  433.     fm_get_aim_origin(id, TargetOrigin)
  434.     get_speed_vector(StartOrigin, TargetOrigin, 800.0, Velocity)
  435.     set_pev(Ent, pev_velocity, Velocity)
  436. }
  437.  
  438. public fw_Think(ent)
  439. {
  440.     if(!pev_valid(ent))
  441.         return
  442.    
  443.     static Float:fFrame; pev(ent, pev_frame, fFrame)
  444.    
  445.     fFrame += 1.5
  446.     fFrame = floatmin(21.0, fFrame)
  447.    
  448.     set_pev(ent, pev_frame, fFrame)
  449.     set_pev(ent, pev_nextthink, get_gametime() + 0.05)
  450.    
  451.     // time remove
  452.     static Float:fTimeRemove, Float:Amount
  453.     pev(ent, pev_fuser1, fTimeRemove)
  454.     pev(ent, pev_renderamt, Amount)
  455.    
  456.     if(get_gametime() >= fTimeRemove)
  457.     {
  458.         remove_entity(ent)
  459.     }
  460. }
  461.  
  462.  
  463.  
  464. public fw_touch(Ent, Id)
  465. {
  466.     // If ent is valid
  467.     if(!pev_valid(Ent))
  468.         return
  469.     static Owner; Owner = pev(Ent, pev_owner)
  470.     if(pev(Ent, pev_movetype) == MOVETYPE_NONE)
  471.         return
  472.     static classnameptd[32]
  473.     pev(Id, pev_classname, classnameptd, 31)
  474.     if (equali(classnameptd, "func_breakable")) ExecuteHamB( Ham_TakeDamage, Id, 0, 0, 60.0, DMG_GENERIC )
  475.    
  476.     // Get it's origin
  477.     new Float:originF[3]
  478.     pev(Ent, pev_origin, originF)
  479.     // Alive...
  480.    
  481.     if(is_user_alive(Id) )
  482.     {
  483.         Damage_tact(Ent, Id)
  484.         remove_entity(Ent)
  485.         create_blood(originF)
  486.         create_blood(originF)
  487.         emit_sound(Id, CHAN_BODY, weapon_sound[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
  488.     }
  489.  
  490.     else
  491.     {
  492.         set_pev(Ent, pev_fuser1, get_gametime() + 3.0)
  493.         make_bullet(Owner, originF)
  494.         engfunc(EngFunc_EmitSound, Ent, CHAN_WEAPON, tact_wall[random( sizeof(tact_wall))], 1.0, ATTN_STATIC, 0, PITCH_NORM)
  495.         set_pev(Ent, pev_movetype, MOVETYPE_NONE)
  496.         set_pev(Ent, pev_solid, SOLID_NOT)
  497.     }
  498. }
  499.  
  500. public fw_touch2(Ent, Id)
  501. {
  502.     // If ent is valid
  503.     if(!pev_valid(Ent))
  504.         return
  505.     if(pev(Ent, pev_movetype) == MOVETYPE_NONE)
  506.         return
  507.        
  508.     static Owner; Owner = pev(Ent, pev_owner)
  509.    
  510.     static classnameptd[32]
  511.     pev(Id, pev_classname, classnameptd, 31)
  512.     if (equali(classnameptd, "func_breakable")) ExecuteHamB( Ham_TakeDamage, Id, 0, 0, 200.0, DMG_GENERIC )
  513.    
  514.     // Get it's origin
  515.     new Float:originF[3]
  516.     pev(Ent, pev_origin, originF)
  517.     // Alive...
  518.    
  519.     if(is_user_alive(Id) )
  520.     {
  521.         Damage_tact2(Ent, Id)
  522.         remove_entity(Ent)
  523.         create_blood(originF)
  524.         create_blood(originF)
  525.         emit_sound(Id, CHAN_BODY, weapon_sound[random_num(4,5)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  526.     }
  527.    
  528.     else
  529.     {
  530.         engfunc(EngFunc_EmitSound, Ent, CHAN_WEAPON, tact_wall[random( sizeof(tact_wall))], 1.0, ATTN_STATIC, 0, PITCH_NORM)
  531.         set_pev(Ent, pev_movetype, MOVETYPE_NONE)
  532.         set_pev(Ent, pev_solid, SOLID_NOT)
  533.     }
  534. }
  535.  
  536. public Damage_tact(Ent, Id)
  537. {
  538.     static Owner; Owner = pev(Ent, pev_owner)
  539.     static Attacker;
  540.     if(!is_user_alive(Owner))
  541.     {
  542.         Attacker = 0
  543.         return
  544.     } else Attacker = Owner
  545.  
  546.     new bool:bIsHeadShot; // never make that one static
  547.     new Float:flAdjustedDamage, bool:death
  548.  
  549.     switch( Get_MissileWeaponHitGroup(Ent) )
  550.     {
  551.         case HIT_GENERIC: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 1.5
  552.         case HIT_CHEST: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 1.0
  553.         case HIT_STOMACH: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 1.0
  554.         case HIT_LEFTLEG, HIT_RIGHTLEG: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 0.75
  555.         case HIT_LEFTARM, HIT_RIGHTARM: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 0.35
  556.         case HIT_HEAD:
  557.         {
  558.             flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 1.50
  559.             bIsHeadShot = true;
  560.         }
  561.     }
  562.     if(pev(Id, pev_health) <= flAdjustedDamage) death = true
  563.    
  564.     if(is_user_alive(Id))
  565.     {
  566.         if( bIsHeadShot && death)
  567.         {
  568.             emessage_begin(MSG_BROADCAST, g_MsgDeathMsg)
  569.             ewrite_byte(Attacker)
  570.             ewrite_byte(Id)
  571.             ewrite_byte(1)
  572.             ewrite_string("Triple Tactical Knife")
  573.             emessage_end()
  574.            
  575.             set_msg_block(g_MsgDeathMsg, BLOCK_SET)
  576.             user_silentkill(Id)
  577.             set_msg_block(g_MsgDeathMsg, BLOCK_NOT)
  578.  
  579.             death = false
  580.         }
  581.         else ExecuteHamB(Ham_TakeDamage, Id, Ent, Attacker, flAdjustedDamage, DMG_BULLET)
  582.     }
  583. }
  584.  
  585. public Damage_tact2(Ent, Id)
  586. {
  587.     static Owner; Owner = pev(Ent, pev_owner)
  588.     static Attacker;
  589.     if(!is_user_alive(Owner))
  590.     {
  591.         Attacker = 0
  592.         return
  593.     } else Attacker = Owner
  594.    
  595.     new bool:bIsHeadShot; // never make that one static
  596.     new Float:flAdjustedDamage, bool:death
  597.  
  598.     switch( Get_MissileWeaponHitGroup(Ent) )
  599.     {
  600.         case HIT_GENERIC: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 1.5
  601.         case HIT_CHEST: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 1.0
  602.         case HIT_STOMACH: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 1.0
  603.         case HIT_LEFTLEG, HIT_RIGHTLEG: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 0.75
  604.         case HIT_LEFTARM, HIT_RIGHTARM: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 0.35
  605.         case HIT_HEAD:
  606.         {
  607.             flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 1.50
  608.             bIsHeadShot = true;
  609.         }
  610.     }
  611.     if(pev(Id, pev_health) <= flAdjustedDamage) death = true
  612.    
  613.     if(is_user_alive(Id))
  614.     {
  615.         if( bIsHeadShot && death)
  616.         {
  617.             emessage_begin(MSG_BROADCAST, g_MsgDeathMsg)
  618.             ewrite_byte(Attacker)
  619.             ewrite_byte(Id)
  620.             ewrite_byte(1)
  621.             ewrite_string("Triple Tactical Knife")
  622.             emessage_end()
  623.            
  624.             set_msg_block(g_MsgDeathMsg, BLOCK_SET)
  625.             user_silentkill(Id)
  626.             set_msg_block(g_MsgDeathMsg, BLOCK_NOT)
  627.  
  628.             death = false
  629.         }
  630.         else ExecuteHamB(Ham_TakeDamage, Id, Ent, Attacker, flAdjustedDamage, DMG_BULLET)
  631.     }
  632. }
  633.  
  634. public fw_SetModel(entity, model[])
  635. {
  636.     if(!pev_valid(entity))
  637.         return FMRES_IGNORED
  638.    
  639.     static Classname[64]
  640.     pev(entity, pev_classname, Classname, sizeof(Classname))
  641.    
  642.     if(!equal(Classname, "weaponbox"))
  643.         return FMRES_IGNORED
  644.    
  645.     static id
  646.     id = pev(entity, pev_owner)
  647.    
  648.     if(equal(model, old_w_model))
  649.     {
  650.         static weapon
  651.         weapon = fm_get_user_weapon_entity(entity, CSW_TACT)
  652.        
  653.         if(!pev_valid(weapon))
  654.             return FMRES_IGNORED
  655.        
  656.         if(g_had_tact[id])
  657.         {
  658.             set_pev(weapon, pev_impulse, WEAPON_SECRETCODE)
  659.             set_pev(weapon, pev_iuser4, g_tact_ammo[id])
  660.             engfunc(EngFunc_SetModel, entity, w_model)
  661.            
  662.             g_had_tact[id] = 0
  663.             g_tact_ammo[id] = 0
  664.            
  665.             return FMRES_SUPERCEDE
  666.         }
  667.     }
  668.  
  669.     return FMRES_IGNORED;
  670. }
  671.  
  672. public fw_AddToPlayer_Post(ent, id)
  673. {
  674.     if(pev(ent, pev_impulse) == WEAPON_SECRETCODE)
  675.     {
  676.         g_had_tact[id] = 1
  677.         g_tact_ammo[id] = pev(ent, pev_iuser4)
  678.        
  679.         set_pev(ent, pev_impulse, 0)
  680.     }          
  681.    
  682.     message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("WeaponList"), _, id)
  683.     write_string((g_had_tact[id] == 1 ? "weapon_tknifeex2" : "weapon_p228"))
  684.     write_byte(1)
  685.     write_byte(52)
  686.     write_byte(-1)
  687.     write_byte(-1)
  688.     write_byte(1)
  689.     write_byte(3)
  690.     write_byte(CSW_TACT)
  691.     write_byte(0)
  692.     message_end()
  693. }
  694.  
  695. public update_ammo(id)
  696. {
  697.     if(!is_user_alive(id))
  698.         return
  699.    
  700.     static weapon_ent; weapon_ent = fm_find_ent_by_owner(-1, weapon_tact, id)
  701.     if(pev_valid(weapon_ent)) cs_set_weapon_ammo(weapon_ent, 1)
  702.    
  703.     cs_set_user_bpammo(id, CSW_P228, 0)
  704.    
  705.     engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, get_user_msgid("CurWeapon"), {0, 0, 0}, id)
  706.     write_byte(1)
  707.     write_byte(CSW_TACT)
  708.     write_byte(-1)
  709.     message_end()
  710.    
  711.     message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("AmmoX"), _, id)
  712.     write_byte(1)
  713.     write_byte(g_tact_ammo[id])
  714.     message_end()
  715. }
  716.  
  717. stock make_bullet(id, Float:Origin[3])
  718. {
  719.     // Find target
  720.     new decal = random_num(41, 45)
  721.     const loop_time = 2
  722.    
  723.     static Body, Target
  724.     get_user_aiming(id, Target, Body, 999999)
  725.    
  726.     if(is_user_connected(Target))
  727.         return
  728.    
  729.     for(new i = 0; i < loop_time; i++)
  730.     {
  731.         // Put decal on "world" (a wall)
  732.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  733.         write_byte(TE_WORLDDECAL)
  734.         engfunc(EngFunc_WriteCoord, Origin[0])
  735.         engfunc(EngFunc_WriteCoord, Origin[1])
  736.         engfunc(EngFunc_WriteCoord, Origin[2])
  737.         write_byte(decal)
  738.         message_end()
  739.        
  740.         // Show sparcles
  741.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  742.         write_byte(TE_GUNSHOTDECAL)
  743.         engfunc(EngFunc_WriteCoord, Origin[0])
  744.         engfunc(EngFunc_WriteCoord, Origin[1])
  745.         engfunc(EngFunc_WriteCoord, Origin[2])
  746.         write_short(id)
  747.         write_byte(decal)
  748.         message_end()
  749.     }
  750. }
  751.  
  752. stock set_weapon_anim(id, anim)
  753. {
  754.     if(!is_user_alive(id))
  755.         return
  756.    
  757.     set_pev(id, pev_weaponanim, anim)
  758.    
  759.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
  760.     write_byte(anim)
  761.     write_byte(pev(id, pev_body))
  762.     message_end()
  763. }
  764.  
  765. stock create_blood(const Float:origin[3])
  766. {
  767.     // Show some blood :)
  768.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  769.     write_byte(TE_BLOODSPRITE)
  770.     engfunc(EngFunc_WriteCoord, origin[0])
  771.     engfunc(EngFunc_WriteCoord, origin[1])
  772.     engfunc(EngFunc_WriteCoord, origin[2])
  773.     write_short(m_iBlood[1])
  774.     write_short(m_iBlood[0])
  775.     write_byte(75)
  776.     write_byte(8)
  777.     message_end()
  778. }
  779.  
  780. stock drop_weapons(id, dropwhat)
  781. {
  782.     static weapons[32], num, i, weaponid
  783.     num = 0
  784.     get_user_weapons(id, weapons, num)
  785.      
  786.     for (i = 0; i < num; i++)
  787.     {
  788.         weaponid = weapons[i]
  789.          
  790.         if (dropwhat == 1 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM))
  791.         {
  792.             static wname[32]
  793.             get_weaponname(weaponid, wname, sizeof wname - 1)
  794.             engclient_cmd(id, "drop", wname)
  795.         }
  796.     }
  797. }
  798.  
  799. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  800. {
  801.     new_velocity[0] = origin2[0] - origin1[0]
  802.     new_velocity[1] = origin2[1] - origin1[1]
  803.     new_velocity[2] = origin2[2] - origin1[2]
  804.     static Float:num; num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  805.     new_velocity[0] *= num
  806.     new_velocity[1] *= num
  807.     new_velocity[2] *= num
  808.    
  809.     return 1;
  810. }
  811.  
  812. stock Get_MissileWeaponHitGroup( iEnt )
  813. {
  814.     new Float:flStart[ 3 ], Float:flEnd[ 3 ];
  815.    
  816.     pev( iEnt, pev_origin, flStart );
  817.     pev( iEnt, pev_velocity, flEnd );
  818.     xs_vec_add( flStart, flEnd, flEnd );
  819.    
  820.     new ptr = create_tr2();
  821.     engfunc( EngFunc_TraceLine, flStart, flEnd, 0, iEnt, ptr );
  822.    
  823.     new iHitGroup
  824.     iHitGroup = get_tr2( ptr, TR_iHitgroup )
  825.     free_tr2( ptr );
  826.    
  827.     return iHitGroup;
  828. }
  829.  
  830. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
  831. {
  832.     static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  833.    
  834.     pev(id, pev_origin, vOrigin)
  835.     pev(id, pev_view_ofs, vUp) //for player
  836.     xs_vec_add(vOrigin, vUp, vOrigin)
  837.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
  838.    
  839.     angle_vector(vAngle, ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
  840.     angle_vector(vAngle, ANGLEVECTOR_RIGHT, vRight)
  841.     angle_vector(vAngle, ANGLEVECTOR_UP, vUp)
  842.    
  843.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  844.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  845.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  846. }
  847.  
  848. stock set_weapons_timeidle(id, WeaponId ,Float:TimeIdle)
  849. {
  850.     if(!is_user_alive(id))
  851.         return
  852.        
  853.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
  854.     if(!pev_valid(entwpn))
  855.         return
  856.        
  857.     set_pdata_float(entwpn, 46, TimeIdle, OFFSET_LINUX_WEAPONS)
  858.     set_pdata_float(entwpn, 47, TimeIdle, OFFSET_LINUX_WEAPONS)
  859.     set_pdata_float(entwpn, 48, TimeIdle + 0.5, OFFSET_LINUX_WEAPONS)
  860. }
  861.  
  862. stock set_player_nextattackx(id, Float:nexttime)
  863. {
  864.     if(!is_user_alive(id))
  865.         return
  866.        
  867.     set_pdata_float(id, m_flNextAttack, nexttime, 5)
  868. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement