Guest User

Untitled

a guest
Jan 21st, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.32 KB | None | 0 0
  1.  
  2. counter = 0
  3. local thunderSounds = {
  4. "ambient/ambience/rainscapes/thunder_close01.wav",
  5. "ambient/ambience/rainscapes/thunder_close02.wav",
  6. "ambient/ambience/rainscapes/thunder_close03.wav",
  7. "ambient/ambience/rainscapes/thunder_close04.wav",
  8. "ambient/ambience/rainscapes/thunder_distant01.wav",
  9. "ambient/ambience/rainscapes/thunder_distant02.wav",
  10. "ambient/ambience/rainscapes/thunder_distant03.wav",
  11. }
  12.  
  13.  
  14. local lightMul = 0
  15. local lightningStrike = false
  16. local function MakeThunder()
  17. lightMul = math.Rand(0.5,1)
  18.  
  19. timer.Simple(math.Rand(0.5,2), function()
  20. local snd = thunderSounds[math.random(1,#thunderSounds)]
  21. LocalPlayer():EmitSound(snd)
  22. end)
  23.  
  24. lightningStrike = true
  25.  
  26. timer.Simple(math.Rand(30,60), MakeThunder)
  27. end
  28. timer.Simple(math.Rand(5,20), MakeThunder)
  29.  
  30.  
  31. //local emitter = ParticleEmitter(LocalPlayer():GetPos())
  32. -- emitter:SetParticleCullRadius(1)
  33. local emitter3d = ParticleEmitter(LocalPlayer():GetPos(), true)
  34.  
  35. -- snd1:Play()
  36. -- snd2:Play()
  37.  
  38. hook.Add("PreDrawSkyBox", "Rain PreDrawSkyBox", function()
  39. end)
  40.  
  41. local mat = Material( "models/debug/debugwhite" )
  42.  
  43. local mat = CreateMaterial( "WhiteMaterial", "UnlitGeneric", { -- Necessary to assign color by vertex
  44. ["$basetexture"] = "color/white",
  45. ["$vertexcolor"] = 1, -- Necessary to assign color by vertex
  46. ["$vertexalpha"] = 1, -- Necessary to assign alpha to vertex
  47. ["$model"] = 1
  48. } );
  49.  
  50. local lightning =
  51. {
  52. {
  53. rad = 0,
  54. segments = {
  55. Vector(100,0,0),
  56. Vector(0,100,0),
  57. Vector(-25,50,0)
  58. },
  59. life = 1
  60. }
  61. }
  62.  
  63. local nextCloudEmit = 0
  64. hook.Add("PostDrawSkyBox", "Rain PostDrawSkyBox", function()
  65.  
  66. lightMul = math.Approach(lightMul, 0, FrameTime() * 3)
  67.  
  68. local alpha = 200 + (55 * lightMul)
  69. cam.Start3D(LocalPlayer():EyePos(),LocalPlayer():EyeAngles())
  70. render.SuppressEngineLighting(true)
  71.  
  72. local light = 255 * lightMul
  73.  
  74. render.SetMaterial( mat )
  75. render.DrawQuadEasy( Vector(0,0,10240), --position of the rect
  76. Vector(0,0,-1), --direction to face in
  77. 20480, 20480, --size of the rect
  78. Color( light, light, light, alpha ), --color
  79. 90 --rotate 90 degrees
  80. )
  81. render.SetMaterial( mat )
  82. render.DrawQuadEasy( Vector(0,10240,0), --position of the rect
  83. Vector(0,-1,0), --direction to face in
  84. 20480, 20480, --size of the rect
  85. Color( light, light, light, alpha ), --color
  86. 90 --rotate 90 degrees
  87. )
  88. render.SetMaterial( mat )
  89. render.DrawQuadEasy( Vector(0,-10240,0), --position of the rect
  90. Vector(0,1,0), --direction to face in
  91. 20480, 20480, --size of the rect
  92. Color( light, light, light, alpha ), --color
  93. 90 --rotate 90 degrees
  94. )
  95. render.SetMaterial( mat )
  96. render.DrawQuadEasy( Vector(10240,0,0), --position of the rect
  97. Vector(-1,0,0), --direction to face in
  98. 20480, 20480, --size of the rect
  99. Color( light, light, light, alpha ), --color
  100. 90 --rotate 90 degrees
  101. )
  102. render.SetMaterial( mat )
  103. render.DrawQuadEasy( Vector(-10240,0,0), --position of the rect
  104. Vector(1,0,0), --direction to face in
  105. 20480, 20480, --size of the rect
  106. Color( light, light, light, alpha ), --color
  107. 90 --rotate 90 degrees
  108. )
  109. render.SuppressEngineLighting(false)
  110.  
  111.  
  112.  
  113. cam.End3D()
  114.  
  115. if(nextCloudEmit < CurTime()) then
  116. p = emitter3d:Add("particle/smokesprites_000" .. math.random(1,9), Vector(math.Rand(-8000,8000),math.Rand(-8000,8000),5000))
  117. p:SetColor(50, 50, 50)
  118. p:SetLifeTime(0)
  119. p:SetDieTime(30)
  120. p:SetStartSize(10500)
  121. p:SetEndSize(0)
  122. p:SetStartAlpha(0)
  123. p:SetEndAlpha(180)
  124. p:SetRoll(math.Rand(0,360))
  125. p:SetAngles(Angle(90,0,0))
  126.  
  127. nextCloudEmit = CurTime() + 0.3
  128. end
  129.  
  130. if(lightningStrike) then
  131. lightningStrike = false
  132. p = emitter3d:Add("particle/smokesprites_000" .. math.random(1,9), Vector(math.Rand(-8000,8000),math.Rand(-8000,8000),4900))
  133. p:SetColor(255, 255, 255)
  134. p:SetLifeTime(0)
  135. p:SetDieTime(0.1)
  136. p:SetStartSize(5500)
  137. p:SetEndSize(0)
  138. p:SetStartAlpha(255)
  139. p:SetEndAlpha(0)
  140. p:SetRoll(math.Rand(0,360))
  141. p:SetAngles(Angle(90,0,0))
  142. end
  143. end)
  144.  
  145. hook.Add("Tick", "Test08", function()
  146. local p = nil
  147. local q = nil
  148. local w = nil
  149. local s = nil
  150. local emitter = ParticleEmitter(LocalPlayer():GetPos())
  151. local retr = LocalPlayer():GetPos() + (LocalPlayer():GetVelocity() * 0.5)
  152. for i=1,60 do
  153. local temp = retr
  154. temp = Vector(temp.x + math.random(-1500, 1500),temp.y + math.random(-1500, 1500),1000)
  155. p = emitter:Add("particle/snow", temp)
  156. p:SetCollide(true)
  157. p:SetLifeTime(0)
  158. p:SetDieTime(0.7)
  159. p:SetStartSize(1)
  160. p:SetStartAlpha(255)
  161. p:SetEndAlpha(255)
  162. p:SetStartLength(50)
  163. p:SetEndLength(50)
  164. p:SetVelocity(Vector(0,0,-3000 + math.random(0, 500)))
  165.  
  166. p:SetCollideCallback(function(part, hitpos, hitnormal)
  167. q = emitter:Add("particle/smokesprites_000" .. math.random(1,9), hitpos)// + (hitnormal * Size))
  168. q:SetLifeTime(0)
  169. q:SetDieTime(0.4)
  170. q:SetStartSize(math.Rand(15,30))
  171. q:SetEndSize(0)
  172. q:SetStartAlpha(16)
  173. q:SetEndAlpha(0)
  174. q:SetRoll(math.random(0,360))
  175. q:SetRollDelta(math.Rand(-0.52,0.52))
  176.  
  177. //if(math.random(0,50) == 0) then
  178. counter = counter+1
  179. if(counter >= 160) then
  180. local temp3 = 1 - 1/LocalPlayer():GetPos():Distance(hitpos)
  181. WorldSound("rain".. math.random(1,4) ..".wav", hitpos, (75*temp3), (50*temp3)+50)
  182. counter = 0
  183. end
  184. end)
  185.  
  186. end
  187. for i=1,3 do
  188. local temp2 = retr
  189. temp2 = Vector(temp2.x + math.random(-5000, 5000),temp2.y + math.random(-5000, 5000),1000)
  190. w = emitter:Add("particle/snow", temp2)
  191. w:SetCollide(true)
  192. w:SetLifeTime(0)
  193. w:SetDieTime(0.7)
  194. w:SetStartSize(1)
  195. w:SetStartAlpha(255)
  196. w:SetEndAlpha(255)
  197. w:SetStartLength(50)
  198. w:SetEndLength(50)
  199. w:SetVelocity(Vector(0,0,-3000))
  200.  
  201. w:SetCollideCallback(function(part, hitpos, hitnormal)
  202. local Size = math.Rand(180,480)
  203. s = emitter:Add("particle/smokesprites_000" .. math.random(1,9), hitpos + ((hitnormal/2) * Size))
  204. s:SetLifeTime(0)
  205. s:SetDieTime(10)
  206. s:SetStartSize(Size)
  207. s:SetEndSize(math.Rand(180,480))
  208. s:SetStartAlpha(5)
  209. s:SetEndAlpha(2)
  210. s:SetRoll(math.random(0,360))
  211. s:SetRollDelta(math.Rand(-0.2,0.2))
  212. end)
  213. end
  214. emitter:Finish()
  215. end)
Add Comment
Please, Sign In to add comment