Advertisement
Dark_EccentricYT

Untitled

Sep 3rd, 2017
1,894
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.69 KB | None | 0 0
  1. --------------------------This is an Official script from Duelist--------------------------
  2. ---{-------------------- -------------------}---
  3. ---{-------------------- / \ -------------------}---
  4. ---{-------------------- II -------------------}---
  5. ---{-------------------- II -------------------}---
  6. ---{-------------------- II -------------------}---
  7. ---{-------------------- A========A -------------------}---
  8. ---{-------------------- II -------------------}---
  9. ---{-------------------- II -------------------}---
  10. ---{-------------------- W -------------------}---
  11. -------------------------------------------------------------------------------------------------------------
  12. -- @author Quenty
  13. -- Stick this guy in the StarterGui...
  14.  
  15. local Players = game:GetService("Players")
  16. --Players.LocalPlayer.CameraMode = "Classic"
  17. --Players.LocalPlayer.CameraMode = "LockFirstPerson"
  18.  
  19.  
  20. -- You can use this to make it fall a lot...
  21. local Configuration = {
  22. SnowModelName = "ThatSnowRenderModel";
  23. SnowColor = Vector3.new(1, 1, 1);
  24. SmallestFlakeSize = 8;-- Divided by 100
  25. LargestFlakeSize = 15;
  26. MaxMoveX = 5; -- Divided by 100
  27. MinMoveX = -5;
  28. MaxMoveY = 1;
  29. MinMoveY = -12;
  30. MaxMoveZ = 5;
  31. MinMoveZ = -5;
  32. CyclesPerLifeMax = 4;
  33. CyclesPerLifeMin = 2;
  34. CycleLife = 20;
  35. MaxTransparency = 0.3;
  36. RangeX = 8;
  37. RangeY = 4;
  38. RangeZ = 8;
  39.  
  40. -- QUICK EDITING STUFF HERE
  41. SnowAmountFactor = 3; -- Snowflakes made every frame. Double this, double lag, more snowflakes!
  42. }
  43.  
  44. local function GetSnowModel()
  45. local Model = workspace:FindFirstChild(Configuration.SnowModelName)
  46. if not Model then
  47. Model = Instance.new("Camera", workspace)
  48. Model.Name = Configuration.SnowModelName
  49. Model.Archivable = false;
  50. end
  51. return Model
  52. end
  53.  
  54. local function GetSnowflakeMovement()
  55. return Vector3.new(
  56. math.random(Configuration.MinMoveX, Configuration.MaxMoveX)/100,
  57. math.random(Configuration.MinMoveY, Configuration.MaxMoveY)/100,
  58. math.random(Configuration.MinMoveZ, Configuration.MaxMoveZ)/100
  59. )
  60. end
  61.  
  62. local function GetRandomSnowflakePosition(LastValidPlace) --, CoordinateFrame)
  63. --[[return CFrame.new(LastValidPlace + Vector3.new(
  64. math.random(-Configuration.RangeX, Configuration.RangeX),
  65. math.random(-3, Configuration.RangeY),
  66. math.random(-Configuration.RangeZ, Configuration.RangeZ)
  67. ) + Players.LocalPlayer.Character.Torso.CFrame.lookVector * 2)--]]
  68. return CFrame.new() + LastValidPlace:pointToWorldSpace(Vector3.new(
  69. math.random(-Configuration.RangeX, Configuration.RangeX),
  70. math.random(-3, Configuration.RangeY),
  71. math.random(-Configuration.RangeZ*2, 0)))
  72. end
  73.  
  74. local SnowflakeQueue = {}
  75.  
  76. local function UpdateQueue()
  77. local HalfLife = Configuration.CycleLife;
  78. local MaxTransparency = Configuration.MaxTransparency
  79. --for Index, SnowFlake in pairs(SnowflakeQueue) do
  80. local Index = 1
  81. while Index <= #SnowflakeQueue do
  82. local SnowFlake = SnowflakeQueue[Index]
  83.  
  84. local CycleTick = SnowFlake.CycleTick
  85. local Flake = SnowFlake.Flake
  86. if SnowFlake.Mode == 2 then
  87. SnowFlake.CyclesLeft = SnowFlake.CyclesLeft - 1
  88. if SnowFlake.CyclesLeft <= 0 then
  89. SnowFlake.Flake:Destroy()
  90. table.remove(SnowflakeQueue, Index)
  91. else
  92. SnowFlake.CycleTick = Configuration.CycleLife
  93. SnowFlake.Mode = 0
  94. Index = Index + 1
  95. end
  96. elseif SnowFlake.Mode == 0 then
  97. Flake.Transparency = (CycleTick/HalfLife)* MaxTransparency + (MaxTransparency)
  98. Flake.CFrame = Flake.CFrame + SnowFlake.MoveRate
  99. SnowFlake.CycleTick = CycleTick - 1
  100. if SnowFlake.CycleTick <= 0 then
  101. SnowFlake.Mode = 1
  102. end
  103. Index = Index + 1
  104. elseif SnowFlake.Mode == 1 then
  105. Flake.Transparency = (CycleTick/HalfLife)*MaxTransparency + (MaxTransparency)
  106. Flake.CFrame = Flake.CFrame + SnowFlake.MoveRate
  107. SnowFlake.CycleTick = CycleTick + 1
  108. if SnowFlake.CycleTick >= HalfLife then
  109. SnowFlake.Mode = 2
  110. end
  111. Index = Index + 1
  112. end
  113. end
  114. end
  115.  
  116. local function MakeSnowFlake(Parent, InitialCFrame)
  117. local FlakeSize = math.random(Configuration.SmallestFlakeSize, Configuration.LargestFlakeSize)/100
  118.  
  119. local Flake = Instance.new("Part", Parent)
  120. Flake.Anchored = true;
  121. Flake.CanCollide = false;
  122. Flake.FormFactor = "Custom";
  123. Flake.Size = Vector3.new(1, 1, 1)
  124. Flake.Name = "SnowFlake";
  125. Flake.BottomSurface = "Smooth";
  126. Flake.CFrame = InitialCFrame
  127. Flake.Transparency = 1;
  128.  
  129. local Mesh = Instance.new("SpecialMesh", Flake)
  130. Mesh.MeshType = "FileMesh"
  131. Mesh.MeshId = "http://www.roblox.com/asset/?id=1185246"
  132. Mesh.TextureId = "http://www.roblox.com/asset/?id=1361097"
  133. Mesh.VertexColor = Configuration.SnowColor;
  134. Mesh.Scale = Vector3.new(FlakeSize, FlakeSize, FlakeSize)
  135.  
  136. local SnowFlake = {}
  137. SnowFlake.Flake = Flake;
  138. SnowFlake.CycleTick = Configuration.CycleLife
  139. SnowFlake.CyclesLeft = math.random(Configuration.CyclesPerLifeMin, Configuration.CyclesPerLifeMax)
  140. SnowFlake.MoveRate = GetSnowflakeMovement()
  141. SnowFlake.Mode = 0
  142. table.insert(SnowflakeQueue, SnowFlake)
  143. end
  144.  
  145. local function CheckPlayer(Player)
  146. --- Makes sure a player has all necessary components.
  147. -- @return Boolean If the player has all the right components
  148.  
  149. return Player and Player:IsA("Player") and Player:IsDescendantOf(Players)
  150. end
  151.  
  152.  
  153. local function CheckCharacter(Player)
  154. -- Makes sure a character has all the right "parts"
  155.  
  156. if CheckPlayer(Player) then
  157. local Character = Player.Character;
  158.  
  159. if Character then
  160.  
  161. return Character.Parent
  162. and Character:FindFirstChild("Humanoid")
  163. and Character:FindFirstChild("HumanoidRootPart")
  164. and Character:FindFirstChild("Torso")
  165. and Character:FindFirstChild("Head")
  166. and Character.Humanoid:IsA("Humanoid")
  167. and Character.Head:IsA("BasePart")
  168. and Character.Torso:IsA("BasePart")
  169. and true
  170. end
  171. else
  172. warn("[CheckCharacter] - Character Check failed!")
  173. end
  174.  
  175. return nil
  176. end
  177.  
  178.  
  179.  
  180.  
  181. local FindPartOnRayWithIgnoreList = workspace.FindPartOnRayWithIgnoreList
  182.  
  183. local function AdvanceRaycast(RayTrace, IgnoreList, TransparencyThreshold, IgnoreCanCollideFalse, TerrainCellsAreCubes, MaximumCastCount, CustomCondition)
  184. -- @param TransparencyThreshold The transparency a part can be for it to be counted. For example, if TransparencyThreshold is 0.25, and a part is 0.24 transparency then it will be counted as solid, otherwise if it
  185. -- is 0.26 then it will be counted as transparent.
  186. -- If you don't want to hit transparent parts, then you can set it to -math.huge.
  187. -- TransparencyThreshold should not be above 1, probably.
  188. -- @param [CustomCondition] A function that can be defined to create a custom condition (such as making sure a character is hit)
  189. -- CustomCondition(HitObject, Position)
  190. -- @return boolean If true, then it will automatically abort the cycle and return.
  191.  
  192. assert(type(MaximumCastCount) == "number", "MaximumCastCount is not a number")
  193. assert(type(TransparencyThreshold) == "number", "TransparencyThreshold must be a number")
  194.  
  195. --print(TransparencyThreshold)
  196.  
  197. local ContinueCasting = true;
  198. local CastCount = 0
  199.  
  200. local function CastAttempt(NewRayTrace)
  201. -- print("Cast attempt " .. CastCount)
  202.  
  203. if CastCount >= MaximumCastCount then
  204. return
  205. else
  206. CastCount = CastCount + 1
  207. end
  208.  
  209. local Object, Position = FindPartOnRayWithIgnoreList(workspace, NewRayTrace, IgnoreList, TerrainCellsAreCubes)
  210.  
  211. if Object and Position then
  212. if CustomCondition and CustomCondition(Object, Position) then
  213. -- print("Custom override")
  214. return Object, Position
  215. elseif IgnoreCanCollideFalse and Object.CanCollide == false then
  216. IgnoreList[#IgnoreList+1] = Object
  217.  
  218. --print("Hit something cancollide false", Object:GetFullName())
  219. return CastAttempt(NewRayTrace)
  220. elseif TransparencyThreshold and Object.Transparency >= TransparencyThreshold then
  221. IgnoreList[#IgnoreList+1] = Object
  222.  
  223. --print("Hit something transparent false", Object:GetFullName())
  224. return CastAttempt(NewRayTrace)
  225. else
  226. return Object, Position
  227. end
  228. else
  229. --print("Just didn't hit anything")
  230. return
  231. end
  232. end
  233.  
  234. local DirectionUnit = RayTrace.Direction.unit
  235. local Magnitude = RayTrace.Direction.magnitude
  236. local CastedMagnitude = 0
  237.  
  238. --game:GetService("Debris"):AddItem(
  239. -- lib.DrawRay(RayTrace, BrickColor.new("Bright orange"))
  240. --, 2)
  241.  
  242. while CastedMagnitude < Magnitude do
  243. local ToCastMagnitude = Magnitude - CastedMagnitude
  244.  
  245. if ToCastMagnitude > 999.5 then
  246. ToCastMagnitude = 999
  247. end
  248.  
  249. local WaysAlongPath = RayTrace.Origin + (DirectionUnit * CastedMagnitude)
  250. local NewRayTrace = Ray.new(WaysAlongPath, DirectionUnit * ToCastMagnitude)
  251. local Object, Position = CastAttempt(NewRayTrace)
  252.  
  253. -- game:GetService("Debris"):AddItem(
  254. -- lib.DrawRay(NewRayTrace, BrickColor.new("Bright green"))
  255. --, 2)
  256.  
  257. if Object then
  258. return Object, Position
  259. end
  260.  
  261. CastedMagnitude = CastedMagnitude + ToCastMagnitude
  262.  
  263. if CastCount >= MaximumCastCount then
  264. print("[AdvanceRaycast] - Reached maximum cast count @ " .. CastCount .. "; MaximumCastCount = " .. MaximumCastCount)
  265. return nil
  266. end
  267. end
  268. end
  269.  
  270. local SnowModel = GetSnowModel()
  271. SnowModel:ClearAllChildren()
  272.  
  273. local LocalPlayer = Players.LocalPlayer
  274. --[[
  275. local function SetupCharacter(Character)
  276. local IgnoreList = {}
  277. local LastValidPlace = nil --Players.LocalPlayer.Character.Torso.Position
  278. while not CheckCharacter(LocalPlayer) and Character == LocalPlayer.Character do
  279. wait()
  280. end
  281.  
  282. while CheckCharacter(LocalPlayer) and Character == LocalPlayer.Character do
  283. --if Character:FindFirstChild("Torso") then
  284.  
  285. local NewRay = Ray.new(Torso.Position + Vector3.new(0, 3, 0), Vector3.new(0, 100, 0))
  286. local Hit, Position = AdvanceRaycast(NewRay, IgnoreList, 0.001, true, true, 5)
  287. if not Hit then
  288. LastValidPlace = Torso.Position
  289. --else
  290. --print("Inside")
  291. end
  292. if LastValidPlace then
  293. MakeSnowFlake(SnowModel, GetRandomSnowflakePosition(LastValidPlace))
  294. end
  295. --end
  296. UpdateQueue()
  297. wait()
  298. end
  299. end
  300.  
  301. if LocalPlayer.Character then
  302. SetupCharacter(LocalPlayer.Character)
  303. end
  304.  
  305. LocalPlayer.CharacterAdded:connect(SetupCharacter)--]]
  306.  
  307. local LastValidPlace
  308. local IgnoreList = {SnowModel, LocalPlayer.Character}
  309. local LastClean = tick()
  310.  
  311. local function CleanIgnoreList()
  312. if LastClean + 5 <= tick() then
  313. IgnoreList = {SnowModel, LocalPlayer.Character}
  314. LastClean = tick()
  315. end
  316. end
  317.  
  318. local function DrawRay(Ray, Color, Parent)
  319. --- Draw's a ray out (for debugging)
  320. -- Credit to Cirrus for initial code.
  321.  
  322. Parent = Parent or workspace
  323.  
  324. local NewPart = Instance.new("Part", Parent)
  325.  
  326. NewPart.FormFactor = "Custom"
  327. NewPart.Size = Vector3.new(0.2, Ray.Direction.magnitude, 0.2)
  328.  
  329. local Center = Ray.Origin + Ray.Direction/2
  330. -- lib.DrawPoint(Ray.Origin).Name = "origin"
  331. -- lib.DrawPoint(Center).Name = "Center"
  332. -- lib.DrawPoint(Ray.Origin + Ray.Direction).Name = "Destination"
  333.  
  334. NewPart.CFrame = CFrame.new(Center, Ray.Origin + Ray.Direction) * CFrame.Angles(math.pi/2, 0, 0) --* GetCFramePitch(math.pi/2)
  335. NewPart.Anchored = true
  336. NewPart.CanCollide = false
  337. NewPart.Transparency = 0.5
  338. NewPart.BrickColor = Color or BrickColor.new("Bright red")
  339. NewPart.Name = "DrawnRay"
  340.  
  341. Instance.new("SpecialMesh", NewPart)
  342.  
  343. return NewPart
  344. end
  345.  
  346.  
  347. while true do
  348. local Camera = workspace.CurrentCamera
  349. if Camera then
  350. -- Check to make sure we're next extending through a roof or something...
  351. local ExtensionRay = Ray.new(Camera.CoordinateFrame.p,
  352. Camera.CoordinateFrame:vectorToWorldSpace(Vector3.new(0, 0, -Configuration.RangeZ))
  353. )
  354. local Hit, Position = AdvanceRaycast(ExtensionRay, IgnoreList, 0.001, true, true, 5)
  355. if not Hit then
  356. -- Extend by mid range.
  357. local NewRay = Ray.new((Camera.CoordinateFrame * CFrame.new(0, 0, -Configuration.RangeZ)).p, Vector3.new(0, 100, 0))
  358. local Hit, Position = AdvanceRaycast(NewRay, IgnoreList, 0.001, true, true, 5)
  359. if not Hit then
  360. LastValidPlace = Camera.CoordinateFrame
  361. end
  362. end
  363.  
  364. if LastValidPlace then
  365. for Index = 1, Configuration.SnowAmountFactor do
  366. MakeSnowFlake(SnowModel, GetRandomSnowflakePosition(LastValidPlace, Camera.CoordinateFrame))
  367. end
  368. end
  369. end
  370. UpdateQueue()
  371. CleanIgnoreList()
  372. wait(0.03)
  373. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement