Advertisement
djroese

Untitled

Nov 9th, 2016
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.06 KB | None | 0 0
  1.  
  2.  
  3. Breeds = {
  4. { -- Brown
  5. fur=BrickColor.new("Brown"),
  6. mane=BrickColor.new("Nougat"),
  7. saddle=BrickColor.Black(),
  8. reins=BrickColor.Black(),
  9. hoof=BrickColor.Black()
  10. },
  11. { -- Black
  12. fur=BrickColor.Black(),
  13. mane=BrickColor.new("Really black"),
  14. saddle=BrickColor.new("Brown"),
  15. reins=BrickColor.new("Brown"),
  16. hoof=BrickColor.new("Dark stone grey")
  17. },
  18. { -- Grey
  19. fur=BrickColor.new("Dark stone grey"),
  20. mane=BrickColor.Black(),
  21. saddle=BrickColor.new("Brown"),
  22. reins=BrickColor.new("Brown"),
  23. hoof=BrickColor.Black()
  24. },
  25. { -- White
  26. fur=BrickColor.new("Light stone grey"),
  27. mane=BrickColor.new("Medium stone grey"),
  28. saddle=BrickColor.Black(),
  29. reins=BrickColor.Black(),
  30. hoof=BrickColor.Black()
  31. }
  32. }
  33.  
  34. local Breed = Breeds[math.random(1,#Breeds)]
  35.  
  36. local ModelName = "Horse"
  37. local ModelParent = workspace
  38. --pcall(function() ModelParent[ModelName]:Destroy() end)
  39.  
  40. local ReinsHold = nil
  41. local Height = 6.2
  42. local rHeight = Height
  43.  
  44. local HasHat = true
  45. local HatMeshId = "rbxassetid://42157240"
  46. local HatTexId = ""
  47. local HorseColor = Breed.fur
  48. local EyeColor = BrickColor.new("Really black")
  49. local ManeColor = Breed.mane
  50. local SaddleColor = Breed.saddle
  51. local ReinsColor = Breed.reins
  52. local HoofColor = Breed.hoof
  53. local oc = oc or function(...) return ... end
  54. local ModelScale = .6
  55.  
  56. local Speed = 0
  57. local WalkSpeed = 15
  58. local WalkSin = 6
  59. local TrotSpeed = 30
  60. local TrotSin = 4
  61. local GallopSin = 20
  62. local MaxSpeed = 100
  63. local SpeedLimit = 100
  64.  
  65.  
  66. local startpos = workspace.djroese.Head.CFrame * CFrame.new(0,Height+1.5,10)--script.Parent:IsA("BasePart") and script.Parent.CFrame * CFrame.new(0,Height,0) or CFrame.new(0,Height+1,20)
  67.  
  68. math.randomseed(tick()+215819240)
  69. math.random() math.random() math.random()
  70. aran = function() return math.random() end
  71. ran = function() return (math.random()-.5)*2 end
  72.  
  73. function Weld(a,b,c,d)
  74. local w = Instance.new("Weld",a)
  75. w.Part0 = a
  76. w.Part1 = b
  77. w.C0 = c or CFrame.new()
  78. w.C1 = d or CFrame.new()
  79. return w
  80. end
  81.  
  82.  
  83. do -- Ignore my clerp stuff stolen from stravvy
  84. local function QuaternionFromCFrame(cf)
  85. local mx, my, mz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components()
  86. local trace = m00 + m11 + m22
  87. if trace > 0 then
  88. local s = math.sqrt(1 + trace)
  89. local recip = 0.5/s
  90. return (m21-m12)*recip, (m02-m20)*recip, (m10-m01)*recip, s*0.5
  91. else
  92. local i = 0
  93. if m11 > m00 then
  94. i = 1
  95. end
  96. if m22 > (i == 0 and m00 or m11) then
  97. i = 2
  98. end
  99. if i == 0 then
  100. local s = math.sqrt(m00-m11-m22+1)
  101. local recip = 0.5/s
  102. return 0.5*s, (m10+m01)*recip, (m20+m02)*recip, (m21-m12)*recip
  103. elseif i == 1 then
  104. local s = math.sqrt(m11-m22-m00+1)
  105. local recip = 0.5/s
  106. return (m01+m10)*recip, 0.5*s, (m21+m12)*recip, (m02-m20)*recip
  107. elseif i == 2 then
  108. local s = math.sqrt(m22-m00-m11+1)
  109. local recip = 0.5/s return (m02+m20)*recip, (m12+m21)*recip, 0.5*s, (m10-m01)*recip
  110. end
  111. end
  112. end
  113. local function QuaternionToCFrame(px, py, pz, x, y, z, w)
  114. local xs, ys, zs = x + x, y + y, z + z
  115. local wx, wy, wz = w*xs, w*ys, w*zs
  116. local xx = x*xs
  117. local xy = x*ys
  118. local xz = x*zs
  119. local yy = y*ys
  120. local yz = y*zs
  121. local zz = z*zs
  122. return CFrame.new(px, py, pz,1-(yy+zz), xy - wz, xz + wy,xy + wz, 1-(xx+zz), yz - wx, xz - wy, yz + wx, 1-(xx+yy))
  123. end
  124. local function QuaternionSlerp(a, b, t)
  125. local cosTheta = a[1]*b[1] + a[2]*b[2] + a[3]*b[3] + a[4]*b[4]
  126. local startInterp, finishInterp;
  127. if cosTheta >= 0.0001 then
  128. if (1 - cosTheta) > 0.0001 then
  129. local theta = math.acos(cosTheta)
  130. local invSinTheta = 1/math.sin(theta)
  131. startInterp = math.sin((1-t)*theta)*invSinTheta
  132. finishInterp = math.sin(t*theta)*invSinTheta
  133. else
  134. startInterp = 1-t
  135. finishInterp = t
  136. end
  137. else
  138. if (1+cosTheta) > 0.0001 then
  139. local theta = math.acos(-cosTheta)
  140. local invSinTheta = 1/math.sin(theta)
  141. startInterp = math.sin((t-1)*theta)*invSinTheta
  142. finishInterp = math.sin(t*theta)*invSinTheta
  143. else
  144. startInterp = t-1
  145. finishInterp = t
  146. end
  147. end
  148. return a[1]*startInterp + b[1]*finishInterp, a[2]*startInterp + b[2]*finishInterp, a[3]*startInterp + b[3]*finishInterp, a[4]*startInterp + b[4]*finishInterp
  149. end
  150. function clerp(a,b,t)
  151. local qa = {QuaternionFromCFrame(a)}
  152. local qb = {QuaternionFromCFrame(b)}
  153. local ax, ay, az = a.x, a.y, a.z
  154. local bx, by, bz = b.x, b.y, b.z
  155. local _t = 1-t
  156. return QuaternionToCFrame(_t*ax + t*bx, _t*ay + t*by, _t*az + t*bz,QuaternionSlerp(qa, qb, t))
  157. end
  158. end
  159.  
  160. function lerp(a,b,c)
  161. return a+(b-a)*c
  162. end
  163.  
  164. function ctlerp(c1,c2,al) -- Older, "worse" clerp if the other one fails..
  165. local com1 = {c1:components()}
  166. local com2 = {c2:components()}
  167. for i,v in pairs(com1) do
  168. com1[i] = lerp(v,com2[i],al)
  169. end
  170. return CFrame.new(unpack(com1))
  171. end
  172.  
  173.  
  174. local Model = Instance.new("Model",ModelParent)
  175. Model.Name = ModelName
  176.  
  177. local BasePart = Instance.new("Part")
  178. BasePart.FormFactor = "Custom"
  179. BasePart.Size = Vector3.new()
  180. BasePart.TopSurface,BasePart.BottomSurface,BasePart.LeftSurface,BasePart.RightSurface,BasePart.FrontSurface,BasePart.BackSurface = 10,10,10,10,10,10
  181. BasePart:BreakJoints()
  182. BasePart.CFrame = startpos
  183.  
  184. function NP()
  185. local p = BasePart:Clone()
  186. p.Parent = Model
  187. return p
  188. end
  189.  
  190. function Sphere(parent,scale)
  191. local sm = Instance.new("SpecialMesh",parent)
  192. sm.MeshType = "Sphere"
  193. sm.Scale = scale or Vector3.new(1,1,1)
  194. return sm
  195. end
  196.  
  197. BasePart.BrickColor = HorseColor
  198.  
  199. local Main = NP()
  200. Main.Size = Vector3.new(3.5,4.5,8)
  201. Main.CFrame = startpos
  202.  
  203. MainMesh = Sphere(Main)
  204.  
  205. local Neck = NP()
  206. Neck.Size = Vector3.new(2,5,2.5)
  207. local NeckWeld = Weld(Main,Neck,CFrame.new(0,0.5,-3.2)*CFrame.Angles(math.rad(-20),0,0),CFrame.new(0,-1.5,0))
  208. local NeckWeld0 = NeckWeld.C0
  209. Sphere(Neck,Vector3.new(1,1,1))
  210.  
  211. local NeckBonus = NP()
  212. NeckBonus.Size = Vector3.new(1.9,3,2)
  213. Weld(Neck,NeckBonus,CFrame.new(0,-1.1,.5)*CFrame.Angles(-.5,0,0))
  214. Sphere(NeckBonus)
  215.  
  216. local Head = NP()
  217. Head.Size = Vector3.new(2,3,3)
  218. local HeadWeld = Weld(Neck,Head,CFrame.new(0,2.5,-.4),CFrame.new(0,0,1))
  219. local HeadWeld0 = HeadWeld.C0
  220. local HeadMesh = Instance.new("SpecialMesh",Head)
  221. HeadMesh.Scale = Vector3.new(0.7,1,1)*1.6
  222. HeadMesh.MeshId = "http://www.roblox.com/asset/?id=114690930"
  223.  
  224. if HasHat then
  225. local Hat = NP()
  226. Hat.Size = Vector3.new()
  227. Hat.BrickColor = SaddleColor
  228. local HatWeld = Weld(Head,Hat,CFrame.new(0,1.11,1.3),CFrame.Angles(math.rad(-20),0,0))
  229. local HatMesh = Instance.new("SpecialMesh",Hat)
  230. HatMesh.Scale = Vector3.new(1.5,1.5,1.5)
  231. HatMesh.MeshId = HatMeshId or "rbxassetid://42157240"
  232. HatMesh.TextureId = HatTexId or ""
  233. end
  234.  
  235. local EyeR = NP()
  236. EyeR.BrickColor = EyeColor
  237. EyeR.Reflectance = .1
  238. EyeR.Size = Vector3.new(.2,.2,.2)
  239. Weld(Head,EyeR,CFrame.new(.631,.23,.11)*CFrame.Angles(-0.2,0.1,0))
  240. Sphere(EyeR,Vector3.new(.9,2.1,2.1))
  241.  
  242. local EyeL = NP()
  243. EyeL.BrickColor = EyeColor
  244. EyeL.Reflectance = .1
  245. EyeL.Size = Vector3.new(.2,.2,.2)
  246. Weld(Head,EyeL,CFrame.new(-.631,.23,.11)*CFrame.Angles(-0.2,-0.1,0))
  247. Sphere(EyeL,Vector3.new(.9,2.1,2.1))
  248.  
  249. BasePart.Name = "Reins"
  250.  
  251. local RPart = NP() -- rs1
  252. RPart.BrickColor = ReinsColor
  253. RPart.Size = Vector3.new(.2,.7,.25)
  254. Weld(Head,RPart,CFrame.new(.4,-.5,-1.05)*CFrame.Angles(-.25,0,0))
  255.  
  256. local Cyl = NP()
  257. Cyl.BrickColor = ReinsColor
  258. Cyl.Size = Vector3.new(.2495,.2,.2)
  259. Instance.new("SpecialMesh",Cyl).MeshType = "Cylinder"
  260. Weld(RPart,Cyl,CFrame.new(0,RPart.Size.Y/2,0)*CFrame.Angles(0,math.pi/2,0))
  261.  
  262. local RPart = NP() -- rs2
  263. RPart.BrickColor = ReinsColor
  264. RPart.Size = Vector3.new(.2,.4,.25)
  265. Weld(Head,RPart,CFrame.new(.4,-.5,-1.05)*CFrame.Angles(-.25,0,0)*CFrame.new(0,-.35,0)*CFrame.Angles(0,0,-.5)*CFrame.new(0,-.2,0))
  266.  
  267. local Cyl = NP()
  268. Cyl.BrickColor = ReinsColor
  269. Cyl.Size = Vector3.new(.2495,.2,.2)
  270. Instance.new("SpecialMesh",Cyl).MeshType = "Cylinder"
  271. Weld(RPart,Cyl,CFrame.new(0,RPart.Size.Y/2,0)*CFrame.Angles(0,math.pi/2,0))
  272. local ReinAnchorR = Cyl
  273.  
  274. local RPart = NP() -- ls1
  275. RPart.BrickColor = ReinsColor
  276. RPart.Size = Vector3.new(.2,.7,.25)
  277. Weld(Head,RPart,CFrame.new(-.4,-.5,-1.05)*CFrame.Angles(-.25,0,0))
  278.  
  279. local Cyl = NP()
  280. Cyl.BrickColor = ReinsColor
  281. Cyl.Size = Vector3.new(.2495,.2,.2)
  282. Instance.new("SpecialMesh",Cyl).MeshType = "Cylinder"
  283. Weld(RPart,Cyl,CFrame.new(0,RPart.Size.Y/2,0)*CF…
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement