Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ENT = {}
- ENT.Type = "anim"
- function ENT:SetupDataTables()
- self:DTVar("Float", 0, "size")
- end
- if CLIENT then
- local mat = Material("sprites/light_glow02_add_noz")
- local size = 5
- function ENT:Draw()
- local size = self.dt.size
- render.SetColorModulation(0,0,0)
- render.SetBlend(0.99)
- self:DrawModel()
- render.SetMaterial(mat)
- render.DrawSprite(self:GetPos(), 500 * size, 500 * size, HSVToColor(math.Rand(0, 40), 0.1, 1))
- end
- hook.Add("RenderScreenspaceEffects", "meteor", function()
- for key, ent in pairs(ents.FindByClass("meteor")) do
- local pos = ent:GetPos()
- local spos = pos:ToScreen()
- if spos.visible then
- local mult = (math.Clamp(pac.EyeAng:Forward():DotProduct((pos - pac.EyePos):GetNormalized()) - 0.5, 0, 1) * 2) ^ 5
- DrawSunbeams(0, 0.1 * mult, 0.05, spos.x/ScrW(), spos.y/ScrH())
- end
- end
- end)
- local pos = here
- local emitter = ParticleEmitter(vector_origin)
- local particles = {}
- local sounds =
- {
- "npc/headcrab_poison/ph_step2.wav",
- "npc/headcrab_poison/ph_step3.wav",
- "npc/headcrab_poison/ph_step4.wav",
- }
- local WorldSound = WorldSound
- local math_random = math.random
- local function collide(self, pos, normal)
- WorldSound(sounds[math_random(#sounds)], pos, 60, math_random(25, 70))
- end
- local gravity = physenv.GetGravity() * 0.5
- local rand_vel = Vector()
- function ENT:Think(mult, vel_mult)
- vel_mult = vel_mult or 1
- mult = mult or 1
- local vel = self:GetVelocity() * vel_mult * self.dt.size * 0.25
- local t = CurTime()
- local delta = FrameTime()
- local c = HSVToColor(math.Rand(0, 40), 0.5, 1)
- local particle = emitter:Add("sprites/light_glow02_add", self:GetPos() + VectorRand() * self:BoundingRadius()/2 * size - vel*0.1)
- rand_vel.x = math.Rand(-1, 1) * 100 * mult
- rand_vel.y = math.Rand(-1, 1) * 100 * mult
- rand_vel.z = math.Rand(-1, 1) * 100 * mult
- -- movement
- particle:SetVelocity(rand_vel - vel)
- particle:SetAirResistance(0)
- particle:SetGravity(gravity)
- particle:SetCollide(true)
- particle:SetBounce(0.25)
- -- appearance
- particle:SetColor(c.r, c.g, c.b)
- particle.clr = c
- particle:SetStartAlpha(255)
- particle:SetEndAlpha(0)
- particle:SetStartSize(100*self.dt.size)
- particle:SetEndSize(0)
- particle:SetDieTime(math.Rand(1.5, 2.5))
- particle:SetStartLength(0)
- particle:SetEndLength(0)
- particle:SetCollideCallback(collide)
- table.insert(particles, particle)
- self:NextThink(t)
- return true
- end
- local mat = Material("particle/Particle_Glow_04_Additive")
- local render_DrawBeam = render.DrawBeam
- local render_SetMaterial = render.SetMaterial
- hook.Add("PostDrawTranslucentRenderables", "meteor", function()
- for key, particle in pairs(particles) do
- local delta = particle:GetDieTime() - particle:GetLifeTime()
- if delta > 0 then
- local pos = particle:GetPos()
- local vel = particle:GetVelocity()
- render_SetMaterial(mat)
- render_DrawBeam(pos + vel * 0.05, pos - vel * 0.25, delta * particle:GetStartSize() * 0.25, 0, 1, particle.clr)
- else
- particles[key] = nil
- end
- end
- end)
- function ENT:OnRemove()
- for i =1, 100 do
- self:Think(10, 0.1)
- end
- local ef = EffectData()
- ef:SetOrigin(self:GetPos())
- util.Effect("explosion", ef)
- end
- end
- if SERVER then
- function ENT:Initialize()
- self:SetModel("models/Combine_Helicopter/helicopter_bomb01.mdl")
- self:PhysicsInit(SOLID_VPHYSICS)
- local phys = self:GetPhysicsObject()
- phys:SetDamping(0,0)
- phys:SetMass(50000)
- self.dt.size = ((math.random() ^ 3) * 8) + 0.5
- end
- function ENT:PhysicsCollide(data)
- if math.deg(math.abs(data.HitNormal.z)) > 50 then
- timer.Simple(0, function() self:Remove() end)
- end
- end
- end
- scripted_ents.Register(ENT, "meteor")
- if SERVER then
- local sky = 40
- local size = 14000
- timer.Create("meteor_spawn", 1, 0, function()
- if math.random() < 0.95 then return end
- local pos = Vector(math.Rand(-size, size), math.Rand(-size, size), math.Rand(sky - 1000, sky))
- if util.IsInWorld(pos) then
- local ent = ents.Create("meteor")
- ent:SetPos(pos)
- ent:Spawn()
- local phys = ent:GetPhysicsObject()
- phys:AddVelocity(Vector(math.Rand(-10, 10), math.Rand(-10, 10), math.Rand(-10, 0))* 10000)
- end
- end)
- end
- --
Advertisement
Add Comment
Please, Sign In to add comment