Advertisement
Kaemi

Untitled

Feb 21st, 2018
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 107.32 KB | None | 0 0
  1.  
  2. --"YALALALALALA"
  3. --Just For Le Lolz.
  4. --
  5. function sandbox(var,func)
  6. local env = getfenv(func)
  7. local newenv = setmetatable({},{
  8. __index = function(self,k)
  9. if k=="script" then
  10. return var
  11. else
  12. return env[k]
  13. end
  14. end,
  15. })
  16. setfenv(func,newenv)
  17. return func
  18. end
  19. cors = {}
  20. mas = Instance.new("Model",game:GetService("Lighting"))
  21. Model0 = Instance.new("Model")
  22. Part1 = Instance.new("Part")
  23. SpecialMesh2 = Instance.new("SpecialMesh")
  24. Decal3 = Instance.new("Decal")
  25. Sound4 = Instance.new("Sound")
  26. Part5 = Instance.new("Part")
  27. Decal6 = Instance.new("Decal")
  28. Motor6D7 = Instance.new("Motor6D")
  29. Motor6D8 = Instance.new("Motor6D")
  30. Motor6D9 = Instance.new("Motor6D")
  31. Motor6D10 = Instance.new("Motor6D")
  32. Motor6D11 = Instance.new("Motor6D")
  33. Sound12 = Instance.new("Sound")
  34. Part13 = Instance.new("Part")
  35. Part14 = Instance.new("Part")
  36. Part15 = Instance.new("Part")
  37. Part16 = Instance.new("Part")
  38. Humanoid17 = Instance.new("Humanoid")
  39. Part18 = Instance.new("Part")
  40. Motor6D19 = Instance.new("Motor6D")
  41. Script20 = Instance.new("Script")
  42. Script21 = Instance.new("Script")
  43. BodyColors22 = Instance.new("BodyColors")
  44. Shirt23 = Instance.new("Shirt")
  45. Script24 = Instance.new("Script")
  46. Script25 = Instance.new("Script")
  47. StringValue26 = Instance.new("StringValue")
  48. Animation27 = Instance.new("Animation")
  49. StringValue28 = Instance.new("StringValue")
  50. Animation29 = Instance.new("Animation")
  51. StringValue30 = Instance.new("StringValue")
  52. Animation31 = Instance.new("Animation")
  53. NumberValue32 = Instance.new("NumberValue")
  54. Animation33 = Instance.new("Animation")
  55. NumberValue34 = Instance.new("NumberValue")
  56. StringValue35 = Instance.new("StringValue")
  57. Animation36 = Instance.new("Animation")
  58. StringValue37 = Instance.new("StringValue")
  59. Animation38 = Instance.new("Animation")
  60. StringValue39 = Instance.new("StringValue")
  61. Animation40 = Instance.new("Animation")
  62. StringValue41 = Instance.new("StringValue")
  63. Animation42 = Instance.new("Animation")
  64. Script43 = Instance.new("Script")
  65. BoolValue44 = Instance.new("BoolValue")
  66. Script45 = Instance.new("Script")
  67. Script46 = Instance.new("Script")
  68. Model0.Name = "Guest 0000"
  69. Model0.Parent = mas
  70. Model0.PrimaryPart = Part1
  71. Part1.Name = "Head"
  72. Part1.Parent = Model0
  73. Part1.BrickColor = BrickColor.new("White")
  74. Part1.Rotation = Vector3.new(-180, 0.439999998, -180)
  75. Part1.Locked = true
  76. Part1.FormFactor = Enum.FormFactor.Symmetric
  77. Part1.Size = Vector3.new(2, 1, 1)
  78. Part1.CFrame = CFrame.new(-44.9244461, 4.50000381, 25.0992126, -0.999970853, 1.92478218e-16, 0.00761902938, 2.02715895e-16, 1, 1.34294564e-15, -0.00761902938, 1.34445103e-15, -0.999970853)
  79. Part1.TopSurface = Enum.SurfaceType.Smooth
  80. Part1.Color = Color3.new(0.94902, 0.952941, 0.952941)
  81. Part1.Position = Vector3.new(-44.9244461, 4.50000381, 25.0992126)
  82. Part1.Orientation = Vector3.new(0, 179.559998, 0)
  83. Part1.Color = Color3.new(0.94902, 0.952941, 0.952941)
  84. SpecialMesh2.Parent = Part1
  85. SpecialMesh2.Scale = Vector3.new(1.25, 1.25, 1.25)
  86. SpecialMesh2.Scale = Vector3.new(1.25, 1.25, 1.25)
  87. Decal3.Name = "face"
  88. Decal3.Parent = Part1
  89. Decal3.Texture = "rbxasset://textures/face.png"
  90. Sound4.Name = "GuestYalala"
  91. Sound4.Parent = Part1
  92. Sound4.SoundId = "http://www.roblox.com/asset/?id=163362237"
  93. Part5.Name = "Torso"
  94. Part5.Parent = Model0
  95. Part5.BrickColor = BrickColor.new("Dark stone grey")
  96. Part5.Rotation = Vector3.new(-180, 0.439999998, -180)
  97. Part5.Locked = true
  98. Part5.FormFactor = Enum.FormFactor.Symmetric
  99. Part5.Size = Vector3.new(2, 2, 1)
  100. Part5.CFrame = CFrame.new(-44.9244461, 3.00000405, 25.0992126, -0.999970853, 1.92478218e-16, 0.00761902938, 2.02715895e-16, 1, 1.34294564e-15, -0.00761902938, 1.34445103e-15, -0.999970853)
  101. Part5.LeftSurface = Enum.SurfaceType.Weld
  102. Part5.RightSurface = Enum.SurfaceType.Weld
  103. Part5.Color = Color3.new(0.388235, 0.372549, 0.384314)
  104. Part5.Position = Vector3.new(-44.9244461, 3.00000405, 25.0992126)
  105. Part5.Orientation = Vector3.new(0, 179.559998, 0)
  106. Part5.Color = Color3.new(0.388235, 0.372549, 0.384314)
  107. Decal6.Name = "roblox"
  108. Decal6.Parent = Part5
  109. Motor6D7.Name = "Right Shoulder"
  110. Motor6D7.Parent = Part5
  111. Motor6D7.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  112. Motor6D7.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  113. Motor6D7.Part0 = Part5
  114. Motor6D7.Part1 = Part14
  115. Motor6D7.MaxVelocity = 0.10000000149012
  116. Motor6D8.Name = "Left Shoulder"
  117. Motor6D8.Parent = Part5
  118. Motor6D8.C0 = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  119. Motor6D8.C1 = CFrame.new(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  120. Motor6D8.Part0 = Part5
  121. Motor6D8.Part1 = Part13
  122. Motor6D8.MaxVelocity = 0.10000000149012
  123. Motor6D9.Name = "Right Hip"
  124. Motor6D9.Parent = Part5
  125. Motor6D9.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  126. Motor6D9.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  127. Motor6D9.Part0 = Part5
  128. Motor6D9.Part1 = Part16
  129. Motor6D9.MaxVelocity = 0.10000000149012
  130. Motor6D10.Name = "Left Hip"
  131. Motor6D10.Parent = Part5
  132. Motor6D10.C0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  133. Motor6D10.C1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  134. Motor6D10.Part0 = Part5
  135. Motor6D10.Part1 = Part15
  136. Motor6D10.MaxVelocity = 0.10000000149012
  137. Motor6D11.Name = "Neck"
  138. Motor6D11.Parent = Part5
  139. Motor6D11.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  140. Motor6D11.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  141. Motor6D11.Part0 = Part5
  142. Motor6D11.Part1 = Part1
  143. Motor6D11.MaxVelocity = 0.10000000149012
  144. Sound12.Name = "GuestExplosion"
  145. Sound12.Parent = Part5
  146. Sound12.Pitch = 1.3999999761581
  147. Sound12.SoundId = "http://www.roblox.com/asset/?id=2233908"
  148. Part13.Name = "Left Arm"
  149. Part13.Parent = Model0
  150. Part13.BrickColor = BrickColor.new("Really black")
  151. Part13.Rotation = Vector3.new(-180, 0.439999998, -180)
  152. Part13.CanCollide = false
  153. Part13.Locked = true
  154. Part13.FormFactor = Enum.FormFactor.Symmetric
  155. Part13.Size = Vector3.new(1, 2, 1)
  156. Part13.CFrame = CFrame.new(-43.4244881, 3.00000405, 25.1106415, -0.999970853, 1.92478218e-16, 0.00761902938, 2.02715895e-16, 1, 1.34294564e-15, -0.00761902938, 1.34445103e-15, -0.999970853)
  157. Part13.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  158. Part13.Position = Vector3.new(-43.4244881, 3.00000405, 25.1106415)
  159. Part13.Orientation = Vector3.new(0, 179.559998, 0)
  160. Part13.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  161. Part14.Name = "Right Arm"
  162. Part14.Parent = Model0
  163. Part14.BrickColor = BrickColor.new("Really black")
  164. Part14.Rotation = Vector3.new(-180, 0.439999998, -180)
  165. Part14.CanCollide = false
  166. Part14.Locked = true
  167. Part14.FormFactor = Enum.FormFactor.Symmetric
  168. Part14.Size = Vector3.new(1, 2, 1)
  169. Part14.CFrame = CFrame.new(-46.4244041, 3.00000405, 25.0877838, -0.999970853, 1.92478218e-16, 0.00761902938, 2.02715895e-16, 1, 1.34294564e-15, -0.00761902938, 1.34445103e-15, -0.999970853)
  170. Part14.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  171. Part14.Position = Vector3.new(-46.4244041, 3.00000405, 25.0877838)
  172. Part14.Orientation = Vector3.new(0, 179.559998, 0)
  173. Part14.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  174. Part15.Name = "Left Leg"
  175. Part15.Parent = Model0
  176. Part15.BrickColor = BrickColor.new("Really black")
  177. Part15.Rotation = Vector3.new(-180, 0.439999998, -180)
  178. Part15.CanCollide = false
  179. Part15.Locked = true
  180. Part15.FormFactor = Enum.FormFactor.Symmetric
  181. Part15.Size = Vector3.new(1, 2, 1)
  182. Part15.CFrame = CFrame.new(-44.4244614, 1.00000405, 25.1030216, -0.999970853, 1.92478218e-16, 0.00761902938, 2.02715895e-16, 1, 1.34294564e-15, -0.00761902938, 1.34445103e-15, -0.999970853)
  183. Part15.BottomSurface = Enum.SurfaceType.Smooth
  184. Part15.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  185. Part15.Position = Vector3.new(-44.4244614, 1.00000405, 25.1030216)
  186. Part15.Orientation = Vector3.new(0, 179.559998, 0)
  187. Part15.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  188. Part16.Name = "Right Leg"
  189. Part16.Parent = Model0
  190. Part16.BrickColor = BrickColor.new("Really black")
  191. Part16.Rotation = Vector3.new(-180, 0.439999998, -180)
  192. Part16.CanCollide = false
  193. Part16.Locked = true
  194. Part16.FormFactor = Enum.FormFactor.Symmetric
  195. Part16.Size = Vector3.new(1, 2, 1)
  196. Part16.CFrame = CFrame.new(-45.4244308, 1.00000405, 25.0954037, -0.999970853, 1.92478218e-16, 0.00761902938, 2.02715895e-16, 1, 1.34294564e-15, -0.00761902938, 1.34445103e-15, -0.999970853)
  197. Part16.BottomSurface = Enum.SurfaceType.Smooth
  198. Part16.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  199. Part16.Position = Vector3.new(-45.4244308, 1.00000405, 25.0954037)
  200. Part16.Orientation = Vector3.new(0, 179.559998, 0)
  201. Part16.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  202. Humanoid17.Parent = Model0
  203. Humanoid17.NameOcclusion = Enum.NameOcclusion.EnemyOcclusion
  204. Humanoid17.RightLeg = Part16
  205. Humanoid17.LeftLeg = Part15
  206. Humanoid17.Torso = Part18
  207. Humanoid17.WalkSpeed = 30
  208. Part18.Name = "HumanoidRootPart"
  209. Part18.Parent = Model0
  210. Part18.BrickColor = BrickColor.new("Bright blue")
  211. Part18.Transparency = 1
  212. Part18.Rotation = Vector3.new(-180, 0.439999998, -180)
  213. Part18.Locked = true
  214. Part18.FormFactor = Enum.FormFactor.Symmetric
  215. Part18.Size = Vector3.new(2, 2, 1)
  216. Part18.CFrame = CFrame.new(-44.9244461, 3.00000405, 25.0992126, -0.999970853, 1.92478218e-16, 0.00761902938, 2.02715895e-16, 1, 1.34294564e-15, -0.00761902938, 1.34445103e-15, -0.999970853)
  217. Part18.BottomSurface = Enum.SurfaceType.Smooth
  218. Part18.TopSurface = Enum.SurfaceType.Smooth
  219. Part18.Color = Color3.new(0.0509804, 0.411765, 0.67451)
  220. Part18.Position = Vector3.new(-44.9244461, 3.00000405, 25.0992126)
  221. Part18.Orientation = Vector3.new(0, 179.559998, 0)
  222. Part18.Color = Color3.new(0.0509804, 0.411765, 0.67451)
  223. Motor6D19.Name = "RootJoint"
  224. Motor6D19.Parent = Part18
  225. Motor6D19.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  226. Motor6D19.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  227. Motor6D19.Part0 = Part18
  228. Motor6D19.Part1 = Part5
  229. Motor6D19.MaxVelocity = 0.10000000149012
  230. Script20.Name = "Sound"
  231. Script20.Parent = Model0
  232. table.insert(cors,sandbox(Script20,function()
  233. -- util
  234.  
  235. function waitForChild(parent, childName)
  236. local child = parent:findFirstChild(childName)
  237. if child then return child end
  238. while true do
  239. child = parent.ChildAdded:wait()
  240. if child.Name==childName then return child end
  241. end
  242. end
  243.  
  244. function newSound(id)
  245. local sound = Instance.new("Sound")
  246. sound.SoundId = id
  247. sound.archivable = false
  248. sound.Parent = script.Parent.Head
  249. return sound
  250. end
  251.  
  252. -- declarations
  253.  
  254. local sDied = newSound("rbxasset://sounds/uuhhh.wav")
  255. local sFallingDown = newSound("rbxasset://sounds/splat.wav")
  256. local sFreeFalling = newSound("rbxasset://sounds/swoosh.wav")
  257. local sGettingUp = newSound("rbxasset://sounds/hit.wav")
  258. local sJumping = newSound("rbxasset://sounds/button.wav")
  259. local sRunning = newSound("rbxasset://sounds/bfsl-minifigfoots1.mp3")
  260. sRunning.Looped = true
  261.  
  262. local Figure = script.Parent
  263. local Head = waitForChild(Figure, "Head")
  264. local Humanoid = waitForChild(Figure, "Humanoid")
  265.  
  266. -- functions
  267.  
  268. function onDied()
  269. sDied:Play()
  270. end
  271.  
  272. function onState(state, sound)
  273. if state then
  274. sound:Play()
  275. else
  276. sound:Pause()
  277. end
  278. end
  279.  
  280. function onRunning(speed)
  281. if speed>0 then
  282. sRunning:Play()
  283. else
  284. sRunning:Pause()
  285. end
  286. end
  287.  
  288. -- connect up
  289.  
  290. Humanoid.Died:connect(onDied)
  291. Humanoid.Running:connect(onRunning)
  292. Humanoid.Jumping:connect(function(state) onState(state, sJumping) end)
  293. Humanoid.GettingUp:connect(function(state) onState(state, sGettingUp) end)
  294. Humanoid.FreeFalling:connect(function(state) onState(state, sFreeFalling) end)
  295. Humanoid.FallingDown:connect(function(state) onState(state, sFallingDown) end)
  296.  
  297. end))
  298. Script21.Name = "Health"
  299. Script21.Parent = Model0
  300. table.insert(cors,sandbox(Script21,function()
  301. --Responsible for regening a player's humanoid's health
  302.  
  303. -- declarations
  304. local Figure = script.Parent
  305. local Head = Figure:WaitForChild("Head")
  306. local Humanoid = Figure:WaitForChild("Humanoid")
  307. local regening = false
  308.  
  309. -- regeneration
  310. function regenHealth()
  311. if regening then return end
  312. regening = true
  313.  
  314. while Humanoid.Health < Humanoid.MaxHealth do
  315. local s = wait(1)
  316. local health = Humanoid.Health
  317. if health > 0 and health < Humanoid.MaxHealth then
  318. local newHealthDelta = 0.01 * s * Humanoid.MaxHealth
  319. health = health + newHealthDelta
  320. Humanoid.Health = math.min(health,Humanoid.MaxHealth)
  321. end
  322. end
  323.  
  324. if Humanoid.Health > Humanoid.MaxHealth then
  325. Humanoid.Health = Humanoid.MaxHealth
  326. end
  327.  
  328. regening = false
  329. end
  330.  
  331. Humanoid.HealthChanged:connect(regenHealth)
  332.  
  333. end))
  334. BodyColors22.Parent = Model0
  335. BodyColors22.HeadColor = BrickColor.new("White")
  336. BodyColors22.LeftArmColor = BrickColor.new("Really black")
  337. BodyColors22.LeftLegColor = BrickColor.new("Really black")
  338. BodyColors22.RightArmColor = BrickColor.new("Really black")
  339. BodyColors22.RightLegColor = BrickColor.new("Really black")
  340. BodyColors22.TorsoColor = BrickColor.new("Dark stone grey")
  341. Shirt23.Name = "Shirt"
  342. Shirt23.Parent = Model0
  343. Shirt23.ShirtTemplate = "http://www.roblox.com/asset/?id=8561740"
  344. Script24.Name = "Respawn"
  345. Script24.Parent = Model0
  346. table.insert(cors,sandbox(Script24,function()
  347. local GuestRespawnSystemScript=script
  348. local Guest=GuestRespawnSystemScript.Parent
  349. local GuestTorso=Guest:WaitForChild("Torso")
  350. local GuestHumanoid=Guest:WaitForChild("Humanoid")
  351. local GuestAIScript=Guest:FindFirstChild("GuestAIScript")
  352. local GuestClone=Guest:Clone()
  353. while true do
  354. Wait(0)
  355. if GuestHumanoid.Health<1 then
  356. GuestAIScript.Disabled=true
  357. Wait(5)
  358. GuestClone=GuestClone:Clone()
  359. GuestClone.Parent=Guest.Parent
  360. GuestClone.Name="Guest "..math.random(1,9999)
  361. GuestClone:makeJoints()
  362. Guest:remove()
  363. end
  364. end
  365. end))
  366. Script25.Name = "Animate"
  367. Script25.Parent = Model0
  368. table.insert(cors,sandbox(Script25,function()
  369. function waitForChild(parent, childName)
  370. local child = parent:findFirstChild(childName)
  371. if child then return child end
  372. while true do
  373. child = parent.ChildAdded:wait()
  374. if child.Name==childName then return child end
  375. end
  376. end
  377.  
  378. local Figure = script.Parent
  379. local Torso = waitForChild(Figure, "Torso")
  380. local RightShoulder = waitForChild(Torso, "Right Shoulder")
  381. local LeftShoulder = waitForChild(Torso, "Left Shoulder")
  382. local RightHip = waitForChild(Torso, "Right Hip")
  383. local LeftHip = waitForChild(Torso, "Left Hip")
  384. local Neck = waitForChild(Torso, "Neck")
  385. local Humanoid = waitForChild(Figure, "Humanoid")
  386. local pose = "Standing"
  387.  
  388. local currentAnim = ""
  389. local currentAnimTrack = nil
  390. local currentAnimKeyframeHandler = nil
  391. local oldAnimTrack = nil
  392. local animTable = {}
  393. local animNames = {
  394. idle = {
  395. { id = "http://www.roblox.com/asset/?id=125750544", weight = 9 },
  396. { id = "http://www.roblox.com/asset/?id=125750618", weight = 1 }
  397. },
  398. walk = {
  399. { id = "http://www.roblox.com/asset/?id=125749145", weight = 10 }
  400. },
  401. run = {
  402. { id = "run.xml", weight = 10 }
  403. },
  404. jump = {
  405. { id = "http://www.roblox.com/asset/?id=125750702", weight = 10 }
  406. },
  407. fall = {
  408. { id = "http://www.roblox.com/asset/?id=125750759", weight = 10 }
  409. },
  410. climb = {
  411. { id = "http://www.roblox.com/asset/?id=125750800", weight = 10 }
  412. },
  413. toolnone = {
  414. { id = "http://www.roblox.com/asset/?id=125750867", weight = 10 }
  415. },
  416. toolslash = {
  417. { id = "http://www.roblox.com/asset/?id=129967390", weight = 10 }
  418. -- { id = "slash.xml", weight = 10 }
  419. },
  420. toollunge = {
  421. { id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
  422. },
  423. }
  424.  
  425. -- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
  426. local emoteNames = { wave = false, point = false, dance = true, laugh = false, cheer = false}
  427.  
  428. math.randomseed(tick())
  429.  
  430. -- Setup animation objects
  431. for name, fileList in pairs(animNames) do
  432. animTable[name] = {}
  433. animTable[name].count = 0
  434. animTable[name].totalWeight = 0
  435.  
  436. -- check for config values
  437. local config = script:FindFirstChild(name)
  438. if (config ~= nil) then
  439. -- print("Loading anims " .. name)
  440. local idx = 1
  441. for _, childPart in pairs(config:GetChildren()) do
  442. animTable[name][idx] = {}
  443. animTable[name][idx].anim = childPart
  444. local weightObject = childPart:FindFirstChild("Weight")
  445. if (weightObject == nil) then
  446. animTable[name][idx].weight = 1
  447. else
  448. animTable[name][idx].weight = weightObject.Value
  449. end
  450. animTable[name].count = animTable[name].count + 1
  451. animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
  452. -- print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
  453. idx = idx + 1
  454. end
  455. end
  456.  
  457. -- fallback to defaults
  458. if (animTable[name].count <= 0) then
  459. for idx, anim in pairs(fileList) do
  460. animTable[name][idx] = {}
  461. animTable[name][idx].anim = Instance.new("Animation")
  462. animTable[name][idx].anim.Name = name
  463. animTable[name][idx].anim.AnimationId = anim.id
  464. animTable[name][idx].weight = anim.weight
  465. animTable[name].count = animTable[name].count + 1
  466. animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
  467. -- print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
  468. end
  469. end
  470. end
  471.  
  472. -- ANIMATION
  473.  
  474. -- declarations
  475. local toolAnim = "None"
  476. local toolAnimTime = 0
  477.  
  478. local jumpAnimTime = 0
  479. local jumpAnimDuration = 0.175
  480.  
  481. local toolTransitionTime = 0.1
  482. local fallTransitionTime = 0.2
  483. local jumpMaxLimbVelocity = 0.75
  484.  
  485. -- functions
  486.  
  487. function stopAllAnimations()
  488. local oldAnim = currentAnim
  489.  
  490. -- return to idle if finishing an emote
  491. if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
  492. oldAnim = "idle"
  493. end
  494.  
  495. currentAnim = ""
  496. if (currentAnimKeyframeHandler ~= nil) then
  497. currentAnimKeyframeHandler:disconnect()
  498. end
  499.  
  500. if (oldAnimTrack ~= nil) then
  501. oldAnimTrack:Stop()
  502. oldAnimTrack:Destroy()
  503. oldAnimTrack = nil
  504. end
  505. if (currentAnimTrack ~= nil) then
  506. currentAnimTrack:Stop()
  507. currentAnimTrack:Destroy()
  508. currentAnimTrack = nil
  509. end
  510. return oldAnim
  511. end
  512.  
  513. function keyFrameReachedFunc(frameName)
  514. if (frameName == "End") then
  515. -- print("Keyframe : ".. frameName)
  516. local repeatAnim = stopAllAnimations()
  517. playAnimation(repeatAnim, 0.0, Humanoid)
  518. end
  519. end
  520.  
  521. -- Preload animations
  522. function playAnimation(animName, transitionTime, humanoid)
  523. if (animName ~= currentAnim) then
  524.  
  525. if (oldAnimTrack ~= nil) then
  526. oldAnimTrack:Stop()
  527. oldAnimTrack:Destroy()
  528. end
  529.  
  530. local roll = math.random(1, animTable[animName].totalWeight)
  531. local origRoll = roll
  532. local idx = 1
  533. while (roll > animTable[animName][idx].weight) do
  534. roll = roll - animTable[animName][idx].weight
  535. idx = idx + 1
  536. end
  537. -- print(animName .. " " .. idx .. " [" .. origRoll .. "]")
  538. local anim = animTable[animName][idx].anim
  539.  
  540. -- load it to the humanoid; get AnimationTrack
  541. oldAnimTrack = currentAnimTrack
  542. currentAnimTrack = humanoid:LoadAnimation(anim)
  543.  
  544. -- play the animation
  545. currentAnimTrack:Play(transitionTime)
  546. currentAnim = animName
  547.  
  548. -- set up keyframe name triggers
  549. if (currentAnimKeyframeHandler ~= nil) then
  550. currentAnimKeyframeHandler:disconnect()
  551. end
  552. currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
  553. end
  554. end
  555.  
  556. -------------------------------------------------------------------------------------------
  557. -------------------------------------------------------------------------------------------
  558.  
  559. local toolAnimName = ""
  560. local toolOldAnimTrack = nil
  561. local toolAnimTrack = nil
  562. local currentToolAnimKeyframeHandler = nil
  563.  
  564. function toolKeyFrameReachedFunc(frameName)
  565. if (frameName == "End") then
  566. -- print("Keyframe : ".. frameName)
  567. local repeatAnim = stopToolAnimations()
  568. playToolAnimation(repeatAnim, 0.0, Humanoid)
  569. end
  570. end
  571.  
  572.  
  573. function playToolAnimation(animName, transitionTime, humanoid)
  574. if (animName ~= toolAnimName) then
  575.  
  576. if (toolAnimTrack ~= nil) then
  577. toolAnimTrack:Stop()
  578. toolAnimTrack:Destroy()
  579. transitionTime = 0
  580. end
  581.  
  582. local roll = math.random(1, animTable[animName].totalWeight)
  583. local origRoll = roll
  584. local idx = 1
  585. while (roll > animTable[animName][idx].weight) do
  586. roll = roll - animTable[animName][idx].weight
  587. idx = idx + 1
  588. end
  589. -- print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
  590. local anim = animTable[animName][idx].anim
  591.  
  592. -- load it to the humanoid; get AnimationTrack
  593. toolOldAnimTrack = toolAnimTrack
  594. toolAnimTrack = humanoid:LoadAnimation(anim)
  595.  
  596. -- play the animation
  597. toolAnimTrack:Play(transitionTime)
  598. toolAnimName = animName
  599.  
  600. currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
  601. end
  602. end
  603.  
  604. function stopToolAnimations()
  605. local oldAnim = toolAnimName
  606.  
  607. if (currentToolAnimKeyframeHandler ~= nil) then
  608. currentToolAnimKeyframeHandler:disconnect()
  609. end
  610.  
  611. toolAnimName = ""
  612. if (toolAnimTrack ~= nil) then
  613. toolAnimTrack:Stop()
  614. toolAnimTrack:Destroy()
  615. toolAnimTrack = nil
  616. end
  617.  
  618.  
  619. return oldAnim
  620. end
  621.  
  622. -------------------------------------------------------------------------------------------
  623. -------------------------------------------------------------------------------------------
  624.  
  625.  
  626. function onRunning(speed)
  627. if speed>0 then
  628. playAnimation("walk", 0.1, Humanoid)
  629. pose = "Running"
  630. else
  631. playAnimation("idle", 0.1, Humanoid)
  632. pose = "Standing"
  633. end
  634. end
  635.  
  636. function onDied()
  637. pose = "Dead"
  638. end
  639.  
  640. function onJumping()
  641. playAnimation("jump", 0.1, Humanoid)
  642. jumpAnimTime = jumpAnimDuration
  643. pose = "Jumping"
  644. end
  645.  
  646. function onClimbing()
  647. playAnimation("climb", 0.1, Humanoid)
  648. pose = "Climbing"
  649. end
  650.  
  651. function onGettingUp()
  652. pose = "GettingUp"
  653. end
  654.  
  655. function onFreeFall()
  656. if (jumpAnimTime <= 0) then
  657. playAnimation("fall", fallTransitionTime, Humanoid)
  658. end
  659. pose = "FreeFall"
  660. end
  661.  
  662. function onFallingDown()
  663. pose = "FallingDown"
  664. end
  665.  
  666. function onSeated()
  667. pose = "Seated"
  668. end
  669.  
  670. function onPlatformStanding()
  671. pose = "PlatformStanding"
  672. end
  673.  
  674. function onSwimming(speed)
  675. if speed>0 then
  676. pose = "Running"
  677. else
  678. pose = "Standing"
  679. end
  680. end
  681.  
  682. function getTool()
  683. for _, kid in ipairs(Figure:GetChildren()) do
  684. if kid.className == "Tool" then return kid end
  685. end
  686. return nil
  687. end
  688.  
  689. function getToolAnim(tool)
  690. for _, c in ipairs(tool:GetChildren()) do
  691. if c.Name == "toolanim" and c.className == "StringValue" then
  692. return c
  693. end
  694. end
  695. return nil
  696. end
  697.  
  698. function animateTool()
  699.  
  700. if (toolAnim == "None") then
  701. playToolAnimation("toolnone", toolTransitionTime, Humanoid)
  702. return
  703. end
  704.  
  705. if (toolAnim == "Slash") then
  706. playToolAnimation("toolslash", 0, Humanoid)
  707. return
  708. end
  709.  
  710. if (toolAnim == "Lunge") then
  711. playToolAnimation("toollunge", 0, Humanoid)
  712. return
  713. end
  714. end
  715.  
  716. function moveSit()
  717. RightShoulder.MaxVelocity = 0.15
  718. LeftShoulder.MaxVelocity = 0.15
  719. RightShoulder:SetDesiredAngle(3.14 /2)
  720. LeftShoulder:SetDesiredAngle(-3.14 /2)
  721. RightHip:SetDesiredAngle(3.14 /2)
  722. LeftHip:SetDesiredAngle(-3.14 /2)
  723. end
  724.  
  725. local lastTick = 0
  726.  
  727. function move(time)
  728. local amplitude = 1
  729. local frequency = 1
  730. local deltaTime = time - lastTick
  731. lastTick = time
  732.  
  733. local climbFudge = 0
  734. local setAngles = false
  735.  
  736. if (jumpAnimTime > 0) then
  737. jumpAnimTime = jumpAnimTime - deltaTime
  738. end
  739.  
  740. if (pose == "FreeFall" and jumpAnimTime <= 0) then
  741. playAnimation("fall", fallTransitionTime, Humanoid)
  742. elseif (pose == "Seated") then
  743. stopAllAnimations()
  744. moveSit()
  745. return
  746. elseif (pose == "Running") then
  747. playAnimation("walk", 0.1, Humanoid)
  748. elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
  749. -- print("Wha " .. pose)
  750. amplitude = 0.1
  751. frequency = 1
  752. setAngles = true
  753. end
  754.  
  755. if (setAngles) then
  756. desiredAngle = amplitude * math.sin(time * frequency)
  757.  
  758. RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
  759. LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
  760. RightHip:SetDesiredAngle(-desiredAngle)
  761. LeftHip:SetDesiredAngle(-desiredAngle)
  762. end
  763.  
  764. -- Tool Animation handling
  765. local tool = getTool()
  766. if tool then
  767.  
  768. animStringValueObject = getToolAnim(tool)
  769.  
  770. if animStringValueObject then
  771. toolAnim = animStringValueObject.Value
  772. -- message recieved, delete StringValue
  773. animStringValueObject.Parent = nil
  774. toolAnimTime = time + .3
  775. end
  776.  
  777. if time > toolAnimTime then
  778. toolAnimTime = 0
  779. toolAnim = "None"
  780. end
  781.  
  782. animateTool()
  783. else
  784. stopToolAnimations()
  785. toolAnim = "None"
  786. toolAnimTime = 0
  787. end
  788. end
  789.  
  790. -- connect events
  791. Humanoid.Died:connect(onDied)
  792. Humanoid.Running:connect(onRunning)
  793. Humanoid.Jumping:connect(onJumping)
  794. Humanoid.Climbing:connect(onClimbing)
  795. Humanoid.GettingUp:connect(onGettingUp)
  796. Humanoid.FreeFalling:connect(onFreeFall)
  797. Humanoid.FallingDown:connect(onFallingDown)
  798. Humanoid.Seated:connect(onSeated)
  799. Humanoid.PlatformStanding:connect(onPlatformStanding)
  800. Humanoid.Swimming:connect(onSwimming)
  801.  
  802.  
  803. -- main program
  804.  
  805. local runService = game:service("RunService");
  806.  
  807. -- initialize to idle
  808. playAnimation("idle", 0.1, Humanoid)
  809. pose = "Standing"
  810.  
  811. while Figure.Parent~=nil do
  812. local _, time = wait(0.1)
  813. move(time)
  814. end
  815. end))
  816. StringValue26.Name = "climb"
  817. StringValue26.Parent = Script25
  818. Animation27.Name = "ClimbAnim"
  819. Animation27.Parent = StringValue26
  820. Animation27.AnimationId = "http://www.roblox.com/asset/?id=125750800"
  821. StringValue28.Name = "fall"
  822. StringValue28.Parent = Script25
  823. Animation29.Name = "FallAnim"
  824. Animation29.Parent = StringValue28
  825. Animation29.AnimationId = "http://www.roblox.com/asset/?id=125750759"
  826. StringValue30.Name = "idle"
  827. StringValue30.Parent = Script25
  828. Animation31.Name = "Animation1"
  829. Animation31.Parent = StringValue30
  830. Animation31.AnimationId = "http://www.roblox.com/asset/?id=125750544"
  831. NumberValue32.Name = "Weight"
  832. NumberValue32.Parent = Animation31
  833. NumberValue32.Value = 9
  834. Animation33.Name = "Animation2"
  835. Animation33.Parent = StringValue30
  836. Animation33.AnimationId = "http://www.roblox.com/asset/?id=125750618"
  837. NumberValue34.Name = "Weight"
  838. NumberValue34.Parent = Animation33
  839. NumberValue34.Value = 1
  840. StringValue35.Name = "jump"
  841. StringValue35.Parent = Script25
  842. Animation36.Name = "JumpAnim"
  843. Animation36.Parent = StringValue35
  844. Animation36.AnimationId = "http://www.roblox.com/asset/?id=125750702"
  845. StringValue37.Name = "run"
  846. StringValue37.Parent = Script25
  847. Animation38.Name = "RunAnim"
  848. Animation38.Parent = StringValue37
  849. Animation38.AnimationId = "http://www.roblox.com/asset/?id=125749145"
  850. StringValue39.Name = "toolnone"
  851. StringValue39.Parent = Script25
  852. Animation40.Name = "ToolNoneAnim"
  853. Animation40.Parent = StringValue39
  854. Animation40.AnimationId = "http://www.roblox.com/asset/?id=125750867"
  855. StringValue41.Name = "walk"
  856. StringValue41.Parent = Script25
  857. Animation42.Name = "WalkAnim"
  858. Animation42.Parent = StringValue41
  859. Animation42.AnimationId = "http://www.roblox.com/asset/?id=125749145"
  860. Script43.Name = "GuestAIScript"
  861. Script43.Parent = Model0
  862. table.insert(cors,sandbox(Script43,function()
  863. --Beta SpeedAI June 2012 -- Still has logic bugs - Look for updates..
  864. -- Kill added.
  865. -- co-operate/other "AI"s
  866. -- Climb "Truss" Parts
  867. -- Offset Ray
  868. -- Swim - Does not work. Don't know why.
  869. -- Adjusted Jump Ray
  870. -- Ray Graphics On/Off - flip line 90
  871. -- Delay next cycle, if Falling.
  872. -- Diagonal movement - I should add right-hand logic as well...
  873.  
  874. local number = 1 + math.random()
  875. local BRAINWave = .6 -- AND line 38: Wait() between cycles of main loop
  876. local hum = nil -- Will be a pointer to the Humanoid of our AI.
  877.  
  878. wait(number) -- hold on a sec. and spread multiple instances.
  879.  
  880. --Globals
  881. local AI = script.Parent
  882. local AIName = AI.Name
  883. local AItorso = AI.Torso
  884.  
  885.  
  886. if true then -- if your torso doesn't have a Humanoid; flip this to false
  887. local HumanoidType = nil -- find-a-HumanoidObject -- make sure
  888.  
  889. local list = AI:GetChildren() -- temp var.
  890. for x = 1, #list do
  891. local temp = list[x]
  892. if (temp.className == "Humanoid") then
  893. HumanoidType = temp.Name
  894. end -- found Humanoid
  895. end -- AI Parts
  896.  
  897. if HumanoidType then
  898. number = math.floor(number*100) -- serial# of AI
  899. hum = AI[HumanoidType]
  900. BRAINWave = 4/hum.WalkSpeed -- For extreme speeds, this may have to be adjusted.
  901. print (script, ": Humanoid = ", hum, AI:GetFullName(), number, "- Think Speed = ", BRAINWave)
  902. end
  903. end -- set speed
  904.  
  905. --Constants;
  906. local RAYLength = 100 -- Not really. A point, off in space.
  907.  
  908. --Declarations
  909. local target = AItorso -- is of type torso
  910. local torsoPos = AItorso.Position
  911. local targpos = target.Position
  912. --local Oldtargpos = targpos
  913.  
  914. local OldPos = torsoPos * 2
  915. local origin = CFrame.new(torsoPos)
  916.  
  917. local Logic = 0
  918. local OldX = 100
  919. local OldZ = 0
  920. local Xdir = 100
  921. local Zdir = 0
  922. local ClimbingLadder = false
  923. local FreeFalling = false
  924. local GraphicsOn = script.GraphicsToggle.Value -- Only set at start
  925.  
  926. --functions
  927.  
  928. -- Are we falling?
  929. hum.FreeFalling:connect(function()
  930. FreeFalling = true
  931. end)
  932.  
  933. -- Find Player (& who else not to find).
  934. function findNearestTorso(pos) -- declare pos a local vector3
  935. local list = game.Workspace:children()
  936. local torso = nil
  937. local dist = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 -- Area to search
  938. local temp = nil
  939. local human = nil
  940. local temp2 = nil
  941. for x = 1, #list do
  942. temp2 = list[x]
  943. if temp2.className == "Model" then
  944. temp = temp2:findFirstChild("Torso")
  945. if temp ~= nil then
  946. human = temp2:findFirstChild("Humanoid")
  947. if human ~= nil and (human.Health > 0) and (temp2.Name ~= AIName) then -- not named the same as us.
  948. if (temp.Position - pos).magnitude < dist then
  949. torso = temp
  950. dist = (temp.Position - pos).magnitude
  951. end -- closer?
  952. end -- human? Not us.
  953. end -- Has torso?
  954. end -- Model?
  955. end -- For. Loop thru parts in Workplace
  956.  
  957. return torso
  958. end -- findNearest
  959.  
  960.  
  961. function DrawRay(origin, point) -- 7 studs long
  962. local Ray = Ray.new(origin, (point).unit * 7) --Make the ray.
  963. local Hit,Position = game.Workspace:FindPartOnRay(Ray,AI) --Check for collisions along the ray, ignoring any Parts of us.
  964.  
  965. if GraphicsOn then --Graphics
  966. local RayPart = Instance.new("Part",AI)
  967. if Hit then
  968. if Logic == 1 then
  969. RayPart.BrickColor = BrickColor.new("Black") --Set its color.
  970. else
  971. RayPart.BrickColor = BrickColor.new("Bright red") --Set its color.
  972. end
  973. else
  974. if Logic == 1 then
  975. RayPart.BrickColor = BrickColor.new("White") --Set its color.
  976. else
  977. RayPart.BrickColor = BrickColor.new("Olive") --Set its color.
  978. end
  979. end
  980. RayPart.Transparency = 0.2 --Set its transparency.
  981. RayPart.Anchored = true --Set whether it will fall or not.
  982. RayPart.CanCollide = false --Set whether people can walk though it or not.
  983. RayPart.formFactor = Enum.FormFactor.Custom --Make it so it can be small.
  984. local Distance = (Position-origin).magnitude --Find the distance between the hit and the torso.
  985. RayPart.Size = Vector3.new(0.4,.2,Distance) --Set its size to the distance.
  986. RayPart.CFrame = CFrame.new(Position, origin) * CFrame.new(0,0,-Distance/2) --Move it halfway.
  987. game.Debris:AddItem(RayPart,2) --Add it to the debris.
  988. end -- Graphics
  989.  
  990. return Hit
  991. end -- DrawRay
  992.  
  993.  
  994. function FireRayToward() -- possible path, and read the Part we hit, if any.
  995. ClimbingLadder = false
  996.  
  997. local originPrime = origin * Vector3.new(.8,0,0) - Vector3.new(0,.4,0) -- Offset Right + OffY
  998. local offset = origin * Vector3.new(.8,0,0) - origin * Vector3.new(-.8,0,0) -- left (I guess this is increment. I didn't WANT to do it this way)
  999. local point = origin.lookVector * 5 -- dir
  1000. local pointPrime = point - offset + Vector3.new(0,2,0) -- dir + OffsetLeft + OffsetY = direction of Ray
  1001.  
  1002. local Hit = DrawRay(originPrime, pointPrime) -- see if we hit anything
  1003.  
  1004. if Hit then
  1005.  
  1006. if target.Parent == Hit.Parent then
  1007. if Hit.Name ~= "Head" and Hit.Name ~= "HumanoidRootPart" and Hit.Name ~= "Left Arm" and Hit.Name ~= "Left Leg" and Hit.Name ~= "Right Arm" and Hit.Name ~= "Right Leg" and Hit.Name ~= "Torso" then
  1008.  
  1009. end -- kill
  1010.  
  1011. Logic = 0
  1012. Hit = nil
  1013.  
  1014. elseif Hit.Parent.Name == AIName then
  1015. -- if Xdir > 0 then -- if going ?North? then ignore, else (?South?); Jump
  1016. -- Hit = nil -- ignore
  1017. -- elseif Xdir == 0 then -- else swerve (only while in logic).
  1018. if Xdir == 0 then
  1019. Hit = Aitorso-- this should result in Hit = true-but-don't-attemp-a-jump, so swerve; doesn't check floor!
  1020. -- return hit -- Swerve, without checking to jump.
  1021. elseif Hit.Velocity.y > 1 then
  1022. Hit = nil -- ignore, if other AI is already jumping; else check to Jump
  1023. end -- East -West collisions - swerve. North/South, check-to-jump.
  1024. end -- endifs
  1025. end -- read hit
  1026.  
  1027. -- Climb or Jump
  1028. if Hit and Hit ~= AItorso then
  1029.  
  1030. if (Hit.Name == "Truss" and target.Position.y > torsoPos.y - 3) or target.Parent == Hit.Parent then -- ignore parts called "Ladder", if AI is level or below CURRENT Targ pos.
  1031. Hit = nil
  1032. ClimbingLadder = true -- Climb and don't check floor
  1033.  
  1034. else
  1035. --print(Hit, Hit.Name)
  1036. if Hit.Name == "Terrain" or Hit.CanCollide == false then -- In front is Water or a steep hill made of Terrain.
  1037. Hit = nil -- swim or climb, or Ray hit a Non-colliding Part; and don't check for floor. This will not do, as we do not get a Hit when under-water, so we will check for floor. We must check Swimming event.
  1038. else -- Jump?
  1039. Hit = DrawRay(originPrime + Vector3.new(0,4.8,0), pointPrime)
  1040. if Hit == nil then -- (Does NOT check CanCollide of Part blocking Jump)
  1041. hum.Jump = true -- we do NOT check for "Floor", if jumping, but it might be a good idea.
  1042. end -- Room to jump?
  1043. end --Terrain? Water?
  1044. end -- Ladder?
  1045.  
  1046. else -- path is clear. Check for cliff... or OK to drop
  1047.  
  1048. local Level = torsoPos.y
  1049. if target then
  1050. Level = target.Position.y -- get Target's current position.
  1051. else -- Target is dead. Abandon all logic...
  1052. Logic = 0 -- but still check for floor
  1053. end
  1054.  
  1055. if torsoPos.y - 2 < Level then -- if Player is not well below us...
  1056.  
  1057. Hit = DrawRay(torsoPos + point * .8 + Vector3.new(0,1,0), Vector3.new(0,-7,0)) -- check for floor 85% of dir ahead
  1058. if Hit == nil then -- There is no floor
  1059. Hit = true -- Force a hit; we may not be able to get back up here.
  1060.  
  1061. else
  1062. Hit = nil -- Force a false to hit, 'cause everything is OK. (Does NOT check CanCollide of Floor!)
  1063. end -- cliff check
  1064. end -- Player Hieght
  1065. end -- path ok?
  1066. return Hit
  1067. end -- FireRayToward
  1068.  
  1069.  
  1070. function FireAtPlayer()
  1071. origin = CFrame.new(torsoPos, Vector3.new(targpos.x, torsoPos.y, targpos.z)) -- This contains Origin & Direction
  1072. local hit = FireRayToward()
  1073. return hit
  1074. end
  1075.  
  1076. function FireRayAhead()
  1077. origin = CFrame.new(torsoPos, torsoPos + Vector3.new(Xdir, 0, Zdir))
  1078. local hit = FireRayToward()
  1079. targpos = torsoPos + Vector3.new(Xdir,0,Zdir)
  1080. return hit
  1081. end
  1082.  
  1083. function FireRay() -- Fire Ahead and diagonaly
  1084. origin = CFrame.new(torsoPos, torsoPos + Vector3.new(Xdag, 0, Zdag))
  1085. local hit = FireRayToward()
  1086. if hit then
  1087. origin = CFrame.new(torsoPos, torsoPos + Vector3.new(Xdir, 0, Zdir))
  1088. hit = FireRayToward()
  1089. if not hit then
  1090. targpos = torsoPos + Vector3.new(Xdir,0,Zdir)
  1091. end
  1092. else
  1093. targpos = torsoPos + Vector3.new(Xdag,0,Zdag)
  1094. end
  1095. return hit
  1096. end -- Fire Ray
  1097.  
  1098. function FireDag()
  1099. origin = CFrame.new(torsoPos, torsoPos + Vector3.new(Xdag, 0, Zdag))
  1100. local hit = FireRayToward()
  1101. return hit
  1102. end -- Fire Diagonaly
  1103.  
  1104.  
  1105. function TurnRight()
  1106.  
  1107. if Xdir == 0 then
  1108. Xdir = -Zdir
  1109. Zdir = 0
  1110. else
  1111. Zdir = Xdir
  1112. Xdir = 0
  1113. end
  1114. if Xdag == Zdag then Xdag = -Xdag else Zdag = -Zdag end
  1115.  
  1116. end -- Left
  1117.  
  1118. function TurnLeft()
  1119. if Xdir == 0 then
  1120. Xdir = Zdir
  1121. Zdir = 0
  1122. else
  1123. Zdir = -Xdir
  1124. Xdir = 0
  1125. end
  1126.  
  1127. if Xdag == Zdag then Zdag = -Zdag else Xdag = -Xdag end
  1128.  
  1129. end -- Left
  1130.  
  1131.  
  1132. function GetDir()
  1133. Xdir = (targpos.x - torsoPos.x) -- Which way are we going?
  1134. Zdir = (targpos.z - torsoPos.z)
  1135.  
  1136. -- if Zdir < 0 then -- Get closest 45 degree angle. Diagonal.
  1137. -- Zdag = -RAYLength
  1138. -- else
  1139. -- Zdag = RAYLength
  1140. -- end
  1141. -- if Xdir < 0 then
  1142. -- Xdag = -RAYLength
  1143. -- else
  1144. -- Xdag = RAYLength
  1145. -- end
  1146.  
  1147. if math.abs(Xdir) > math.abs(Zdir) then -- Ordinal.
  1148. if Xdir < 0 then
  1149. Xdir = -RAYLength
  1150. -- convert to our direction indicator.
  1151. else
  1152. Xdir = RAYLength
  1153. end
  1154. Zdag = Xdir -- Diagonal Right.
  1155. Xdag = Xdir
  1156. Zdir = 0
  1157. else -- abs
  1158. if Zdir < 0 then
  1159. Zdir = -RAYLength
  1160. else
  1161. Zdir = RAYLength
  1162. end
  1163. Zdag = Zdir
  1164. Xdag = -Zdir
  1165. Xdir = 0
  1166. end -- abs
  1167. end -- GetDir
  1168.  
  1169.  
  1170. while AItorso do -- while I still have a body; search.
  1171. torsoPos = AItorso.Position
  1172. local targ = Workspace.Terrain -- Temp targ
  1173. local Distance =(torsoPos - OldPos).magnitude -- Distance traveled, since last loop
  1174. --local Distance =10
  1175. if target == nil then Logic = 0
  1176. -- Distance = 10
  1177. end -- Player died.
  1178.  
  1179.  
  1180. if Logic == 0 then -- Defalt logic
  1181.  
  1182. target = findNearestTorso(torsoPos) --- target is some Player. FindNearest and get xdir, ydir.
  1183.  
  1184. if target ~= nil then
  1185. targ = target
  1186. -- if ClimbingLadder and Distance >= 1 then
  1187. -- targpos = torsoPos + AItorso.CFrame.lookVector * 9
  1188. -- else
  1189. targpos = target.Position
  1190. -- end
  1191.  
  1192. if Distance < 1 and (torsoPos - targpos).magnitude > 4 then -- Check if we are stuck.
  1193. GetDir()
  1194. OldX = Xdir -- Goal direction.
  1195. OldZ = Zdir
  1196.  
  1197. Logic = 1 -- Impeded
  1198.  
  1199. else
  1200. if FireAtPlayer() then -- hit
  1201.  
  1202. GetDir()
  1203. OldX = Xdir -- Goal direction.
  1204. OldZ = Zdir
  1205.  
  1206. if FireDag() then
  1207. Logic = 1 -- Go Left; Look Right.
  1208. ClimbingLadder = true -- first time thru logic 1 indicator
  1209. else
  1210. targpos = torsoPos + Vector3.new(Xdag,0,Zdag) -- go Right
  1211.  
  1212. end -- dagRight
  1213. end -- hit?
  1214. end -- impeded?
  1215. else
  1216. print(AIName, number, ": No target. - ", target)
  1217. -- torsoPos = torsoPos * 2 -- Turn Impeded?, off
  1218. -- Distance = 10
  1219. end -- if no target?
  1220. end -- Logic 0
  1221.  
  1222.  
  1223. -- 1 - Look Right or Go left
  1224. if Logic == 1 then
  1225.  
  1226. if Distance >= 1 then
  1227. if ClimbingLadder == false then -- or target.Position.y < torsoPos.y + 4 then
  1228. TurnRight()
  1229. end -- else go straight or go up
  1230. else
  1231. TurnLeft()
  1232. end
  1233.  
  1234. if FireRayAhead() then -- Check straight first. (And Diagonaly left)
  1235. TurnLeft()
  1236. if FireRay() then -- Check left (And Diagonaly left & back)
  1237. TurnLeft()
  1238. if FireRay() then
  1239. TurnLeft()
  1240. if FireRay() then
  1241. targpos = torsoPos + Vector3.new(Xdir,0,Zdir)
  1242. hum.Jump = true
  1243. end -- right
  1244. end -- Back
  1245. end -- Left
  1246. else -- If succesful Ahead then... (We only check RightTurns for a get-out-of-jail-Free card)
  1247.  
  1248. if Xdir == OldX and OldZ == Zdir then -- Gracefully exiting Logic 1
  1249. Logic = 0
  1250. end -- check Goal dir?
  1251. end -- Ahead
  1252. end -- Logic 1
  1253.  
  1254. -- go
  1255. OldPos = torsoPos
  1256. hum:MoveTo(targpos, targ) -- MoveToward Target
  1257.  
  1258. --wait
  1259. wait(BRAINWave)
  1260.  
  1261. while FreeFalling do
  1262. FreeFalling = false
  1263. wait(.2)
  1264. end
  1265.  
  1266. end -- Main
  1267.  
  1268. end))
  1269. BoolValue44.Name = "GraphicsToggle"
  1270. BoolValue44.Parent = Script43
  1271. Script45.Name = "GuestSuicideYalalaScript"
  1272. Script45.Parent = Model0
  1273. table.insert(cors,sandbox(Script45,function()
  1274. Wait(0.3)
  1275. --[[Last Change By: Brutez. (1:20 PM PACIFIC TIME) (6/22/14)]]--
  1276. local Guest = script.Parent
  1277. local GuestHead = Guest:FindFirstChild("Head")
  1278. local YALALA=GuestHead:FindFirstChild("GuestYalala")
  1279. local GuestTorso = Guest:FindFirstChild("Torso")
  1280. local GuestExplosionSound = GuestTorso:FindFirstChild("GuestExplosion")
  1281. function FindSomeOneToSwordFightWith(pos)
  1282. local list = game.Workspace:children()
  1283. local torso = nil
  1284. local dist = 20
  1285. local temp = nil
  1286. local human = nil
  1287. local temp2 = nil
  1288. for x = 1, #list do
  1289. temp2 = list[x]
  1290. if (temp2.className == "Model") and (temp2 ~= script.Parent) then
  1291. temp = temp2:findFirstChild("Torso")
  1292. human = temp2:findFirstChild("Humanoid")
  1293. if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  1294. if (temp.Position - pos).magnitude < dist then
  1295. torso = temp
  1296. dist = (temp.Position - pos).magnitude
  1297. end
  1298. end
  1299. end
  1300. end
  1301. return torso
  1302. end
  1303. while true do
  1304. Wait(0)
  1305. local target = FindSomeOneToSwordFightWith(GuestTorso.Position)
  1306. if target ~= nil then
  1307. YALALA:Play()
  1308. Wait(4)
  1309. end
  1310. end
  1311. end))
  1312. Script46.Name = "GuestSuicideExplosionScript"
  1313. Script46.Parent = Model0
  1314. table.insert(cors,sandbox(Script46,function()
  1315. Wait(0.3)
  1316. --[[Last Change By: Brutez. (1:20 PM PACIFIC TIME) (6/22/14)]]--
  1317. local Guest = script.Parent
  1318. local GuestHead = Guest:FindFirstChild("Head")
  1319. local YALALA=GuestHead:FindFirstChild("GuestYalala")
  1320. local GuestTorso = Guest:FindFirstChild("Torso")
  1321. local GuestExplosionSound = GuestTorso:FindFirstChild("GuestExplosion")
  1322. function GuestExplosion()
  1323. GuestExplosionSound:Play()
  1324. GuestExplosionParticle = Instance.new("Explosion")
  1325. GuestExplosionParticle.BlastRadius = 22
  1326. GuestExplosionParticle.BlastPressure = 1000000 -- these are really wussy units
  1327. GuestExplosionParticle.Position = GuestTorso.Position
  1328. GuestExplosionParticle.Parent = Game.Workspace
  1329. end
  1330. function FindSomeOneToSwordFightWith(pos)
  1331. local list = game.Workspace:children()
  1332. local torso = nil
  1333. local dist = 6
  1334. local temp = nil
  1335. local human = nil
  1336. local temp2 = nil
  1337. for x = 1, #list do
  1338. temp2 = list[x]
  1339. if (temp2.className == "Model") and (temp2 ~= script.Parent) then
  1340. temp = temp2:findFirstChild("Torso")
  1341. human = temp2:findFirstChild("Humanoid")
  1342. if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  1343. if (temp.Position - pos).magnitude < dist then
  1344. torso = temp
  1345. dist = (temp.Position - pos).magnitude
  1346. end
  1347. end
  1348. end
  1349. end
  1350. return torso
  1351. end
  1352. while true do
  1353. Wait(0)
  1354. local target = FindSomeOneToSwordFightWith(GuestTorso.Position)
  1355. if target ~= nil then
  1356. GuestExplosion()
  1357. Wait(0)
  1358. end
  1359. end
  1360. end))
  1361. for i,v in pairs(mas:GetChildren()) do
  1362. v.Parent = workspace
  1363. pcall(function() v:MakeJoints() end)
  1364. end
  1365. mas:Destroy()
  1366. for i,v in pairs(cors) do
  1367. spawn(function()
  1368. pcall(v)
  1369. end)
  1370. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement