Advertisement
CapsAdmin

Untitled

May 25th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.61 KB | None | 0 0
  1. if CLIENT then
  2.    
  3.     local blur = Material("pp/blurscreen")
  4.    
  5.     hook.Add("RenderScreenspaceEffects", "water", function()
  6.         local ply = LocalPlayer()
  7.  
  8.         if not ply:IsFlying() or ply ~= me then
  9.             if ply.water_snd then ply.water_snd:Stop() ply.water_snd = nil ply:SetDSP(0) end       
  10.         return end
  11.                        
  12.         if not ply.water_snd then
  13.             ply.water_snd = CreateSound(LocalPlayer(), "ambient/water/underwater.wav") 
  14.         elseif not ply.water_snd:IsPlaying() then
  15.             ply.water_snd = nil
  16.         end
  17.                        
  18.         ply.water_snd:PlayEx(1, 30)
  19.         -- lowpass filter
  20.         ply:SetDSP(31)     
  21.            
  22.         local W = ScrW()
  23.         local H = ScrH()
  24.            
  25.         surface.SetMaterial(blur)  
  26.         surface.SetDrawColor(255, 255, 255, 255)
  27.                    
  28.         for i = 0.33, 2, 0.33 do
  29.             blur:SetFloat("$blur", 2 * i)
  30.             blur:Recompute()
  31.             render.UpdateScreenEffectTexture()
  32.             surface.DrawTexturedRect(0, 0, W, H)
  33.         end
  34.     end)
  35.    
  36.     local function draw_fog()
  37.         local ply = LocalPlayer()
  38.         if not ply:IsFlying() or ply ~= me then return end
  39.            
  40.         render.SetFogZ(5)
  41.         render.FogMode(1)
  42.         render.FogStart(0)
  43.         render.FogEnd(256)
  44.         render.FogMaxDensity(0.999)
  45.        
  46.         local c = render.GetLightColor(ply:EyePos())
  47.        
  48.         c.r = c.r * 0.6
  49.         c.g = c.g * 1
  50.         c.b = c.b * 2
  51.        
  52.         c = c * 255
  53.        
  54.         render.FogColor(c.r, c.g, c.b)
  55.    
  56.         return true
  57.     end
  58.    
  59.     hook.Add("SetupSkyboxFog", "water", function()
  60.         return draw_fog()
  61.     end)
  62.    
  63.     hook.Add("SetupWorldFog", "water", function()
  64.         return draw_fog()
  65.     end)
  66. end
  67.  
  68. hook.Add("Move", "water", function(ply)
  69.     if not ply:IsFlying() or ply ~= me then return end
  70.     local vel = ply:GetVelocity()
  71.         vel.z = vel.z * 3
  72.     ply:SetVelocity(vel * -0.1)
  73. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement