Skip to content

Instantly share code, notes, and snippets.

@complover116
Created March 26, 2015 13:58
Show Gist options
  • Save complover116/c168ca06d70d58577b16 to your computer and use it in GitHub Desktop.
Save complover116/c168ca06d70d58577b16 to your computer and use it in GitHub Desktop.
EFFECT.Mat = Material( "effects/blueblacklargebeam" )
function EFFECT:Init( data )
self.texcoord = math.Rand( 0, 20 )/3
self.Position = data:GetStart()
self.WeaponEnt = data:GetEntity()
self.Attachment = data:GetAttachment()
self.StartPos = self:GetTracerShootPos( self.Position, self.WeaponEnt, self.Attachment )
self.EndPos = data:GetOrigin()
self.Entity:SetCollisionBounds( self.StartPos - self.EndPos, Vector( 110, 110, 110 ) )
self.Entity:SetRenderBoundsWS( self.StartPos, self.EndPos, Vector()*8 )
self.StartPos = self:GetTracerShootPos( self.Position, self.WeaponEnt, self.Attachment )
self.Alpha = 255
self.FlashA = 255
self.WeaponEnt = data:GetEntity()
self.Attachment = data:GetAttachment()
self.Position = self:GetTracerShootPos(data:GetOrigin(), self.WeaponEnt, self.Attachment)
self.Forward = data:GetNormal()
self.Angle = self.Forward:Angle()
self.Right = self.Angle:Right()
self.Up = self.Angle:Up()
end
function EFFECT:Think( )
self.FlashA = self.FlashA - 1 * FrameTime()
if (self.FlashA < 0) then self.FlashA = 0 end
self.Alpha = self.Alpha - 950 * FrameTime()
if (self.Alpha < 0) then self:Remove() return false end
return true
end
function EFFECT:Render( )
self.Length = (self.StartPos - self.EndPos):Length()
if GetConVarNumber( "linkinglaser_cl_dynamiclights" ) == 1 then
local dlight = DynamicLight( self:EntIndex() )
if ( dlight ) then
dlight.pos = self.EndPos
dlight.r = 0
dlight.g = 180
dlight.b = 255
dlight.brightness = 2
dlight.Decay = 1000
dlight.Size = 512
dlight.DieTime = CurTime() + 1
end
end
local texcoord = self.texcoord
render.SetMaterial( self.Mat )
render.DrawBeam( self.StartPos, // Start
self.EndPos, // End
3, // Width
texcoord, // Start tex coord
texcoord + self.Length / 256, // End tex coord
Color(0, 199, 199, math.Clamp(self.Alpha, 0,255))) // Color (optional)'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment