Skip to content

Instantly share code, notes, and snippets.

@severedskullz
Created April 11, 2010 19:41
Show Gist options
  • Select an option

  • Save severedskullz/363008 to your computer and use it in GitHub Desktop.

Select an option

Save severedskullz/363008 to your computer and use it in GitHub Desktop.
//----------------------------------------------
//Author Info
//----------------------------------------------
SWEP.Author = "SeveredSkullz"
SWEP.Contact = "Severed_skullz@hotmail.com"
SWEP.Purpose = "Blow Shit Up!"
SWEP.Instructions = "A Multi-Function Grenade Launcher"
SWEP.Category = "A35 Multi-Launcher"
//----------------------------------------------
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
// First person Model
SWEP.ViewModel = "models/weapons/v_a35.mdl"
// Third Person Model
SWEP.WorldModel = "models/weapons/w_a35.mdl"
// Weapon Details
SWEP.Primary.Clipsize = 6
SWEP.Primary.DefaultClip = 6
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "grenade"
SWEP.Secondary.Clipsize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.Mode = "grenade"
SWEP.Primary.Recoil = 2.50
SWEP.ClipRound1 = "grenade"
SWEP.ClipRound2 = "grenade"
SWEP.ClipRound3 = "grenade"
SWEP.ClipRound4 = "grenade"
SWEP.ClipRound5 = "grenade"
SWEP.ClipRound6 = "grenade"
// Sound
local ShootSound = Sound ("weapons/a35/a35_launch.wav")
function SWEP:Reload()
// Already reloading
if ( self.Weapon:GetNetworkedBool( "reloading", false ) ) then return end
// Start reloading if we can
if ( self.Weapon:Clip1() < self.Primary.ClipSize && self.Owner:GetAmmoCount( self.Primary.Ammo ) > 0 ) then
self.Weapon:SetNetworkedBool( "reloading", true )
self.Weapon:SetVar( "reloadtimer", CurTime() + 0.3 )
self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
end
end
/*---------------------------------------------------------
Think does nothing
---------------------------------------------------------*/
function SWEP:Think()
if ( self.Weapon:GetNetworkedBool( "reloading", false ) ) then
if ( self.Weapon:GetVar( "reloadtimer", 0 ) < CurTime() ) then
// Finish filling, final pump
if ( self.Weapon:Clip1() >= self.Primary.ClipSize || self.Owner:GetAmmoCount( self.Primary.Ammo ) <= 0 ) then
self.Weapon:SendWeaponAnim( ACT_SHOTGUN_RELOAD_FINISH )
self.Weapon:SetNetworkedBool( "reloading", false )
return
end
if self.ClipRound1 == "none" then
self.ClipRound1 = self.Mode
elseif self.ClipRound2 == "none" then
self.ClipRound2 = self.Mode
elseif self.ClipRound3 == "none" then
self.ClipRound3 = self.Mode
elseif self.ClipRound4 == "none" then
self.ClipRound4 = self.Mode
elseif self.ClipRound5 == "none" then
self.ClipRound5 = self.Mode
elseif self.ClipRound6 == "none" then
self.ClipRound6 = self.Mode
end
// Next cycle
//self.Weapon:SetVar( "reloadtimer", CurTime() + 0.3 )
self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
// Add ammo
self.Owner:RemoveAmmo( 1, self.Primary.Ammo, false )
self.Weapon:SetClip1( self.Weapon:Clip1() + 1 )
end
end
end
//--------------------------------------------
// Called when the player Shoots
//--------------------------------------------
function SWEP:PrimaryAttack()
if ( self.Weapon:GetNetworkedBool( "reloading") == true ) then
return
end
local tr = self.Owner:GetEyeTrace()
//if ( ) then return end
self.Force = 0
local ent
if self.ClipRound1 == "grenade" then
ent = ents.Create ("a35_grenade")
self.Force = 150000 //velocity of object
elseif self.ClipRound1 == "smoke" then
ent = ents.Create ("a35_smoke")
self.Force = 7500 //velocity of object
elseif self.ClipRound1 == "flash" then
ent = ents.Create ("a35_flashbang")
self.Force = 7500 //velocity of object
elseif self.ClipRound1 == "none" then
self:EmitSound( "weapons/a35/a35_empty.wav" )
return
end
//Fix the Ammo
self.ClipRound1 = self.ClipRound2
self.ClipRound2 = self.ClipRound3
self.ClipRound3 = self.ClipRound4
self.ClipRound4 = self.ClipRound5
self.ClipRound5 = self.ClipRound6
self.ClipRound6 = "none"
local PlayerAim = self.Owner:GetAimVector()
local v = self.Owner:GetShootPos()
v = v + self.Owner:GetForward() * 5
//v = v + self.Owner:GetRight() * 9
//v = v + self.Owner:GetUp() * -8.5
ent:SetPos( v )
ent:SetAngles(PlayerAim:Angle())
ent.GrenadeOwner = self.Owner
ent:Spawn()
local phys = ent:GetPhysicsObject()
local shot_length = tr.HitPos:Length()
phys:ApplyForceCenter(self.Owner:GetAimVector() * self.Force + Vector(0 ,0 ,0))
self.Owner:ViewPunch(Angle(math.Rand(-0.5,-2.5) * (self.Primary.Recoil), math.Rand(-1,1) * (self.Primary.Recoil), 0))
self.Owner:SetAnimation(PLAYER_ATTACK1)
self.Weapon:EmitSound(ShootSound)
self:TakePrimaryAmmo(1)
end
//--------------------------------------------
// Called when the player Uses secondary attack
//--------------------------------------------
function SWEP:SecondaryAttack()
if self.Mode == "grenade" then
self.Mode = "smoke"
self.Primary.Ammo = "grenade"
elseif self.Mode == "smoke" then
self.Mode = "flash"
self.Primary.Ammo = "smoke"
elseif self.Mode == "flash" then
self.Mode = "grenade"
self.Primary.Ammo = "flashbang"
end
// Any Code you want to my executed when the player uses secondary attack goes in here
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment