Skip to content

Instantly share code, notes, and snippets.

@GermanAizek
Created October 18, 2020 02:53
Show Gist options
  • Save GermanAizek/4d9f99b1ccd70461b033b3ad837802ec to your computer and use it in GitHub Desktop.
Save GermanAizek/4d9f99b1ccd70461b033b3ad837802ec to your computer and use it in GitHub Desktop.
cop_muzzleflash_plasma.lua
AddCSLuaFile()
function EFFECT:Init(data)
local ent = data:GetEntity()
local att = data:GetAttachment()
local origin = self:GetTracerShootPos2(data:GetOrigin(), ent, att) - data:GetNormal() * 20
local emitter = ParticleEmitter(origin)
local rollDelta = (math.random() - math.random()) * 2
local particle = emitter:Add("weapons/stalker_cop/pfx_light", origin)
particle:SetDieTime(0.1)
particle:SetStartAlpha(255)
particle:SetEndAlpha(0)
particle:SetStartSize(12)
particle:SetEndSize(4)
particle:SetRoll(math.random(0, 360))
particle:SetRollDelta(rollDelta)
particle:SetColor(255, 255, 255)
emitter:Finish()
local dlight = DynamicLight(self:EntIndex())
dlight.r = 140
dlight.g = 160
dlight.b = 255
dlight.Brightness = 2
dlight.Pos = origin
dlight.Size = 200
dlight.Decay = 1000
dlight.DieTime = CurTime() + 0.1
end
function EFFECT:GetTracerShootPos2(pos, ent, att)
if !IsValid( ent ) then return pos end
if !ent:IsWeapon() then return pos end
if (ent:IsCarriedByLocalPlayer() && !LocalPlayer():ShouldDrawLocalPlayer()) then
local VM = ent.VM or ent.Owner:GetViewModel()
if IsValid(VM) then
local att = VM:GetAttachment(att)
if att then
pos = att.Pos
end
end
else
local att = ent:GetAttachment(att)
if att then
pos = att.Pos
end
end
return pos
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment