|
ENT.Base = "ananke_entitybase" |
|
|
|
ENT.PrintName = "wp_smoke" |
|
ENT.Author = "Lenny., WARPAC team" |
|
ENT.Contact = "warpac-rp.com" |
|
ENT.Instructions = "mhm" |
|
|
|
ENT.Spawnable = true |
|
ENT.Emitter = false |
|
|
|
|
|
ENT.Sound = {} |
|
ENT.Sound.name = "wp_smoke_sound" |
|
ENT.Sound.channel = CHAN_AUTO |
|
ENT.Sound.volume = 1 |
|
ENT.Sound.pitchstart = 100 |
|
ENT.Sound.pitchend = 100 |
|
ENT.Sound.sound = "weapons/smokegrenade/sg_explode.wav" |
|
|
|
ENT.GoOffEnt = "env_spar" |
|
|
|
sound.Add(ENT.Sound) |
|
|
|
|
|
ENT.SmokePartTab = {} |
|
|
|
for i = 1, 9 do |
|
table.insert(ENT.SmokePartTab, "000"..i) |
|
end |
|
for i = 1, 6 do |
|
table.insert(ENT.SmokePartTab, "001"..i) |
|
end |
|
|
|
function ENT:Initialize() |
|
self.Emitter = ParticleEmitter(self:GetExhaustPos()) |
|
timer.Simple(3, function() |
|
self:EmitSound(self.Sound.name) |
|
self:Smoke() |
|
end) |
|
end |
|
function ENT:Smoke() |
|
if CLIENT then chat.AddText("Smoking!") end |
|
timer.Create("Smoke"..self:EntIndex(), .01, 500, function() |
|
self:SmokeParticles() |
|
end) |
|
end |
|
|
|
function ENT:GetExhaustPos() |
|
return self:GetPos() + self:GetUp()*6 |
|
end |
|
|
|
function ENT:SmokeParticles() |
|
local particle = self.Emitter:Add("particle/smokesprites_"..self:RandSmokeSprite(), self:GetExhaustPos()) |
|
if particle then |
|
particle:SetVelocity(self:SmokeVel()) |
|
particle:SetLifeTime(0) |
|
particle:SetDieTime(3) |
|
particle:SetStartAlpha( 255 ) |
|
particle:SetEndAlpha(0) |
|
particle:SetStartSize(1) |
|
particle:SetEndSize(200) |
|
particle:SetColor(200, 200, 200) |
|
particle:SetGravity(Vector(0,0, 50)) |
|
particle:SetAirResistance(50) |
|
particle:SetCollide(true) |
|
particle:SetBounce(.2) |
|
end |
|
end |
|
|
|
function ENT:RandSmokeSprite() |
|
return table.Random(self.SmokePartTab) |
|
end |
|
|
|
function ENT:SmokeVel() |
|
|
|
local xspeed = math.random(200, 450) |
|
local yspeed = math.random(200, 450) |
|
local zspeed = math.random(0, 50) |
|
local dir = self:GetUp() |
|
local rand = Vector(xspeed, yspeed,zspeed) |
|
local smokevel = Vector(dir.x*xspeed, dir.y*yspeed, dir.z*zspeed) |
|
return smokevel |
|
end |
|
|
|
function ENT:Think() |
|
if self.Emitter then |
|
self.Emitter:SetPos(self:GetExhaustPos()) |
|
end |
|
end |
|
|
|
function ENT:OnRemove() |
|
if self.Emitter then |
|
timer.Destroy("Smoke"..self:EntIndex()) |
|
self.Emitter:Finish() |
|
end |
|
end |