Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- params : ...
- repeat
- wait()
- until game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name)
- local p = game.Players.LocalPlayer
- local ch = game.Workspace:WaitForChild(p.Name)
- local feet = {}
- local run = {}
- local event = {}
- local physics = {}
- local renderstepped = game:GetService("RunService").RenderStepped
- local cf = CFrame.new
- local ca = CFrame.Angles
- local nc = cf()
- local v3 = Vector3.new
- local nv = v3()
- local comp = nc.components
- local cos = math.cos
- local sin = math.sin
- local atan2 = math.atan2
- local sort = table.sort
- local inf = math.huge
- local b1 = Instance.new("Part", ch)
- b1.Size = v3(1.5, 0.25, 1)
- b1.BrickColor = BrickColor.Gray()
- b1.BottomSurface = Enum.SurfaceType.Smooth
- b1.TopSurface = Enum.SurfaceType.Smooth
- b1.CanCollide = false
- b1.Anchored = false
- local b2 = b1:Clone()
- b2.Parent = ch
- physics.spring = {}
- physics.cspring = {}
- physics.grounded = function(p)
- local r = Ray.new(p.Position, Vector3.new(0, -4, 0))
- local h, pos = game.Workspace:FindPartOnRay(r, p.Parent)
- if h and h.CanCollide == true and p.Position - pos.Magnitude < 2.999 then
- return true
- end
- return false
- end
- physics.spring.new = function(initial)
- local t0 = tick()
- local p0 = initial or 0
- local v0 = initial and 0 * initial or 0
- local t = initial or 0
- local d = 1
- local s = 1
- local positionvelocity = function(tick)
- local x = tick - t0
- local c0 = p0 - t
- if s == 0 then
- return p0, 0
- else
- if d < 1 then
- local c = 1 - d * d ^ 0.5
- local c1 = (v0 / s + d * c0) / c
- local co = cos(c * s * x)
- local si = sin(c * s * x)
- local e = 2.718281828459 ^ (d * s * x)
- return t + (c0 * co + c1 * si) / e, s * ((c * c1 - d * c0) * co - (c * c0 + d * c1) * si) / e
- else
- do
- local c1 = v0 / s + c0
- local e = 2.718281828459 ^ (s * x)
- do return t + (c0 + c1 * s * x) / e, s * (c1 - c0 - c1 * s * x) / e end
- end
- end
- end
- end
- return setmetatable({accelerate = function(_, acceleration)
- local time = tick()
- local p, v = positionvelocity(time)
- p0 = p
- v0 = v + acceleration
- t0 = time
- end
- }, {__index = function(_, index)
- if index == "value" or index == "position" or index == "p" then
- local p, v = positionvelocity(tick())
- return p
- else
- do
- if index == "velocity" or index == "v" then
- local p, v = positionvelocity(tick())
- return v
- else
- do
- if index == "acceleration" or index == "a" then
- local x = tick() - t0
- local c0 = p0 - t
- if s == 0 then
- return 0
- else
- if d < 1 then
- local c = 1 - d * d ^ 0.5
- local c1 = (v0 / s + d * c0) / c
- return s * s * ((d * d * c0 - 2 * c * d * c1 - c * c * c0) * cos(c * s * x) + (d * d * c1 + 2 * c * d * c0 - c * c * c1) * sin(c * s * x)) / 2.718281828459 ^ (d * s * x)
- else
- do
- do
- local c1 = v0 / s + c0
- do return s * s * (c0 - 2 * c1 + c1 * s * x) / 2.718281828459 ^ (s * x) end
- if index == "target" or index == "t" then
- return t
- else
- if index == "damper" or index == "d" then
- return d
- else
- if index == "speed" or index == "s" then
- return s
- else
- if index == "magnitude" or index == "m" then
- local p, v = positionvelocity(tick())
- return p.magnitude
- else
- do
- error(index .. " is not a valid member of spring", 0)
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- , __newindex = function(_, index, value)
- local time = tick()
- if index == "value" or index == "position" or index == "p" then
- local p, v = positionvelocity(time)
- p0 = value
- else
- do
- if index == "velocity" or index == "v" then
- local p, v = positionvelocity(time)
- p0 = p
- else
- do
- if index == "acceleration" or index == "a" then
- local p, v = positionvelocity(time)
- p0 = p
- else
- do
- if index == "target" or index == "t" then
- p0 = positionvelocity(time)
- t = value
- else
- if index == "damper" or index == "d" then
- p0 = positionvelocity(time)
- d = (value < 0 and 0) or (value < 1 and value) or 1
- else
- if index == "speed" or index == "s" then
- p0 = positionvelocity(time)
- s = value < 0 and 0 or value
- else
- error(index .. " is not a valid member of spring", 0)
- end
- end
- end
- t0 = time
- end
- end
- end
- end
- end
- end
- end
- )
- end
- do
- local meta = {__index = function(t, i)
- if i == "t" then
- return t.t
- else
- if i == "p" or i == "position" then
- local c1, c2, c3, c4 = t.c1, t.c2, t.c3, t.c4
- return CFrame.new(c1.p.x, c1.p.y, c1.p.z, c2.p.x, c2.p.y, c2.p.z, c3.p.x, c3.p.y, c3.p.z, c4.p.x, c4.p.y, c4.p.z)
- else
- do
- if i == "s" or i == "speed" then
- return t.settings.s
- else
- if i == "d" or i == "damper" then
- return t.settings.d
- else
- if i == "m" or i == "magnitude" then
- return t.c1.magnitude + t.c2.magnitude + t.c3.magnitude + t.c4.magnitude
- end
- end
- end
- end
- end
- end
- end
- , __newindex = function(t, i, v)
- local c1, c2, c3, c4 = t.c1, t.c2, t.c3, t.c4
- if i == "t" or i == "target" then
- local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = comp(v)
- c1.t = Vector3.new(x, y, z)
- else
- do
- if i == "s" or i == "speed" then
- t.settings.s = v
- c1.s = v
- else
- if i == "d" or i == "damper" then
- t.settings.d = v
- c1.d = v
- end
- end
- end
- end
- end
- }
- do
- physics.cspring.new = function(start, s, d)
- local settings = {s = s or 1, d = d or 1}
- local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = comp(start)
- local c1, c2, c3, c4 = physics.spring.new(Vector3.new(x, y, z)), physics.spring.new(Vector3.new(R00, R01, R02)), physics.spring.new(Vector3.new(R10, R11, R12)), physics.spring.new(Vector3.new(R20, R21, R22))
- c1.s = s
- c1.d = d
- local t = setmetatable({settings = settings, c1 = c1, c2 = c2, c3 = c3, c4 = c4}, meta)
- return t
- end
- end
- event.new = function(eventtable)
- if not eventtable then
- local self = {}
- end
- local removelist = {}
- local functions = {}
- local pendingdeletion = false
- self.connect = function(self, func)
- functions[#functions + 1] = func
- return function()
- removelist[func] = true
- pendingdeletion = true
- end
- end
- return function(...)
- if pendingdeletion then
- pendingdeletion = false
- local j = 1
- for i = 1, #functions do
- local f = functions[i]
- functions[i] = nil
- if removelist[f] then
- removelist[f] = nil
- else
- f(...)
- functions[j] = f
- j = j + 1
- end
- end
- else
- do
- for i = 1, #functions do
- functions[i](...)
- end
- end
- end
- end
- , self
- end
- local humanoid = ch:WaitForChild("Humanoid)
- humanoid.Animator:Destroy()
- humanoid.Status:Destroy()
- ch.Animate:Destroy()
- local torso = ch:WaitForChild("Torso")
- local hrp = ch:WaitForChild("HumanoidRootPart")
- local state = "None"
- game.Workspace.CurrentCamera.CameraSubject = humanoid
- local defaultSpeed = 15
- local jumpPower = 40
- local lhspring = physics.cspring.new(nc, 32000, 1)
- local rhspring = physics.cspring.new(nc, 32000, 1)
- local lhspring2 = physics.cspring.new(nc, 32000, 1)
- local rhspring2 = physics.cspring.new(nc, 32000, 1)
- local hrpspring = physics.cspring.new(nc, 12, 0.4)
- local hrpspring2 = physics.cspring.new(nc, 12, 0.4)
- local lsspring = physics.cspring.new(nc, 12, 0.7)
- local rsspring = physics.cspring.new(nc, 12, 0.7)
- local stances = {
- None = {1, CFrame.new(0, -1, 0), 1}
- ,
- Sprint = {1.3, CFrame.new(0, -1, 0), 0.9}
- ,
- Crouch = {0.5, CFrame.new(0, -2, 0) * CFrame.Angles(-math.pi / 12, 0, 0), 0.6}
- ,
- Prone = {0.3, CFrame.new(0, -2.4, 0) * CFrame.Angles(-math.pi / 2.1, 0, 0), 0}
- }
- local direction = Vector3.new(0, 0, -1)
- local stride = 2
- local cycleSpeed = 14
- local left, right = 0, math.pi
- local rhipcf = CFrame.new(0.5, -1, 0.25)
- local lhipcf = CFrame.new(-0.5, -1, 0.25)
- local atn2, acs = math.atan2, math.acos
- local pi = math.pi
- local LerpNumber = function(a, b, t)
- return a + (b - a) * t
- end
- local IsNAN = function(x)
- do return x ~= x end
- -- DECOMPILER ERROR: 1 unprocessed JMP targets
- end
- do
- local lastTick = tick()
- feet.step = function()
- local deltaTime = tick() - lastTick
- lastTick = tick()
- local lerp10 = math.min(deltaTime * 10, 1)
- local velocity = Vector3.new(torso.Velocity.X, 0, torso.Velocity.Z)
- if velocity.magnitude > 0.1 then
- direction = direction:Lerp(velocity.unit, deltaTime * 10)
- end
- local climbing = humanoid:GetState() == Enum.HumanoidStateType.Climbing
- if climbing then
- velocity = velocity + Vector3.new(0, torso.Velocity.Y, 0)
- direction = torso.CFrame.lookVector
- end
- right = (right + velocity.magnitude / defaultSpeed * deltaTime * cycleSpeed) % (pi * 2)
- left = (left + velocity.magnitude / defaultSpeed * deltaTime * cycleSpeed) % (pi * 2)
- humanoid.WalkSpeed = defaultSpeed * stances[state][1]
- humanoid.JumpPower = jumpPower * stances[state][3]
- local localVelocity = hrp.CFrame:vectorToObjectSpace(velocity) * 0.6
- hrpspring.t = hrp.RootJoint.C0:lerp(stances[state][2], lerp10)
- hrp.RootJoint.C0 = hrpspring.p
- hrpspring2.t = CFrame.new(0, -1, 0) * CFrame.Angles(math.rad(localVelocity.Z), math.cos(right) * 0.1 - math.rad(localVelocity.X) * 2, math.rad(-localVelocity.X)):inverse()
- hrp.RootJoint.C1 = hrpspring2.p
- local up = velocity.magnitude / defaultSpeed
- local hip = torso.CFrame * rhipcf.p
- do
- local ground = torso.CFrame * CFrame.new(0.5, -3, 0)
- if state == "Prone" or climbing then
- ground = ground * CFrame.new(0, 0, -stride / 2)
- end
- ground = ground.p
- local desiredPosition = CFrame.new(ground, ground + direction) * CFrame.Angles(-right, 0, 0) * CFrame.new(0, 0, -stride / 2).p
- local distance = math.min(hip - desiredPosition.magnitude, 2)
- local ray = Ray.new(hip, CFrame.new(hip, desiredPosition).lookVector * LerpNumber(2, distance, up))
- local hit, footPosition = game.Workspace:FindPartOnRayWithIgnoreList(ray, {ch, game.Workspace:FindFirstChild("Ignore", true)})
- spawn(function()
- local pa = Instance.new("Part", ch)
- pa.Anchored = true
- pa.CanCollide = false
- pa.Transparency = 0.5
- pa.BrickColor = BrickColor.Red()
- pa.Size = nv
- pa.CFrame = cf(footPosition)
- game:GetService("Debris"):AddItem(pa, 0.1)
- end)
- distance = hip - footPosition.magnitude
- local offset = torso.CFrame * rhipcf:pointToObjectSpace(footPosition)
- local x, y = atn2(offset.Z, offset.Y), atn2(offset.X, offset.Y)
- rhspring.t = rhipcf * CFrame.Angles(x, 0, 0) * CFrame.Angles(0, 0, y) * CFrame.Angles(0, pi, 0)
- torso["Right Hip"].C0 = rhspring.p
- if distance < 2 then
- local angle = -acs(distance / 2)
- do
- local newCF = torso["Right Hip"].C0 * CFrame.Angles(-angle, 0, 0) * CFrame.new(0, -0.6, 0) * CFrame.Angles(angle * 1.6, 0, 0) * CFrame.new(0, 0.6, 0)
- rhspring2.t = newCF
- torso["Right Hip"].C0 = rhspring2.p
- -- DECOMPILER ERROR at PC346: LeaveBlock: unexpected jumping out IF_THEN_STMT
- -- DECOMPILER ERROR at PC346: LeaveBlock: unexpected jumping out IF_STMT
- end
- end
- end
- local hip = torso.CFrame * lhipcf.p
- local ground = torso.CFrame * CFrame.new(-0.5, -3, 0)
- if state == "Prone" or climbing then
- ground = ground * CFrame.new(0, 0, -stride / 2)
- end
- ground = ground.p
- local desiredPosition = CFrame.new(ground, ground + direction) * CFrame.Angles(-left, 0, 0) * CFrame.new(0, 0, -stride / 2).p
- local distance = math.min(hip - desiredPosition.magnitude, 2)
- local ray = Ray.new(hip, CFrame.new(hip, desiredPositio).lookVector * LerpNumber(, distance, up))
- local hit, footPosition = game.Workspace:FindPartOnRayWithIgnoreList(ray, {ch, game.Workspace:FindFirstChild("Ignore", true))
- spawn(function()
- local pa = Instance.new("Part", ch)
- pa.Anchored = true
- pa.CanCollide = false
- pa.Transparency = 0.5
- pa.BrickColor = BrickColor.Red()
- pa.Size = nv
- pa.CFrame = cf(desiredPosition)
- game:GetService("Debris"):AddItem(pa, 0.1)
- end)
- distance = hip - footPosition.magnitude
- local offset = torso.CFrame * lhipcf:pointToObjectSpace(footPosition)
- local x, y = atn2(offset.Z, offset.Y), atn2(offset.X, offset.Y)
- lhspring.t = lhipcf * CFrame.Angles(x, 0, 0) * CFrame.Angles(0, 0, y) * CFrame.Angles(0, pi, 0)
- torso["Left Hip"].C0 = lhspring.p
- if distance < 2 then
- local angle = -acs(distance / 2)
- local newCF = torso["Left Hip"].C0 * CFrame.Angles(-angle, 0, 0) * CFrame.new(0, -0.6, 0) * CFrame.Angles(angle * 1.6, 0, 0) * CFrame.new(0, 0.6, 0)
- lhspring2.t = newCF
- torso["Left Hip"].C0 = lhspring2.p
- end
- do
- local localDirection = torso.CFrame:vectorToObjectSpace(direction)
- torso["Right Shoulder"].C0 = CFrame.new(-0.9, 0.5, 0) * CFrame.Angles(-math.cos(left) * 0.7 * localDirection.Z, 0, math.cos(left) * 0.55 * localDirection.X)
- torso["Right Shoulder"].C0 = torso["Right Shoulder"].C0 * CFrame.new(0, -0.5, 0) * CFrame.Angles(pi / 12, 0, 0) * CFrame.new(0, 0.4, 0.05)
- rsspring.t = torso["Right Shoulder"].C0:lerp(CFrame.new(-0.9, 0.45, 0), 1.2 - up)
- torso["Right Shoulder"].C0 = rsspring.p
- if state == "Prone" or climbing then
- torso["Right Shoulder"].C1 = torso["Right Shoulder"].C1:lerp(CFrame.new(-0.5, 0.5, 0) * CFrame.Angles(-pi / 1.1, 0, ), lerp10)
- else
- torso["Right Shoulder"].C1 = torso["Right Shoulder"].C1:lerp(CFrame.new(0.5, 0.5, 0), lerp10)
- end
- torso["Left Shoulder"].C0 = CFrame.new(0.9, 0.5, 0) * CFrame.Angles(-math.cos(right) * 0.7 * localDirection.Z, 0, math.cos(right) * 0.55 * localDirection.X)
- torso["Left Shoulder"].C0 = torso["Left Shoulder"].C0 * CFrame.new(0, -0.5, 0) * CFrame.Angles(pi / 12, 0, 0) * CFrame.new(0, 0.4, 0.05)
- lsspring.t = torso["Left Shoulder"].C0:lerp(CFrame.new(0.9, 0.45, 0), 1.2 - up)
- torso["Left Shoulder"].C0 = lsspring.p
- if state == "Prone" or climbing then
- torso["Left Shoulder"].C1 = torso["Left Shoulder"].C1:lerp(CFrame.new(-0.5, 0.5, 0) * CFrame.Angles(-pi / 1.1, 0, ), lerp10)
- else
- torso["Left Shoulder"].C1 = torso["Left Shoulder"].C1:lerp(CFrame.new(-0.5, 0.5, 0), lerp10)
- end
- -- DECOMPILER ERROR: 14 unprocessed JMP targets
- end
- end
- run.time = tick()
- run.dt = 0.016666666666667
- run.framerate = 60
- run.onstep = {}
- run.onthink = {}
- local wait = renderstepped.wait
- local eng = {feet.step}
- local fireonstep = event.new(run.onstep)
- local fireonthink = event.new(run.onthink)
- run.wait = function()
- wait(renderstepped)
- end
- renderstepped:connect(function()
- local newtime = tick()
- run.dt = newtime - run.time
- run.time = newtime
- run.framerate = 0.95 * run.framerate + 0.05 / run.dt
- for i = 1, #eng do
- eng[i](run.dt)
- end
- fireonstep(run.dt)
- end)
- game:GetService("RunService).Stepped:connect(function()
- fireonthink()
- end)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement