Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( CLIENT ) then
- SWEP.PrintName = "Gluon Gun"
- SWEP.Author = "uwu burglar"
- SWEP.Category = "Gluon Gun"
- SWEP.Slot = 1
- SWEP.SlotPos = 4
- SWEP.ViewModelFOV = 90
- SWEP.IconLetter = "x"
- --killicon.Add( "add the name here", "add directory to it here", color_white )
- end
- SWEP.Spawnable = false
- SWEP.AdminSpawnable = false
- SWEP.ViewModel = "models/v_egon.mdl"
- SWEP.WorldModel = "models/weapons/w_physics.mdl"
- SWEP.HoldType = "physgun"
- SWEP.IsGluonGun = true
- SWEP.Primary.ClipSize = 100
- SWEP.Primary.Ammo = "Default"
- SWEP.Primary.DefaultClip = 300
- SWEP.Primary.Automatic = true
- SWEP.Secondary.ClipSize = -1
- SWEP.Secondary.DefaultClip = -1
- SWEP.Secondary.Automatic = false
- SWEP.Secondary.Ammo = "none"
- function SWEP:Initialize()
- self:SetHoldType(self.HoldType)
- if (CLIENT) then
- Beamz = CreateMaterial( "xeno/beamz2", "UnlitGeneric", {
- [ "$basetexture" ] = "sprites/physbeam3",
- [ "$additive" ] = "1",
- [ "$vertexcolor" ] = "1",
- [ "$vertexalpha" ] = "1",
- } )
- Beamtwo = CreateMaterial( "xeno/beam22", "UnlitGeneric", {
- [ "$basetexture" ] = "sprites/laserbeam2",
- [ "$additive" ] = "1",
- [ "$vertexcolor" ] = "1",
- [ "$vertexalpha" ] = "1",
- } )
- end
- self.NextShoot = CurTime()
- end
- function SWEP:PrimaryAttack()
- if (!self:CanPrimaryAttack()) then return end
- if not self.NextShoot then self.NextShoot = CurTime() end
- if CurTime()>=self.NextShoot and self.Owner:KeyDown(IN_ATTACK) then
- if self.IsReloading then self.IsReloading = false end
- if !self.ALT_ON then
- self.Weapon:EmitSound("pack/up2.wav")
- ChargeSnd = Sound("pack/run2.wav")
- self.SndLoop = CreateSound(self.Weapon, ChargeSnd )
- self.SndLoop:Play()
- self.ALT_ON = true
- self:SetNWBool("fier", self.ALT_ON)
- end
- end
- end
- function SWEP:SecondaryAttack()
- end
- function SWEP:Think()
- if (self:Clip1() <= 0) or self.IsReloading then
- if self.ALT_ON then
- self:SetNextPrimaryFire(CurTime() + 4)
- self.ALT_ON = false
- if self.SndLoop then
- self.SndLoop:Stop()
- end
- self:SetNWBool("fier", self.ALT_ON)
- self.Weapon:EmitSound("pack/off2.wav")
- end
- return
- end
- if self.Owner:KeyReleased(IN_ATTACK) then
- self.ALT_ON = false
- if self.SndLoop then
- self.SndLoop:Stop()
- end
- self:SetNWBool("fier", self.ALT_ON)
- self.Weapon:EmitSound("pack/off2.wav")
- end
- if self.Owner:KeyDown(IN_ATTACK) and self.ALT_ON then
- if not self.SndLoop then
- self.Weapon:EmitSound("pack/up2.wav")
- ChargeSnd = Sound("pack/run2.wav")
- self.SndLoop = CreateSound(self.Weapon, ChargeSnd )
- self.SndLoop:Play()
- end
- if SERVER then
- self.Owner:LagCompensation( true )
- local eyetrace = self.Owner:GetEyeTrace()
- local pos = self.Owner:GetShootPos()
- local ang = self.Owner:GetAimVector()
- local gluon = {}
- gluon.start = pos
- gluon.endpos = eyetrace.HitPos
- gluon.filter = self.Owner
- gluon.mins = Vector(-7, -7, 0)
- gluon.maxs = Vector(7, 7, 7)
- local tr = util.TraceHull(gluon)
- if tr.HitPos:Distance(self.Owner:GetPos()) <= 600 or (IsValid(self.Owner) and self.Owner:IsInEvent()) then
- if IsValid(tr.Entity) and tr.Entity:IsPlayer() then
- local dmg = DamageInfo()
- dmg:SetAttacker(self.Owner)
- dmg:SetInflictor(self.Weapon)
- dmg:SetDamageType(DMG_DISSOLVE)
- dmg:SetDamage(150)
- tr.Entity:TakeDamageInfo(dmg)
- self.Owner:LagCompensation( false )
- end
- if !self.Owner:IsInEvent() then self:TakePrimaryAmmo( 1 ) end
- end
- self:NextThink( CurTime() + 0.2 )
- return true
- end
- function SWEP:Deploy()
- self:SetHoldType(self.HoldType)
- self.ALT_ON = false
- self:SetNWBool("fier", false)
- return true
- end
- function SWEP:Equip()
- self:SetHoldType(self.HoldType)
- end
- function SWEP:OnRemove()
- self:SetNWBool("fier", false)
- if self.SndLoop then
- self.SndLoop:Stop()
- end
- end
- function SWEP:ShootEffects()
- self:SendWeaponAnim( ACT_VM_SECONDARYATTACK )
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
- end
- function SWEP:ShouldDropOnDie()
- return false
- end
- if(CLIENT)then
- function SWEP:DrawHUD()
- end
- function SWEP:ViewModelDrawn()
- self:Drawspiral()
- end
- function SWEP:DrawWorldModel()
- self:Drawspiral()
- self.Weapon:DrawModel()
- end
- function SWEP:Drawspiral()
- Beamz = CreateMaterial( "xeno/beamz2", "UnlitGeneric", {
- [ "$basetexture" ] = "sprites/physbeam3",
- [ "$additive" ] = "1",
- [ "$vertexcolor" ] = "1",
- [ "$vertexalpha" ] = "1",
- } )
- Beamtwo = CreateMaterial( "xeno/beam22", "UnlitGeneric", {
- [ "$basetexture" ] = "sprites/laserbeam2",
- [ "$additive" ] = "1",
- [ "$vertexcolor" ] = "1",
- [ "$vertexalpha" ] = "1",
- } )
- if self:GetNWBool("fier",false) then
- local tr = self.Weapon.Owner:GetEyeTraceNoCursor()
- if tr.Hit then
- self.StartPos = self:GetMuzzlePos( self, 1 )
- self.EndPos = tr.HitPos
- if not self.StartPos then return end
- if not self.EndPos then return end
- render.SetMaterial(Material("effects/exit1"))
- render.DrawSprite( self.EndPos, 32, 32, Color(255,0,0,255))
- self.Weapon:SetRenderBoundsWS( self.StartPos, self.EndPos )
- local sinq = 3
- render.SetMaterial( Beamz )
- Rotator = Rotator or 0
- Rotator = Rotator - 10
- local Times = 50 --12
- render.StartBeam( 2 + Times );
- // add start
- self.Dir = (self.EndPos - self.StartPos):GetNormal()
- self.Inc = (self.EndPos - self.StartPos):Length() / Times
- local RAng = self.Dir:Angle()
- RAng:RotateAroundAxis(RAng:Right(),90)
- RAng:RotateAroundAxis(RAng:Up(),Rotator)
- render.AddBeam(
- self.StartPos, // Start position
- 20, // Width
- CurTime(), // Texture coordinate
- Color( 255, 255, 255, 200 ) // Color --Color( 64, 255, 64, 200 )
- )
- for i = 0, Times do
- // get point
- RAng:RotateAroundAxis(RAng:Up(),360/(Times/sinq))
- local point = ( self.StartPos + self.Dir * ( i * self.Inc ) ) + RAng:Forward() * (math.sin((i/Times)*math.pi))*25
- render.AddBeam(
- point,
- 20,
- CurTime() + ( 1 / Times ) * i,
- Color( 255, 255, 255, 200 )
- )
- end
- render.AddBeam(
- self.EndPos,
- 20,
- CurTime() + 1,
- Color( 255, 255, 255, 200 )
- )
- render.EndBeam()
- --second beam >_<
- render.StartBeam( 2 + Times );
- // add start
- self.Dir = (self.EndPos - self.StartPos):GetNormal()
- self.Inc = (self.EndPos - self.StartPos):Length() / Times
- local RAng = self.Dir:Angle()
- RAng:RotateAroundAxis(RAng:Right(),90)
- RAng:RotateAroundAxis(RAng:Up(),Rotator*-1)
- render.AddBeam(
- self.StartPos,
- 20,
- CurTime(),
- Color( 255, 255, 255, 200 )
- )
- for i = 0, Times do
- // get point
- RAng:RotateAroundAxis(RAng:Up(),360/(Times/sinq))
- local point = ( self.StartPos + self.Dir * ( i * self.Inc ) ) + RAng:Forward() * (math.sin((i/Times)*math.pi))*12
- render.AddBeam(
- point,
- 20,
- CurTime() + ( 1 / Times ) * i,
- Color( 255, 255, 255, 200 )
- )
- end
- render.AddBeam(
- self.EndPos,
- 20,
- CurTime() + 1,
- Color( 255, 255, 255, 200 )
- )
- render.EndBeam()
- -- third one X_x
- render.StartBeam( 2 + Times );
- // add start
- self.Dir = (self.EndPos - self.StartPos):GetNormal()
- self.Inc = (self.EndPos - self.StartPos):Length() / Times
- local RAng = self.Dir:Angle()
- RAng:RotateAroundAxis(RAng:Right(),90)
- render.AddBeam(
- self.StartPos,
- 20,
- CurTime(),
- Color( 255, 255, 255, 200 )
- )
- for i = 0, Times do
- // get point
- local point = ( self.StartPos + self.Dir * ( i * self.Inc ) ) --+ VectorRand()*math.random(1,10)
- render.AddBeam(
- point,
- 20,
- CurTime() + ( 1 / Times ) * i,
- Color( 255, 255, 255, 200 )
- )
- end
- render.AddBeam(
- self.EndPos,
- 20,
- CurTime() + 1,
- Color( 255, 255, 255, 200 )
- )
- render.EndBeam()
- end
- end
- end
- function SWEP:GetMuzzlePos( weapon, attachment )
- if(!IsValid(weapon)) then return end
- local origin = weapon:GetPos()
- local angle = weapon:GetAngles()
- if weapon:IsWeapon() and weapon:IsCarriedByLocalPlayer() then
- if( IsValid( weapon:GetOwner() ) && GetViewEntity() == weapon:GetOwner() ) then
- local viewmodel = weapon:GetOwner():GetViewModel()
- if( IsValid( viewmodel ) ) then
- weapon = viewmodel
- end
- end
- end
- local attachment = weapon:GetAttachment( attachment or 1 )
- if( !attachment ) then
- return origin, angle
- end
- return attachment.Pos, attachment.Ang
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement