Advertisement
Guest User

weapon_zm_flawless

a guest
Feb 12th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.90 KB | None | 0 0
  1.  
  2. AddCSLuaFile()
  3.  
  4. SWEP.HoldType = "shotgun"
  5.  
  6. if CLIENT then
  7. SWEP.PrintName = "shotgun_name"
  8.  
  9. SWEP.Slot = 2
  10. SWEP.Icon = "vgui/ttt/icon_shotgun"
  11. SWEP.IconLetter = "B"
  12.  
  13. SWEP.VElements = {
  14. ["element_name2"] = { type = "Model", model = "models/props_combine/combine_bridge.mdl", bone = "v_weapon.M3_PARENT", rel = "element_name1", pos = Vector(2.596, -0.92, -5.715), angle = Angle(-85.325, -29.222, 92.337), size = Vector(0.012, 0.012, 0.012), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
  15. ["element_name1"] = { type = "Model", model = "models/Items/battery.mdl", bone = "v_weapon.M3_PARENT", rel = "element_name", pos = Vector(1.557, -0.519, 3.635), angle = Angle(31.558, -75.974, 78.311), size = Vector(0.172, 0.172, 0.172), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
  16. ["element_name"] = { type = "Model", model = "models/props_combine/breenconsole.mdl", bone = "v_weapon.M3_PARENT", rel = "", pos = Vector(0, -1.558, -5.715), angle = Angle(85.324, 0, -85.325), size = Vector(0.086, 0.086, 0.086), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
  17. }
  18. SWEP.WElements = {
  19. ["element_name2"] = { type = "Model", model = "models/props_combine/combine_bridge.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "element_name1", pos = Vector(2.596, -0.92, -5.715), angle = Angle(-85.325, -29.222, 92.337), size = Vector(0.012, 0.012, 0.012), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
  20. ["element_name1"] = { type = "Model", model = "models/Items/battery.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "element_name", pos = Vector(1.557, -0.519, 3.635), angle = Angle(31.558, -75.974, 78.311), size = Vector(0.172, 0.172, 0.172), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
  21. ["element_name"] = { type = "Model", model = "models/props_combine/breenconsole.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(15.064, 0.518, -2.597), angle = Angle(0, -180, -180), size = Vector(0.107, 0.107, 0.107), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
  22. }
  23. end
  24.  
  25.  
  26. SWEP.Base = "weapon_tttbase"
  27. SWEP.Spawnable = true
  28.  
  29. SWEP.Kind = WEAPON_HEAVY
  30. SWEP.WeaponID = AMMO_SHOTGUN
  31.  
  32. SWEP.Primary.Ammo = "Buckshot"
  33. SWEP.Primary.Damage = 13
  34. SWEP.Primary.Cone = 0.065
  35. SWEP.Primary.Delay = 0.9
  36. SWEP.Primary.ClipSize = 8
  37. SWEP.Primary.ClipMax = 24
  38. SWEP.Primary.DefaultClip = 8
  39. SWEP.Primary.Automatic = false
  40. SWEP.Primary.NumShots = 9
  41. SWEP.AutoSpawnable = true
  42. SWEP.AmmoEnt = "item_box_buckshot_ttt"
  43.  
  44. SWEP.UseHands = true
  45. SWEP.ViewModelFlip = false
  46. SWEP.ViewModelFOV = 54
  47. SWEP.ViewModel = "models/weapons/cstrike/c_shot_m3super90.mdl"
  48. SWEP.WorldModel = "models/weapons/w_shot_m3super90.mdl"
  49. SWEP.Primary.Sound = Sound("weapons/m3/m3-1.wav")
  50. SWEP.Primary.Recoil = 7
  51.  
  52. SWEP.IronSightsPos = Vector(-6.881, -9.214, 2.66)
  53. SWEP.IronSightsAng = Vector(-0.101, -0.7, -0.201)
  54.  
  55. SWEP.TracerName = "pulse"
  56. SWEP.reloadtimer = 0
  57.  
  58. function SWEP:SetupDataTables()
  59. self:DTVar("Bool", 0, "reloading")
  60.  
  61. return self.BaseClass.SetupDataTables(self)
  62. end
  63.  
  64. function SWEP:Reload()
  65.  
  66. --if self:GetNetworkedBool( "reloading", false ) then return end
  67. if self.dt.reloading then return end
  68.  
  69. if not IsFirstTimePredicted() then return end
  70.  
  71. if self:Clip1() < self.Primary.ClipSize and self.Owner:GetAmmoCount( self.Primary.Ammo ) > 0 then
  72.  
  73. if self:StartReload() then
  74. return
  75. end
  76. end
  77.  
  78. end
  79.  
  80. function SWEP:StartReload()
  81. --if self:GetNWBool( "reloading", false ) then
  82. if self.dt.reloading then
  83. return false
  84. end
  85.  
  86. self:SetIronsights( false )
  87.  
  88. if not IsFirstTimePredicted() then return false end
  89.  
  90. self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  91.  
  92. local ply = self.Owner
  93.  
  94. if not ply or ply:GetAmmoCount(self.Primary.Ammo) <= 0 then
  95. return false
  96. end
  97.  
  98. local wep = self
  99.  
  100. if wep:Clip1() >= self.Primary.ClipSize then
  101. return false
  102. end
  103.  
  104. wep:SendWeaponAnim(ACT_SHOTGUN_RELOAD_START)
  105.  
  106. self.reloadtimer = CurTime() + wep:SequenceDuration()
  107.  
  108. --wep:SetNWBool("reloading", true)
  109. self.dt.reloading = true
  110.  
  111. return true
  112. end
  113.  
  114. function SWEP:PerformReload()
  115. local ply = self.Owner
  116.  
  117. -- prevent normal shooting in between reloads
  118. self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  119.  
  120. if not ply or ply:GetAmmoCount(self.Primary.Ammo) <= 0 then return end
  121.  
  122. if self:Clip1() >= self.Primary.ClipSize then return end
  123.  
  124. self.Owner:RemoveAmmo( 1, self.Primary.Ammo, false )
  125. self:SetClip1( self:Clip1() + 1 )
  126.  
  127. self:SendWeaponAnim(ACT_VM_RELOAD)
  128.  
  129. self.reloadtimer = CurTime() + self:SequenceDuration()
  130. end
  131.  
  132. function SWEP:FinishReload()
  133. self.dt.reloading = false
  134. self:SendWeaponAnim(ACT_SHOTGUN_RELOAD_FINISH)
  135.  
  136. self.reloadtimer = CurTime() + self:SequenceDuration()
  137. end
  138.  
  139. function SWEP:CanPrimaryAttack()
  140. if self:Clip1() <= 0 then
  141. self:EmitSound( "Weapon_Shotgun.Empty" )
  142. self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  143. return false
  144. end
  145. return true
  146. end
  147.  
  148. function SWEP:Think()
  149. if self.dt.reloading and IsFirstTimePredicted() then
  150. if self.Owner:KeyDown(IN_ATTACK) then
  151. self:FinishReload()
  152. return
  153. end
  154.  
  155. if self.reloadtimer <= CurTime() then
  156.  
  157. if self.Owner:GetAmmoCount(self.Primary.Ammo) <= 0 then
  158. self:FinishReload()
  159. elseif self:Clip1() < self.Primary.ClipSize then
  160. self:PerformReload()
  161. else
  162. self:FinishReload()
  163. end
  164. return
  165. end
  166. end
  167. end
  168.  
  169. function SWEP:Deploy()
  170. self.dt.reloading = false
  171. self.reloadtimer = 0
  172. return self.BaseClass.Deploy(self)
  173. end
  174.  
  175. -- The shotgun's headshot damage multiplier is based on distance. The closer it
  176. -- is, the more damage it does. This reinforces the shotgun's role as short
  177. -- range weapon by reducing effectiveness at mid-range, where one could score
  178. -- lucky headshots relatively easily due to the spread.
  179. function SWEP:GetHeadshotMultiplier(victim, dmginfo)
  180. local att = dmginfo:GetAttacker()
  181. if not IsValid(att) then return 3 end
  182.  
  183. local dist = victim:GetPos():Distance(att:GetPos())
  184. local d = math.max(0, dist - 140)
  185.  
  186. -- decay from 3.1 to 1 slowly as distance increases
  187. return 1 + math.max(0, (2.1 - 0.002 * (d ^ 1.25)))
  188. end
  189.  
  190. function SWEP:SecondaryAttack()
  191. if self.NoSights or (not self.IronSightsPos) or self.dt.reloading then return end
  192. --if self:GetNextSecondaryFire() > CurTime() then return end
  193.  
  194. self:SetIronsights(not self:GetIronsights())
  195.  
  196. self:SetNextSecondaryFire(CurTime() + 0.3)
  197. end
  198.  
  199. function SWEP:EmitFireSound()
  200. self:EmitSound(self.Primary.Sound, 50,math.random(240,255))
  201. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement