Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile()
- SWEP.HoldType = "shotgun"
- if CLIENT then
- SWEP.PrintName = "shotgun_name"
- SWEP.Slot = 2
- SWEP.Icon = "vgui/ttt/icon_shotgun"
- SWEP.IconLetter = "B"
- SWEP.VElements = {
- ["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 = {} },
- ["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 = {} },
- ["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 = {} }
- }
- SWEP.WElements = {
- ["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 = {} },
- ["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 = {} },
- ["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 = {} }
- }
- end
- SWEP.Base = "weapon_tttbase"
- SWEP.Spawnable = true
- SWEP.Kind = WEAPON_HEAVY
- SWEP.WeaponID = AMMO_SHOTGUN
- SWEP.Primary.Ammo = "Buckshot"
- SWEP.Primary.Damage = 13
- SWEP.Primary.Cone = 0.065
- SWEP.Primary.Delay = 0.9
- SWEP.Primary.ClipSize = 8
- SWEP.Primary.ClipMax = 24
- SWEP.Primary.DefaultClip = 8
- SWEP.Primary.Automatic = false
- SWEP.Primary.NumShots = 9
- SWEP.AutoSpawnable = true
- SWEP.AmmoEnt = "item_box_buckshot_ttt"
- SWEP.UseHands = true
- SWEP.ViewModelFlip = false
- SWEP.ViewModelFOV = 54
- SWEP.ViewModel = "models/weapons/cstrike/c_shot_m3super90.mdl"
- SWEP.WorldModel = "models/weapons/w_shot_m3super90.mdl"
- SWEP.Primary.Sound = Sound("weapons/m3/m3-1.wav")
- SWEP.Primary.Recoil = 7
- SWEP.IronSightsPos = Vector(-6.881, -9.214, 2.66)
- SWEP.IronSightsAng = Vector(-0.101, -0.7, -0.201)
- SWEP.TracerName = "pulse"
- SWEP.reloadtimer = 0
- function SWEP:SetupDataTables()
- self:DTVar("Bool", 0, "reloading")
- return self.BaseClass.SetupDataTables(self)
- end
- function SWEP:Reload()
- --if self:GetNetworkedBool( "reloading", false ) then return end
- if self.dt.reloading then return end
- if not IsFirstTimePredicted() then return end
- if self:Clip1() < self.Primary.ClipSize and self.Owner:GetAmmoCount( self.Primary.Ammo ) > 0 then
- if self:StartReload() then
- return
- end
- end
- end
- function SWEP:StartReload()
- --if self:GetNWBool( "reloading", false ) then
- if self.dt.reloading then
- return false
- end
- self:SetIronsights( false )
- if not IsFirstTimePredicted() then return false end
- self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
- local ply = self.Owner
- if not ply or ply:GetAmmoCount(self.Primary.Ammo) <= 0 then
- return false
- end
- local wep = self
- if wep:Clip1() >= self.Primary.ClipSize then
- return false
- end
- wep:SendWeaponAnim(ACT_SHOTGUN_RELOAD_START)
- self.reloadtimer = CurTime() + wep:SequenceDuration()
- --wep:SetNWBool("reloading", true)
- self.dt.reloading = true
- return true
- end
- function SWEP:PerformReload()
- local ply = self.Owner
- -- prevent normal shooting in between reloads
- self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
- if not ply or ply:GetAmmoCount(self.Primary.Ammo) <= 0 then return end
- if self:Clip1() >= self.Primary.ClipSize then return end
- self.Owner:RemoveAmmo( 1, self.Primary.Ammo, false )
- self:SetClip1( self:Clip1() + 1 )
- self:SendWeaponAnim(ACT_VM_RELOAD)
- self.reloadtimer = CurTime() + self:SequenceDuration()
- end
- function SWEP:FinishReload()
- self.dt.reloading = false
- self:SendWeaponAnim(ACT_SHOTGUN_RELOAD_FINISH)
- self.reloadtimer = CurTime() + self:SequenceDuration()
- end
- function SWEP:CanPrimaryAttack()
- if self:Clip1() <= 0 then
- self:EmitSound( "Weapon_Shotgun.Empty" )
- self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
- return false
- end
- return true
- end
- function SWEP:Think()
- if self.dt.reloading and IsFirstTimePredicted() then
- if self.Owner:KeyDown(IN_ATTACK) then
- self:FinishReload()
- return
- end
- if self.reloadtimer <= CurTime() then
- if self.Owner:GetAmmoCount(self.Primary.Ammo) <= 0 then
- self:FinishReload()
- elseif self:Clip1() < self.Primary.ClipSize then
- self:PerformReload()
- else
- self:FinishReload()
- end
- return
- end
- end
- end
- function SWEP:Deploy()
- self.dt.reloading = false
- self.reloadtimer = 0
- return self.BaseClass.Deploy(self)
- end
- -- The shotgun's headshot damage multiplier is based on distance. The closer it
- -- is, the more damage it does. This reinforces the shotgun's role as short
- -- range weapon by reducing effectiveness at mid-range, where one could score
- -- lucky headshots relatively easily due to the spread.
- function SWEP:GetHeadshotMultiplier(victim, dmginfo)
- local att = dmginfo:GetAttacker()
- if not IsValid(att) then return 3 end
- local dist = victim:GetPos():Distance(att:GetPos())
- local d = math.max(0, dist - 140)
- -- decay from 3.1 to 1 slowly as distance increases
- return 1 + math.max(0, (2.1 - 0.002 * (d ^ 1.25)))
- end
- function SWEP:SecondaryAttack()
- if self.NoSights or (not self.IronSightsPos) or self.dt.reloading then return end
- --if self:GetNextSecondaryFire() > CurTime() then return end
- self:SetIronsights(not self:GetIronsights())
- self:SetNextSecondaryFire(CurTime() + 0.3)
- end
- function SWEP:EmitFireSound()
- self:EmitSound(self.Primary.Sound, 50,math.random(240,255))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement