Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.37 KB | None | 0 0
  1. hook.Add("PlayerFootstep", "snow", function(ply, pos, foot, sound, volume, rf)
  2. if sound:find("grass") then
  3. ply:EmitSound(Format("player/footsteps/snow%s.wav", math.random(6)), 60, math.random(95,105))
  4. return true
  5. end
  6. end)
  7.  
  8. if SERVER then
  9. engine.LightStyle(0, "b")
  10. end
  11.  
  12. if CLIENT then
  13. timer.Simple(1, function()
  14. render.RedownloadAllLightmaps()
  15. end)
  16. end
  17.  
  18. if SERVER then return end
  19. module ( "ms" , package.seeall )
  20.  
  21. --snow_data = nil
  22. snow_data = snow_data or {}
  23.  
  24. local replace = {
  25. ["METASTRUCT_2/GRASS"] = true,
  26. ["GM_CONSTRUCT/GRASS"] = true,
  27. ["nature/grassfloor002a"] = true,
  28. ["nature/blendgrassgravel001a"] = true,
  29. ["metastruct_2/blendgrass"] = true,
  30. ["shadertest/seamless7"] = true,
  31. ["nature/blenddirtgrass008b_lowfriction"] = true,
  32. ["metastruct_2/blend_mud_rock"] = true,
  33. ["nature/blenddirtgrass005a"] = true,
  34. ["nature/blendsandgrass008a"] = true,
  35. ["nature/red_grass"] = true,
  36. ["nature/red_grass"] = true,
  37. ["metastruct_2/blendg"] = true,
  38. ["gm_construct/grass-sand"] = true,
  39. ["nature/grassfloor002a_replacement"] = true,
  40. ["nature/blendgrassgrass001a"] = true,
  41. ["nature/blendsandgr"] = true,
  42. ["nature/blendgroundtograss008"] = true,
  43. ["custom/grasstexture4"] = true,
  44. ["custom/grasssandblend08"] = true,
  45. ["custom/grasssandblend09"] = true,
  46. ["maps/gm_bluehills/custom/grasssandblend08_wvt_patch"] = true,
  47. ["maps/gm_bluehills/custom/grasssandblend09_wvt_patch"] = true,
  48. ["METASTRUCT_2/LOBBYFLOOR"] = true,
  49. ["maps/gm_construct_m_56/concrete/concretefloor039a_-13999_38_14371"] = true,
  50. ["maps/gm_construct_m_56/concrete/concretefloor039a_-13165_34_14392"] = true,
  51.  
  52. --[[ ["maps/metastruct_2/metastruct_2/road_6120_8680_-12944"] = true,
  53. ["maps/metastruct_2/metastruct_2/road_-3656_12928_-13216"] = true,
  54. ["maps/metastruct_2/metastruct_2/road_-6332_11456_-13184"] = true,
  55. ["CONCRETE/CONCRETEFLOOR001A"] = true,
  56. ["maps/metastruct_2/tile/tileroof004b_-13744_12784_-13200"] = true,
  57. ["maps/metastruct_2/tile/tileroof004a_-14224_11856_-13216"] = true,
  58. ["maps/metastruct_2/tile/tileroof004a_-14192_12176_-12784"] = true,
  59. ["maps/metastruct_2/metastruct_2/road_-13008_12656_-13104"] = true,
  60.  
  61.  
  62.  
  63.  
  64. ["maps/metastruct_2/tile/tileroof004a_6120_8680_-12944"] = true,
  65. ["maps/metastruct_2/tile/tileroof004b_-14192_12176_-12784"] = true,
  66. ["maps/metastruct_2/tile/tileroof004b_-9035_13056_-13188"] = true,
  67. ["maps/metastruct_2/metastruct_2/road_-9035_13056_-13188"] = true,
  68. ["maps/metastruct_2/tile/tileroof004a_-6332_11456_-13184"] = true,
  69. ["maps/metastruct_2/tile/tileroof004b_6120_8680_-12944"] = true, ]]
  70.  
  71.  
  72. }
  73. local rt = { "roof", "grass", "ceiling" }
  74.  
  75. if table.Count(snow_data) == 0 then
  76.  
  77. local max = 16000
  78. local grid_size = 768
  79. local range = max/grid_size
  80.  
  81. local pos
  82.  
  83. for x = -range, range do
  84. x = x * grid_size
  85. for y = -range, range do
  86. y = y * grid_size
  87. for z = -range, range do
  88. z = z * grid_size
  89.  
  90. pos = Vector(x,y,z)
  91. local conents = util.PointContents( pos )
  92.  
  93. if conents == CONTENTS_EMPTY or conents == CONTENTS_TESTFOGVOLUME then
  94. local up = util.QuickTrace(pos, vector_up*max*2)
  95. if up.HitTexture == "TOOLS/TOOLSSKYBOX" or up.HitTexture == "**empty**" then
  96. table.insert(snow_data, pos)
  97. --[[ local down = util.QuickTrace(pos, (vector_up*-1)*max*2)
  98. if down.Hit then
  99. local t = down.HitTexture:lower()
  100. for k,v in pairs(rt) do
  101. if string.find(t, v) ~= nil then
  102. replace[t] = true
  103. end
  104. end
  105. end ]]
  106. end
  107. end
  108. end
  109. end
  110. end
  111. end
  112.  
  113. local function FastLength(point)
  114. return point.x*point.x+point.y*point.y+point.z*point.z
  115. end
  116.  
  117. draw_these = {}
  118.  
  119. local emitter = ParticleEmitter(EyePos(), false)
  120.  
  121. local snow_explode = CreateClientConVar("snow_explode", "0", true, false)
  122.  
  123. local function SnowCallback(p, hitpos)
  124. if snow_explode:GetBool() then
  125. local efdata = EffectData() --Grab base EffectData table
  126. efdata:SetOrigin(hitpos) --Sets the origin of it to the hitpos of the particle
  127. efdata:SetStart(hitpos)
  128. efdata:SetScale(0.2)
  129. util.Effect("Explosion", efdata) --Create the effect
  130. end
  131. p:SetDieTime(0)
  132. end
  133.  
  134. if true then
  135. hook.Add("Think", "snow", function()
  136. for _, point in pairs(draw_these) do
  137. if math.random() < 0.95 then continue end
  138. local particle = emitter:Add("particle/snow", point)
  139. if (particle) then
  140. particle:SetVelocity(VectorRand()*100*Vector(1,1,0))
  141. particle:SetAngles(Angle(math.random(360), math.random(360), math.random(360)))
  142. particle:SetLifeTime(0)
  143. particle:SetDieTime(10)
  144. particle:SetStartAlpha(255)
  145. particle:SetEndAlpha(0)
  146. particle:SetStartSize(0)
  147. particle:SetEndSize(5)
  148. particle:SetGravity(Vector(0,0,math.Rand(-30, -200)))
  149. particle:SetCollide(true)
  150. particle:SetCollideCallback(SnowCallback)
  151. end
  152. end
  153. end)
  154.  
  155. local function CreateSnowLoop(t)
  156. local iterations = math.min(math.ceil(#snow_data/(1/t)), #snow_data)
  157. local lastkey = 1
  158. local lastpos = nil
  159. local len = 3000^2
  160. local movelen = 100^2
  161. local LastLoop = -1
  162. timer.Create("hide_points", t, 0, function()
  163. if not IsValid(LP) then
  164. LP = LocalPlayer()
  165. if not IsValid(LP) then return end
  166. end
  167. local EP = LP:EyePos()+LP:GetVelocity()
  168. --[[local d = SysTime()-LastLoop
  169. if LastLoop ~= -1 and d > t+0.1 then
  170. local nt = t+0.05
  171. CreateSnowLoop(nt)
  172. return
  173. elseif t >= 0.1 and d <= t+0.01 then
  174. local nt = t-0.05
  175. CreateSnowLoop(nt)
  176. return
  177. end]]
  178. if lastpos == nil or FastLength(lastpos-EP) > movelen then
  179. local c = #snow_data
  180. local r = math.min(iterations, c)
  181. local completed = false
  182. for i=1,r do
  183. local key = lastkey+1
  184. if key > c then
  185. completed = true
  186. lastkey = 1
  187. break
  188. end
  189. local point = snow_data[key]
  190. local dc = FastLength(point - EP) < len
  191. if dc and draw_these[key] == nil then
  192. draw_these[key] = point
  193. elseif not dc and draw_these[key] ~= nil then
  194. draw_these[key] = nil
  195. end
  196. lastkey = key
  197. end
  198. if completed then lastpos = EP end
  199. end
  200. end)
  201. end
  202. CreateSnowLoop(0.1)
  203. end
  204. do
  205. materials = materials or {} local self = materials
  206.  
  207.  
  208. materials.Replaced = {}
  209.  
  210. function materials.ReplaceTexture(path, to)
  211. check(path, "string")
  212. check(to, "string", "ITexture", "Material")
  213.  
  214. path = path:lower()
  215.  
  216. local mat = Material(path)
  217.  
  218. if not mat:IsError() then
  219.  
  220. local typ = type(to)
  221. local tex
  222.  
  223. if typ == "string" then
  224. tex = Material(to):GetTexture("$basetexture")
  225. elseif typ == "ITexture" then
  226. tex = to
  227. elseif typ == "Material" then
  228. tex = to:GetTexture("$basetexture")
  229. else return false end
  230.  
  231. self.Replaced[path] = self.Replaced[path] or {}
  232.  
  233. self.Replaced[path].OldTexture = self.Replaced[path].OldTexture or mat:GetTexture("$basetexture")
  234. self.Replaced[path].NewTexture = tex
  235.  
  236. mat:SetTexture("$basetexture",tex)
  237.  
  238. return true
  239. end
  240.  
  241. return false
  242. end
  243.  
  244.  
  245. function materials.SetColor(path, color)
  246. check(path, "string")
  247. check(color, "Vector")
  248.  
  249. path = path:lower()
  250.  
  251. local mat = Material(path)
  252.  
  253. if not mat:IsError() then
  254. self.Replaced[path] = self.Replaced[path] or {}
  255. self.Replaced[path].OldColor = self.Replaced[path].OldColor or mat:GetVector("$color")
  256. self.Replaced[path].NewColor = color
  257.  
  258. mat:SetVector("$color", color)
  259.  
  260. return true
  261. end
  262.  
  263. return false
  264. end
  265.  
  266.  
  267. function materials.RestoreAll()
  268. for name, tbl in pairs(self.Replaced) do
  269. if
  270. !pcall(function()
  271. if tbl.OldTexture then
  272. materials.ReplaceTexture(name, tbl.OldTexture)
  273. end
  274.  
  275. if tbl.OldColor then
  276. materials.SetColor(name, tbl.OldColor)
  277. end
  278. end)
  279. then
  280. print("Failed to restore: " .. tostring(name))
  281. end
  282. end
  283. end
  284. hook.Add('ShutDown','MatRestorer',materials.RestoreAll)
  285.  
  286. --if not ms then
  287.  
  288. -- Material Extensions / SkyBox modder
  289. local sky =
  290. {
  291. ["up"]=true,
  292. ["dn"]=true,
  293. ["lf"]=true,
  294. ["rt"]=true,
  295. ["ft"]=true,
  296. ["bk"]=true,
  297. }
  298.  
  299. local sky_name = GetConVarString("sv_skyname")
  300.  
  301. for side, path in pairs(sky) do
  302. path = "skybox/" .. sky_name .. side
  303. materials.ReplaceTexture(path, "Decals/decal_paintsplatterpink001")
  304. materials.SetColor(path, Vector(1,0.8,0.7)*0.05)
  305. end
  306.  
  307. end
  308. --end
  309.  
  310.  
  311. for k,v in pairs(replace) do
  312. materials.ReplaceTexture(k, "NATURE/SNOWFLOOR001A")
  313. materials.SetColor(k, Vector(1, 1, 1)*(ms and 0.6 or 0.7))
  314. end
  315.  
  316. hook.Add("RenderScreenspaceEffects", "hm", function()
  317. --DrawToyTown( 2, 200)
  318.  
  319. local tbl = {}
  320. tbl[ "$pp_colour_addr" ] = 0
  321. tbl[ "$pp_colour_addg" ] = 0.01
  322. tbl[ "$pp_colour_addb" ] = 0.02
  323. tbl[ "$pp_colour_brightness" ] = 0.05
  324. tbl[ "$pp_colour_contrast" ] = 1
  325. tbl[ "$pp_colour_colour" ] = 1
  326. tbl[ "$pp_colour_mulr" ] = 0
  327. tbl[ "$pp_colour_mulg" ] = 0
  328. tbl[ "$pp_colour_mulb" ] = 0
  329. DrawColorModify( tbl )
  330.  
  331. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement