Advertisement
CapsAdmin

Untitled

Feb 17th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.09 KB | None | 0 0
  1. hook.Add("EmitSoundWave", 1, function(ent)
  2.     local i = 1
  3.     local id = "particle_test" .. ent:EntIndex()
  4.        
  5.     local emitter = ParticleEmitter(ent:GetPos())
  6.      
  7.     local function Think()
  8.         if i < 0 or not ent:IsValid() then hook.Remove("Think", id) return end
  9.            
  10.         local pos = ent:NearestPoint(ent:GetPos() - ent:GetVelocity())
  11.        
  12.         for i = 1, 50 do
  13.                
  14.             local particle = emitter:Add("sprites/heatwave", pos)
  15.      
  16.             -- movement
  17.             particle:SetVelocity(VectorRand() * 1000)
  18.             particle:SetAirResistance(0)
  19.      
  20.             -- appearance
  21.             particle:SetColor(255, 255, 255)
  22.      
  23.             particle:SetStartAlpha(255)
  24.             particle:SetEndAlpha(0)
  25.      
  26.             particle:SetStartSize(ent:BoundingRadius())
  27.             particle:SetEndSize(0)
  28.      
  29.             particle:SetDieTime(math.random() * 0.3)
  30.        
  31.         end
  32.                
  33.         i = i - FrameTime()
  34.     end
  35.      
  36.     hook.Add("Think", id, Think)
  37. end)
  38.  
  39. sonic_boom_backup=sonic_boom_backup or backup or physenv.GetPerformanceSettings()
  40.  
  41. local settings={}
  42. settings.MaxVelocity=50000
  43. settings.MaxAngularVelocity=50000
  44. physenv.SetPerformanceSettings(settings)
  45.  
  46. local WAVE_CONSTANT=0.001
  47. --size in newtons
  48. function EmitSoundWave(b)
  49.     hook.Run("EmitSoundWave",b)
  50.    
  51.     local speed=((b:GetVelocity():Length()*3600*0.0000254*0.75)/3600)/1000
  52.     local pos=b:GetPos()
  53.     local pitch=0
  54.     local v = LocalPlayer()
  55.    
  56.     pitch=255/((speed*(v:GetPos():Distance(pos)*0.01905))/WAVE_CONSTANT)
  57.     if pitch<255 and pitch>0 then
  58.         if v:GetPos():Distance(pos)>512 then
  59.             if math.random(1,2)==1 then
  60.                 sound.Play('/ambient/weather/thunder4.wav',pos,0,pitch)
  61.             else
  62.                 sound.Play('/ambient/weather/thunder3.wav',pos,0,pitch)
  63.             end
  64.             sound.Play('/fireworks/firework_explosion_3.wav',pos,0,pitch)
  65.             sound.Play('/ambient/arrowlight.wav',pos,0,pitch)
  66.         else
  67.             sound.Play('/ambient/machines/floodgate_stop1',pos,0,128)
  68.         end
  69.     end
  70.  
  71. end
  72.  
  73. timer.Create('DSPtest',0.25,0,function()
  74.     for k,v in pairs(ents.GetAll()) do
  75.         if ((v:GetVelocity():Length()*3600*0.01905)/1000)>100 and v:IsPlayer()==false then
  76.             if v.sonicboom==nil then
  77.                 v.sonicboom=true
  78.                 EmitSoundWave(v)
  79.             end
  80.         else
  81.             v.sonicboom=nil
  82.         end
  83.     end
  84. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement