Advertisement
iiFlamez

Untitled

Nov 5th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.04 KB | None | 0 0
  1. -- params : ...
  2.  
  3. repeat
  4. wait()
  5. until game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name)
  6. local p = game.Players.LocalPlayer
  7. local ch = game.Workspace:WaitForChild(p.Name)
  8. local feet = {}
  9. local run = {}
  10. local event = {}
  11. local physics = {}
  12. local renderstepped = game:GetService("RunService").RenderStepped
  13. local cf = CFrame.new
  14. local ca = CFrame.Angles
  15. local nc = cf()
  16. local v3 = Vector3.new
  17. local nv = v3()
  18. local comp = nc.components
  19. local cos = math.cos
  20. local sin = math.sin
  21. local atan2 = math.atan2
  22. local sort = table.sort
  23. local inf = math.huge
  24. local b1 = Instance.new("Part", ch)
  25. b1.Size = v3(1.5, 0.25, 1)
  26. b1.BrickColor = BrickColor.Gray()
  27. b1.BottomSurface = Enum.SurfaceType.Smooth
  28. b1.TopSurface = Enum.SurfaceType.Smooth
  29. b1.CanCollide = false
  30. b1.Anchored = false
  31. local b2 = b1:Clone()
  32. b2.Parent = ch
  33. physics.spring = {}
  34. physics.cspring = {}
  35. physics.grounded = function(p)
  36. local r = Ray.new(p.Position, Vector3.new(0, -4, 0))
  37. local h, pos = game.Workspace:FindPartOnRay(r, p.Parent)
  38. if h and h.CanCollide == true and p.Position - pos.Magnitude < 2.999 then
  39. return true
  40. end
  41. return false
  42. end
  43.  
  44. physics.spring.new = function(initial)
  45. local t0 = tick()
  46. local p0 = initial or 0
  47. local v0 = initial and 0 * initial or 0
  48. local t = initial or 0
  49. local d = 1
  50. local s = 1
  51. local positionvelocity = function(tick)
  52. local x = tick - t0
  53. local c0 = p0 - t
  54. if s == 0 then
  55. return p0, 0
  56. else
  57. if d < 1 then
  58. local c = 1 - d * d ^ 0.5
  59. local c1 = (v0 / s + d * c0) / c
  60. local co = cos(c * s * x)
  61. local si = sin(c * s * x)
  62. local e = 2.718281828459 ^ (d * s * x)
  63. return t + (c0 * co + c1 * si) / e, s * ((c * c1 - d * c0) * co - (c * c0 + d * c1) * si) / e
  64. else
  65. do
  66. local c1 = v0 / s + c0
  67. local e = 2.718281828459 ^ (s * x)
  68. do return t + (c0 + c1 * s * x) / e, s * (c1 - c0 - c1 * s * x) / e end
  69. end
  70. end
  71. end
  72. end
  73.  
  74. return setmetatable({accelerate = function(_, acceleration)
  75. local time = tick()
  76. local p, v = positionvelocity(time)
  77. p0 = p
  78. v0 = v + acceleration
  79. t0 = time
  80. end
  81. }, {__index = function(_, index)
  82. if index == "value" or index == "position" or index == "p" then
  83. local p, v = positionvelocity(tick())
  84. return p
  85. else
  86. do
  87. if index == "velocity" or index == "v" then
  88. local p, v = positionvelocity(tick())
  89. return v
  90. else
  91. do
  92. if index == "acceleration" or index == "a" then
  93. local x = tick() - t0
  94. local c0 = p0 - t
  95. if s == 0 then
  96. return 0
  97. else
  98. if d < 1 then
  99. local c = 1 - d * d ^ 0.5
  100. local c1 = (v0 / s + d * c0) / c
  101. 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)
  102. else
  103. do
  104. do
  105. local c1 = v0 / s + c0
  106. do return s * s * (c0 - 2 * c1 + c1 * s * x) / 2.718281828459 ^ (s * x) end
  107. if index == "target" or index == "t" then
  108. return t
  109. else
  110. if index == "damper" or index == "d" then
  111. return d
  112. else
  113. if index == "speed" or index == "s" then
  114. return s
  115. else
  116. if index == "magnitude" or index == "m" then
  117. local p, v = positionvelocity(tick())
  118. return p.magnitude
  119. else
  120. do
  121. error(index .. " is not a valid member of spring", 0)
  122. end
  123. end
  124. end
  125. end
  126. end
  127. end
  128. end
  129. end
  130. end
  131. end
  132. end
  133. end
  134. end
  135. end
  136. end
  137. , __newindex = function(_, index, value)
  138. local time = tick()
  139. if index == "value" or index == "position" or index == "p" then
  140. local p, v = positionvelocity(time)
  141. p0 = value
  142. else
  143. do
  144. if index == "velocity" or index == "v" then
  145. local p, v = positionvelocity(time)
  146. p0 = p
  147. else
  148. do
  149. if index == "acceleration" or index == "a" then
  150. local p, v = positionvelocity(time)
  151. p0 = p
  152. else
  153. do
  154. if index == "target" or index == "t" then
  155. p0 = positionvelocity(time)
  156. t = value
  157. else
  158. if index == "damper" or index == "d" then
  159. p0 = positionvelocity(time)
  160. d = (value < 0 and 0) or (value < 1 and value) or 1
  161. else
  162. if index == "speed" or index == "s" then
  163. p0 = positionvelocity(time)
  164. s = value < 0 and 0 or value
  165. else
  166. error(index .. " is not a valid member of spring", 0)
  167. end
  168. end
  169. end
  170. t0 = time
  171. end
  172. end
  173. end
  174. end
  175. end
  176. end
  177. end
  178. )
  179. end
  180.  
  181. do
  182. local meta = {__index = function(t, i)
  183. if i == "t" then
  184. return t.t
  185. else
  186. if i == "p" or i == "position" then
  187. local c1, c2, c3, c4 = t.c1, t.c2, t.c3, t.c4
  188. 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)
  189. else
  190. do
  191. if i == "s" or i == "speed" then
  192. return t.settings.s
  193. else
  194. if i == "d" or i == "damper" then
  195. return t.settings.d
  196. else
  197. if i == "m" or i == "magnitude" then
  198. return t.c1.magnitude + t.c2.magnitude + t.c3.magnitude + t.c4.magnitude
  199. end
  200. end
  201. end
  202. end
  203. end
  204. end
  205. end
  206. , __newindex = function(t, i, v)
  207. local c1, c2, c3, c4 = t.c1, t.c2, t.c3, t.c4
  208. if i == "t" or i == "target" then
  209. local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = comp(v)
  210. c1.t = Vector3.new(x, y, z)
  211. else
  212. do
  213. if i == "s" or i == "speed" then
  214. t.settings.s = v
  215. c1.s = v
  216. else
  217. if i == "d" or i == "damper" then
  218. t.settings.d = v
  219. c1.d = v
  220. end
  221. end
  222. end
  223. end
  224. end
  225. }
  226. do
  227. physics.cspring.new = function(start, s, d)
  228. local settings = {s = s or 1, d = d or 1}
  229. local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = comp(start)
  230. 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))
  231. c1.s = s
  232. c1.d = d
  233. local t = setmetatable({settings = settings, c1 = c1, c2 = c2, c3 = c3, c4 = c4}, meta)
  234. return t
  235. end
  236.  
  237. end
  238. event.new = function(eventtable)
  239. if not eventtable then
  240. local self = {}
  241. end
  242. local removelist = {}
  243. local functions = {}
  244. local pendingdeletion = false
  245. self.connect = function(self, func)
  246. functions[#functions + 1] = func
  247. return function()
  248. removelist[func] = true
  249. pendingdeletion = true
  250. end
  251.  
  252. end
  253.  
  254. return function(...)
  255. if pendingdeletion then
  256. pendingdeletion = false
  257. local j = 1
  258. for i = 1, #functions do
  259. local f = functions[i]
  260. functions[i] = nil
  261. if removelist[f] then
  262. removelist[f] = nil
  263. else
  264. f(...)
  265. functions[j] = f
  266. j = j + 1
  267. end
  268. end
  269. else
  270. do
  271. for i = 1, #functions do
  272. functions[i](...)
  273. end
  274. end
  275. end
  276. end
  277. , self
  278. end
  279.  
  280. local humanoid = ch:WaitForChild("Humanoid)
  281. humanoid.Animator:Destroy()
  282. humanoid.Status:Destroy()
  283. ch.Animate:Destroy()
  284. local torso = ch:WaitForChild("Torso")
  285. local hrp = ch:WaitForChild("HumanoidRootPart")
  286. local state = "None"
  287. game.Workspace.CurrentCamera.CameraSubject = humanoid
  288. local defaultSpeed = 15
  289. local jumpPower = 40
  290. local lhspring = physics.cspring.new(nc, 32000, 1)
  291. local rhspring = physics.cspring.new(nc, 32000, 1)
  292. local lhspring2 = physics.cspring.new(nc, 32000, 1)
  293. local rhspring2 = physics.cspring.new(nc, 32000, 1)
  294. local hrpspring = physics.cspring.new(nc, 12, 0.4)
  295. local hrpspring2 = physics.cspring.new(nc, 12, 0.4)
  296. local lsspring = physics.cspring.new(nc, 12, 0.7)
  297. local rsspring = physics.cspring.new(nc, 12, 0.7)
  298. local stances = {
  299. None = {1, CFrame.new(0, -1, 0), 1}
  300. ,
  301. Sprint = {1.3, CFrame.new(0, -1, 0), 0.9}
  302. ,
  303. Crouch = {0.5, CFrame.new(0, -2, 0) * CFrame.Angles(-math.pi / 12, 0, 0), 0.6}
  304. ,
  305. Prone = {0.3, CFrame.new(0, -2.4, 0) * CFrame.Angles(-math.pi / 2.1, 0, 0), 0}
  306. }
  307. local direction = Vector3.new(0, 0, -1)
  308. local stride = 2
  309. local cycleSpeed = 14
  310. local left, right = 0, math.pi
  311. local rhipcf = CFrame.new(0.5, -1, 0.25)
  312. local lhipcf = CFrame.new(-0.5, -1, 0.25)
  313. local atn2, acs = math.atan2, math.acos
  314. local pi = math.pi
  315. local LerpNumber = function(a, b, t)
  316. return a + (b - a) * t
  317. end
  318.  
  319. local IsNAN = function(x)
  320. do return x ~= x end
  321. -- DECOMPILER ERROR: 1 unprocessed JMP targets
  322. end
  323.  
  324. do
  325. local lastTick = tick()
  326. feet.step = function()
  327. local deltaTime = tick() - lastTick
  328. lastTick = tick()
  329. local lerp10 = math.min(deltaTime * 10, 1)
  330. local velocity = Vector3.new(torso.Velocity.X, 0, torso.Velocity.Z)
  331. if velocity.magnitude > 0.1 then
  332. direction = direction:Lerp(velocity.unit, deltaTime * 10)
  333. end
  334. local climbing = humanoid:GetState() == Enum.HumanoidStateType.Climbing
  335. if climbing then
  336. velocity = velocity + Vector3.new(0, torso.Velocity.Y, 0)
  337. direction = torso.CFrame.lookVector
  338. end
  339. right = (right + velocity.magnitude / defaultSpeed * deltaTime * cycleSpeed) % (pi * 2)
  340. left = (left + velocity.magnitude / defaultSpeed * deltaTime * cycleSpeed) % (pi * 2)
  341. humanoid.WalkSpeed = defaultSpeed * stances[state][1]
  342. humanoid.JumpPower = jumpPower * stances[state][3]
  343. local localVelocity = hrp.CFrame:vectorToObjectSpace(velocity) * 0.6
  344. hrpspring.t = hrp.RootJoint.C0:lerp(stances[state][2], lerp10)
  345. hrp.RootJoint.C0 = hrpspring.p
  346. 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()
  347. hrp.RootJoint.C1 = hrpspring2.p
  348. local up = velocity.magnitude / defaultSpeed
  349. local hip = torso.CFrame * rhipcf.p
  350. do
  351. local ground = torso.CFrame * CFrame.new(0.5, -3, 0)
  352. if state == "Prone" or climbing then
  353. ground = ground * CFrame.new(0, 0, -stride / 2)
  354. end
  355. ground = ground.p
  356. local desiredPosition = CFrame.new(ground, ground + direction) * CFrame.Angles(-right, 0, 0) * CFrame.new(0, 0, -stride / 2).p
  357. local distance = math.min(hip - desiredPosition.magnitude, 2)
  358. local ray = Ray.new(hip, CFrame.new(hip, desiredPosition).lookVector * LerpNumber(2, distance, up))
  359. local hit, footPosition = game.Workspace:FindPartOnRayWithIgnoreList(ray, {ch, game.Workspace:FindFirstChild("Ignore", true)})
  360. spawn(function()
  361. local pa = Instance.new("Part", ch)
  362. pa.Anchored = true
  363. pa.CanCollide = false
  364. pa.Transparency = 0.5
  365. pa.BrickColor = BrickColor.Red()
  366. pa.Size = nv
  367. pa.CFrame = cf(footPosition)
  368. game:GetService("Debris"):AddItem(pa, 0.1)
  369. end)
  370. distance = hip - footPosition.magnitude
  371. local offset = torso.CFrame * rhipcf:pointToObjectSpace(footPosition)
  372. local x, y = atn2(offset.Z, offset.Y), atn2(offset.X, offset.Y)
  373. rhspring.t = rhipcf * CFrame.Angles(x, 0, 0) * CFrame.Angles(0, 0, y) * CFrame.Angles(0, pi, 0)
  374. torso["Right Hip"].C0 = rhspring.p
  375. if distance < 2 then
  376. local angle = -acs(distance / 2)
  377. do
  378. 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)
  379. rhspring2.t = newCF
  380. torso["Right Hip"].C0 = rhspring2.p
  381. -- DECOMPILER ERROR at PC346: LeaveBlock: unexpected jumping out IF_THEN_STMT
  382.  
  383. -- DECOMPILER ERROR at PC346: LeaveBlock: unexpected jumping out IF_STMT
  384.  
  385. end
  386. end
  387. end
  388. local hip = torso.CFrame * lhipcf.p
  389. local ground = torso.CFrame * CFrame.new(-0.5, -3, 0)
  390. if state == "Prone" or climbing then
  391. ground = ground * CFrame.new(0, 0, -stride / 2)
  392. end
  393. ground = ground.p
  394. local desiredPosition = CFrame.new(ground, ground + direction) * CFrame.Angles(-left, 0, 0) * CFrame.new(0, 0, -stride / 2).p
  395. local distance = math.min(hip - desiredPosition.magnitude, 2)
  396. local ray = Ray.new(hip, CFrame.new(hip, desiredPositio).lookVector * LerpNumber(, distance, up))
  397. local hit, footPosition = game.Workspace:FindPartOnRayWithIgnoreList(ray, {ch, game.Workspace:FindFirstChild("Ignore", true))
  398. spawn(function()
  399. local pa = Instance.new("Part", ch)
  400. pa.Anchored = true
  401. pa.CanCollide = false
  402. pa.Transparency = 0.5
  403. pa.BrickColor = BrickColor.Red()
  404. pa.Size = nv
  405. pa.CFrame = cf(desiredPosition)
  406. game:GetService("Debris"):AddItem(pa, 0.1)
  407. end)
  408. distance = hip - footPosition.magnitude
  409. local offset = torso.CFrame * lhipcf:pointToObjectSpace(footPosition)
  410. local x, y = atn2(offset.Z, offset.Y), atn2(offset.X, offset.Y)
  411. lhspring.t = lhipcf * CFrame.Angles(x, 0, 0) * CFrame.Angles(0, 0, y) * CFrame.Angles(0, pi, 0)
  412. torso["Left Hip"].C0 = lhspring.p
  413. if distance < 2 then
  414. local angle = -acs(distance / 2)
  415. 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)
  416. lhspring2.t = newCF
  417. torso["Left Hip"].C0 = lhspring2.p
  418. end
  419. do
  420. local localDirection = torso.CFrame:vectorToObjectSpace(direction)
  421. 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)
  422. 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)
  423. rsspring.t = torso["Right Shoulder"].C0:lerp(CFrame.new(-0.9, 0.45, 0), 1.2 - up)
  424. torso["Right Shoulder"].C0 = rsspring.p
  425. if state == "Prone" or climbing then
  426. torso["Right Shoulder"].C1 = torso["Right Shoulder"].C1:lerp(CFrame.new(-0.5, 0.5, 0) * CFrame.Angles(-pi / 1.1, 0, ), lerp10)
  427. else
  428. torso["Right Shoulder"].C1 = torso["Right Shoulder"].C1:lerp(CFrame.new(0.5, 0.5, 0), lerp10)
  429. end
  430. 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)
  431. 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)
  432. lsspring.t = torso["Left Shoulder"].C0:lerp(CFrame.new(0.9, 0.45, 0), 1.2 - up)
  433. torso["Left Shoulder"].C0 = lsspring.p
  434. if state == "Prone" or climbing then
  435. torso["Left Shoulder"].C1 = torso["Left Shoulder"].C1:lerp(CFrame.new(-0.5, 0.5, 0) * CFrame.Angles(-pi / 1.1, 0, ), lerp10)
  436. else
  437. torso["Left Shoulder"].C1 = torso["Left Shoulder"].C1:lerp(CFrame.new(-0.5, 0.5, 0), lerp10)
  438. end
  439. -- DECOMPILER ERROR: 14 unprocessed JMP targets
  440. end
  441. end
  442.  
  443. run.time = tick()
  444. run.dt = 0.016666666666667
  445. run.framerate = 60
  446. run.onstep = {}
  447. run.onthink = {}
  448. local wait = renderstepped.wait
  449. local eng = {feet.step}
  450. local fireonstep = event.new(run.onstep)
  451. local fireonthink = event.new(run.onthink)
  452. run.wait = function()
  453. wait(renderstepped)
  454. end
  455.  
  456. renderstepped:connect(function()
  457. local newtime = tick()
  458. run.dt = newtime - run.time
  459. run.time = newtime
  460. run.framerate = 0.95 * run.framerate + 0.05 / run.dt
  461. for i = 1, #eng do
  462. eng[i](run.dt)
  463. end
  464. fireonstep(run.dt)
  465. end)
  466. game:GetService("RunService).Stepped:connect(function()
  467. fireonthink()
  468. end)
  469. end
  470. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement