if (SERVER) then
	AddCSLuaFile( "shared.lua" )
	SWEP.Weight				= 5
	SWEP.AutoSwitchTo		= true
	SWEP.AutoSwitchFrom		= true
end
if (CLIENT) then
	SWEP.DrawAmmo			= true
	SWEP.DrawCrosshair		= false
	SWEP.ViewModelFOV		= 82
	SWEP.ViewModelFlip		= true
	SWEP.CSMuzzleFlashes	= true
	
	SWEP.ViewModelFlip		= false
end
if ( CLIENT ) then
	SWEP.Author			= "[JEM]TheReignOfTheDesserted"
	SWEP.Contact			= "
[email protected]"
	SWEP.Purpose			= "I will the world mayy cry!"
	SWEP.Instructions		= "Left klick to Throw"
	SWEP.PrintName			= "FusionFrenade"
	SWEP.Slot			= 3
	SWEP.SlotPos			= 2
	SWEP.IconLetter			= "O"
	
	SWEP.ViewModelFlip		= false
	
end
SWEP.Spawnable			= true
SWEP.AdminSpawnable		= true
SWEP.ViewModel			= "models/weapons/v_gravball.mdl"
SWEP.WorldModel			= "models/weapons/w_gravball.mdl"
SWEP.HoldType			= "grenade"
SWEP.Primary.Sound		= Sound("Default.PullPin_Grenade")
SWEP.Primary.Recoil		= 0
SWEP.Primary.Unrecoil		= 0
SWEP.Primary.Damage		= 50000
SWEP.Primary.NumShots		= 1
SWEP.Primary.Cone		= 0
SWEP.Primary.Delay		= 1
SWEP.Primary.ClipSize		= 10
SWEP.Primary.DefaultClip	= 10000
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.Next = CurTime()
SWEP.Primed = 0
function SWEP:Reload()
	return false
end
function SWEP:Deploy()
	return true
end
function SWEP:Holster()
	self.Next = CurTime()
	self.Primed = 0
	return true
end
function SWEP:ShootEffects()
	self.Weapon:SendWeaponAnim( ACT_VM_THROW ) 		// View model animation
	//self.Owner:MuzzleFlash()								// Crappy muzzle light
	self.Owner:SetAnimation( PLAYER_ATTACK1 )				// 3rd Person Animation
end
function SWEP:PrimaryAttack()
	if self.Next < CurTime() then
		if self.Primed == 1 and not self.Owner:KeyDown(IN_ATTACK) then
			self.Weapon:SendWeaponAnim(ACT_VM_THROW)
			self.Primed = 2
			self.Next = CurTime() + .3
		elseif self.Primed == 2 then
			self.Primed = 0
			self.Next = CurTime() + self.Primary.Delay
			
			if SERVER then
				local ent = ents.Create("grenade")
				
				ent:SetPos(self.Owner:GetShootPos())
				ent:SetAngles(Vector(1,0,0))
				ent:Spawn()
				
				local phys = ent:GetPhysicsObject()
				phys:SetVelocity(self.Owner:GetAimVector() * 1000)
				phys:AddAngleVelocity(Vector(math.random(-1000,1000),math.random(-1000,1000),math.random(-1000,1000)))
				
				self.Owner:RemoveAmmo(1,self.Primary.Ammo)
				
				if self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then
					self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
				end
			end
		end
	end
if ( !self:CanPrimaryAttack() ) then return end
			self:TakePrimaryAmmo( 1 )
			
			self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
			
			self.Owner:SetAnimation( PLAYER_ATTACK1 )
			
			self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
			
			self.Weapon:EmitSound( self.Primary.Sound, 100, 100 )
			
		self.Owner:ViewPunch(Vector(math.Rand(-1,1),math.Rand(-1,1),math.Rand(-9,-4))) --soft viewpunch
		
				if (!CLIENT) then
				
					local Ang = self.Owner:EyeAngles()
					
					Ang.pitch = Ang.pitch - 5
					
					self.Owner:SetEyeAngles( Ang ) --rough viewpunch
				
				end
				
		local trace={}
		trace.start=self.Owner:GetShootPos()
		trace.endpos=self.Owner:GetShootPos()+self.Owner:G etForward()*2000000000
		trace.filter=self.Owner
		local tracer = util.TraceLine( trace )
		
		if tracer.Hit then
			local effect = EffectData()
			effect:SetEntity( self.Owner )
			effect:SetStart( self.Owner:GetShootPos() + self.Owner:GetRight())
			effect:SetAttachment( 1 )
			effect:SetOrigin( tracer.HitPos )
			effect:SetScale( 1.0 )
			effect:SetMagnitude( 3000 )
			util.Effect( "FBG-Beam", effect )
         end                                                                                                                                                                
     end        local damage = ents.Create("point_hurt")
		damage:SetKeyValue("DamageRadius", 3000)
		damage:SetKeyValue("Damage" , 1000)
		damage:SetKeyValue("DamageDelay", 3)
		damage:SetKeyValue("DamageType" ,"67108864")
		damage:SetPos(tracer.HitPos)
		damage:Fire("TurnOn" , "", 0)
		damage:Fire("TurnOff" , "", 2)
		damage:Fire("kill","", 2)
 		
		local fx = EffectData()
		fx:SetOrigin(tracer.HitPos)
		fx:SetScale(0.5)
		util.Effect( "HelicopterMegaBomb", fx )
		local fx2 = EffectData()
		fx2:SetOrigin(tracer.HitPos)
		fx2:SetScale(0.1)
		util.Effect( "FBG-Explosion", fx2 )
			
		util.BlastDamage(self.Owner,self.Owner,tracer.HitP os,128,self.Primary.Damage)
		local trace2={}
		trace2.start=tracer.HitPos + self.Owner:GetAimVector()*32
		trace2.endpos=tracer.HitPos + self.Owner:GetAimVector()*2000000000
		trace2.filter=trace.Entity
		local tracer2 = util.TraceLine( trace2 )
		util.BlastDamage(self.Owner,self.Owner,tracer2.Hit Pos,64,self.Primary.Damage)
		if tracer2.Hit then
		local fx3 = EffectData()
		fx3:SetOrigin(tracer2.HitPos)
		fx3:SetScale(0.5)
		util.Effect( "HelicopterMegaBomb", fx3 )
		local fx4 = EffectData()
		fx4:SetOrigin(tracer2.HitPos)
		fx4:SetScale(0.1)
		util.Effect( "FBG-Explosion", fx4 )
		
		local trace3={}
		trace3.start=tracer2.HitPos + self.Owner:GetAimVector()*32
		trace3.endpos=tracer2.HitPos + self.Owner:GetAimVector()*2000000000
		trace3.filter=tracer2.Entity
		local tracer3 = util.TraceLine( trace3 )
		util.BlastDamage(self.Owner,self.Owner,tracer3.Hit Pos,64,self.Primary.Damage)
		if tracer3.Hit then
		local fx6 = EffectData()
		fx6:SetOrigin(tracer3.HitPos)
		fx6:SetScale(0.5)
		util.Effect( "HelicopterMegaBomb", fx6 )
		local fx7 = EffectData()
		fx7:SetOrigin(tracer3.HitPos)
		fx7:SetScale(0.1)
		util.Effect( "FBG-Explosion", fx7 )
		
		local trace4={}
		trace4.start=tracer3.HitPos + self.Owner:GetAimVector()*32
		trace4.endpos=tracer3.HitPos + self.Owner:GetAimVector()*2000000000
		trace4.filter=tracer3.Entity
		local tracer4 = util.TraceLine( trace4 )
		if tracer4.Hit then
		util.BlastDamage(self.Owner,self.Owner,tracer4.Hit Pos,64,self.Primary.Damage)
		
		local fx8 = EffectData()
		fx8:SetOrigin(tracer4.HitPos)
		fx8:SetScale(0.5)
		util.Effect( "HelicopterMegaBomb", fx8 )
		local fx9 = EffectData()
		fx9:SetOrigin(tracer4.HitPos)
		fx9:SetScale(0.1)
		util.Effect( "FBG-Explosion", fx9 )
		
		local trace5={}
		trace5.start=tracer4.HitPos + self.Owner:GetAimVector()*32
		trace5.endpos=tracer4.HitPos + self.Owner:GetAimVector()*2000000000
		trace5.filter=tracer4.Entity
		local tracer5 = util.TraceLine( trace5 )
		if tracer5.Hit then
		util.BlastDamage(self.Owner,self.Owner,tracer5.Hit Pos,64,self.Primary.Damage)
		local fx10 = EffectData()
		fx10:SetOrigin(tracer5.HitPos)
		fx10:SetScale(0.5)
		util.Effect( "HelicopterMegaBomb", fx10 )
		local fx11 = EffectData()
		fx11:SetOrigin(tracer5.HitPos)
		fx11:SetScale(0.1)
		util.Effect( "FBG-Explosion", fx11 )
		
					end
				end
			end
		end
function SWEP:Think()
end