Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if CLIENT then
- local blur = Material("pp/blurscreen")
- local emitter = ParticleEmitter(Vector(0,0,0))
- local function emmit_bubbles(ent)
- if ent:BoundingRadius() < 10 then return end
- local vel = ent:GetVelocity()
- local len = vel:Length()
- if len < 100 then return end
- local min, max = ent:OBBMins(), ent:OBBMaxs()
- local pos = Vector(math.Rand(min.x, max.x), math.Rand(min.y, max.y), math.Rand(min.z, max.z))
- for i = 1, 10 do
- local particle = emitter:Add("effects/bubble", ent:GetPos() + pos)
- particle:SetColor(255, 255, 255, 255)
- particle:SetVelocity((vel / 4) + VectorRand() * 10)
- local size = math.Rand(0.25, 3)
- particle:SetDieTime(size)
- particle:SetLifeTime(0)
- particle:SetStartSize(0)
- particle:SetEndSize(size * math.Rand(1, 2))
- particle:SetStartAlpha(255)
- particle:SetEndAlpha(0)
- particle:SetGravity(Vector(math.Rand(-4, 4),math.Rand(-4, 4), size * math.Rand(10, 25)))
- particle:SetCollide(true)
- particle:SetRollDelta(1)
- end
- ent:EmitSound(("ambient/water/wave%i.wav"):format(math.random(1, 6)), 100, math.random(200, 230))
- end
- hook.Add("RenderScreenspaceEffects", "water", function()
- local ply = LocalPlayer()
- if not ply:IsFlying() or ply ~= me then
- if ply.water_snd then ply.water_snd:Stop() ply.water_snd = nil ply:SetDSP(0) end
- return end
- if not ply.water_snd then
- ply.water_snd = CreateSound(ply, "ambient/water/underwater.wav")
- elseif not ply.water_snd:IsPlaying() then
- ply.water_snd = nil
- end
- for k,v in pairs(ents.FindInSphere(ply:GetPos(), 500)) do
- emmit_bubbles(v)
- end
- ply.water_snd:PlayEx(1, 30)
- -- lowpass filter
- ply:SetDSP(31)
- local W = ScrW()
- local H = ScrH()
- surface.SetMaterial(blur)
- surface.SetDrawColor(255, 255, 255, 255)
- for i = 0.33, 2, 0.33 do
- blur:SetFloat("$blur", 2 * i)
- blur:Recompute()
- render.UpdateScreenEffectTexture()
- surface.DrawTexturedRect(0, 0, W, H)
- end
- end)
- local function draw_fog()
- local ply = LocalPlayer()
- if not ply:IsFlying() or ply ~= me then return end
- render.SetFogZ(5)
- render.FogMode(1)
- render.FogStart(0)
- render.FogEnd(256)
- render.FogMaxDensity(0.999)
- local c = render.GetLightColor(ply:EyePos())
- c.r = c.r * 0.6
- c.g = c.g * 1
- c.b = c.b * 2
- c = c * 255
- render.FogColor(c.r, c.g, c.b)
- return true
- end
- hook.Add("SetupSkyboxFog", "water", function()
- return draw_fog()
- end)
- hook.Add("SetupWorldFog", "water", function()
- return draw_fog()
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement