Guest User

TTT M60

a guest
Jul 11th, 2015
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.64 KB | None | 0 0
  1. if SERVER then
  2.    AddCSLuaFile( "shared.lua" )
  3.    resource.AddFile( "materials/vgui/ttt/m60-icon.vmt" )
  4. end
  5.  
  6. if CLIENT then
  7.    SWEP.PrintName           = "M60"
  8.    SWEP.Slot                = 2
  9.    SWEP.Icon = "vgui/ttt/m60-icon"
  10. end
  11.  
  12. --Sound file mapping
  13.  if true then
  14. sound.Add({
  15.     name =          "Weapon_M60.Single",
  16.     channel =       CHAN_USER_BASE+10,
  17.     volume =        1.0,
  18.     sound =             "weapons/m60/m60_fire.wav"
  19. })
  20. end
  21.  
  22. -- Always derive from weapon_tttbase
  23. SWEP.Base               = "weapon_tttbase"
  24.  
  25. -- Standard GMod values
  26. SWEP.Spawnable = true
  27. SWEP.Kind = WEAPON_HEAVY
  28. SWEP.WeaponID = AMMO_M60
  29.  
  30. SWEP.Primary.Delay          = 0.1275
  31. SWEP.Primary.Recoil         = 1.25
  32. SWEP.Primary.Automatic = true
  33. SWEP.Primary.Ammo = "AirboatGun"
  34. SWEP.Primary.Damage = 17
  35. SWEP.Primary.Cone = 0.04
  36. SWEP.Primary.ClipSize = 100
  37. SWEP.Primary.ClipMax = 100
  38. SWEP.Primary.DefaultClip = 100
  39. SWEP.AutoSpawnable      = true
  40. SWEP.HoldType           = "ar2"
  41. SWEP.UseHands           = true
  42. SWEP.ViewModelFlip      = false
  43. SWEP.ViewModelFOV       = 64
  44. SWEP.ViewModel              = "models/weapons/v_mach_m60.mdl"            -- View Model of your SWEP
  45. SWEP.WorldModel             = "models/weapons/w_mach_m60.mdl"          -- World Model
  46. SWEP.HeadshotMultiplier = 2.0
  47.  
  48. SWEP.Primary.Sound = Sound( "Weapon_M60.Single" )
  49.  
  50. SWEP.IronSightsPos = Vector(-2.881, -3.593, 0.647)
  51. SWEP.IronSightsAng = Vector(0, 0.014, -0.176)
  52. SWEP.Pos = nil
  53. SWEP.Ang = nil
  54.  
  55. function SWEP:CalcAbsolutePosition(pos, ang)
  56.     self.Pos = pos
  57.     self.Ang = ang
  58.     return
  59. end
  60.  
  61. function SWEP:SetZoom(state)
  62.    if CLIENT then return end
  63.    if not (IsValid(self.Owner) and self.Owner:IsPlayer()) then return end
  64.    if state then
  65.       self.Owner:SetFOV(75, 0.5)
  66.    else
  67.       self.Owner:SetFOV(0, 0.2)
  68.    end
  69. end
  70.  
  71. -- Add some zoom to ironsights for this gun
  72. function SWEP:SecondaryAttack()
  73.    if not self.IronSightsPos then return end
  74.    if self:GetNextSecondaryFire() > CurTime() then return end
  75.  
  76.    bIronsights = not self:GetIronsights()
  77.  
  78.    self:SetIronsights( bIronsights )
  79.  
  80.    if SERVER then
  81.       self:SetZoom( bIronsights )
  82.    end
  83.  
  84.    self:SetNextSecondaryFire( CurTime() + 0.3 )
  85. end
  86.  
  87. function SWEP:PreDrop()
  88.    self:SetZoom(false)
  89.    self:SetIronsights(false)
  90.    return self.BaseClass.PreDrop(self)
  91. end
  92.  
  93. function SWEP:Holster()
  94.    self:SetIronsights(false)
  95.    self:SetZoom(false)
  96.    return true
  97. end
  98.  
  99. SWEP.Offset = {
  100. Pos = {
  101. Up = 0,
  102. Right = 1,
  103. Forward = -3,
  104. },
  105. Ang = {
  106. Up = 0,
  107. Right = 0,
  108. Forward = 0,
  109. }
  110. }
  111.  
  112. function SWEP:Think()
  113.     self:DrawWorldModel( )
  114. end
  115.  
  116. function SWEP:RenderOverride()
  117.     self:DrawWorldModel()
  118. end
  119.  
  120. function SWEP:OnDrop()
  121.     self.Owner = nil
  122. end
  123.  
  124. function SWEP:DrawWorldModel( )
  125. local hand, offset, rotate
  126.  
  127. if not IsValid( self.Owner ) then  
  128.     self:SetRenderOrigin(self.Pos)
  129.     self:SetRenderAngles(self.Ang)
  130.     self:DrawModel( )
  131. return
  132. end
  133.  
  134. if not self.Hand then
  135. self.Hand = self.Owner:LookupAttachment( "anim_attachment_rh" )
  136. end
  137.  
  138. hand = self.Owner:GetAttachment( self.Hand )
  139.  
  140. if not hand then
  141.     --self:SetRenderOrigin(self:GetNetworkOrigin())
  142.     --self:SetRenderAngles(self:GetNetworkAngles())
  143.     self:SetRenderOrigin(self.Pos)
  144.     self:SetRenderAngles(self.Ang)
  145.     self:DrawModel( )
  146.     return
  147. end
  148.  
  149. offset = hand.Ang:Right( ) * self.Offset.Pos.Right + hand.Ang:Forward( ) * self.Offset.Pos.Forward + hand.Ang:Up( ) * self.Offset.Pos.Up
  150.  
  151. hand.Ang:RotateAroundAxis( hand.Ang:Right( ), self.Offset.Ang.Right )
  152. hand.Ang:RotateAroundAxis( hand.Ang:Forward( ), self.Offset.Ang.Forward )
  153. hand.Ang:RotateAroundAxis( hand.Ang:Up( ), self.Offset.Ang.Up )
  154.  
  155. if self.SetRenderOrigin == nil or self.SetRenderAngles == nil then return end
  156.  
  157. self:SetRenderOrigin( hand.Pos + offset )
  158. self:SetRenderAngles( hand.Ang )
  159.  
  160. self:DrawModel( )
  161. end
Advertisement
Add Comment
Please, Sign In to add comment