Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Vector = {}
- local EventHandler = {}
- local Particle = {}
- local Run = {}
- local ParticleStep = nil
- local LocalPlayer = game.Players.LocalPlayer
- local cos = math.cos
- do
- local sin = math.sin
- local random = math.random
- local tau = 2 * math.pi
- local v3 = Vector3.new
- local Dot = v3().Dot
- Vector.RandomUnit = function(t)
- local r = (1 - (t and cos(t) or -1)) * random() - 1
- local a = random() * tau
- local s = 1 - r * r ^ 0.5
- return v3(sin(a) * s, cos(a) * s, r)
- end
- Vector.Random = function(t)
- local r = (1 - (t and cos(t) or -1)) * random() - 1
- local a = random() * tau
- local s = 1 - r * r ^ 0.5 * random() ^ 0.33333333333333
- return v3(sin(a) * s, cos(a) * s, r)
- end
- Vector.Lerp = function(v0, v1, t)
- return v0 + (v1 - v0) * t
- end
- Vector.Slerp = function(v0, v1, t)
- return v0 + (v1 - v0) * t
- end
- Vector.Constrain = function(v, c, r)
- local rv = v - c
- if r < rv.magnitude then
- return c + rv.unit * r
- else
- return v
- end
- end
- Vector.ClosestPointOnLineSegment = function(a, b, p)
- local l = b - a
- local u, m = l.unit, l.magnitude
- local d = Dot(u, p - a)
- if m < d then
- return a + l
- else
- if d < 0 then
- return a
- else
- return a + u * d
- end
- end
- end
- Vector.ClosestPointOnDirection = function(d, p)
- local u = d.unit
- return u * Dot(u, p)
- end
- end
- local insert = table.insert
- local remove = table.remove
- do
- local setmetatable = setmetatable
- EventHandler.New = function()
- local AddQueue = {}
- local RemoveQueue = {}
- local Connections = {}
- local Remove = function(self)
- RemoveQueue[self] = true
- end
- return {Connect = function(Function)
- local Connection = {Function = Function, Disabled = false, Remove = Remove}
- AddQueue[#AddQueue + 1] = Connection
- return Connection
- end
- , Fire = function(...)
- local InitialCount = #Connections
- for i = 1, #AddQueue do
- Connections[InitialCount + i] = AddQueue[i]
- AddQueue[i] = nil
- end
- local Setback = 0
- for i = 1, #Connections do
- local f = Connections[i - Setback]
- if f then
- if RemoveQueue[f] then
- remove(Connections, i - Setback)
- Setback = Setback + 1
- RemoveQueue[f] = nil
- else
- if not f.Disabled then
- f.Function(...)
- end
- end
- else
- break
- end
- end
- end
- }
- end
- local setmetatable = setmetatable
- local atan2 = math.atan2
- local degrees = math.pi / 180
- local remove = table.remove
- local tan = math.tan
- local Workspace = game.Workspace
- local v3 = Vector3.new
- local Ray = Ray.new
- local RayCast = Workspace.FindPartOnRay
- local ud2 = UDim2.new
- local PlayerCamera = Workspace.CurrentCamera
- local components = CFrame.new().components
- local Screen = Instance.new("ScreenGui", LocalPlayer.PlayerGui)
- local RemoveQueue = {}
- local UpdateFunctions = {}
- local ReserveFrames = {}
- local PlaneY, PlaneX, ScreenCorrection, PixelSize, CameraPosition = nil, nil, nil, nil, nil
- local cx, cy, cz, cxx, cyx, czx, cxy, cyy, czy, cxz, cyz, czz = 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1
- Particle.New = function(Position)
- local px, py, pz = 0, 0, 0
- if Position then
- px = Position.x
- end
- local vx, vy, vz = 0, 0, 0
- local WindResistance = 0.2
- local CanCollide = true
- local Elasticity = 0.3
- local Gravity = -196.2
- local llx = (px - cx) * cxx + (py - cy) * cxy + (pz - cz) * cxz
- local lly = (px - cx) * cyx + (py - cy) * cyy + (pz - cz) * cyz
- local llz = -(px - cx) * czx - (py - cy) * czy - (pz - cz) * czz
- local Size = 0.2
- local Brightness = 1
- local Bloom = 2
- local Culling = true
- local MaxViewDistance = 1000
- local Life = false
- local Replicated = false
- local Interface, OnCollide, Frame = nil, nil, nil
- if #ReserveFrames > 0 then
- Frame = ReserveFrames[#ReserveFrames]
- ReserveFrames[#ReserveFrames] = nil
- else
- Frame = Instance.new("Frame", Screen)
- Frame.BorderSizePixel = 0
- end
- local Visible = false
- local Color = Color3.new(1, 1, 1)
- Frame.BackgroundColor3 = Color
- local Update = function(dt)
- if (Life and Life < tick()) or py < -500 then
- Frame.Visible = false
- ReserveFrames[#ReserveFrames + 1] = Frame
- RemoveQueue[l_0_8_r26] = true
- else
- local v = vx * vx + vy * vy + vz * vz ^ 0.5
- local w = 2 / (2 + dt * WindResistance / 1024 * v)
- if CanCollide then
- local Part, Position, Normal = RayCast(Workspace, Ray(v3(px, py, pz), v3(vx * dt, vy * dt, vz * dt)))
- if Part then
- local nx, ny, nz = Normal.x, Normal.y, Normal.z
- local vn = vx * nx + vy * ny + vz * nz
- local d = (1 + Elasticity) * vn
- if vn < 1 or vn > 100 then
- px = Position.x + nx / 256
- end
- vx = vx * w - d * nx
- if OnCollide then
- if OnCollide == "Remove" then
- Life = 0
- else
- OnCollide(Interface, Part, Position, Normal)
- end
- end
- else
- do
- do
- px = px + vx * dt
- vx = vx * w
- px = px + vx * dt
- vx = vx * w
- local rx, ry, rz = px - cx, py - cy, pz - cz
- local clx = rx * cxx + ry * cxy + rz * cxz
- local cly = rx * cyx + ry * cyy + rz * cyz
- local clz = -rx * czx - ry * czy - rz * czz
- local CurrentTest = clz > 1
- do
- local LastTest = llz > 1
- if Brightness > 0 and clz < MaxViewDistance and (CurrentTest or LastTest) then
- local u0x, u0y, u1x, u1y = nil, nil, nil, nil
- if CurrentTest and not LastTest then
- local d = (1 - llz) / (clz - llz)
- u0x = llx + d * (clx - llx)
- u1x = clx / clz
- elseif not CurrentTest and LastTest then
- local d = (1 - llz) / (clz - llz)
- -- DECOMPILER ERROR at PC279: Overwrote pending register: R12 in 'AssignReg'
- u0x = llx + d * (clx - llx)
- -- DECOMPILER ERROR at PC286: Overwrote pending register: R14 in 'AssignReg'
- u1x = llx / llz
- else
- -- DECOMPILER ERROR at PC290: Overwrote pending register: R12 in 'AssignReg'
- u0x = clx / clz
- -- DECOMPILER ERROR at PC297: Overwrote pending register: R14 in 'AssignReg'
- u1x = llx / llz
- end
- local p0x, p0y = (PlaneX + u0x * ScreenCorrection) * PixelSize, (PlaneY - (u0y)) * PixelSize * ScreenCorrection
- local p1x, p1y = (PlaneX + u1x * ScreenCorrection) * PixelSize, (PlaneY - u1y) * PixelSize * ScreenCorrection
- local dx, dy = p1x - p0x, p1y - p0y
- local Length = dx * dx + dy * dy ^ 0.5
- local s = Size / (llz < clz and clz or llz) * PixelSize
- local sx, sy = Length + s + Bloom, s + Bloom
- local Transparency = 1 - Brightness * s * s / (sx * sy)
- if Transparency < 0.99 and sy > 1 and (not Culling or not RayCast(Workspace, Ray(CameraPosition, v3(px - cx, py - cy, pz - cz)))) then
- if not Visible then
- Frame.Visible = true
- Visible = true
- end
- Frame.Position = ud2(0, (p0x + p1x - sx) / 2, 0, (p0y + p1y - sy) / 2)
- Frame.Size = ud2(0, sx, 0, sy)
- Frame.Transparency = Transparency
- local Rotation = atan2(dy, dx) / degrees
- if Rotation ~= 0 then
- Frame.Rotation = Rotation
- end
- elseif Visible then
- Frame.Visible = false
- Visible = false
- end
- elseif Visible then
- Frame.Visible = false
- Visible = false
- end
- -- DECOMPILER ERROR at PC432: Overwrote pending register: R12 in 'AssignReg'
- llx = clx
- -- DECOMPILER ERROR: 14 unprocessed JMP targets
- end
- end
- end
- end
- end
- end
- end
- UpdateFunctions[#UpdateFunctions + 1] = Update
- Interface = setmetatable({ReplicateToServer = function()
- if not Replicated then
- Replicated = true
- end
- end
- , Remove = function()
- Life = 0
- Interface.Remove = nil
- end
- }, {__index = function(_, Index)
- if Index == "Position" then
- return v3(px, py, pz)
- else
- if Index == "Velocity" then
- return v3(vx, vy, vz)
- else
- if Index == "WindResistance" then
- return WindResistance
- else
- if Index == "CanCollide" then
- return CanCollide
- else
- if Index == "Elasticity" then
- return Elasticity
- else
- if Index == "Gravity" then
- return Gravity
- else
- if Index == "Size" then
- return Size
- else
- if Index == "Brightness" then
- return Brightness
- else
- if Index == "Bloom" then
- return Bloom
- else
- if Index == "Color" then
- return Color
- else
- if Index == "Culling" then
- return Culling
- else
- if Index == "MaxViewDistance" then
- return MaxViewDistance
- else
- if Index == "Life" then
- return Life - tick()
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- , __newindex = function(_, Index, Value)
- if Index == "Position" then
- px = Value.x
- else
- if Index == "Velocity" then
- vx = Value.x
- else
- if Index == "WindResistance" then
- WindResistance = Value
- else
- if Index == "CanCollide" then
- CanCollide = Value
- else
- if Index == "Elasticity" then
- Elasticity = Value
- else
- if Index == "Gravity" then
- Gravity = Value
- else
- if Index == "Size" then
- Size = Value
- else
- if Index == "Brightness" then
- Brightness = Value
- else
- if Index == "Bloom" then
- Bloom = Value
- else
- if Index == "Color" then
- Color = Value
- else
- if Index == "Culling" then
- Culling = Value
- else
- if Index == "MaxViewDistance" then
- MaxViewDistance = Value
- else
- if Index == "Life" then
- Life = tick() + Value
- else
- if Index == "OnCollide" then
- OnCollide = Value
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- })
- return Interface
- end
- do
- local Counter = 0
- ParticleStep = function(dt)
- local ScreenSize = Screen.AbsoluteSize
- local ScreenY, ScreenX = ScreenSize.y, ScreenSize.x
- PlaneY = tan(degrees * PlayerCamera.FieldOfView / 2)
- PlaneX = PlaneY * ScreenX / ScreenY
- PixelSize = ScreenY / PlaneY / 2
- ScreenCorrection = ScreenY / (ScreenY - 20)
- CameraPosition = PlayerCamera.CoordinateFrame.p
- cx = components(PlayerCamera.CoordinateFrame)
- for R7_PC39 = 1, #UpdateFunctions do
- R8_PC38 = UpdateFunctions
- R8_PC38 = R8_PC38[i]
- R9_PC37 = dt
- R8_PC38(R9_PC37)
- end
- -- DECOMPILER ERROR at PC53: Confused about usage of register R6 for local variables in 'ReleaseLocals'
- Counter = Counter % 60 + 1
- if Counter == 60 then
- print("Particles: " .. #UpdateFunctions)
- end
- for i = #UpdateFunctions, 1, -1 do
- local l_0_9_10, i = nil
- l_0_9_10 = UpdateFunctions
- l_0_9_10 = l_0_9_10[l_0_9_9]
- local f = nil
- if l_0_9_10 then
- i = RemoveQueue
- i = i[l_0_9_10]
- if i then
- i = remove
- f = UpdateFunctions
- R11_PC35 =
- i(f, R11_PC35)
- i = RemoveQueue
- i[l_0_9_10] = nil
- end
- end
- end
- -- DECOMPILER ERROR at PC86: Confused about usage of register R5 for local variables in 'ReleaseLocals'
- end
- local insert = table.insert
- local remove = table.remove
- local setmetatable = setmetatable
- local tick = tick
- local RenderStepped = game:GetService("RunService").RenderStepped
- local AddQueue = {}
- local RemoveQueue = {}
- local Functions = {}
- local Time = tick()
- do
- local Remove = function(self)
- RemoveQueue[self] = true
- end
- Run.Add = function(Function)
- local RunObject = {Function = Function, Paused = false, Remove = Remove}
- AddQueue[#AddQueue + 1] = RunObject
- return RunObject
- end
- RenderStepped:connect(function()
- local dt = tick() - Time
- Time = Time + dt
- ParticleStep(dt)
- local InitialCount = #Functions
- for i = 1, #AddQueue do
- Functions[InitialCount + i] = AddQueue[i]
- AddQueue[i] = nil
- end
- local Setback = 0
- for i = 1, #Functions do
- local f = Functions[i - Setback]
- if f then
- if RemoveQueue[f] then
- remove(Functions, i - Setback)
- Setback = Setback + 1
- RemoveQueue[f] = nil
- else
- if not f.Paused then
- f.Function(dt)
- end
- end
- else
- break
- end
- end
- end
- )
- while 1 do
- wait(0.5)
- local Stuff = game.Players.LocalPlayer.Character.Head.CFrame
- local c = Particle.New(Stuff.p)
- c.Velocity = Stuff.lookVector * 100 + Vector3.new(0, 200, 0)
- c.Brightness = 10
- c.Size = 1
- c.OnCollide = function(_, _, Position, Normal)
- local RandColor = Color3.new(1 - math.random() ^ 2, 1 - math.random() ^ 2, 1 - math.random() ^ 2)
- for i = 1, 100 do
- local Blah = Particle.New(Position)
- Blah.Life = math.random() * 5
- Blah.Brightness = math.random() * 5 + 10
- Blah.Size = math.random() * 0.5 + 0.05
- Blah.MaxViewDistance = 720
- Blah.Culling = true
- Blah.Color = RandColor
- Blah.Velocity = (Normal + Vector.Random()) * 100
- Blah.OnCollide = "Remove"
- end
- c:Remove()
- end
- end
- return {Vector = Vector, Particle = Particle, Run = Run}
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement