Python1320

NightExcessive

Dec 3rd, 2010
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.96 KB | None | 0 0
  1. --snow_data = nil
  2.  
  3. snow_data = snow_data or {}
  4.  
  5.  
  6. if table.Count(snow_data) == 0 then
  7.  
  8.     local max = 16000
  9.     local grid_size = 512
  10.     local range = max/grid_size
  11.  
  12.     local pos
  13.  
  14.     for x = -range, range do
  15.         x = x * grid_size
  16.         for y = -range, range do
  17.             y = y * grid_size
  18.             for z = -range, range do
  19.                 z = z * grid_size
  20.                
  21.                 pos = Vector(x,y,z)
  22.                 local up = util.QuickTrace(pos, vector_up*max*2)
  23.                 local conents = util.PointContents( pos )
  24.                
  25.                 if (up.HitTexture == "TOOLS/TOOLSSKYBOX" or up.HitTexture == "**empty**") and (conents == CONTENTS_EMPTY or conents == CONTENTS_TESTFOGVOLUME)  then
  26.                     table.insert(snow_data, pos)
  27.                 end
  28.             end
  29.         end
  30.     end
  31.  
  32. end
  33.  
  34. local function FastLength(point)
  35.     return point.x*point.x+point.y*point.y+point.z*point.z
  36. end
  37.  
  38. local draw_these = {}
  39.  
  40. local emitter = ParticleEmitter(EyePos(), false)
  41.  
  42. hook.Add("Think", "snow", function()
  43.     for _, point in pairs(draw_these) do
  44.         if math.random() < 0.95 then continue end
  45.         local particle = emitter:Add("particle/snow", point)
  46.         if (particle) then
  47.             particle:SetVelocity(VectorRand()*70*Vector(1,1,0))
  48.             particle:SetAngles(Angle(math.random(360), math.random(360), math.random(360)))
  49.             particle:SetLifeTime(0)
  50.             particle:SetDieTime(10)
  51.             particle:SetStartAlpha(255)
  52.             particle:SetEndAlpha(0)
  53.             particle:SetStartSize(0)
  54.             particle:SetEndSize(5)
  55.             particle:SetGravity(Vector(0,0,math.Rand(-30, -200)))
  56.             particle:SetCollide(true)
  57.         end
  58.     end
  59. end)
  60.  
  61. timer.Create("hide_points", 1, 0, function()
  62.     for key, point in pairs(snow_data) do
  63.         if FastLength(point - LocalPlayer():EyePos()) < 4000000 then
  64.             draw_these[key] = point
  65.         else
  66.             draw_these[key] = nil
  67.         end
  68.     end
  69. end)
  70.  
  71. do return end
  72.  
  73. --[[ hook.Remove("HUDPaint",1)
  74.  
  75. local mat = Material("sprites/sent_ball")
  76.  
  77. hook.Add("PostDrawOpaqueRenderables", 1, function()
  78.  
  79.     render.SetMaterial(mat)
  80.     for key, point in pairs(draw_these) do
  81.         render.DrawSprite(point, 50, 50, color_white)
  82.     end
  83.    
  84. end)]]
Advertisement
Add Comment
Please, Sign In to add comment