Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile()
- SWEP.PrintName = "Unstable Deagle" -- This will be shown in the spawn menu, and in the weapon selection menu
- SWEP.Author = "Greenhourglass" -- These two options will be shown when you have the weapon highlighted in the weapon selection menu
- SWEP.Instructions = "It may or may not blow your arm off"
- SWEP.Category = "Other"
- SWEP.Spawnable = true
- SWEP.AdminOnly = false
- SWEP.DisableDuplicator = false
- SWEP.HoldType = "pistol"
- SWEP.UseHands = true
- SWEP.ViewModel = Model( "models/weapons/cstrike/c_pist_deagle.mdl" )
- SWEP.WorldModel = Model( "models/weapons/w_pist_deagle.mdl" )
- SWEP.ViewModelFlip = false
- SWEP.ViewModelFOV = 54
- SWEP.CSMuzzleFlashes = true
- SWEP.CSMuzzleX = true
- SWEP.Primary.Damage = 50
- SWEP.Primary.Force = 10
- SWEP.Primary.Num = 1
- SWEP.Primary.Cone = 0.06
- SWEP.Primary.ClipSize = 7
- SWEP.Primary.DefaultClip = 14
- SWEP.Primary.Automatic = false
- SWEP.Primary.Ammo = "357"
- SWEP.Primary.Delay = 0.15
- SWEP.Primary.BlowUpChance = 0.2
- SWEP.Secondary.ClipSize = -1
- SWEP.Secondary.DefaultClip = -1
- SWEP.Secondary.Automatic = true
- SWEP.Secondary.Ammo = "none"
- SWEP.Secondary.Delay = 0.2
- SWEP.Weight = 5
- SWEP.AutoSwitchTo = false
- SWEP.AutoSwitchFrom = false
- SWEP.BobScale = 1
- SWEP.SwayScale = 3
- SWEP.m_WeaponDeploySpeed = 1
- SWEP.Slot = 1
- SWEP.SlotPos = 2
- SWEP.BounceWeaponIcon = true
- SWEP.DrawWeaponInfoBox = true
- if CLIENT then
- SWEP.WepSelectIcon = surface.GetTextureID( "weapons/swep" )
- end
- SWEP.DrawAmmo = false
- SWEP.DrawCrosshair = true
- SWEP.AccurateCrosshair = false
- SWEP.SoundPrimary = Sound( "Weapon_DEagle.Single" )
- function SWEP:SetupDataTables()
- end
- --[[---------------------------------------------------------------
- -- PREDICTED functions
- --]]---------------------------------------------------------------
- function SWEP:PrimaryAttack()
- if ( !self:CanPrimaryAttack() ) then return end -- Make sure we can shoot first
- self:TakePrimaryAmmo( 1 )
- self.Owner:ViewPunch( Angle( math.Rand(-1,-3), math.Rand(-2,2), 0 ) )
- self.Weapon:EmitSound( self.SoundPrimary )
- self:ShootBullet( self.Primary.Damage, self.Primary.Num, self.Primary.Cone, self.Primary.Force )
- if math.Rand(0,1) <= self.Primary.BlowUpChance then
- self:BlowUp()
- end
- self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
- end
- function SWEP:SecondaryAttack()
- self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
- end
- function SWEP:ShootBullet( damage, num_bullets, aimcone, force )
- local bullet = {}
- bullet.Num = num_bullets
- bullet.Src = self.Owner:GetShootPos() -- Source
- bullet.Dir = self.Owner:GetAimVector() -- Dir of bullet
- bullet.Spread = Vector( aimcone, aimcone, 0 ) -- Aim Cone
- bullet.Tracer = 1 -- Show a tracer on every x bullets
- bullet.Force = force -- Amount of force to give to phys objects
- bullet.Damage = damage
- bullet.AmmoType = "Pistol"
- self.Owner:FireBullets( bullet )
- self:ShootEffects()
- end
- --[[---------------------------------------------------------------
- -- SHARED functions
- --]]---------------------------------------------------------------
- -- Think is technically predicted but IS called clientside in singleplayer.
- function SWEP:Think()
- end
- function SWEP:Initialize()
- self:SetHoldType( self.HoldType )
- end
- function SWEP:DoImpactEffect( tr, nDamageType )
- if ( tr.HitSky ) then return end
- local effectdata = EffectData()
- effectdata:SetOrigin( tr.HitPos + tr.HitNormal )
- effectdata:SetNormal( tr.HitNormal )
- effectdata:SetMagnitude( 1 )
- if (tr.MatType == MAT_METAL) or (tr.MatType == MAT_VENT) then
- util.Effect( "ElectricSpark", effectdata )
- else
- util.Effect( "AR2Impact", effectdata )
- end
- end
- --[[---------------------------------------------------------------
- -- SERVER functions
- --]]---------------------------------------------------------------
- function SWEP:BlowUp()
- if not SERVER then return end
- local ply = self.Owner
- local expPos = ply:GetShootPos()
- local boneid = ply:LookupBone( "ValveBiped.Bip01_R_Hand" )
- if boneid then
- local newPos,ang = ply:GetBonePosition( boneid )
- if newPos and !(newPos == Vector(0,0,0)) and util.IsInWorld(newPos) then
- expPos = newPos
- end
- end
- local explosion = ents.Create( "env_explosion" )
- explosion:SetPos( expPos )
- explosion:Spawn()
- explosion:SetKeyValue( "iMagnitude", 150 )
- explosion:SetKeyValue( "iRadiusOverride", 100 )
- explosion:SetOwner( ply )
- self.Owner:StripWeapon( self:GetClass() )
- explosion:Fire( "Explode" )
- util.ScreenShake( expPos, 100, 80, 0.5, 100 )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement