Files
wnsrc/lua/effects/muzzleflash_ar3/init.lua

75 lines
1.9 KiB
Lua
Raw Permalink Normal View History

2024-08-04 23:54:45 +03:00
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local ang
EFFECT.ParticleName = "muzzleflash_ar3"
function EFFECT:Init(data)
self.WeaponEnt = data:GetEntity()
if not IsValid(self.WeaponEnt) then return end
self.Attachment = data:GetAttachment()
self.Position = self:GetTracerShootPos(data:GetOrigin(), self.WeaponEnt, self.Attachment)
local att2 = self:LookupAttachment( "punch" )
self.Position2 = self:GetTracerShootPos(data:GetOrigin(), self.WeaponEnt, att2 )
if IsValid(self.WeaponEnt.Owner) then
if self.WeaponEnt.Owner == LocalPlayer() then
if not self.WeaponEnt:IsFirstPerson() then
ang = self.WeaponEnt.Owner:EyeAngles()
ang:Normalize()
--ang.p = math.max(math.min(ang.p,55),-55)
self.Forward = ang:Forward()
else
self.WeaponEnt = self.WeaponEnt.Owner:GetViewModel()
end
--ang.p = math.max(math.min(ang.p,55),-55)
else
ang = self.WeaponEnt.Owner:EyeAngles()
ang:Normalize()
self.Forward = ang:Forward()
end
end
self.Forward = self.Forward or data:GetNormal()
self.Angle = self.Forward:Angle()
local dlight = DynamicLight(self.WeaponEnt:EntIndex())
if (dlight) then
dlight.pos = self.Position + self.Angle:Up() * 3 + self.Angle:Right() * -2
dlight.r = 255
dlight.g = 192
dlight.b = 64
dlight.brightness = 5
dlight.Size = math.Rand(32, 64)
dlight.Decay = math.Rand(32, 64) / 0.05
dlight.DieTime = CurTime() + 0.05
end
local pcf = CreateParticleSystem(self.WeaponEnt, self.ParticleName, PATTACH_POINT_FOLLOW, self.Attachment)
if IsValid(pcf) then
pcf:StartEmission()
end
timer.Simple(3.0, function()
if IsValid(pcf) then
pcf:StopEmissionAndDestroyImmediately()
end
end)
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end