Advertisement
Guest User

M9K - shared.lua

a guest
Mar 24th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.49 KB | None | 0 0
  1. -- Variables that are used on both client and server
  2. SWEP.Gun = ("m9k_fists") -- must be the name of your swep but NO CAPITALS!
  3. SWEP.Category               = "M9K Specialties"
  4. SWEP.Author             = ""
  5. SWEP.Contact                = ""
  6. SWEP.Purpose                = ""
  7. SWEP.Instructions               = ("Right click, right jab.".. "\n".. "Left Click, Left Jab." .. "\n" .. "Hold Reload to put up your guard.")
  8. SWEP.PrintName              = "Fists"       -- Weapon name (Shown on HUD)  
  9. SWEP.Slot               = 0             -- Slot in the weapon selection menu
  10. SWEP.SlotPos                = 114           -- Position in the slot
  11. SWEP.DrawAmmo               = false     -- Should draw the default HL2 ammo counter
  12. SWEP.DrawWeaponInfoBox          = true      -- Should draw the weapon info box
  13. SWEP.BounceWeaponIcon           =   false   -- Should the weapon icon bounce?
  14. SWEP.DrawCrosshair          = false     -- set false if you want no crosshair
  15. SWEP.Weight             = 30            -- rank relative ot other weapons. bigger is better
  16. SWEP.AutoSwitchTo           = true      -- Auto switch to if we pick it up
  17. SWEP.AutoSwitchFrom         = true      -- Auto switch from if you pick up a better weapon
  18. SWEP.HoldType               = "fist"        -- how others view you carrying the weapon
  19. -- normal melee melee2 fist knife smg ar2 pistol rpg physgun grenade shotgun crossbow slam passive
  20. -- you're mostly going to use ar2, smg, shotgun or pistol. rpg and crossbow make for good sniper rifles
  21.  
  22. SWEP.ViewModelFOV           = 70
  23. SWEP.ViewModelFlip          = false
  24. SWEP.ViewModel              = "models/weapons/v_punchy.mdl" -- Weapon view model
  25. SWEP.WorldModel             = ""    -- Weapon world model
  26. SWEP.ShowWorldModel         = true
  27. SWEP.Base               = "bobs_gun_base"
  28. SWEP.Spawnable              = true
  29. SWEP.AdminSpawnable         = true
  30. SWEP.FiresUnderwater = false
  31.  
  32. SWEP.Primary.RPM            = 180           -- This is in Rounds Per Minute
  33. SWEP.Primary.ClipSize           = 30        -- Size of a clip
  34. SWEP.Primary.DefaultClip        = 60        -- Bullets you start with
  35. SWEP.Primary.KickUp             = 0.4       -- Maximum up recoil (rise)
  36. SWEP.Primary.KickDown           = 0.3       -- Maximum down recoil (skeet)
  37. SWEP.Primary.KickHorizontal     = 0.3       -- Maximum up recoil (stock)
  38. SWEP.Primary.Automatic          = false     -- Automatic = true; Semi Auto = false
  39. SWEP.Primary.Ammo           = ""            -- pistol, 357, smg1, ar2, buckshot, slam, SniperPenetratedRound, AirboatGun
  40. -- Pistol, buckshot, and slam always ricochet. Use AirboatGun for a light metal peircing shotgun pellets
  41.  
  42. SWEP.Secondary.IronFOV          = 0     -- How much you 'zoom' in. Less is more!    
  43.  
  44. SWEP.data               = {}                --The starting firemode
  45. SWEP.data.ironsights            = 1
  46.  
  47. SWEP.Primary.Damage     = 25    -- Base damage per bullet
  48. SWEP.Primary.Spread     = .02   -- Define from-the-hip accuracy 1 is terrible, .0001 is exact)
  49. SWEP.Primary.IronAccuracy = .01 -- Ironsight accuracy, should be the same for shotguns
  50.  
  51. //Enter iron sight info and bone mod info below
  52. SWEP.IronSightsPos = Vector(-0.094, -6.755, 1.003)
  53. SWEP.IronSightsAng = Vector(36.123, 0, 0)
  54. SWEP.SightsPos = Vector(-0.094, -6.755, 1.003)
  55. SWEP.SightsAng = Vector(36.123, 0, 0)
  56. SWEP.RunSightsPos = Vector(0, 0, 0)
  57. SWEP.RunSightsAng = Vector(-25.577, 0, 0)
  58.  
  59. SWEP.Slash = 1
  60.  
  61. SWEP.Primary.Sound  = Sound("Weapon_Knife.Slash") //woosh
  62. punchtable = {"punchies/1.mp3","punchies/2.mp3","punchies/3.mp3","punchies/4.mp3","punchies/5.mp3",}
  63. woosh = {"punchies/miss1.mp3", "punchies/miss2.mp3"}
  64.  
  65.  
  66. function SWEP:PrimaryAttack()
  67.  
  68.     vm = self.Owner:GetViewModel()
  69.     if self:CanPrimaryAttack() and self.Owner:IsPlayer() then
  70.     self.Weapon:SendWeaponAnim( ACT_VM_IDLE )
  71.         if !self.Owner:KeyDown(IN_SPEED) and !self.Owner:KeyDown(IN_RELOAD) then
  72.             self.Owner:ViewPunch(Angle(math.random(-5,5),-10,5))
  73.             vm:SetSequence(vm:LookupSequence("punchmiss2")) //left
  74.             vm:SetPlaybackRate( 1.5 )
  75.             self.Weapon:EmitSound(Sound(table.Random(woosh)))//slash in the wind sound here
  76.             timer.Create("LeftJab", .1, 1, function() if not IsValid(self) then return end
  77.            
  78.             if IsValid(self.Owner) and 
  79.            
  80.             IsValid(self.Weapon) then
  81.            
  82.             if self.Owner:Alive() and self.Owner:GetActiveWeapon():GetClass() == self.Gun then  
  83.             self:LeftJab() end end end)
  84.             self.Owner:SetAnimation( PLAYER_ATTACK1 )
  85.             self.Weapon:SetNextPrimaryFire(CurTime()+1/(self.Primary.RPM/60))
  86.             self.Weapon:SetNextSecondaryFire((CurTime()+1/(self.Primary.RPM/60))/2)
  87.         end
  88.     end
  89. end
  90.  
  91. function SWEP:LeftJab()
  92.  
  93.     pos = self.Owner:GetShootPos()
  94.     ang = self.Owner:GetAimVector()
  95.     damagedice = math.Rand(.95,1.95)
  96.     pain = self.Primary.Damage * damagedice
  97.     self.Owner:LagCompensation(true)
  98.     if SERVER and IsValid(self.Owner) and IsValid(self.Weapon) then
  99.         if self.Owner:Alive() then if self.Owner:GetActiveWeapon():GetClass() == self.Gun then
  100.             local slash = {}
  101.             slash.start = pos
  102.             slash.endpos = pos + (ang * 30)
  103.             slash.filter = self.Owner
  104.             slash.mins = Vector(-5, -3, 0)
  105.             slash.maxs = Vector(3, 3, 3)
  106.             local slashtrace = util.TraceHull(slash)
  107.             if slashtrace.Hit then
  108.                 targ = slashtrace.Entity
  109.                 if targ:IsPlayer() or targ:IsNPC() then
  110.                     //find a way to splash a little blood
  111.                    
  112.                     self.Weapon:EmitSound(Sound(table.Random(punchtable)))//stab noise
  113.                     paininfo = DamageInfo()
  114.                     paininfo:SetDamage(pain)
  115.                     paininfo:SetDamageType(DMG_CLUB)
  116.                     paininfo:SetAttacker(self.Owner)
  117.                     paininfo:SetInflictor(self.Weapon)
  118.                     paininfo:SetDamageForce(slashtrace.Normal *5000)
  119.                     if SERVER then
  120.                         targ:TakeDamageInfo(paininfo)
  121.                         if targ:IsPlayer() then targ:ViewPunch(Angle(math.random(-5, 5), math.random(-25,25), math.random(-50,50))) end
  122.                     end
  123.                 else
  124.                     self.Weapon:EmitSound("Weapon_Crowbar.Melee_Hit")//thunk
  125.                 end
  126.             end
  127.         end end
  128.     end
  129.     self.Owner:LagCompensation(false)
  130. end
  131.  
  132. function SWEP:SecondaryAttack()
  133.     if self:CanPrimaryAttack() and self.Owner:IsPlayer() then
  134.     self.Weapon:SendWeaponAnim( ACT_VM_IDLE )
  135.         if !self.Owner:KeyDown(IN_SPEED) and !self.Owner:KeyDown(IN_RELOAD) then
  136.             self.Owner:ViewPunch(Angle(math.random(-5,5),10,-5))
  137.             vm:SetSequence(vm:LookupSequence("punchmiss1")) //right
  138.             vm:SetPlaybackRate( 1.5 )
  139.             self.Weapon:EmitSound(Sound(table.Random(woosh)))//slash in the wind sound here
  140.            
  141.             timer.Create("RightJab", .1, 1, function() if not IsValid(self) then return end
  142.                 if IsValid(self.Owner) and IsValid(self.Weapon) then
  143.                 if self.Owner:Alive() and self.Owner:GetActiveWeapon():GetClass() == self.Gun then
  144.                 self:RightJab()  end end end)
  145.             self.Owner:SetAnimation( PLAYER_ATTACK1 )
  146.             self.Weapon:SetNextSecondaryFire(CurTime()+1/(self.Primary.RPM/60))
  147.             self.Weapon:SetNextPrimaryFire((CurTime()+1/(self.Primary.RPM/60))/2)--one-two punch!
  148.         end
  149.     end
  150. end
  151.  
  152. function SWEP:RightJab()
  153.  
  154.     rpos = self.Owner:GetShootPos()
  155.     rang = self.Owner:GetAimVector()
  156.     damagedice = math.Rand(.95,1.95)
  157.     pain = self.Primary.Damage * damagedice
  158.     self.Owner:LagCompensation(true)
  159.     if SERVER and IsValid(self.Owner) and IsValid(self.Weapon)  then
  160.         if self.Owner:Alive() then if self.Owner:GetActiveWeapon():GetClass() == self.Gun then
  161.             local rslash = {}
  162.             rslash.start = rpos
  163.             rslash.endpos = rpos + (rang * 30)
  164.             rslash.filter = self.Owner
  165.             rslash.mins = Vector(-3, -3, 0)
  166.             rslash.maxs = Vector(3, 5, 3)
  167.             local rslashtrace = util.TraceHull(rslash)
  168.             if rslashtrace.Hit then
  169.                 rtarg = rslashtrace.Entity
  170.                 if rtarg:IsPlayer() or rtarg:IsNPC() then
  171.                     //find a way to splash a little blood
  172.                     self.Weapon:EmitSound(Sound(table.Random(punchtable)))//stab noise
  173.                     paininfo = DamageInfo()
  174.                     paininfo:SetDamage(pain)
  175.                     paininfo:SetDamageType(DMG_CLUB)
  176.                     paininfo:SetAttacker(self.Owner)
  177.                     paininfo:SetInflictor(self.Weapon)
  178.                     paininfo:SetDamageForce(rslashtrace.Normal *5000)
  179.                     if SERVER then
  180.                         rtarg:TakeDamageInfo(paininfo)
  181.                         if rtarg:IsPlayer() then rtarg:ViewPunch(Angle(math.random(-5, 5), math.random(-25,25), math.random(-50,50))) end
  182.                     end
  183.                 else
  184.                     self.Weapon:EmitSound("Weapon_Crowbar.Melee_Hit")//thunk
  185.                 end
  186.             end
  187.         end end
  188.     end
  189.     self.Owner:LagCompensation(false)
  190.  
  191. end
  192.  
  193. function SWEP:Reload()
  194. end
  195.  
  196. --[[ function DukesUp(victim, info)
  197.  
  198.     if !IsValid(victim) then return end
  199.     if victim:IsPlayer() and victim:Alive() then
  200.         -- if victim:GetActiveWeapon() != nil then
  201.             -- if victim:GetActiveWeapon():GetClass() == "m9k_fists" then
  202.                 if victim:GetNWBool("DukesAreUp", false) and info:GetDamageType() == DMG_CLUB then
  203.                     victim:SetHealth(victim:Health() + (info:GetDamage()))
  204.                     victim:SetHealth(victim:Health() - (info:GetDamage()/4))
  205.                 end
  206.             --end
  207.         --end
  208.     end
  209. end
  210. hook.Add("EntityTakeDamage", "DukesUp", DukesUp ) ]]
  211. --This hook has been moved to Autorun
  212.  
  213. function SWEP:Holster()
  214.    
  215.     if CLIENT and IsValid(self.Owner) and not self.Owner:IsNPC() then
  216.         local vm = self.Owner:GetViewModel()
  217.         if IsValid(vm) then
  218.             self:ResetBonePositions(vm)
  219.         end
  220.     end
  221.     self.Owner:SetNWBool("DukesAreUp", false)
  222.     return true
  223. end
  224.  
  225. function SWEP:IronSight()
  226.  
  227.     if !self.Owner:IsNPC() then
  228.         if self.Owner:GetNWBool("DukesAreUp") == nil then
  229.             self.Owner:SetNWBool("DukesAreUp", false)
  230.         end
  231.         if self.ResetSights and CurTime() >= self.ResetSights then
  232.             self.ResetSights = nil
  233.             self:SendWeaponAnim(ACT_VM_IDLE)
  234.         end
  235.     end
  236.    
  237.     if self.Owner:KeyDown(IN_RELOAD) and self.Owner:KeyPressed(IN_SPEED) then
  238.         self.Owner:SetNWBool("DukesAreUp", false)
  239.     end
  240.    
  241.     if self.Owner:KeyDown(IN_SPEED) and not (self.Weapon:GetNWBool("Reloading")) then       -- If you are running
  242.     self.Weapon:SetNextPrimaryFire(CurTime()+0.3)               -- Make it so you can't shoot for another quarter second
  243.     self.IronSightsPos = self.RunSightsPos                  -- Hold it down
  244.     self.IronSightsAng = self.RunSightsAng                  -- Hold it down
  245.     self:SetIronsights(true, self.Owner)                    -- Set the ironsight true
  246.     self.Owner:SetFOV( 0, 0.3 )
  247.     end                            
  248.  
  249.     if self.Owner:KeyReleased (IN_SPEED) then   -- If you release run then
  250.     self:SetIronsights(false, self.Owner)                   -- Set the ironsight true
  251.     self.Owner:SetFOV( 0, 0.3 )
  252.     end                             -- Shoulder the gun
  253.    
  254.     if !self.Owner:KeyDown(IN_USE) and !self.Owner:KeyDown(IN_SPEED) then
  255.     -- If the key E (Use Key) is not pressed, then
  256.  
  257.         if self.Owner:KeyPressed(IN_RELOAD) then
  258.             self.Owner:SetFOV( self.Secondary.IronFOV, 0.3 )
  259.             self.IronSightsPos = self.SightsPos                 -- Bring it up
  260.             self.IronSightsAng = self.SightsAng                 -- Bring it up
  261.             self:SetIronsights(true, self.Owner)
  262.             self.Owner:SetNWBool("DukesAreUp", true)
  263.             -- Set the ironsight true
  264.  
  265.             if CLIENT then return end
  266.         end
  267.     end
  268.  
  269.     if self.Owner:KeyReleased(IN_RELOAD) and !self.Owner:KeyDown(IN_USE) and !self.Owner:KeyDown(IN_SPEED) then
  270.     -- If the right click is released, then
  271.         self.Owner:SetFOV( 0, 0.3 )
  272.         self:SetIronsights(false, self.Owner)
  273.         self.Owner:SetNWBool("DukesAreUp", false)
  274.         -- Set the ironsight false
  275.  
  276.         if CLIENT then return end
  277.     end
  278.    
  279. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement