Advertisement
BobMe

PathAI

Jan 30th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.89 KB | None | 0 0
  1.  
  2. --Converted with ttyyuu12345's model to script plugin v4
  3. function sandbox(var,func)
  4. local env = getfenv(func)
  5. local newenv = setmetatable({},{
  6. __index = function(self,k)
  7. if k=="script" then
  8. return var
  9. else
  10. return env[k]
  11. end
  12. end,
  13. })
  14. setfenv(func,newenv)
  15. return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Model0 = Instance.new("Model")
  20. Part1 = Instance.new("Part")
  21. Motor6D2 = Instance.new("Motor6D")
  22. Part3 = Instance.new("Part")
  23. SpecialMesh4 = Instance.new("SpecialMesh")
  24. Motor6D5 = Instance.new("Motor6D")
  25. Motor6D6 = Instance.new("Motor6D")
  26. Motor6D7 = Instance.new("Motor6D")
  27. Motor6D8 = Instance.new("Motor6D")
  28. Motor6D9 = Instance.new("Motor6D")
  29. Part10 = Instance.new("Part")
  30. SpecialMesh11 = Instance.new("SpecialMesh")
  31. Part12 = Instance.new("Part")
  32. SpecialMesh13 = Instance.new("SpecialMesh")
  33. Part14 = Instance.new("Part")
  34. SpecialMesh15 = Instance.new("SpecialMesh")
  35. Part16 = Instance.new("Part")
  36. SpecialMesh17 = Instance.new("SpecialMesh")
  37. Part18 = Instance.new("Part")
  38. SpecialMesh19 = Instance.new("SpecialMesh")
  39. Decal20 = Instance.new("Decal")
  40. Sound21 = Instance.new("Sound")
  41. Sound22 = Instance.new("Sound")
  42. Sound23 = Instance.new("Sound")
  43. Sound24 = Instance.new("Sound")
  44. Sound25 = Instance.new("Sound")
  45. Sound26 = Instance.new("Sound")
  46. Humanoid27 = Instance.new("Humanoid")
  47. Color3Value28 = Instance.new("Color3Value")
  48. Script29 = Instance.new("Script")
  49. Model30 = Instance.new("Model")
  50. Script31 = Instance.new("Script")
  51. Backpack32 = Instance.new("Backpack")
  52. Script33 = Instance.new("Script")
  53. BindableEvent34 = Instance.new("BindableEvent")
  54. Script35 = Instance.new("Script")
  55. ObjectValue36 = Instance.new("ObjectValue")
  56. AnimationController37 = Instance.new("AnimationController")
  57. Script38 = Instance.new("Script")
  58. Model0.Name = "Pathfinding Wanderer"
  59. Model0.Parent = mas
  60. Part1.Name = "HumanoidRootPart"
  61. Part1.Parent = Model0
  62. Part1.Material = Enum.Material.SmoothPlastic
  63. Part1.BrickColor = BrickColor.new("Dark green")
  64. Part1.Transparency = 1
  65. Part1.Rotation = Vector3.new(0, -18.2399998, 0)
  66. Part1.RotVelocity = Vector3.new(-0.0160937011, -8.44836613e-05, 0.0028687357)
  67. Part1.Velocity = Vector3.new(-0.00699306419, 6.5494175, -0.0277098417)
  68. Part1.FormFactor = Enum.FormFactor.Symmetric
  69. Part1.Size = Vector3.new(0.887999892, 0.887999892, 0.443999946)
  70. Part1.CFrame = CFrame.new(-14.8580265, 6.19717216, 26.9827309, 0.949730039, 7.18516989e-13, -0.313070148, 3.12449421e-13, 1, 3.24291397e-12, 0.313070148, -3.17771113e-12, 0.949730039)
  71. Part1.BottomSurface = Enum.SurfaceType.Smooth
  72. Part1.TopSurface = Enum.SurfaceType.Smooth
  73. Part1.Color = Color3.new(0.156863, 0.498039, 0.278431)
  74. Part1.Position = Vector3.new(-14.8580265, 6.19717216, 26.9827309)
  75. Part1.Orientation = Vector3.new(0, -18.2399998, 0)
  76. Part1.Color = Color3.new(0.156863, 0.498039, 0.278431)
  77. Motor6D2.Name = "Root Hip"
  78. Motor6D2.Parent = Part1
  79. Motor6D2.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  80. Motor6D2.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  81. Motor6D2.Part0 = Part1
  82. Motor6D2.Part1 = Part3
  83. Motor6D2.MaxVelocity = 0.10000000149012
  84. Part3.Name = "Torso"
  85. Part3.Parent = Model0
  86. Part3.Material = Enum.Material.DiamondPlate
  87. Part3.BrickColor = BrickColor.new("Light stone grey")
  88. Part3.Rotation = Vector3.new(0, -18.2399998, 0)
  89. Part3.RotVelocity = Vector3.new(-0.0160937011, -8.44836613e-05, 0.0028687357)
  90. Part3.Velocity = Vector3.new(-0.00699306419, 6.5494175, -0.0277098417)
  91. Part3.FormFactor = Enum.FormFactor.Symmetric
  92. Part3.Size = Vector3.new(0.887999892, 0.887999892, 0.443999946)
  93. Part3.CFrame = CFrame.new(-14.8580265, 6.19717216, 26.9827309, 0.949730039, 7.18516989e-13, -0.313070148, 3.12449421e-13, 1, 3.24291397e-12, 0.313070148, -3.17771113e-12, 0.949730039)
  94. Part3.BottomSurface = Enum.SurfaceType.Smooth
  95. Part3.TopSurface = Enum.SurfaceType.Smooth
  96. Part3.Color = Color3.new(0.898039, 0.894118, 0.87451)
  97. Part3.Position = Vector3.new(-14.8580265, 6.19717216, 26.9827309)
  98. Part3.Orientation = Vector3.new(0, -18.2399998, 0)
  99. Part3.Color = Color3.new(0.898039, 0.894118, 0.87451)
  100. SpecialMesh4.Parent = Part3
  101. SpecialMesh4.MeshId = "rbxasset://fonts/torso.mesh"
  102. SpecialMesh4.Scale = Vector3.new(0.443999976, 0.443999976, 0.443999976)
  103. SpecialMesh4.MeshType = Enum.MeshType.FileMesh
  104. SpecialMesh4.Scale = Vector3.new(0.443999976, 0.443999976, 0.443999976)
  105. Motor6D5.Name = "Left Hip"
  106. Motor6D5.Parent = Part3
  107. Motor6D5.C0 = CFrame.new(-0.221999973, -0.443999946, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  108. Motor6D5.C1 = CFrame.new(0, 0.443999946, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  109. Motor6D5.Part0 = Part3
  110. Motor6D5.Part1 = Part10
  111. Motor6D5.MaxVelocity = 0.10000000149012
  112. Motor6D6.Name = "Right Hip"
  113. Motor6D6.Parent = Part3
  114. Motor6D6.C0 = CFrame.new(0.221999973, -0.443999946, 0, -4.37113883e-08, 0, 1, -0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  115. Motor6D6.C1 = CFrame.new(0, 0.443999946, 0, -4.37113883e-08, 0, 1, 0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  116. Motor6D6.Part0 = Part3
  117. Motor6D6.Part1 = Part12
  118. Motor6D6.MaxVelocity = 0.10000000149012
  119. Motor6D7.Name = "Left Shoulder"
  120. Motor6D7.Parent = Part3
  121. Motor6D7.C0 = CFrame.new(-0.443999946, 0.221999973, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  122. Motor6D7.C1 = CFrame.new(0.221999973, 0.221999973, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  123. Motor6D7.Part0 = Part3
  124. Motor6D7.Part1 = Part14
  125. Motor6D7.CurrentAngle = -3.1400001049042
  126. Motor6D7.DesiredAngle = -3.1400001049042
  127. Motor6D7.MaxVelocity = 0.75
  128. Motor6D8.Name = "Right Shoulder"
  129. Motor6D8.Parent = Part3
  130. Motor6D8.C0 = CFrame.new(0.443999946, 0.221999973, 0, -4.37113883e-08, 0, 1, -0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  131. Motor6D8.C1 = CFrame.new(-0.221999973, 0.221999973, 0, -4.37113883e-08, 0, 1, 0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  132. Motor6D8.Part0 = Part3
  133. Motor6D8.Part1 = Part16
  134. Motor6D8.CurrentAngle = 3.1400001049042
  135. Motor6D8.DesiredAngle = 3.1400001049042
  136. Motor6D8.MaxVelocity = 0.75
  137. Motor6D9.Name = "Neck"
  138. Motor6D9.Parent = Part3
  139. Motor6D9.C0 = CFrame.new(0, 0.443999946, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  140. Motor6D9.C1 = CFrame.new(0, -0.221999973, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  141. Motor6D9.Part0 = Part3
  142. Motor6D9.Part1 = Part18
  143. Motor6D9.MaxVelocity = 0.10000000149012
  144. Part10.Name = "Left Leg"
  145. Part10.Parent = Model0
  146. Part10.Material = Enum.Material.DiamondPlate
  147. Part10.BrickColor = BrickColor.new("Dark green")
  148. Part10.Rotation = Vector3.new(0, -18.2399998, 0)
  149. Part10.RotVelocity = Vector3.new(-0.0160937011, -8.44836613e-05, 0.0028687357)
  150. Part10.Velocity = Vector3.new(-0.00443975534, 6.54769421, -0.0134364478)
  151. Part10.CanCollide = false
  152. Part10.FormFactor = Enum.FormFactor.Symmetric
  153. Part10.Size = Vector3.new(0.443999946, 0.887999892, 0.443999946)
  154. Part10.CFrame = CFrame.new(-15.0688667, 5.30917215, 26.913229, 0.949730039, 7.1851688e-13, -0.313070148, 3.12449421e-13, 0.999999881, 3.24291397e-12, 0.313070148, -3.1777107e-12, 0.949730039)
  155. Part10.BottomSurface = Enum.SurfaceType.Smooth
  156. Part10.TopSurface = Enum.SurfaceType.Smooth
  157. Part10.Color = Color3.new(0.156863, 0.498039, 0.278431)
  158. Part10.Position = Vector3.new(-15.0688667, 5.30917215, 26.913229)
  159. Part10.Orientation = Vector3.new(0, -18.2399998, 0)
  160. Part10.Color = Color3.new(0.156863, 0.498039, 0.278431)
  161. SpecialMesh11.Parent = Part10
  162. SpecialMesh11.MeshId = "rbxasset://fonts/leftleg.mesh"
  163. SpecialMesh11.Scale = Vector3.new(0.443999976, 0.443999976, 0.443999976)
  164. SpecialMesh11.MeshType = Enum.MeshType.FileMesh
  165. SpecialMesh11.Scale = Vector3.new(0.443999976, 0.443999976, 0.443999976)
  166. Part12.Name = "Right Leg"
  167. Part12.Parent = Model0
  168. Part12.Material = Enum.Material.DiamondPlate
  169. Part12.BrickColor = BrickColor.new("Dark green")
  170. Part12.Rotation = Vector3.new(0, -18.2399998, 0)
  171. Part12.RotVelocity = Vector3.new(-0.0160937011, -8.44836613e-05, 0.0028687357)
  172. Part12.Velocity = Vector3.new(-0.00445149839, 6.55114079, -0.0134008229)
  173. Part12.CanCollide = false
  174. Part12.FormFactor = Enum.FormFactor.Symmetric
  175. Part12.Size = Vector3.new(0.443999946, 0.887999892, 0.443999946)
  176. Part12.CFrame = CFrame.new(-14.6471863, 5.30917215, 27.0522327, 0.949730039, 7.1851688e-13, -0.313070148, 3.12449421e-13, 0.999999881, 3.24291397e-12, 0.313070148, -3.1777107e-12, 0.949730039)
  177. Part12.BottomSurface = Enum.SurfaceType.Smooth
  178. Part12.TopSurface = Enum.SurfaceType.Smooth
  179. Part12.Color = Color3.new(0.156863, 0.498039, 0.278431)
  180. Part12.Position = Vector3.new(-14.6471863, 5.30917215, 27.0522327)
  181. Part12.Orientation = Vector3.new(0, -18.2399998, 0)
  182. Part12.Color = Color3.new(0.156863, 0.498039, 0.278431)
  183. SpecialMesh13.Parent = Part12
  184. SpecialMesh13.MeshId = "rbxasset://fonts/leftleg.mesh"
  185. SpecialMesh13.Scale = Vector3.new(0.443999976, 0.443999976, 0.443999976)
  186. SpecialMesh13.MeshType = Enum.MeshType.FileMesh
  187. SpecialMesh13.Scale = Vector3.new(0.443999976, 0.443999976, 0.443999976)
  188. Part14.Name = "Left Arm"
  189. Part14.Parent = Model0
  190. Part14.Material = Enum.Material.DiamondPlate
  191. Part14.BrickColor = BrickColor.new("Bright yellow")
  192. Part14.Rotation = Vector3.new(179.899994, 18.2399998, 0.0299999993)
  193. Part14.RotVelocity = Vector3.new(-0.0160937011, -8.44836613e-05, 0.0028687357)
  194. Part14.Velocity = Vector3.new(-0.00824913848, 6.54424238, -0.0349088684)
  195. Part14.CanCollide = false
  196. Part14.FormFactor = Enum.FormFactor.Symmetric
  197. Part14.Size = Vector3.new(0.443999946, 0.887999892, 0.443999946)
  198. Part14.CFrame = CFrame.new(-15.4904356, 6.64117193, 26.7738895, 0.94972986, -0.000498579233, 0.31306985, 6.9924927e-11, -0.999998629, -0.00159254775, 0.313070178, 0.00151249045, -0.949728847)
  199. Part14.BottomSurface = Enum.SurfaceType.Smooth
  200. Part14.TopSurface = Enum.SurfaceType.Smooth
  201. Part14.Color = Color3.new(0.960784, 0.803922, 0.188235)
  202. Part14.Position = Vector3.new(-15.4904356, 6.64117193, 26.7738895)
  203. Part14.Orientation = Vector3.new(0.0899999961, 161.759995, 180)
  204. Part14.Color = Color3.new(0.960784, 0.803922, 0.188235)
  205. SpecialMesh15.Parent = Part14
  206. SpecialMesh15.MeshId = "rbxasset://fonts/leftleg.mesh"
  207. SpecialMesh15.Scale = Vector3.new(0.443999976, 0.443999976, 0.443999976)
  208. SpecialMesh15.MeshType = Enum.MeshType.FileMesh
  209. SpecialMesh15.Scale = Vector3.new(0.443999976, 0.443999976, 0.443999976)
  210. Part16.Name = "Right Arm"
  211. Part16.Parent = Model0
  212. Part16.Material = Enum.Material.DiamondPlate
  213. Part16.BrickColor = BrickColor.new("Bright yellow")
  214. Part16.Rotation = Vector3.new(179.899994, 18.2399998, 0.0299999993)
  215. Part16.RotVelocity = Vector3.new(-0.0160937011, -8.44836613e-05, 0.0028687357)
  216. Part16.Velocity = Vector3.new(-0.00828436855, 6.5545826, -0.0348019935)
  217. Part16.CanCollide = false
  218. Part16.FormFactor = Enum.FormFactor.Symmetric
  219. Part16.Size = Vector3.new(0.443999946, 0.887999892, 0.443999946)
  220. Part16.CFrame = CFrame.new(-14.2253962, 6.64117193, 27.1908989, 0.94972986, -0.000498579117, 0.313069671, -6.93000241e-11, -0.999998629, -0.00159254775, 0.313069999, 0.00151249045, -0.949728847)
  221. Part16.BottomSurface = Enum.SurfaceType.Smooth
  222. Part16.TopSurface = Enum.SurfaceType.Smooth
  223. Part16.Color = Color3.new(0.960784, 0.803922, 0.188235)
  224. Part16.Position = Vector3.new(-14.2253962, 6.64117193, 27.1908989)
  225. Part16.Orientation = Vector3.new(0.0899999961, 161.759995, -180)
  226. Part16.Color = Color3.new(0.960784, 0.803922, 0.188235)
  227. SpecialMesh17.Parent = Part16
  228. SpecialMesh17.MeshId = "rbxasset://fonts/leftleg.mesh"
  229. SpecialMesh17.Scale = Vector3.new(0.443999976, 0.443999976, 0.443999976)
  230. SpecialMesh17.MeshType = Enum.MeshType.FileMesh
  231. SpecialMesh17.Scale = Vector3.new(0.443999976, 0.443999976, 0.443999976)
  232. Part18.Name = "Head"
  233. Part18.Parent = Model0
  234. Part18.Material = Enum.Material.DiamondPlate
  235. Part18.BrickColor = BrickColor.new("Bright yellow")
  236. Part18.Rotation = Vector3.new(0, -18.2399998, 0)
  237. Part18.RotVelocity = Vector3.new(-0.0160937011, -8.44836613e-05, 0.0028687357)
  238. Part18.Velocity = Vector3.new(-0.00890364219, 6.5494175, -0.038428247)
  239. Part18.FormFactor = Enum.FormFactor.Symmetric
  240. Part18.Size = Vector3.new(0.887999892, 0.443999946, 0.443999946)
  241. Part18.CFrame = CFrame.new(-14.8580265, 6.86317205, 26.9827309, 0.949730039, 7.18516989e-13, -0.313070148, 3.12449421e-13, 1, 3.24291397e-12, 0.313070148, -3.17771113e-12, 0.949730039)
  242. Part18.BottomSurface = Enum.SurfaceType.Smooth
  243. Part18.TopSurface = Enum.SurfaceType.Smooth
  244. Part18.Color = Color3.new(0.960784, 0.803922, 0.188235)
  245. Part18.Position = Vector3.new(-14.8580265, 6.86317205, 26.9827309)
  246. Part18.Orientation = Vector3.new(0, -18.2399998, 0)
  247. Part18.Color = Color3.new(0.960784, 0.803922, 0.188235)
  248. SpecialMesh19.Parent = Part18
  249. SpecialMesh19.Scale = Vector3.new(1.25, 1.25, 1.25)
  250. SpecialMesh19.Scale = Vector3.new(1.25, 1.25, 1.25)
  251. Decal20.Name = "Face"
  252. Decal20.Parent = Part18
  253. Decal20.Texture = "rbxasset://textures/face.png"
  254. Sound21.Parent = Part18
  255. Sound21.Archivable = false
  256. Sound21.SoundId = "rbxasset://sounds/uuhhh.wav"
  257. Sound22.Parent = Part18
  258. Sound22.Archivable = false
  259. Sound22.SoundId = "rbxasset://sounds/splat.wav"
  260. Sound23.Parent = Part18
  261. Sound23.Archivable = false
  262. Sound23.SoundId = "rbxasset://sounds/swoosh.wav"
  263. Sound23.TimePosition = 0.034001454987447
  264. Sound24.Parent = Part18
  265. Sound24.Archivable = false
  266. Sound24.SoundId = "rbxasset://sounds/hit.wav"
  267. Sound25.Parent = Part18
  268. Sound25.Archivable = false
  269. Sound25.SoundId = "rbxasset://sounds/button.wav"
  270. Sound25.TimePosition = 0.015921851576422
  271. Sound26.Parent = Part18
  272. Sound26.Archivable = false
  273. Sound26.SoundId = "rbxasset://sounds/bfsl-minifigfoots1.mp3"
  274. Sound26.TimePosition = 0.016002419855795
  275. Sound26.Looped = true
  276. Humanoid27.Parent = Model0
  277. Humanoid27.NameOcclusion = Enum.NameOcclusion.NoOcclusion
  278. Humanoid27.RightLeg = Part12
  279. Humanoid27.LeftLeg = Part10
  280. Humanoid27.Torso = Part1
  281. Humanoid27.WalkToPoint = Vector3.new(-14.8579988, 2.64978838, 26.9664841)
  282. Color3Value28.Name = "Team"
  283. Color3Value28.Parent = Humanoid27
  284. Color3Value28.Value = Color3.new(0.156863, 0.498039, 0.278431)
  285. Script29.Name = "Sound"
  286. Script29.Parent = Model0
  287. table.insert(cors,sandbox(Script29,function()
  288. wait(0.5)
  289.  
  290. function waitForChild(parent, childName)
  291. local child = parent:findFirstChild(childName)
  292. if child then return child end
  293. while true do
  294. child = parent.ChildAdded:wait()
  295. if child.Name==childName then return child end
  296. end
  297. end
  298.  
  299. function newSound(id)
  300. local sound = Instance.new("Sound")
  301. sound.SoundId = id
  302. sound.archivable = false
  303. sound.Parent = script.Parent.Head
  304. return sound
  305. end
  306.  
  307.  
  308. local sDied = newSound("rbxasset://sounds/uuhhh.wav")
  309. local sFallingDown = newSound("rbxasset://sounds/splat.wav")
  310. local sFreeFalling = newSound("rbxasset://sounds/swoosh.wav")
  311. local sGettingUp = newSound("rbxasset://sounds/hit.wav")
  312. local sJumping = newSound("rbxasset://sounds/button.wav")
  313. local sRunning = newSound("rbxasset://sounds/bfsl-minifigfoots1.mp3")
  314. sRunning.Looped = true
  315.  
  316. local Figure = script.Parent
  317. local Head = waitForChild(Figure, "Head")
  318. local Humanoid = waitForChild(Figure, "Humanoid")
  319.  
  320. function onDied()
  321. sDied:Play()
  322. end
  323.  
  324. function onState(state, sound)
  325. if state then
  326. sound:Play()
  327. else
  328. sound:Pause()
  329. end
  330. end
  331.  
  332. function onRunning(speed)
  333. if speed>1 then
  334. sRunning:Play()
  335. else
  336. sRunning:Pause()
  337. end
  338. end
  339.  
  340.  
  341. Humanoid.Died:connect(onDied)
  342. Humanoid.Running:connect(onRunning)
  343. Humanoid.Jumping:connect(function(state) onState(state, sJumping) end)
  344. Humanoid.GettingUp:connect(function(state) onState(state, sGettingUp) end)
  345. Humanoid.FreeFalling:connect(function(state) onState(state, sFreeFalling) end)
  346. Humanoid.FallingDown:connect(function(state) onState(state, sFallingDown) end)
  347.  
  348. end))
  349. Model30.Name = "DebugPathDraw"
  350. Model30.Parent = Model0
  351. Script31.Name = "Animate"
  352. Script31.Parent = Model0
  353. table.insert(cors,sandbox(Script31,function()
  354. function waitForChild(parent, childName)
  355. local child = parent:findFirstChild(childName)
  356. if child then return child end
  357. while true do
  358. child = parent.ChildAdded:wait()
  359. if child.Name==childName then return child end
  360. end
  361. end
  362.  
  363. -- ANIMATION
  364.  
  365. -- declarations
  366.  
  367. local Figure = script.Parent
  368. local Torso = waitForChild(Figure, "Torso")
  369. local RightShoulder = waitForChild(Torso, "Right Shoulder")
  370. local LeftShoulder = waitForChild(Torso, "Left Shoulder")
  371. local RightHip = waitForChild(Torso, "Right Hip")
  372. local LeftHip = waitForChild(Torso, "Left Hip")
  373. local Neck = waitForChild(Torso, "Neck")
  374. local Humanoid = waitForChild(Figure, "Humanoid")
  375. local pose = "Standing"
  376.  
  377. local toolAnim = "None"
  378. local toolAnimTime = 0
  379.  
  380. local jumpMaxLimbVelocity = 0.75
  381.  
  382. -- functions
  383.  
  384. function onRunning(speed)
  385. if speed>1 then
  386. pose = "Running"
  387. else
  388. pose = "Standing"
  389. end
  390. end
  391.  
  392. function onDied()
  393. pose = "Dead"
  394. end
  395.  
  396. function onJumping()
  397. pose = "Jumping"
  398. end
  399.  
  400. function onClimbing()
  401. pose = "Climbing"
  402. end
  403.  
  404. function onGettingUp()
  405. pose = "GettingUp"
  406. end
  407.  
  408. function onFreeFall()
  409. pose = "FreeFall"
  410. end
  411.  
  412. function onFallingDown()
  413. pose = "FallingDown"
  414. end
  415.  
  416. function onSeated()
  417. pose = "Seated"
  418. end
  419.  
  420. function onPlatformStanding()
  421. pose = "PlatformStanding"
  422. end
  423.  
  424. function onSwimming(speed)
  425. if speed>0 then
  426. pose = "Running"
  427. else
  428. pose = "Standing"
  429. end
  430. end
  431.  
  432. function moveJump()
  433. RightShoulder.MaxVelocity = jumpMaxLimbVelocity
  434. LeftShoulder.MaxVelocity = jumpMaxLimbVelocity
  435. RightShoulder:SetDesiredAngle(3.14)
  436. LeftShoulder:SetDesiredAngle(-3.14)
  437. RightHip:SetDesiredAngle(0)
  438. LeftHip:SetDesiredAngle(0)
  439. end
  440.  
  441.  
  442. -- same as jump for now
  443.  
  444. function moveFreeFall()
  445. RightShoulder.MaxVelocity = jumpMaxLimbVelocity
  446. LeftShoulder.MaxVelocity = jumpMaxLimbVelocity
  447. RightShoulder:SetDesiredAngle(3.14)
  448. LeftShoulder:SetDesiredAngle(-3.14)
  449. RightHip:SetDesiredAngle(0)
  450. LeftHip:SetDesiredAngle(0)
  451. end
  452.  
  453. function moveSit()
  454. RightShoulder.MaxVelocity = 0.15
  455. LeftShoulder.MaxVelocity = 0.15
  456. RightShoulder:SetDesiredAngle(3.14 /2)
  457. LeftShoulder:SetDesiredAngle(-3.14 /2)
  458. RightHip:SetDesiredAngle(3.14 /2)
  459. LeftHip:SetDesiredAngle(-3.14 /2)
  460. end
  461.  
  462. function getTool()
  463. for _, kid in ipairs(Figure:GetChildren()) do
  464. if kid.className == "Tool" then return kid end
  465. end
  466. return nil
  467. end
  468.  
  469. function getToolAnim(tool)
  470. for _, c in ipairs(tool:GetChildren()) do
  471. if c.Name == "toolanim" and c.className == "StringValue" then
  472. return c
  473. end
  474. end
  475. return nil
  476. end
  477.  
  478. function animateTool()
  479.  
  480. if (toolAnim == "None") then
  481. RightShoulder:SetDesiredAngle(1.57)
  482. return
  483. end
  484.  
  485. if (toolAnim == "Slash") then
  486. RightShoulder.MaxVelocity = 0.5
  487. RightShoulder:SetDesiredAngle(0)
  488. return
  489. end
  490.  
  491. if (toolAnim == "Lunge") then
  492. RightShoulder.MaxVelocity = 0.5
  493. LeftShoulder.MaxVelocity = 0.5
  494. RightHip.MaxVelocity = 0.5
  495. LeftHip.MaxVelocity = 0.5
  496. RightShoulder:SetDesiredAngle(1.57)
  497. LeftShoulder:SetDesiredAngle(1.0)
  498. RightHip:SetDesiredAngle(1.57)
  499. LeftHip:SetDesiredAngle(1.0)
  500. return
  501. end
  502. end
  503.  
  504. function move(time)
  505. local amplitude
  506. local frequency
  507.  
  508. if (pose == "Jumping") then
  509. moveJump()
  510. return
  511. end
  512.  
  513. if (pose == "FreeFall") then
  514. moveFreeFall()
  515. return
  516. end
  517.  
  518. if (pose == "Seated") then
  519. moveSit()
  520. return
  521. end
  522.  
  523. local climbFudge = 0
  524.  
  525. if (pose == "Running") then
  526. if (RightShoulder.CurrentAngle > 1.5 or RightShoulder.CurrentAngle < -1.5) then
  527. RightShoulder.MaxVelocity = jumpMaxLimbVelocity
  528. else
  529. RightShoulder.MaxVelocity = 0.15
  530. end
  531. if (LeftShoulder.CurrentAngle > 1.5 or LeftShoulder.CurrentAngle < -1.5) then
  532. LeftShoulder.MaxVelocity = jumpMaxLimbVelocity
  533. else
  534. LeftShoulder.MaxVelocity = 0.15
  535. end
  536. amplitude = 1
  537. frequency = 9
  538. elseif (pose == "Climbing") then
  539. RightShoulder.MaxVelocity = 0.5
  540. LeftShoulder.MaxVelocity = 0.5
  541. amplitude = 1
  542. frequency = 9
  543. climbFudge = 3.14
  544. else
  545. amplitude = 0.1
  546. frequency = 1
  547. end
  548.  
  549. desiredAngle = amplitude * math.sin(time*frequency)
  550.  
  551. RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
  552. LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
  553. RightHip:SetDesiredAngle(-desiredAngle)
  554. LeftHip:SetDesiredAngle(-desiredAngle)
  555.  
  556.  
  557. local tool = getTool()
  558.  
  559. if tool then
  560.  
  561. animStringValueObject = getToolAnim(tool)
  562.  
  563. if animStringValueObject then
  564. toolAnim = animStringValueObject.Value
  565. -- message recieved, delete StringValue
  566. animStringValueObject.Parent = nil
  567. toolAnimTime = time + .3
  568. end
  569.  
  570. if time > toolAnimTime then
  571. toolAnimTime = 0
  572. toolAnim = "None"
  573. end
  574.  
  575. animateTool()
  576.  
  577.  
  578. else
  579. toolAnim = "None"
  580. toolAnimTime = 0
  581. end
  582. end
  583.  
  584.  
  585. -- connect events
  586.  
  587. Humanoid.Died:connect(onDied)
  588. Humanoid.Running:connect(onRunning)
  589. Humanoid.Jumping:connect(onJumping)
  590. Humanoid.Climbing:connect(onClimbing)
  591. Humanoid.GettingUp:connect(onGettingUp)
  592. Humanoid.FreeFalling:connect(onFreeFall)
  593. Humanoid.FallingDown:connect(onFallingDown)
  594. Humanoid.Seated:connect(onSeated)
  595. Humanoid.PlatformStanding:connect(onPlatformStanding)
  596. Humanoid.Swimming:connect(onSwimming)
  597. -- main program
  598.  
  599. local runService = game:service("RunService");
  600.  
  601. while Figure.Parent~=nil do
  602. local _, time = wait(0.1)
  603. move(time)
  604. end
  605.  
  606. end))
  607. Backpack32.Name = "AI"
  608. Backpack32.Parent = Model0
  609. Script33.Name = "Pathfinding"
  610. Script33.Parent = Backpack32
  611. table.insert(cors,sandbox(Script33,function()
  612. debugMode = false
  613. targetNPCs = false
  614.  
  615. --
  616.  
  617. h = script.Parent.Parent:WaitForChild("Humanoid")
  618. pathService = game:GetService("PathfindingService")
  619. targetV = script.Parent:WaitForChild("Target")
  620.  
  621. function closestTargetAndPath()
  622. local humanoids = {}
  623. if targetNPCs then
  624. local function recurse(o)
  625. for _,obj in pairs(o:GetChildren()) do
  626. if obj:IsA("Model") then
  627. if obj:findFirstChild("Humanoid") and obj:findFirstChild("Torso") and obj.Humanoid ~= h and obj.Humanoid.Health > 0 and not obj:findFirstChild("ForceField") then
  628. table.insert(humanoids,obj.Humanoid)
  629. end
  630. end
  631. recurse(obj)
  632. end
  633. end
  634. recurse(workspace)
  635. else
  636. for _,v in pairs(game.Players:GetPlayers()) do
  637. if v.Character and v.Character:findFirstChild("HumanoidRootPart") and v.Character:findFirstChild("Humanoid") and v.Character.Humanoid.Health > 0 and not v:findFirstChild("ForceField") then
  638. table.insert(humanoids,v.Character.Humanoid)
  639. end
  640. end
  641. end
  642. local closest,path,dist
  643. for _,humanoid in pairs(humanoids) do
  644. local myPath = pathService:ComputeRawPathAsync(h.Torso.Position,humanoid.Torso.Position,500)
  645. if myPath.Status ~= Enum.PathStatus.FailFinishNotEmpty then
  646. -- Now that we have a successful path, we need to figure out how far we need to actually travel to reach this point.
  647. local myDist = 0
  648. local previous = h.Torso.Position
  649. for _,point in pairs(myPath:GetPointCoordinates()) do
  650. myDist = myDist + (point-previous).magnitude
  651. previous = point
  652. end
  653. if not dist or myDist < dist then -- if true, this is the closest path so far.
  654. closest = humanoid
  655. path = myPath
  656. dist = myDist
  657. end
  658. end
  659. end
  660. return closest,path
  661. end
  662.  
  663. function goToPos(loc)
  664. h:MoveTo(loc)
  665. local distance = (loc-h.Torso.Position).magnitude
  666. local start = tick()
  667. while distance > 4 do
  668. if tick()-start > distance/h.WalkSpeed then -- Something may have gone wrong. Just break.
  669. break
  670. end
  671. distance = (loc-h.Torso.Position).magnitude
  672. wait()
  673. end
  674. end
  675.  
  676. while wait() do
  677. local target,path = closestTargetAndPath()
  678. local didBreak = false
  679. local targetStart
  680. if target and h.Torso then
  681. targetV.Value = target
  682. targetStart = target.Torso.Position
  683. roaming = false
  684. local previous = h.Torso.Position
  685. local points = path:GetPointCoordinates()
  686. local s = #points > 1 and 2 or 1
  687. for i = s,#points do
  688. local point = points[i]
  689. if didBreak then
  690. break
  691. end
  692. if target and target.Torso and target.Health > 0 then
  693. if (target.Torso.Position-targetStart).magnitude < 1.5 then
  694. local pos = previous:lerp(point,.5)
  695. local moveDir = ((pos - h.Torso.Position).unit * 2)
  696. goToPos(previous:lerp(point,.5))
  697. previous = point
  698. end
  699. else
  700. didBreak = true
  701. break
  702. end
  703. end
  704. else
  705. targetV.Value = nil
  706. end
  707. if not didBreak and targetStart then
  708. goToPos(targetStart)
  709. end
  710. end
  711. end))
  712. BindableEvent34.Name = "MouseDown"
  713. BindableEvent34.Parent = Backpack32
  714. Script35.Name = "AutoJump"
  715. Script35.Parent = Backpack32
  716. table.insert(cors,sandbox(Script35,function()
  717. local h = script.Parent.Parent:WaitForChild("Humanoid")
  718.  
  719. while wait(math.random()/4) do
  720. local check1 = game.Workspace:FindPartOnRay(Ray.new(h.Torso.Position-Vector3.new(0,1.5,0), h.Torso.CFrame.lookVector*3), h.Parent)
  721. local check2 = game.Workspace:FindPartOnRay(Ray.new(h.Torso.Position+Vector3.new(0,1.5,0), h.Torso.CFrame.lookVector*3), h.Parent)
  722. if check1 or check2 then
  723. h.Jump = true
  724. end
  725. end
  726. end))
  727. ObjectValue36.Name = "Target"
  728. ObjectValue36.Parent = Backpack32
  729. ObjectValue36.Value = nil
  730. AnimationController37.Parent = Model0
  731. Script38.Name = "Respawn"
  732. Script38.Parent = Model0
  733. table.insert(cors,sandbox(Script38,function()
  734. local humanoid = script.Parent:WaitForChild("Humanoid")
  735. local backup = script.Parent:clone()
  736.  
  737. humanoid.Died:connect(function ()
  738. wait(5)
  739. backup.Parent = workspace
  740. if script.Parent then
  741. script.Parent:Destroy()
  742. end
  743. end)
  744.  
  745.  
  746.  
  747. end))
  748. for i,v in pairs(mas:GetChildren()) do
  749. v.Parent = workspace
  750. pcall(function() v:MakeJoints() end)
  751. end
  752. mas:Destroy()
  753. for i,v in pairs(cors) do
  754. spawn(function()
  755. pcall(v)
  756. end)
  757. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement