Converted Tactical Knife / Throwing Knives!

Zombies/Humans Extra-Items
Post Reply
User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 279
Joined: 9 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

Tactical Knife / Throwing Knives!

#1

Post by Mark » 9 Months Ago

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

tact_knife.zip
(745 KiB) Downloaded 24 times
tact_knife.zip
(745 KiB) Downloaded 24 times
Last edited by Mark on 12 Oct 2018, 04:32, edited 5 times in total.
These users thanked the author Mark for the post (total 2):
Raheem (9 Months Ago) • Jack GamePlay (9 Months Ago)

Rain1153
Senior Member
Senior Member
India
Posts: 277
Joined: 1 Year Ago
Has thanked: 2 times
Been thanked: 1 time
Age: 18
Contact:

#2

Post by Rain1153 » 9 Months Ago

Extra items for human? Or human vips? U included ze_vip
LOL

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 279
Joined: 9 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#3

Post by Mark » 9 Months Ago

Rain1153 wrote:
9 Months Ago
Extra items for human? Or human vips? U included ze_vip
The only thing there was the include witch does nothing.

shady101852
Member
Member
United States of America
Posts: 27
Joined: 8 Months Ago
Has thanked: 9 times
Been thanked: 2 times
Contact:

#4

Post by shady101852 » 8 Months Ago

can this be added to the extra item menu? I tried to use it but was unable to.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 279
Joined: 9 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#5

Post by Mark » 8 Months Ago

Update 1.1 First post aswell as download.

Damage on zombies not working now fixed!

shady101852
Member
Member
United States of America
Posts: 27
Joined: 8 Months Ago
Has thanked: 9 times
Been thanked: 2 times
Contact:

#6

Post by shady101852 » 8 Months Ago

Mark wrote:
8 Months Ago
Update 1.1 First post aswell as download.

Damage on zombies not working now fixed!
works great thanks

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests