SHOW:
|
|
- or go back to the newest paste.
| 1 | if CLIENT then | |
| 2 | ||
| 3 | local blur = Material("pp/blurscreen")
| |
| 4 | local emitter = ParticleEmitter(Vector(0,0,0)) | |
| 5 | ||
| 6 | local function emmit_bubbles(ent) | |
| 7 | ||
| 8 | if ent:BoundingRadius() < 10 then return end | |
| 9 | ||
| 10 | local vel = ent:GetVelocity() | |
| 11 | local len = vel:Length() | |
| 12 | if len < 100 then return end | |
| 13 | - | ply.water_snd = CreateSound(LocalPlayer(), "ambient/water/underwater.wav") |
| 13 | + | |
| 14 | local min, max = ent:OBBMins(), ent:OBBMaxs() | |
| 15 | ||
| 16 | local pos = Vector(math.Rand(min.x, max.x), math.Rand(min.y, max.y), math.Rand(min.z, max.z)) | |
| 17 | ||
| 18 | for i = 1, 10 do | |
| 19 | ||
| 20 | local particle = emitter:Add("effects/bubble", ent:GetPos() + pos)
| |
| 21 | ||
| 22 | particle:SetColor(255, 255, 255, 255) | |
| 23 | particle:SetVelocity((vel / 4) + VectorRand() * 10) | |
| 24 | ||
| 25 | local size = math.Rand(0.25, 3) | |
| 26 | ||
| 27 | particle:SetDieTime(size) | |
| 28 | particle:SetLifeTime(0) | |
| 29 | ||
| 30 | particle:SetStartSize(0) | |
| 31 | particle:SetEndSize(size * math.Rand(1, 2)) | |
| 32 | ||
| 33 | particle:SetStartAlpha(255) | |
| 34 | particle:SetEndAlpha(0) | |
| 35 | particle:SetGravity(Vector(math.Rand(-4, 4),math.Rand(-4, 4), size * math.Rand(10, 25))) | |
| 36 | particle:SetCollide(true) | |
| 37 | particle:SetRollDelta(1) | |
| 38 | end | |
| 39 | ||
| 40 | ent:EmitSound(("ambient/water/wave%i.wav"):format(math.random(1, 6)), 100, math.random(200, 230))
| |
| 41 | end | |
| 42 | ||
| 43 | hook.Add("RenderScreenspaceEffects", "water", function()
| |
| 44 | local ply = LocalPlayer() | |
| 45 | ||
| 46 | if not ply:IsFlying() or ply ~= me then | |
| 47 | if ply.water_snd then ply.water_snd:Stop() ply.water_snd = nil ply:SetDSP(0) end | |
| 48 | return end | |
| 49 | ||
| 50 | if not ply.water_snd then | |
| 51 | ply.water_snd = CreateSound(ply, "ambient/water/underwater.wav") | |
| 52 | elseif not ply.water_snd:IsPlaying() then | |
| 53 | ply.water_snd = nil | |
| 54 | end | |
| 55 | ||
| 56 | for k,v in pairs(ents.FindInSphere(ply:GetPos(), 500)) do | |
| 57 | emmit_bubbles(v) | |
| 58 | end | |
| 59 | ||
| 60 | ply.water_snd:PlayEx(1, 30) | |
| 61 | -- lowpass filter | |
| 62 | ply:SetDSP(31) | |
| 63 | ||
| 64 | local W = ScrW() | |
| 65 | local H = ScrH() | |
| 66 | - | end |
| 66 | + | |
| 67 | surface.SetMaterial(blur) | |
| 68 | - | hook.Add("Move", "water", function(ply)
|
| 68 | + | |
| 69 | - | if not ply:IsFlying() or ply ~= me then return end |
| 69 | + | |
| 70 | - | local vel = ply:GetVelocity() |
| 70 | + | |
| 71 | - | vel.z = vel.z * 3 |
| 71 | + | |
| 72 | - | ply:SetVelocity(vel * -0.1) |
| 72 | + | |
| 73 | - | end) |
| 73 | + | |
| 74 | surface.DrawTexturedRect(0, 0, W, H) | |
| 75 | end | |
| 76 | end) | |
| 77 | ||
| 78 | local function draw_fog() | |
| 79 | local ply = LocalPlayer() | |
| 80 | if not ply:IsFlying() or ply ~= me then return end | |
| 81 | ||
| 82 | render.SetFogZ(5) | |
| 83 | render.FogMode(1) | |
| 84 | render.FogStart(0) | |
| 85 | render.FogEnd(256) | |
| 86 | render.FogMaxDensity(0.999) | |
| 87 | ||
| 88 | local c = render.GetLightColor(ply:EyePos()) | |
| 89 | ||
| 90 | c.r = c.r * 0.6 | |
| 91 | c.g = c.g * 1 | |
| 92 | c.b = c.b * 2 | |
| 93 | ||
| 94 | c = c * 255 | |
| 95 | ||
| 96 | render.FogColor(c.r, c.g, c.b) | |
| 97 | ||
| 98 | return true | |
| 99 | end | |
| 100 | ||
| 101 | hook.Add("SetupSkyboxFog", "water", function()
| |
| 102 | return draw_fog() | |
| 103 | end) | |
| 104 | ||
| 105 | hook.Add("SetupWorldFog", "water", function()
| |
| 106 | return draw_fog() | |
| 107 | end) | |
| 108 | end |