Discord
Steam
/
Garry's Mod
/
Developers
/
Effect is weir..
Login/Join
Event Log
Effect is weird and partially draws in the skybox
0 replies, posted
Search
In This Thread
[lua] local EFFECT = {} local matRefraction = Material( "refract_ring" ) local tMats = {} tMats.Glow1 = Material("particles/fire_glow") tMats.Glow2 = Material("particles/fire_glow") local tMats = {} tMats.Glow1 = Material("particles/fire_glow") tMats.Glow2 = Material("particles/fire_glow") for _,mat in pairs(tMats) do mat:SetInt("$spriterendermode",9) mat:SetInt("$ignorez",1) mat:SetInt("$illumfactor",8) end local SmokeParticleUpdate = function(particle) if particle:GetStartAlpha() == 0 and particle:GetLifeTime() >= 0.5*particle:GetDieTime() then particle:SetStartAlpha(particle:GetEndAlpha()) particle:SetEndAlpha(0) particle:SetNextThink(-1) else particle:SetNextThink(CurTime() + 0.1) end return particle end function EFFECT:Init(data) self.Scale = data:GetScale() self.ScaleSlow = math.sqrt(self.Scale) self.ScaleSlowest = math.sqrt(self.ScaleSlow) self.Normal = data:GetNormal() self.RightAngle = self.Normal:Angle():Right():Angle() self.Position = data:GetOrigin() - 12*self.Normal self.Position2 = self.Position + self.Scale*64*self.Normal local CurrentTime = CurTime() self.Duration = 2 --*self.Scale self.KillTime = CurrentTime + self.Duration self.GlowAlpha = 200 self.GlowSize = 100*self.Scale self.FlashAlpha = 100 self.FlashSize = 0 self.emitter = ParticleEmitter(self.Position) for i=1,math.ceil(self.Scale*5) do local vecang = Vector(math.Rand(-1,1),math.Rand(-1,1),0):GetNormalized() local velocity = 10*vecang local particle = self.emitter:Add("particles/flamelet"..math.random(1,5), self.Position + Vector(0,0,10)) local dietime = 2*self.Scale particle:SetVelocity(velocity) particle:SetDieTime(dietime) particle:SetLifeTime(0) particle:SetStartAlpha(60) particle:SetEndAlpha(0) particle:SetStartSize(20*self.ScaleSlowest) particle:SetEndSize(50*self.ScaleSlowest) particle:SetColor(255,255,255) end for i=1,42 do local sparks = self.emitter:Add("effects/spark", self.Position + Vector(0,0,10)) if (sparks) then sparks:SetColor(250, 0, 20) sparks:SetVelocity(VectorRand():GetNormal()*math.random(300, 500)) sparks:SetRoll(math.Rand(0, 360)) sparks:SetRollDelta(math.Rand(-2, 2)) sparks:SetDieTime(2) sparks:SetLifeTime(0) sparks:SetStartSize(3) sparks:SetStartAlpha(255) sparks:SetStartLength(15) sparks:SetEndLength(3) sparks:SetEndSize(3) sparks:SetEndAlpha(255) sparks:SetGravity(Vector(0,0,-800)) end end for i=1,math.ceil(self.Scale*25) do local vecang = ((self.Normal*2) + VectorRand()*math.Rand(32,32)):GetNormalized() local velocity = math.Rand(356,900)*vecang local particle = self.emitter:Add("particle/particle_smokegrenade", self.Position + vecang*16*self.Scale) particle:SetVelocity(velocity*self.Scale) particle:SetGravity(VectorRand()*math.Rand(200,400)) particle:SetAirResistance(300) particle:SetDieTime(math.Rand(6.6,8.8)*self.Scale) particle:SetStartAlpha(math.Rand(230,250)) particle:SetStartSize(math.Rand(150,200)*self.ScaleSlow) particle:SetEndSize(math.Rand(200,240)*self.ScaleSlow) particle:SetRoll(math.Rand(150,180)) particle:SetRollDelta(0.4*math.random(-1,1)) particle:SetColor(55,55,55) end for i=1,math.ceil(self.Scale*25) do local vecang = ((self.Normal*2) + VectorRand()*math.Rand(32,32)):GetNormalized() local velocity = math.Rand(35,90)*vecang local particle = self.emitter:Add("particle/particle_smokegrenade", self.Position + vecang*16*self.Scale) particle:SetVelocity(velocity*self.Scale) particle:SetGravity(self.Normal*math.Rand(500,800)) particle:SetAirResistance(300) particle:SetDieTime(math.Rand(2.6,3.8)*self.Scale) particle:SetStartAlpha(math.Rand(230,250)) particle:SetStartSize(math.Rand(50,100)*self.ScaleSlow) particle:SetEndSize(math.Rand(100,140)*self.ScaleSlow) particle:SetRoll(math.Rand(150,180)) particle:SetRollDelta(0.4*math.random(-1,1)) particle:SetColor(55,55,55) end for i=1,math.ceil(self.Scale*15) do local vecang = (self.Normal + VectorRand()*math.Rand(32,32)):GetNormalized() local velocity = (self.Normal*math.Rand(64,256)) + (math.Rand(256,400)*vecang) local particle = self.emitter:Add("particles/fire1", self.Position + vecang*5*self.Scale) particle:SetVelocity(velocity*self.Scale) particle:SetGravity(self.Normal*math.Rand(150,175)) particle:SetAirResistance(300) particle:SetDieTime(math.Rand(2.6,3.8)*self.Scale) particle:SetStartAlpha(255) particle:SetEndAlpha(0) particle:SetStartSize(math.Rand(100,200)*self.ScaleSlow) particle:SetEndSize(math.Rand(100,200)*self.ScaleSlow) particle:SetColor(255,255,255) end for i=1,math.ceil(self.Scale*45) do local vecang = Vector(math.Rand(-1,1),math.Rand(-1,1),0):GetNormalized() local velocity = 1200*vecang local particle = self.emitter:Add("sprites/heatwave", self.Position + Vector(0,0,10)) local dietime = 0.8*self.Scale particle:SetVelocity(velocity) particle:SetDieTime(dietime) particle:SetLifeTime(0) particle:SetStartAlpha(60) particle:SetEndAlpha(0) particle:SetStartSize(40*self.Scale) particle:SetEndSize(160*self.Scale) particle:SetColor(205,205,255) particle:SetAirResistance(10) local vecang = Vector(math.Rand(-1,1),math.Rand(-1,1),0):GetNormalized() local velocity = 800*vecang local particle = self.emitter:Add("particle/smoke_black_smokestack000", self.Position + Vector(0,0,10)) local dietime = 0.8*self.Scale particle:SetVelocity(velocity) particle:SetDieTime(dietime) particle:SetLifeTime(0) particle:SetStartAlpha(80) particle:SetEndAlpha(0) particle:SetStartSize(40*self.Scale) particle:SetEndSize(160*self.Scale) particle:SetColor(205,205,255) particle:SetAirResistance(400) end self.emitter:Finish() surface.PlaySound("ambient/explosions/exp2.wav") self.Entity:EmitSound("ambient/explosions/explode_1.wav") end --THINK -- Returning false makes the entity die function EFFECT:Think() local TimeLeft = self.KillTime - CurTime() local TimeScale = TimeLeft/self.Duration local FTime = FrameTime() if TimeLeft > 0 then self.FlashAlpha = self.FlashAlpha - 200*FTime self.FlashSize = self.FlashSize + 60000*FTime self.GlowAlpha = 200*TimeScale self.GlowSize = TimeLeft*self.Scale return true else return false end end -- Draw the effect function EFFECT:Render() --base glow render.SetMaterial(tMats.Glow1) render.DrawSprite(self.Position2,7000*self.GlowSize,5500*self.GlowSize,Color(255,240,220,self.GlowAlpha)) --blinding flash if self.FlashAlpha > 0 then render.SetMaterial(tMats.Glow2) render.DrawSprite(self.Position2,self.FlashSize,self.FlashSize,Color(255,245,215,self.FlashAlpha)) end end effects.Register( EFFECT, "bewm_new", true ) [/lua] What it should (and used to, despite me not changing anything) look like: [img]http://cloud.steampowered.com/ugc/1099141251736494572/1AAECC719B6C4ABF2010D1BE130B97B07FD4325B/[/img] What it does now: [img]http://cloud.steampowered.com/ugc/1099141251736384475/91A706087D792746526898242518BCB512A70992/[/img] [img]http://cloud.steampowered.com/ugc/1099141251736522627/16B00B1E9777DCDF84CDCA146C0B1827CC27F0FB/[/img]
Sorry, you need to
Log In
to post a reply to this thread.