Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SWEP.Author = "Pimpdaddy"
- SWEP.Category = "Smoke"
- SWEP.Purpose = "Beach&CLear"
- SWEP.Instructions = "Left-Click: Throw big grenade Right-Click: Throw small grenade"
- SWEP.Spawnable = true
- SWEP.AdminSpawnable = true
- SWEP.Primary.Automatic = false
- SWEP.Primary.ClipSize = 1
- SWEP.Primary.DefaultClip = 0
- SWEP.Primary.Ammo = "grenade"
- SWEP.DrawCrosshair = true
- SWEP.base = "weapon_Grenade"
- SWEP.Primary.Delay = 100
- SWEP.HoldType = "grenade"
- SWEP.ViewModelFOV = 49.849246231156
- SWEP.ViewModelFlip = false
- SWEP.ViewModel = "models/weapons/v_grenade.mdl"
- SWEP.WorldModel = "models/weapons/w_grenade.mdl"
- SWEP.ShowViewModel = true
- SWEP.ShowWorldModel = true
- SWEP.Primary.NumberofShots = 1
- function SWEP:Initialize()
- self:SetWeaponHoldType( self.HoldType )
- end
- //Precache stuff
- function SWEP:Precache()
- //Grenade model
- util.PrecacheModel("models/weapons/v_grenade.mdl")
- //Throwing sounds
- util.PrecacheSound("weapons/ar2/ar2_reload_rotate.wav")
- //Grenade sounds
- util.PrecacheSound("weapons/grenade/tick1.wav")
- util.PrecacheSound("weapons/ar2/npc_ar2_altfire.wav")
- util.PrecacheSound("weapons/ar2/ar2_altfire.wav")
- end
- //PRIMARY FIRE
- function SWEP:PrimaryAttack()
- if ( not self:CanPrimaryAttack() ) then
- return
- end
- self.Weapon:SetNextPrimaryFire(CurTime() + 1.21)
- self.Weapon:SetNextSecondaryFire(CurTime() + 1.21)
- self.Weapon:SendWeaponAnim(ACT_VM_SECONDARYATTACK)
- //self.Owner:SetAnimation(PLAYER_ATTACK2)
- if (SERVER) then
- timer.Simple(0.157, function() if self:IsValid() then self:ThrowBigGrenade() end end)
- end
- if not self.InfiniteAmmo then
- if self:Clip1() <= 0 then return end
- self:TakePrimaryAmmo(1)
- end
- end
- //SECONDARY FIRE
- function SWEP:SecondaryAttack()
- self.Weapon:SetNextPrimaryFire(CurTime() + 1.02)
- self.Weapon:SetNextSecondaryFire(CurTime() + 1.02)
- self.Weapon:SendWeaponAnim(ACT_VM_SECONDARYATTACK)
- //self.Owner:SetAnimation(PLAYER_ATTACK2)
- if (SERVER) then
- timer.Simple(0.157, function() if self:IsValid() then self:ThrowSmallGrenade() end end)
- end
- end
- //Play a nice sound on deploying
- function SWEP:Deploy()
- self.Weapon:SendWeaponAnim(ACT_VM_SECONDARYATTACK)
- return true
- end
- //Grenade throw function (Big)
- function SWEP:ThrowBigGrenade()
- //Safeguard
- if !self || !self.Owner then return end
- if ( not self:CanPrimaryAttack() ) then
- return
- end
- //Create grenade
- local grenadeobj = ents.Create("sent_smokenade")
- grenadeobj:SetPos( self.Owner:GetShootPos() + Vector(0,0,-9.2) )
- grenadeobj:SetAngles( self.Owner:GetAimVector():Angle() )
- grenadeobj:SetPhysicsAttacker(self.Owner)
- grenadeobj:SetOwner(self.Owner)
- grenadeobj:Spawn()
- //Throw it
- grenadeobj:GetPhysicsObject():ApplyForceCenter( self.Owner:GetAimVector() * math.random(1000,2000) + Vector(0, 0, math.random(100,120)) )
- //Play throwing sound
- self.Owner:EmitSound( "weapons/ar2/ar2_reload_rotate.wav", 40, 100 )
- end
- //Grenade throw function (Small)
- function SWEP:ThrowSmallGrenade()
- //Safeguard
- if !self || !self.Owner then return end
- //Create grenade
- local grenadeobj = ents.Create("sent_smokenade_small")
- grenadeobj:SetPos( self.Owner:GetShootPos() + Vector(0,0,-9.2) )
- grenadeobj:SetAngles( self.Owner:GetAimVector():Angle() )
- grenadeobj:SetPhysicsAttacker(self.Owner)
- grenadeobj:SetOwner(self.Owner)
- grenadeobj:Spawn()
- //Throw it
- grenadeobj:GetPhysicsObject():ApplyForceCenter( self.Owner:GetAimVector() * math.random(500,1000) + Vector(0, 0, math.random(100,120)) )
- //Play throwing sound
- self.Owner:EmitSound( "weapons/ar2/ar2_reload_rotate.wav", 40, 100 )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement