Advertisement
worm246411

Untitled

Jan 11th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.73 KB | None | 0 0
  1. do --CFrame lerp
  2. local function QuaternionFromCFrame(cf)
  3. local mx, my, mz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components()
  4. local trace = m00 + m11 + m22
  5. if trace > 0 then
  6. local s = math.sqrt(1 + trace)
  7. local recip = 0.5/s
  8. return (m21-m12)*recip, (m02-m20)*recip, (m10-m01)*recip, s*0.5
  9. else
  10. local i = 0
  11. if m11 > m00 then
  12. i = 1
  13. end
  14. if m22 > (i == 0 and m00 or m11) then
  15. i = 2
  16. end
  17. if i == 0 then
  18. local s = math.sqrt(m00-m11-m22+1)
  19. local recip = 0.5/s
  20. return 0.5*s, (m10+m01)*recip, (m20+m02)*recip, (m21-m12)*recip
  21. elseif i == 1 then
  22. local s = math.sqrt(m11-m22-m00+1)
  23. local recip = 0.5/s
  24. return (m01+m10)*recip, 0.5*s, (m21+m12)*recip, (m02-m20)*recip
  25. elseif i == 2 then
  26. local s = math.sqrt(m22-m00-m11+1)
  27. local recip = 0.5/s return (m02+m20)*recip, (m12+m21)*recip, 0.5*s, (m10-m01)*recip
  28. end
  29. end
  30. end
  31. local function QuaternionToCFrame(px, py, pz, x, y, z, w)
  32. local xs, ys, zs = x + x, y + y, z + z
  33. local wx, wy, wz = w*xs, w*ys, w*zs
  34. local xx = x*xs
  35. local xy = x*ys
  36. local xz = x*zs
  37. local yy = y*ys
  38. local yz = y*zs
  39. local zz = z*zs
  40. return CFrame.new(px, py, pz,1-(yy+zz), xy - wz, xz + wy,xy + wz, 1-(xx+zz), yz - wx, xz - wy, yz + wx, 1-(xx+yy))
  41. end
  42. local function QuaternionSlerp(a, b, t)
  43. local cosTheta = a[1]*b[1] + a[2]*b[2] + a[3]*b[3] + a[4]*b[4]
  44. local startInterp, finishInterp;
  45. if cosTheta >= 0.0001 then
  46. if (1 - cosTheta) > 0.0001 then
  47. local theta = math.acos(cosTheta)
  48. local invSinTheta = 1/math.sin(theta)
  49. startInterp = math.sin((1-t)*theta)*invSinTheta
  50. finishInterp = math.sin(t*theta)*invSinTheta
  51. else
  52. startInterp = 1-t
  53. finishInterp = t
  54. end
  55. else
  56. if (1+cosTheta) > 0.0001 then
  57. local theta = math.acos(-cosTheta)
  58. local invSinTheta = 1/math.sin(theta)
  59. startInterp = math.sin((t-1)*theta)*invSinTheta
  60. finishInterp = math.sin(t*theta)*invSinTheta
  61. else
  62. startInterp = t-1
  63. finishInterp = t
  64. end
  65. end
  66. return a[1]*startInterp + b[1]*finishInterp, a[2]*startInterp + b[2]*finishInterp, a[3]*startInterp + b[3]*finishInterp, a[4]*startInterp + b[4]*finishInterp
  67. end
  68. function clerp(a,b,t)
  69. local qa = {QuaternionFromCFrame(a)}
  70. local qb = {QuaternionFromCFrame(b)}
  71. local ax, ay, az = a.x, a.y, a.z
  72. local bx, by, bz = b.x, b.y, b.z
  73. local _t = 1-t
  74. return QuaternionToCFrame(_t*ax + t*bx, _t*ay + t*by, _t*az + t*bz,QuaternionSlerp(qa, qb, t))
  75. end
  76.  
  77. end
  78. do --the animating
  79. plr = game:service'Players'.LocalPlayer
  80. char = plr.Character
  81. mouse = plr:GetMouse()
  82. humanoid = char:findFirstChild("Humanoid")
  83. torso = char:findFirstChild("Torso")
  84. head = char.Head
  85. ra = char:findFirstChild("Right Arm")
  86. la = char:findFirstChild("Left Arm")
  87. rl = char:findFirstChild("Right Leg")
  88. ll = char:findFirstChild("Left Leg")
  89. rs = torso:findFirstChild("Right Shoulder")
  90. ls = torso:findFirstChild("Left Shoulder")
  91. rh = torso:findFirstChild("Right Hip")
  92. lh = torso:findFirstChild("Left Hip")
  93. neck = torso:findFirstChild("Neck")
  94. rj = char:findFirstChild("HumanoidRootPart"):findFirstChild("RootJoint")
  95. anim = char:findFirstChild("Animate")
  96. rootpart = char:findFirstChild("HumanoidRootPart")
  97. camera = workspace.CurrentCamera
  98. if anim then
  99. anim:Destroy()
  100. end
  101.  
  102.  
  103. local rm = Instance.new("Motor", torso)
  104. rm.C0 = CFrame.new(1.5, 0.5, 0)
  105. rm.C1 = CFrame.new(0, 0.5, 0)
  106. rm.Part0 = torso
  107. rm.Part1 = ra
  108. local lm = Instance.new("Motor", torso)
  109. lm.C0 = CFrame.new(-1.5, 0.5, 0)
  110. lm.C1 = CFrame.new(0, 0.5, 0)
  111. lm.Part0 = torso
  112. lm.Part1 = la
  113.  
  114. local rlegm = Instance.new("Motor", torso)
  115. rlegm.C0 = CFrame.new(0.5, -1, 0)
  116. rlegm.C1 = CFrame.new(0, 1, 0)
  117. rlegm.Part0 = torso
  118. rlegm.Part1 = rl
  119. local llegm = Instance.new("Motor", torso)
  120. llegm.C0 = CFrame.new(-0.5, -1, 0)
  121. llegm.C1 = CFrame.new(0, 1, 0)
  122. llegm.Part0 = torso
  123. llegm.Part1 = ll
  124.  
  125. neck.C0 = CFrame.new(0, 1, 0)
  126. neck.C1 = CFrame.new(0, -0.5, 0)
  127.  
  128.  
  129. rj.C0 = CFrame.new()
  130. rj.C1 = CFrame.new()
  131.  
  132.  
  133. local sound = Instance.new("Sound", head)
  134. sound.SoundId = "http://www.roblox.com/asset/?id=130797915"
  135. sound.Volume = 0.8
  136. sound.Looped = true
  137.  
  138. for i,v in pairs(char:children()) do
  139. if v:IsA("Hat") then
  140. v:Destroy()
  141. end
  142. end
  143.  
  144.  
  145. --look of the fox here
  146. game:service'InsertService':LoadAsset(25930301):children()[1].Parent = char
  147. Instance.new("PointLight", head).Range = 10
  148.  
  149.  
  150.  
  151.  
  152. local speed = 0.3
  153. local angle = 0
  154. local sitting = false
  155. local humanwalk = false
  156. local anglespeed = 1
  157. rsc0 = rm.C0
  158. lsc0 = lm.C0
  159. llc0 = llegm.C0
  160. rlc0 = rlegm.C0
  161. neckc0 = neck.C0
  162.  
  163. local controllerService = game:GetService("ControllerService")
  164. local controller = controllerService:GetChildren()[1]
  165.  
  166. controller.Parent = nil
  167.  
  168. Instance.new("HumanoidController", game:service'ControllerService')
  169. Instance.new("SkateboardController", game:service'ControllerService')
  170. Instance.new("VehicleController", game:service'ControllerService')
  171. local controller = controllerService:GetChildren()[1]
  172. mouse.KeyDown:connect(function(k)
  173. if k == "q" then
  174. humanwalk = not humanwalk
  175. end
  176. if k == "z" then
  177. if not sound.IsPlaying then
  178. sound:stop()
  179. sound.SoundId = "http://www.roblox.com/asset/?id=130802245"
  180. wait()
  181. sound:play()
  182. end
  183. end
  184. if k == "x" then
  185. if not sound.IsPlaying then
  186. sound:stop()
  187. sound.SoundId = "http://www.roblox.com/asset/?id=130797915"
  188. wait()
  189. sound:play()
  190. end
  191. end
  192. if k == "c" then
  193. if not sound.IsPlaying then
  194. sound:stop()
  195. sound.SoundId = "http://www.roblox.com/asset/?id=149713968"
  196. wait()
  197. sound:play()
  198. end
  199. end
  200. if string.byte(k) == 48 then
  201. humanoid.WalkSpeed = 34
  202. end
  203.  
  204. end)
  205. mouse.KeyUp:connect(function(k)
  206.  
  207. if string.byte(k) == 48 then
  208. humanoid.WalkSpeed = 16
  209. end
  210.  
  211. end)
  212.  
  213.  
  214.  
  215. while wait() do
  216. angle = (angle % 100) + anglespeed/10
  217. mvmnt = math.pi * math.sin(math.pi*2/100*(angle*10))
  218. local rscf = rsc0
  219. local lscf = lsc0
  220. local rlcf = rlc0
  221. local llcf = llc0
  222. local rjcf = CFrame.new()
  223. local ncf = neckc0
  224. local rayz = Ray.new(rootpart.Position, Vector3.new(0, -6, 0))
  225. local hitz, enz = workspace:findPartOnRay(rayz, char)
  226. if not hitz then
  227. if sound.IsPlaying then
  228. sound:stop()
  229. end
  230.  
  231. if Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude > 2 then
  232.  
  233. ncf = neckc0 * CFrame.Angles(math.pi/5, 0, 0)
  234. rjcf = CFrame.new() * CFrame.Angles(-math.pi/5, math.sin(angle)*0.05, 0)
  235. rscf = rsc0 * CFrame.Angles(math.pi/1.7+math.sin(angle)*0.1, 0, 0)
  236. lscf = lsc0 * CFrame.Angles(math.pi/1.7+math.sin(-angle)*0.1, 0, 0)
  237. rlcf = rlc0 * CFrame.Angles(-math.pi/10+math.sin(-angle)*0.3, 0, 0)
  238. llcf = llc0 * CFrame.Angles(-math.pi/10+math.sin(angle)*0.3, 0, 0)
  239.  
  240. else
  241.  
  242. ncf = neckc0 * CFrame.Angles(math.pi/14, 0, 0)
  243. rjcf = CFrame.new() * CFrame.Angles(-math.pi/18, math.sin(angle)*0.05, 0)
  244. rscf = rsc0 * CFrame.Angles(-math.pi/10+math.sin(angle)*0.2, 0, 0)
  245. lscf = lsc0 * CFrame.Angles(-math.pi/10+math.sin(-angle)*0.2, 0, 0)
  246. rlcf = rlc0 * CFrame.new(0, 0.7, -0.5) CFrame.Angles(-math.pi/14, 0, 0)
  247. llcf = llc0 * CFrame.Angles(-math.pi/20, 0, 0)
  248.  
  249. end
  250. elseif humanoid.Sit then
  251. if sound.IsPlaying and sound.SoundId == "http://www.roblox.com/asset/?id=130797915" then
  252. anglespeed = 6
  253. ncf = neckc0 * CFrame.Angles(math.pi/5-math.sin(angle)*0.1, 0, 0)
  254. rjcf = CFrame.new(0, -0.8, 0) * CFrame.Angles(-math.pi/5, 0, 0)
  255. rscf = rsc0 * CFrame.new(-.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, -math.rad(15))
  256. lscf = lsc0 * CFrame.new(.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, math.rad(15))
  257. rlcf = rlc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, math.rad(20))
  258. llcf = llc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, -math.rad(20))
  259. elseif sound.IsPlaying and sound.SoundId == "http://www.roblox.com/asset/?id=135570347" then
  260. anglespeed = 4
  261. ncf = neckc0 * CFrame.Angles(math.pi/5-math.abs(math.sin(angle))*0.3, 0, 0)
  262. rjcf = CFrame.new(0, -0.8, 0) * CFrame.Angles(-math.pi/5, 0, 0)
  263. rscf = rsc0 * CFrame.new(-.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, -math.rad(15))
  264. lscf = lsc0 * CFrame.new(.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, math.rad(15))
  265. rlcf = rlc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, math.rad(20))
  266. llcf = llc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, -math.rad(20))
  267. elseif sound.IsPlaying and sound.SoundId == "http://www.roblox.com/asset/?id=149713968" then
  268. anglespeed = 2
  269. ncf = neckc0 * CFrame.Angles(math.pi/5, 0, math.sin(angle)*0.08)
  270. rjcf = CFrame.new(0, -0.8, 0) * CFrame.Angles(-math.pi/5, math.sin(angle)*0.01, 0)
  271. rscf = rsc0 * CFrame.new(-.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, -math.rad(15))
  272. lscf = lsc0 * CFrame.new(.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, math.rad(15))
  273. rlcf = rlc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, math.rad(20))
  274. llcf = llc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, -math.rad(20))
  275. else
  276. anglespeed = 1/2
  277. ncf = neckc0 * CFrame.Angles(math.pi/5, 0, math.sin(angle)*0.08)
  278. rjcf = CFrame.new(0, -0.8, 0) * CFrame.Angles(-math.pi/5, math.sin(angle)*0.01, 0)
  279. rscf = rsc0 * CFrame.new(-.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, -math.rad(15))
  280. lscf = lsc0 * CFrame.new(.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, math.rad(15))
  281. rlcf = rlc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, math.rad(20))
  282. llcf = llc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, -math.rad(20))
  283. end
  284. elseif Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude < 2 then
  285. if sound.IsPlaying and sound.SoundId == "http://www.roblox.com/asset/?id=130797915" then
  286. anglespeed = 6
  287. ncf = neckc0 * CFrame.Angles(math.pi/10-math.sin(angle)*0.07, 0, 0)
  288. rjcf = CFrame.new(0, 0, 0) * CFrame.Angles(-math.pi/10, math.sin(angle)*0.001, 0)
  289. rscf = rsc0 * CFrame.Angles(math.pi/1+math.sin(angle)*0.5, 0, 0)
  290. lscf = lsc0 * CFrame.Angles(math.pi/1+math.sin(angle)*0.5, 0, 0)
  291. rlcf = rlc0 * CFrame.Angles(math.pi/10, math.sin(angle)*0.08, math.rad(6.5))
  292. llcf = llc0 * CFrame.Angles(math.pi/10, -math.sin(angle)*0.08, -math.rad(6.5))
  293. elseif sound.IsPlaying and sound.SoundId == "http://www.roblox.com/asset/?id=149713968" then
  294. anglespeed = 2
  295. ncf = neckc0 * CFrame.Angles(math.pi/10-math.abs(math.sin(angle))*0.3, 0, 0)
  296. rjcf = CFrame.new(0, 0, 0) * CFrame.Angles(-math.pi/20, math.sin(angle)*0.001, 0)
  297. rscf = rsc0 * CFrame.Angles(math.pi/2+math.abs(math.sin(angle)*1), 0, 0)
  298. lscf = lsc0 * CFrame.Angles(math.pi/2+math.abs(math.sin(angle)*1), 0, 0)
  299. rlcf = rlc0 * CFrame.Angles(math.pi/20, math.sin(angle)*0.08, math.rad(2.5))
  300. llcf = llc0 * CFrame.Angles(math.pi/20, -math.sin(angle)*0.08, -math.rad(2.5))
  301. elseif sound.IsPlaying and sound.SoundId == "http://www.roblox.com/asset/?id=130802245" then
  302. anglespeed = 3
  303. ncf = neckc0 * CFrame.Angles(math.sin(angle)*0.07, math.rad(30), 0)
  304. rjcf = CFrame.new(0, 0, 0) * CFrame.Angles(0, math.sin(angle)*0.001, 0)
  305. rscf = rsc0 * CFrame.Angles(math.sin(angle)*0.05, 0, 0)
  306. lscf = lsc0 * CFrame.Angles(math.sin(-angle)*0.05, 0, 0)
  307. rlcf = rlc0 * CFrame.new(0, -0.1 + math.abs(mvmnt)*0.1, -0.1) * CFrame.Angles(0, math.rad(5), math.rad(5))
  308. llcf = llc0 * CFrame.Angles(0, math.rad(2.5), math.rad(1))
  309. else
  310. if humanwalk then
  311. anglespeed = 1/4
  312. ncf = neckc0 * CFrame.Angles(-math.sin(angle)*0.07, 0, 0)
  313. rjcf = CFrame.new(0, 0, 0) * CFrame.Angles(0, math.sin(angle)*0.001, 0)
  314. rscf = rsc0 * CFrame.Angles(math.sin(angle)*0.1, 0, 0)
  315. lscf = lsc0 * CFrame.Angles(math.sin(-angle)*0.1, 0, 0)
  316. rlcf = rlc0 * CFrame.Angles(0, math.sin(angle)*0.08, math.rad(2.5))
  317. llcf = llc0 * CFrame.Angles(0, -math.sin(angle)*0.08, -math.rad(2.5))
  318. else
  319. anglespeed = 1/2
  320. ncf = neckc0 * CFrame.Angles(math.pi/5, 0, math.sin(angle)*0.08)
  321. rjcf = CFrame.new(0, -2, 0) * CFrame.Angles(-math.pi/5, math.sin(angle)*0.01, 0)
  322. rscf = rsc0 * CFrame.new(-.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, -math.rad(15))
  323. lscf = lsc0 * CFrame.new(.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, math.rad(15))
  324. rlcf = rlc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, math.rad(20))
  325. llcf = llc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, -math.rad(20))
  326. end
  327. end
  328. elseif Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude < 20 then
  329. if sound.IsPlaying then
  330. sound:stop()
  331. end
  332. if humanwalk then
  333. anglespeed = 4
  334. ncf = neckc0 * CFrame.Angles(math.pi/24, mvmnt*.02, 0)
  335. rjcf = CFrame.new(0, math.abs(mvmnt)*0.05, 0) * CFrame.Angles(-math.pi/24, -mvmnt*.02, 0)
  336. rscf = rsc0 * CFrame.Angles(math.sin(angle)*1.25, 0, -math.abs(mvmnt)*0.02)
  337. lscf = lsc0 * CFrame.Angles(math.sin(-angle)*1.25, 0, math.abs(mvmnt)*0.02)
  338. rlcf = rlc0 * CFrame.Angles(math.sin(-angle)*1, 0, math.rad(.5))
  339. llcf = llc0 * CFrame.Angles(math.sin(angle)*1, 0, -math.rad(.5))
  340. else
  341. anglespeed = 4
  342. ncf = neckc0 * CFrame.new(0, 0, .2) * CFrame.Angles(math.pi/1.9, 0, 0)
  343. rjcf = CFrame.new(0, -1.5+math.abs(mvmnt)*0.05, 0) * CFrame.Angles(-math.pi/1.9, math.sin(mvmnt/2)*0.05, 0)
  344. rscf = rsc0 * CFrame.new(-.45, 0.2, -.4+math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/2+math.sin(angle)*0.7, 0, math.rad(5))
  345. lscf = lsc0 * CFrame.new(.45, 0.2, .1-math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/2+math.sin(-angle)*0.7, 0, -math.rad(5))
  346. rlcf = rlc0 * CFrame.new(0, 0, -.3+math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/2.5+math.sin(-angle)*0.6, 0, math.abs(mvmnt)*0.025)
  347. llcf = llc0 * CFrame.new(0, 0, .3-math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/2.5+math.sin(angle)*.6, 0, -math.abs(mvmnt)*0.025)
  348. end
  349. elseif Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude >= 20 then
  350. if sound.IsPlaying then
  351. sound:stop()
  352. end
  353. if humanwalk then
  354. anglespeed = 5
  355. ncf = neckc0 * CFrame.Angles(math.pi/20, math.sin(angle)*.04, 0)
  356. rjcf = CFrame.new(0, -.4 + math.abs(mvmnt)*0.25, 0) * CFrame.Angles(-math.pi/20, -math.sin(angle)*.08, 0)
  357. rscf = rsc0 * CFrame.new(0, 0, -.3+math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/18+math.sin(angle)*1.5, 0, -math.abs(mvmnt)*0.02)
  358. lscf = lsc0 * CFrame.new(0, 0, .3-math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/18+math.sin(-angle)*1.5, 0, math.abs(mvmnt)*0.02)
  359. rlcf = rlc0 * CFrame.new(0, 0, -.6+math.abs(mvmnt)*0.125) * CFrame.Angles(-math.pi/18+math.sin(-angle)*1.3, 0, math.rad(.5))
  360. llcf = llc0 * CFrame.new(0, 0, -math.abs(mvmnt)*0.125) * CFrame.Angles(-math.pi/18+math.sin(angle)*1.3, 0, -math.rad(.5))
  361. else
  362. anglespeed = 5.5
  363. ncf = neckc0 * CFrame.new(0, 0, .2) * CFrame.Angles(math.pi/1.9+math.sin(mvmnt/2)*0.05, 0, 0)
  364. rjcf = CFrame.new(0, -1.3+math.abs(mvmnt)*0.05, 0) * CFrame.Angles(-math.pi/1.9+math.abs(mvmnt/2)*0.1, 0, 0)
  365. rscf = rsc0 * CFrame.new(-1, 0.2, -.5) * CFrame.Angles(math.pi/2+math.sin(angle)*1.8, 0, math.rad(5))
  366. lscf = lsc0 * CFrame.new(1, 0.2, -.5) * CFrame.Angles(math.pi/2+math.sin(angle)*1.8, 0, -math.rad(5))
  367. rlcf = rlc0 * CFrame.new(0, .3-math.abs(mvmnt)*0.125, -.3+math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/2.5+math.sin(-angle)*1.4, 0, math.abs(mvmnt)*0.025)
  368. llcf = llc0 * CFrame.new(0, .3-math.abs(mvmnt)*0.125, .3-math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/2.5+math.sin(-angle)*1.4, 0, -math.abs(mvmnt)*0.025)
  369. end
  370. end
  371.  
  372. rm.C0 = clerp(rm.C0,rscf,speed)
  373. lm.C0 = clerp(lm.C0,lscf,speed)
  374. rj.C0 = clerp(rj.C0,rjcf,speed)
  375. neck.C0 = clerp(neck.C0,ncf,speed)
  376. rlegm.C0 = clerp(rlegm.C0,rlcf,speed)
  377. llegm.C0 = clerp(llegm.C0,llcf,speed)
  378. end
  379.  
  380.  
  381. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement