Vec2 Pack

broken image


Jun 19th, 2017

Download link: Page: for VEC2 Pack 2ALSO, like this facebook page for access. Debug / Decompile algorithms (from Shadertoy, etc) Texture generator (noise patterns, etc) Unit Test shaders! Quick prototype.

Never
Not a member of Pastebin yet?Sign Up, it unlocks many cool features!
  1. char = p.Character
  2. fling = true
  3. falling = false
  4. --char.Shirt:Remove()
  5. --for i,v in pairs(char:GetChildren()) do if v:IsA('Pants') then v:Remove() end end
  6. for i,v in pairs(char:GetChildren()) do if v:IsA('Hat') then v.Handle:Remove() end end
  7. --shirt.Name = 'Shirt'
  8. --pants.Name = 'Pants'
  9. --char.Shirt.ShirtTemplate = 'http://www.roblox.com/asset/?id=433403860'
  10. --char.Pants.PantsTemplate = 'http://www.roblox.com/asset/?id=433408506'
  11. shoot = true
  12. punch = true
  13. neck = char.Torso.Neck
  14. wait()
  15. des = false
  16. torso = char.Torso
  17. char.Head.face.Texture = 'rbxassetid://420259243'
  18. local player = game.Players.LocalPlayer
  19. lig = Instance.new('PointLight',player.Character.Torso)
  20. m=player:GetMouse()
  21. bb = Instance.new('BillboardGui',player.Character.Head)
  22. function newRay(start,face,range,wat)
  23. local rey=Ray.new(start.p,(face.p-start.p).Unit*range)
  24. hit,pos=Workspace:FindPartOnRayWithIgnoreList(rey,wat)
  25. end
  26. torso=game.Players.LocalPlayer.Character.Torso
  27. local WorldUp = Vector3.new(0,1,0)
  28. local Orig = Vec1
  29. Vec2 = Vec2+Vector3.new(0,1,0)
  30. local Up = (WorldUp-WorldUp:Dot(Forward)*Forward).unit
  31. Forward = -Forward
  32. return CFrame.new(Orig.X,Orig.Y,Orig.Z,Right.X,Up.X,Forward.X,Right.Y,Up.Y,Forward.Y,Right.Z,Up.Z,Forward.Z)
  33. local A = Vector3.new(0,0,0)
  34. local CF = look2(A,Vector3.new(A.X,B.Y,B.Z))
  35. CF = CFr*(CF*CFrame.Angles(0,0,math.pi))
  36. if B.Y > 0 then
  37. elseif B.Y < 0 then
  38. else
  39. end
  40. local _,_,_,_,X,_,_,Y,_,_,Z,_ = CF:components()
  41. local Forward = (Vec2-CFr.p).unit
  42. Forward = -Forward
  43. return CFrame.new(CFr.X,CFr.Y,CFr.Z,Right.X,Up.X,Forward.X,Right.Y,Up.Y,Forward.Y,Right.Z,Up.Z,Forward.Z)
  44. local joint = j
  45. if v[1]:FindFirstChild('Weld') then
  46. if i > 1 then joint = t[i-1][1].CFrame*CFrame.new(0,0,d*.5) end
  47. local dir = (v[2].p-(joint.p+Vector3.new(0,0.2,0)+stiff)).unit
  48. local dis = (v[2].p-(joint.p+Vector3.new(0,0.2,0)+stiff)).magnitude
  49. --if v[1].CFrame.y<=workspace.Base.CFrame.y then pos = joint.p+(dir*(d*.5)) end
  50. local rel1 = inv:inverse()*pos
  51. local cf = look(CFrame.new(rel1),rel2)--CFrame.new(pos,pos-(dir*dis))*CFrame.fromEulerAnglesXYZ(r.x,r.y,r.z)
  52. v[2] = inv*cf
  53. end
  54. end
  55. local p = Instance.new('Part',char)
  56. p.BrickColor = BrickColor.new('Institutional white')
  57. p.FormFactor='Custom'
  58. p.TopSurface = 'SmoothNoOutlines'
  59. p.RightSurface = 'SmoothNoOutlines'
  60. p.FrontSurface = 'SmoothNoOutlines'
  61. p:BreakJoints() -- sometimes the parts are stuck to something so you have to breakjoints them
  62. mesh.Scale = Vector3.new(1,1,4)
  63. w.Part0 = aa1[i-1] and aa1[i-1][1] or torso
  64. w.Name = 'Weld'
  65. aa1[i] = {p,p.CFrame}
  66. end
  67. game:service'RunService'.Stepped:connect(function()
  68. simulate(torso.CFrame*CFrame.new(0,0.9,.5),.6,torso,Vector3.new(),aa1)
  69. bb.AlwaysOnTop = true
  70. bb.StudsOffset = Vector3.new(0,1,0)
  71. gui.Text = '* '
  72. gui.Position=UDim2.new(0,57,0,-40)
  73. gui.BackgroundColor3=Color3.new(0,0,0)
  74. gui.TextScaled = true
  75. gui.TextYAlignment = 'Top'
  76. gui.BorderColor3 = Color3.new(0,0,0)
  77. gui1=Instance.new('TextButton',bb)
  78. gui1.Size = UDim2.new(0,190,0,51)
  79. gui1.TextColor3 = Color3.new(255,255,255)
  80. jump2 = true
  81. img = Instance.new('ImageLabel',bb)
  82. img.Position = UDim2.new(0,10,0,-41)
  83. img.BorderColor3 = Color3.new(0,0,0)
  84. soka = Instance.new('Sound',char)
  85. soka.SoundId = 'http://www.roblox.com/asset/?id = 447199232'
  86. boom = Instance.new('Sound',char)
  87. boom.SoundId = 'http://www.roblox.com/asset/?id = 447041606'
  88. boom2 = Instance.new('Sound',char)
  89. boom2.SoundId = 'http://www.roblox.com/asset/?id = 449025737'
  90. boom3 = Instance.new('Sound',char)
  91. boom3.SoundId = 'http://www.roblox.com/asset/?id = 450719019'
  92. tps = Instance.new('Sound',char)
  93. tps.SoundId = 'http://www.roblox.com/asset/?id = 449860746'
  94. asd = Instance.new('Sound',char)
  95. asd.SoundId = 'http://www.roblox.com/asset/?id = 447310433'
  96. asd1 = Instance.new('Sound',char)
  97. asd1.SoundId = 'http://www.roblox.com/asset/?id = 358280695'
  98. asd2 = Instance.new('Sound',char)
  99. asd2.SoundId = 'http://www.roblox.com/asset/?id = 386713054'
  100. asd2.Volume = 5
  101. asd3.SoundId = 'http://www.roblox.com/asset/?id = 378387996'
  102. asd4 = Instance.new('Sound',char)
  103. asd4.SoundId = 'http://www.roblox.com/asset/?id = 401258325'
  104. asd5 = Instance.new('Sound',char)
  105. asd5.SoundId = 'http://www.roblox.com/asset/?id = 362252261'
  106. gas = Instance.new('Sound',char)
  107. gas.SoundId = 'http://www.roblox.com/asset/?id = 345052019'
  108. asd6.SoundId = 'http://www.roblox.com/asset/?id = 401258325'
  109. function play(play)
  110. wait(0.05)
  111. end
  112. ------------
  113. local parts = {}
  114. local p = Instance.new('Part',char)
  115. p.Transparency = 0.5
  116. p.BottomSurface = 0
  117. p.BrickColor = BrickColor.new('Institutional white')
  118. p.CFrame = CFrame.new(origin+dir*i*size)*CFrame.Angles(math.random()*math.pi,math.random()*math.pi,math.random()*math.pi)
  119. parts[i] = {p,CFrame.Angles(math.random()*math.pi/5,math.random()*math.pi/5,math.random()*math.pi/5)}
  120. end
  121. while parts do
  122. if v[1].Parent char then
  123. else
  124. break
  125. end
  126. end
  127. end
  128. --[[-- listen for their chatting
  129. a = string.len(message)
  130. gui.Visible = true
  131. des = false
  132. print(a)
  133. gui.Text = '
  134. gui.Text =gui.Text..message:sub(i,i)
  135. end
  136. end)]]--
  137. if k 'g' then
  138. end
  139. if k 'r' then
  140. asd4:Play()
  141. end)
  142. if k 'q' then
  143. asd3:Play()
  144. end)
  145. if k 'z' then
  146. end)
  147. if k 'c' then
  148. end)
  149. if k 'b' then
  150. asd6:Play()
  151. end)
  152. m.KeyDown:connect(function(k)
  153. end
  154. m.KeyDown:connect(function(k)
  155. end
  156. m.KeyDown:connect(function(k)
  157. char.Head.face.Texture = 'rbxassetid://444037452'
  158. end)
  159. if k:byte() 51 then
  160. char.Head.face.Texture = 'rbxassetid://332768867'
  161. end)
  162. if k:byte() 48 then
  163. hum.WalkSpeed = 16
  164. end)
  165. if m 'Okay.' then
  166. end
  167. m.KeyDown:connect(function(k)
  168. if des true then
  169. gui.Text = '* '
  170. img.Visible = false
  171. end
  172. m.KeyDown:connect(function(key)
  173. if tp true then
  174. tps:Play()
  175. for i,v in pairs(char:GetChildren()) do if v:IsA('Part') then v.Transparency = 1
  176. wait(0.5)
  177. for i,v in pairs(char:GetChildren()) do if v:IsA('Part') then v.Transparency = 0
  178. char.HumanoidRootPart.CFrame = mouse.Hit * CFrame.new(0, 3, 0)
  179. game.Lighting.face.Parent = char.Head
  180. end
  181. end)
  182. if key 't' then
  183. punch2 = false
  184. ChatService:Chat(char.Head, 'I...will become a hero!')
  185. local ChatService = game:GetService('Chat')
  186. ChatService:Chat(char.Head ,'I...I-I can do this!')
  187. local ChatService = game:GetService('Chat')
  188. ChatService:Chat(char.Head, 'DETROIT SMAAAAAAAAAAAASH!')
  189. wait(0.6)
  190. char.Torso['Left Shoulder'].C0 = char.Torso['Left Shoulder'].C0 * CFrame.new(-0.3,0,0) * CFrame.Angles(0,0,math.rad(-90))
  191. killbrick2 = Instance.new('Part',char)
  192. killbrick2.Transparency = 1
  193. killbrick2.CanCollide = true
  194. killbrick2.CanCollide = false
  195. killbrick2.Anchored = true
  196. killbrick2.CFrame = char.Torso.CFrame * CFrame.new(0,0,-1005)
  197. killbrick2.Touched:connect(function(h)
  198. if x then
  199. if x.Parent.Name game.Players.LocalPlayer.Name then
  200. else safe = false
  201. if x then
  202. h.Parent.Torso.Velocity = CFrame.new(char.Torso.Position,h.Parent.Torso.Position).lookVector * 900
  203. local bodyforc = Instance.new('BodyForce', h.Parent.Torso)
  204. bodyforc.force = Vector3.new(0, h.Parent.Torso:GetMass() * 196.1, 0)
  205. x.Parent:BreakJoints()
  206. safe = true
  207. end
  208. end)
  209. rng.Anchored = true
  210. rng.CanCollide = false
  211. rng.Name = 'Ring'
  212. rng.Transparency = 0.8
  213. rng.BottomSurface = 0
  214. rng.CFrame = char['Left Arm'].CFrame * CFrame.new(0,-2,0)
  215. rng.CFrame = rng.CFrame * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0))
  216. rngm.MeshId = 'http://www.roblox.com/asset/?id=3270017'
  217. local rng1 = Instance.new('Part', char)
  218. rng1.BrickColor = BrickColor.new('Persimmon')
  219. rng1.FormFactor = 3
  220. rng1.Size = Vector3.new(1, 1, 1)
  221. rng1.TopSurface = 0
  222. rng1.CFrame = char['Left Arm'].CFrame * CFrame.new(0,-2,0)
  223. rng1.CFrame = rng1.CFrame * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0))
  224. rngm1.MeshId = 'http://www.roblox.com/asset/?id=3270017'
  225. stream(p.p,((p*Vector3.new(-0.7,0,1))-p.p).unit,90,5) -- 20 is number of parts, 6 is distance between each one
  226. stream(p.p,((p*Vector3.new(0.7,0,1))-p.p).unit,90,5) -- same here
  227. local rng2 = Instance.new('Part', char)
  228. rng2.BrickColor = BrickColor.new('Persimmon')
  229. rng2.FormFactor = 3
  230. rng2.Size = Vector3.new(1, 1, 1)
  231. rng2.TopSurface = 0
  232. rng2.CFrame = char['Left Arm'].CFrame * CFrame.new(0,-2,0)
  233. rng2.CFrame = rng2.CFrame * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0))
  234. rngm2.MeshId = 'http://www.roblox.com/asset/?id=3270017'
  235. wait(0.1)
  236. boom3:Play()
  237. for i = 1, 35, 0.5 do
  238. rngm.Scale = Vector3.new(50 + i*2, 10 + i*2, 2.5+ i*4)
  239. rngm1.Scale = Vector3.new(50 + i*2, 1.4 + i*2, 1.4+ i*4)
  240. rngm2.Scale = Vector3.new(50 + i*2, 10 + i*2, 1.2+ i*4)
  241. wait()
  242. wait()
  243. rng1:Destroy()
  244. killbrick2:Remove()
  245. char.Torso['Left Shoulder'].C0 = org
  246. punch2 = true
  247. wait()
  248. wait(.1)
  249. end)
  250. m.KeyDown:connect(function(key)
  251. if punch true then
  252. org = char.Torso['Left Shoulder'].C0
  253. char.Torso['Left Shoulder'].C0 = char.Torso['Left Shoulder'].C0 * CFrame.new(-0.3,0,0) * CFrame.Angles(0,0,math.rad(-90))
  254. killbrick.Size = Vector3.new(5,1,5)
  255. killbrick:BreakJoints()
  256. local wel = Instance.new('Weld',killbrick)
  257. wel.Part1 = char['Left Arm']
  258. force = 90
  259. killbrick.Touched:connect(function(h)
  260. if x.Health >= 6000 then
  261. end
  262. fling = true
  263. local stop = h.Parent.Torso.Velocity
  264. if x.Parent.Name game.Players.LocalPlayer.Name then
  265. else safe = false
  266. if x then
  267. if fling true then
  268. if fling false then
  269. end
  270. h.Parent.Torso.Velocity = CFrame.new(char.Torso.Position,h.Parent.Torso.Position).lookVector * force
  271. local bodyforc = Instance.new('BodyForce', h.Parent.Torso)
  272. bodyforc.force = Vector3.new(0, h.Parent.Torso:GetMass() * 196.1, 0)
  273. x:TakeDamage(5000)
  274. safe = true
  275. h.Parent.Torso.Velocity = stop
  276. end
  277. end)
  278. rng.Anchored = true
  279. rng.BrickColor = BrickColor.new('Institutional white')
  280. rng.FormFactor = 3
  281. rng.Size = Vector3.new(1, 1, 1)
  282. rng.TopSurface = 0
  283. rng.CFrame = char['Left Arm'].CFrame * CFrame.new(0,-2,0)
  284. rng.CFrame = rng.CFrame * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0))
  285. rngm.MeshId = 'http://www.roblox.com/asset/?id=3270017'
  286. wait(0.1)
  287. boom2:Play()
  288. for i = 1, 10, .4 do
  289. end
  290. rng:Destroy()
  291. wait(0.5)
  292. wait(1)
  293. punch = true
  294. end)()
  295. end
  296. end
  297. m.KeyDown:connect(function(key)
  298. if jump true then
  299. local rng = Instance.new('Part', char)
  300. rng.BrickColor = BrickColor.new('Institutional white')
  301. rng.FormFactor = 3
  302. rng.Size = Vector3.new(1, 1, 1)
  303. rng.TopSurface = 0
  304. rng.Position = torso.Position - Vector3.new(0,2,0)
  305. rng.CFrame = rng.CFrame * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0))
  306. rngm.MeshId = 'http://www.roblox.com/asset/?id=3270017'
  307. wait(0.1)
  308. BV.maxForce = Vector3.new(0,20000,0)
  309. BV.velocity = Vector3.new(0,100,0)
  310. coroutine.wrap(function()
  311. rngm.Scale = Vector3.new(2 + i*2, 2 + i*2, 1)
  312. wait()
  313. wait()
  314. wait(1)
  315. for i,v in pairs(torso:GetChildren()) do if v:IsA('BodyVelocity') then
  316. v:Destroy() jumping2 = true falling = true wait(0.3) jumping2 = false falling = false wait(1.7) jump = true hum.WalkSpeed = 16 falling = false
  317. wait()
  318. wait(.1)
  319. end)
  320. if key 'n' then
  321. if falling true then
  322. if jumping2 true then
  323. jump = false
  324. BV.maxForce = Vector3.new(0,-20000,0)
  325. BV.velocity = Vector3.new(0,-70,0)
  326. local rng = Instance.new('Part', char)
  327. rng.BrickColor = BrickColor.new('Institutional white')
  328. rng.FormFactor = 3
  329. rng.Size = Vector3.new(1, 1, 1)
  330. rng.TopSurface = 0
  331. rng.Position = torso.Position - Vector3.new(0,2,0)
  332. rng.CFrame = rng.CFrame * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0))
  333. rngm.MeshId = 'http://www.roblox.com/asset/?id=3270017'
  334. boom:Play()
  335. for i = 1, 60, 2 do
  336. rng.Transparency = i/60
  337. end
  338. rng:Destroy()
  339. for i,v in pairs(torso:GetChildren()) do if v:IsA('BodyVelocity') then
  340. v:Destroy() wait(2) jumping2 = true hum.WalkSpeed = 16
  341. wait()
  342. wait(.1)
  343. end
  344. end)
  345. if k 'f' then
  346. asd2:Stop()
  347. asd6:Stop()
  348. end
  349. ------------
p = game.Players.LocalPlayer char = p.Character des = false fling = true dot = false falling = false jump = true --char.Shirt:Remove() --for i,v in pairs(char:GetChildren()) do if v:IsA('Pants') then v:Remove() end end for i,v in pairs(char:GetChildren()) do if v:IsA('Hat') then v.Handle:Remove() end end wait()--shirt = Instance.new('Shirt', char) --shirt.Name = 'Shirt' --pants = Instance.new('Pants', char) --pants.Name = 'Pants' --char.Shirt.ShirtTemplate = 'http://www.roblox.com/asset/?id=433403860' --char.Pants.PantsTemplate = 'http://www.roblox.com/asset/?id=433408506' tp = true shoot = true hum = char.Humanoid punch = true neckp = char.Torso.Neck.C0 neck = char.Torso.Neck hum.MaxHealth = 999999999 wait() hum.Health =hum.MaxHealth des = false root=char.HumanoidRootPart torso = char.Torso char.Head.face.Texture = 'rbxassetid://420259243' local ChatService = game:GetService('Chat') local player = game.Players.LocalPlayer lig = Instance.new('PointLight',player.Character.Torso) lig.Color=Color3.new(255,0,0) m=player:GetMouse() bb = Instance.new('BillboardGui',player.Character.Head) bb.Enabled = true function newRay(start,face,range,wat) local rey=Ray.new(start.p,(face.p-start.p).Unit*range) hit,pos=Workspace:FindPartOnRayWithIgnoreList(rey,wat) return rey,hit,pos end aa1={} torso=game.Players.LocalPlayer.Character.Torso local WorldUp = Vector3.new(0,1,0) function look2(Vec1,Vec2) local Orig = Vec1 Vec1 = Vec1+Vector3.new(0,1,0) Vec2 = Vec2+Vector3.new(0,1,0) local Forward = (Vec2-Vec1).unit local Up = (WorldUp-WorldUp:Dot(Forward)*Forward).unit local Right = Up:Cross(Forward).unit Forward = -Forward Right = -Right return CFrame.new(Orig.X,Orig.Y,Orig.Z,Right.X,Up.X,Forward.X,Right.Y,Up.Y,Forward.Y,Right.Z,Up.Z,Forward.Z) end function look(CFr,Vec2) local A = Vector3.new(0,0,0) local B = CFr:inverse()*Vec2 local CF = look2(A,Vector3.new(A.X,B.Y,B.Z)) if B.Z > 0 then CF = CFr*(CF*CFrame.Angles(0,0,math.pi)) elseif B.Z 0 then if B.Y > 0 then CF = CFr*CFrame.Angles(math.pi/2,0,0) elseif B.Y < 0 then CF = CFr*CFrame.Angles(-math.pi/2,0,0) else CF = CFr end end local _,_,_,_,X,_,_,Y,_,_,Z,_ = CF:components() local Up = Vector3.new(X,Y,Z) local Forward = (Vec2-CFr.p).unit local Right = Up:Cross(Forward) Forward = -Forward Right = -Right return CFrame.new(CFr.X,CFr.Y,CFr.Z,Right.X,Up.X,Forward.X,Right.Y,Up.Y,Forward.Y,Right.Z,Up.Z,Forward.Z) end function simulate(j,d,m,r,t) local joint = j for i,v in ipairs(t) do if v[1]:FindFirstChild('Weld') then local stiff = m.CFrame.lookVector*0.03 if i > 1 then joint = t[i-1][1].CFrame*CFrame.new(0,0,d*.5) end local dir = (v[2].p-(joint.p+Vector3.new(0,0.2,0)+stiff)).unit local dis = (v[2].p-(joint.p+Vector3.new(0,0.2,0)+stiff)).magnitude local pos = joint.p+(dir*(d*0.5)) --if v[1].CFrame.y<=workspace.Base.CFrame.y then pos = joint.p+(dir*(d*.5)) end local inv = v[1].Weld.Part0.CFrame local rel1 = inv:inverse()*pos local rel2 = inv:inverse()*(pos-(dir*dis)) local cf = look(CFrame.new(rel1),rel2)--CFrame.new(pos,pos-(dir*dis))*CFrame.fromEulerAnglesXYZ(r.x,r.y,r.z) v[1].Weld.C0 = cf v[2] = inv*cf --v[1].CFrame = cf end end end for i=1,8 do local p = Instance.new('Part',char) p.Anchored = false p.BrickColor = BrickColor.new('Institutional white') p.CanCollide = false p.FormFactor='Custom' p.Material = 'SmoothPlastic' p.TopSurface = 'SmoothNoOutlines' p.BottomSurface = 'SmoothNoOutlines' p.RightSurface = 'SmoothNoOutlines' p.LeftSurface = 'SmoothNoOutlines' p.FrontSurface = 'SmoothNoOutlines' p.BackSurface = 'SmoothNoOutlines' p.Size=Vector3.new(2,.2,0.2) p:BreakJoints() -- sometimes the parts are stuck to something so you have to breakjoints them mesh = Instance.new('BlockMesh',p) mesh.Scale = Vector3.new(1,1,4) local w = Instance.new('Motor6D',p) w.Part0 = aa1[i-1] and aa1[i-1][1] or torso w.Part1 = p w.Name = 'Weld' --table.insert(aa1,p) aa1[i] = {p,p.CFrame} end game:service'RunService'.Stepped:connect(function() simulate(torso.CFrame*CFrame.new(0,0.9,.5),.6,torso,Vector3.new(),aa1) end) bb.AlwaysOnTop = true bb.Size = UDim2.new(0,200,0,50) bb.StudsOffset = Vector3.new(0,1,0) gui=Instance.new('TextBox',bb) gui.Text = '* ' gui.Size = UDim2.new(0,133,0,45) gui.Position=UDim2.new(0,57,0,-40) gui.TextColor3 = Color3.new(255,255,255) gui.BackgroundColor3=Color3.new(0,0,0) gui.TextWrapped = true gui.TextScaled = true gui.TextXAlignment = 'Left' gui.TextYAlignment = 'Top' gui.Visible = false gui.BorderColor3 = Color3.new(0,0,0) punch2 = true gui1=Instance.new('TextButton',bb) gui1.Position=UDim2.new(0,5,0,-43) gui1.Size = UDim2.new(0,190,0,51) gui1.TextColor3 = Color3.new(255,255,255) gui1.BackgroundColor3=Color3.new(255,255,255) jump2 = true gui1.Visible = false img = Instance.new('ImageLabel',bb) img.Size = UDim2.new(0,46,0,47) img.Position = UDim2.new(0,10,0,-41) img.Image = 'rbxassetid://447301252' img.BorderColor3 = Color3.new(0,0,0) img.Visible = false soka = Instance.new('Sound',char) soka.SoundId = 'http://www.roblox.com/asset/?id = 447199232' soka.Volume = 1 boom = Instance.new('Sound',char) boom.SoundId = 'http://www.roblox.com/asset/?id = 447041606' boom.Volume = 1 boom2 = Instance.new('Sound',char) boom2.SoundId = 'http://www.roblox.com/asset/?id = 449025737' boom2.Volume = 1 boom3 = Instance.new('Sound',char) boom3.SoundId = 'http://www.roblox.com/asset/?id = 450719019' boom3.Volume = 1 tps = Instance.new('Sound',char) tps.SoundId = 'http://www.roblox.com/asset/?id = 449860746' tps.Volume = 1 asd = Instance.new('Sound',char) asd.SoundId = 'http://www.roblox.com/asset/?id = 447310433' asd.Volume =1 asd1 = Instance.new('Sound',char) asd1.SoundId = 'http://www.roblox.com/asset/?id = 358280695' asd2 = Instance.new('Sound',char) asd2.SoundId = 'http://www.roblox.com/asset/?id = 386713054' asd2.Looped = true asd2.Volume = 5 asd3 = Instance.new('Sound',char) asd3.SoundId = 'http://www.roblox.com/asset/?id = 378387996' asd3.Looped = true asd4 = Instance.new('Sound',char) asd4.SoundId = 'http://www.roblox.com/asset/?id = 401258325' asd4.Looped = true asd5 = Instance.new('Sound',char) asd5.SoundId = 'http://www.roblox.com/asset/?id = 362252261' asd5.Looped = true gas = Instance.new('Sound',char) gas.SoundId = 'http://www.roblox.com/asset/?id = 345052019' asd6 = Instance.new('Sound',char) asd6.SoundId = 'http://www.roblox.com/asset/?id = 401258325' asd6.Looped = true function play(play) asd:Play() wait(0.05) --asd1:Play() end ------------ ------------------------- function stream(origin,dir,length,size) local parts = {} for i = 1,length do local p = Instance.new('Part',char) p.Anchored = true p.Transparency = 0.5 p.TopSurface = 0 p.BottomSurface = 0 p.CanCollide = false p.BrickColor = BrickColor.new('Institutional white') p.Size = Vector3.new(10,30,10) -- for now p.CFrame = CFrame.new(origin+dir*i*size)*CFrame.Angles(math.random()*math.pi,math.random()*math.pi,math.random()*math.pi) parts[i] = {p,CFrame.Angles(math.random()*math.pi/5,math.random()*math.pi/5,math.random()*math.pi/5)} game:GetService('Debris'):AddItem(p,3) end Spawn(function() while parts do for i,v in pairs(parts) do if v[1].Parent char then v[1].CFrame = v[1].CFrame*v[2] else parts = nil break end end wait(0.02) end end) end --[[-- listen for their chatting player.Chatted:connect(function(message) a = string.len(message) gui.Text = ' gui.Visible = true gui1.Visible = true des = false img.Visible = true print(a) if dot false then gui.Text = ' for i = 1,string.len(message) do gui.Text =gui.Text..message:sub(i,i) play() end end des = true end)]]-- m.KeyDown:connect(function(k) if k 'g' then asd2:Play() end end) m.KeyDown:connect(function(k) if k 'r' then asd4:Play() end end) m.KeyDown:connect(function(k) if k 'q' then asd3:Play() end end) m.KeyDown:connect(function(k) if k 'z' then img.Image = 'rbxassetid://332766052' end end) m.KeyDown:connect(function(k) if k 'c' then img.Image = 'rbxassetid://447301252' end end) m.KeyDown:connect(function(k) if k 'b' then asd6:Play() end end) mouse = p:GetMouse() m.KeyDown:connect(function(k) if k:byte() 48 then hum.WalkSpeed = 100 end end) m.KeyDown:connect(function(k) if k:byte() 50 then soka:Play() end end) m.KeyDown:connect(function(k) if k:byte() 52 then char.Head.face.Texture = 'rbxassetid://444037452' end end) m.KeyDown:connect(function(k) if k:byte() 51 then char.Head.face.Texture = 'rbxassetid://332768867' end end) m.KeyUp:connect(function(k) if k:byte() 48 then hum.WalkSpeed = 16 end end) p.Chatted:connect(function(m) if m 'Okay.' then soka:Play() end end) m.KeyDown:connect(function(k) if k 'x' then if des true then gui.Visible = false gui.Text = '* ' gui1.Visible = false img.Visible = false end end end) m.KeyDown:connect(function(key) if key 'j' then if tp true then tp = false tps:Play() char.Head.face.Parent = game.Lighting for i,v in pairs(char:GetChildren()) do if v:IsA('Part') then v.Transparency = 1 end end wait(0.5) for i,v in pairs(char:GetChildren()) do if v:IsA('Part') then v.Transparency = 0 end end char.HumanoidRootPart.CFrame = mouse.Hit * CFrame.new(0, 3, 0) char.HumanoidRootPart.Transparency = 1 game.Lighting.face.Parent = char.Head wait(0.2) tp = true end end end) m.KeyDown:connect(function(key) if key 't' then if punch2 true then punch2 = false punch = false local ChatService = game:GetService('Chat') neck.C0 = neck.C0 * CFrame.Angles(0.3,0,0) ChatService:Chat(char.Head, 'I...will become a hero!') wait(1) local ChatService = game:GetService('Chat') ChatService:Chat(char.Head ,'I...I-I can do this!') wait(1) local ChatService = game:GetService('Chat') ChatService:Chat(char.Head, 'DETROIT SMAAAAAAAAAAAASH!') neck.C0 = neckp wait(0.6) org = char.Torso['Left Shoulder'].C0 char.Torso['Left Shoulder'].C0 = char.Torso['Left Shoulder'].C0 * CFrame.new(-0.3,0,0) * CFrame.Angles(0,0,math.rad(-90)) wait() killbrick2 = Instance.new('Part',char) killbrick2.Size = Vector3.new(80,80,9000) killbrick2.Transparency = 1 killbrick2.CanCollide = true wait(0.1) killbrick2.CanCollide = false killbrick2.Anchored = true killbrick2.CFrame = char.Torso.CFrame * CFrame.new(0,0,-1005) killbrick2.Touched:connect(function(h) local x = h.Parent:FindFirstChild('Humanoid') if x then if x.Parent.Name game.Players.LocalPlayer.Name then safe = true else safe = false end if x then if safe false then h.Parent.Torso.Velocity = CFrame.new(char.Torso.Position,h.Parent.Torso.Position).lookVector * 900 local bodyforc = Instance.new('BodyForce', h.Parent.Torso) boom:Play() bodyforc.force = Vector3.new(0, h.Parent.Torso:GetMass() * 196.1, 0) wait(0.2) x.Parent:BreakJoints() wait() safe = true end end end end) local rng = Instance.new('Part', char) rng.Anchored = true rng.BrickColor = BrickColor.new('Persimmon') rng.CanCollide = false rng.FormFactor = 3 rng.Name = 'Ring' rng.Size = Vector3.new(1, 1, 1) rng.Transparency = 0.8 rng.TopSurface = 0 rng.BottomSurface = 0 rng.CFrame = char['Left Arm'].CFrame * CFrame.new(0,-2,0) --rng.Rotation = Vector3.new(math.pi/2,0,0) rng.CFrame = rng.CFrame * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)) local rngm = Instance.new('SpecialMesh', rng) rngm.MeshId = 'http://www.roblox.com/asset/?id=3270017' rngm.Scale = Vector3.new(1, 1.3, 2) local rng1 = Instance.new('Part', char) rng1.Anchored = true rng1.BrickColor = BrickColor.new('Persimmon') rng1.CanCollide = false rng1.FormFactor = 3 rng1.Name = 'Ring' rng1.Size = Vector3.new(1, 1, 1) rng1.Transparency = 0.8 rng1.TopSurface = 0 rng1.BottomSurface = 0 rng1.CFrame = char['Left Arm'].CFrame * CFrame.new(0,-2,0) --rng1.Rotation = Vector3.new(math.pi/2,0,0) rng1.CFrame = rng1.CFrame * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)) local rngm1 = Instance.new('SpecialMesh', rng1) rngm1.MeshId = 'http://www.roblox.com/asset/?id=3270017' rngm1.Scale = Vector3.new(1, 1.3, 2) local p = (torso.CFrame*CFrame.new(-20,0,3)) stream(p.p,((p*Vector3.new(-0.7,0,1))-p.p).unit,90,5) -- 20 is number of parts, 6 is distance between each one local p = (torso.CFrame*CFrame.new(20,0,3)) stream(p.p,((p*Vector3.new(0.7,0,1))-p.p).unit,90,5) -- same here local rng2 = Instance.new('Part', char) rng2.Anchored = true rng2.BrickColor = BrickColor.new('Persimmon') rng2.CanCollide = false rng2.FormFactor = 3 rng2.Name = 'Ring' rng2.Size = Vector3.new(1, 1, 1) rng2.Transparency = 0.8 rng2.TopSurface = 0 rng2.BottomSurface = 0 rng2.CFrame = char['Left Arm'].CFrame * CFrame.new(0,-2,0) --rng1.Rotation = Vector3.new(math.pi/2,0,0) rng2.CFrame = rng2.CFrame * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)) local rngm2 = Instance.new('SpecialMesh', rng2) rngm2.MeshId = 'http://www.roblox.com/asset/?id=3270017' rngm2.Scale = Vector3.new(1, 1.3, 2) wait(0.1) boom3:Play() coroutine.wrap(function() for i = 1, 35, 0.5 do rngm.Scale = Vector3.new(50 + i*2, 10 + i*2, 2.5+ i*4) rngm1.Scale = Vector3.new(50 + i*2, 1.4 + i*2, 1.4+ i*4) rngm2.Scale = Vector3.new(50 + i*2, 10 + i*2, 1.2+ i*4) wait() end wait() rng:Destroy() rng1:Destroy() rng2:Destroy() killbrick2:Remove() wait(0.5) char.Torso['Left Shoulder'].C0 = org wait(1) punch2 = true punch = true wait() end)() end wait(.1) end end) m.KeyDown:connect(function(key) if key 'k' then if punch true then punch = false org = char.Torso['Left Shoulder'].C0 char.Torso['Left Shoulder'].C0 = char.Torso['Left Shoulder'].C0 * CFrame.new(-0.3,0,0) * CFrame.Angles(0,0,math.rad(-90)) killbrick = Instance.new('Part',char) killbrick.Size = Vector3.new(5,1,5) killbrick.Transparency = 1 killbrick:BreakJoints() killbrick.CanCollide = false local wel = Instance.new('Weld',killbrick) wel.Part0 = killbrick wel.Part1 = char['Left Arm'] wel.C0 = CFrame.new(0,1,0) force = 90 killbrick.Touched:connect(function(h) local x = h.Parent.Humanoid if x.Health >= 6000 then fling = false end if x.Health < 6000 then fling = true end local stop = h.Parent.Torso.Velocity if x.Parent.Name game.Players.LocalPlayer.Name then safe = true else safe = false end if x then if safe false then if fling true then force = 900 end if fling false then force = 200 end h.Parent.Torso.Velocity = CFrame.new(char.Torso.Position,h.Parent.Torso.Position).lookVector * force local bodyforc = Instance.new('BodyForce', h.Parent.Torso) boom:Play() bodyforc.force = Vector3.new(0, h.Parent.Torso:GetMass() * 196.1, 0) wait(0.2) x:TakeDamage(5000) wait() safe = true bodyforc:Remove() h.Parent.Torso.Velocity = stop end end end) local rng = Instance.new('Part', char) rng.Anchored = true rng.BrickColor = BrickColor.new('Institutional white') rng.CanCollide = false rng.FormFactor = 3 rng.Name = 'Ring' rng.Size = Vector3.new(1, 1, 1) rng.Transparency = 0.8 rng.TopSurface = 0 rng.BottomSurface = 0 rng.CFrame = char['Left Arm'].CFrame * CFrame.new(0,-2,0) --rng.Rotation = Vector3.new(math.pi/2,0,0) rng.CFrame = rng.CFrame * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)) local rngm = Instance.new('SpecialMesh', rng) rngm.MeshId = 'http://www.roblox.com/asset/?id=3270017' rngm.Scale = Vector3.new(1, 1.3, 2) wait(0.1) boom2:Play() coroutine.wrap(function() for i = 1, 10, .4 do rngm.Scale = Vector3.new(2 + i*2, 2 + i*2, 1) wait() end wait() rng:Destroy() killbrick:Remove() wait(0.5) char.Torso['Left Shoulder'].C0 = org wait(1) punch = true wait() end)() end wait(.1) end end) m.KeyDown:connect(function(key) if key 'm' then if jump true then jump = false local rng = Instance.new('Part', char) rng.Anchored = true rng.BrickColor = BrickColor.new('Institutional white') rng.CanCollide = false rng.FormFactor = 3 rng.Name = 'Ring' rng.Size = Vector3.new(1, 1, 1) rng.Transparency = 0.35 rng.TopSurface = 0 rng.BottomSurface = 0 rng.Position = torso.Position - Vector3.new(0,2,0) rng.CFrame = rng.CFrame * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)) local rngm = Instance.new('SpecialMesh', rng) rngm.MeshId = 'http://www.roblox.com/asset/?id=3270017' rngm.Scale = Vector3.new(1, 1.3, 2) wait(0.1) BV = Instance.new('BodyVelocity', torso) BV.maxForce = Vector3.new(0,20000,0) BV.P = 1000 BV.velocity = Vector3.new(0,100,0) boom:Play() coroutine.wrap(function() for i = 1, 60, 2 do rngm.Scale = Vector3.new(2 + i*2, 2 + i*2, 1) rng.Transparency = i/60 wait() end wait() rng:Destroy() hum.WalkSpeed = 50 wait(1) for i,v in pairs(torso:GetChildren()) do if v:IsA('BodyVelocity') then v:Destroy() jumping2 = true falling = true wait(0.3) jumping2 = false falling = false wait(1.7) jump = true hum.WalkSpeed = 16 falling = false end end wait() end)() end wait(.1) end end) m.KeyDown:connect(function(key) if key 'n' then if falling true then falling = false if jumping2 true then jumping2 = false jump = false BV = Instance.new('BodyVelocity', torso) BV.maxForce = Vector3.new(0,-20000,0) BV.P = -1000 BV.velocity = Vector3.new(0,-70,0) wait(0.6) local rng = Instance.new('Part', char) rng.Anchored = true rng.BrickColor = BrickColor.new('Institutional white') rng.CanCollide = false rng.FormFactor = 3 rng.Name = 'Ring' rng.Size = Vector3.new(1, 1, 1) rng.Transparency = 0.35 rng.TopSurface = 0 rng.BottomSurface = 0 rng.Position = torso.Position - Vector3.new(0,2,0) rng.CFrame = rng.CFrame * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)) local rngm = Instance.new('SpecialMesh', rng) rngm.MeshId = 'http://www.roblox.com/asset/?id=3270017' rngm.Scale = Vector3.new(1, 1.3, 2) boom:Play() coroutine.wrap(function() for i = 1, 60, 2 do rngm.Scale = Vector3.new(2 + i*2, 2 + i*2, 1) rng.Transparency = i/60 wait() end wait() rng:Destroy() for i,v in pairs(torso:GetChildren()) do if v:IsA('BodyVelocity') then v:Destroy() wait(2) jumping2 = true hum.WalkSpeed = 16 end end wait() end)() end wait(.1) end end end) m.KeyDown:connect(function(k) if k 'f' then asd3:Stop() asd2:Stop() asd4:Stop() asd6:Stop() asd5:Stop() end end) ------------ -- ~CLarramore 2016

A generic library useful when you need to work with points/vectors in 2d space.

Use

Stuff to Note: most of the Vec2's methods take a returnNew as the last parameter. If passed a truthy value, a new vector will be returned to you. Otherwise the operation will be applied to this and this will be returned.

Also, since Infinityand NaN are so insidious, this library will throw as soon as it detects either of these so you can take action to fix your data/algorithm.

Supported operations

change([fn])

Add an observer fn that will be called whenever this vector changes. Calling this method without a function causes it to notify observers.

fn signature: function(vec, prev) {} - where prev is a clone of the vector before the last operation.

this function returns the passed fn

returns: Vec2

ignore([fn])

Vec2 Pack

Pass a fn to remove it from the observers list. Calling this function without a fn will remove all observers.

returns: Vec2

set(x, y [, notify]) or set(vec2 [, notify])

Sets the x and y coordinates of this vector. If false is passed for notify, none of the observers will be called.

returns: Vec2

zero()

Sets the x and y of this vector to 0

returns: Vec2

clone()

Returns a clone of this vector.

Note: this does not clone observers

returns: Vec2

negate([returnNew])

Negate the x and y coords of this vector. If returnNew is truthy, a new vector with the negated coordinates will be returned.

returns: Vec2

add(x, y [, returnNew]) or add(array, [, returnNew]) or add(vec2 [, returnNew])

Add the x and y to this vector's coordinates.

If returnNew is truthy, return a new vector containing the resulting coordinates. Otherwise apply them to this vector and return it.

returns: Vec2

subtract(x, y [, returnNew]) or subtract(array, [, returnNew]) or subtract(vec2 [, returnNew])

returns: Vec2

multiply(scalar [, returnNew]) or multiply(x, y [, returnNew]) or multiply(array, [, returnNew]) or multiply(vec2 [, returnNew])

Multiply this vectors components with the incoming, returning a clone if returnNew is truthy.

returns: Vec2

divide(scalar [, returnNew]) or divide(x, y [, returnNew]) or divide(array, [, returnNew]) or divide(vec2 [, returnNew])

Divide this vectors components by the incoming, returning a clone if returnNew is truthy.

note: this method will throw if you attempt to divide by zero or pass values that cause NaNs

returns: Vec2

rotate(radians [, inverse [, returnNew]])

Rotate this vector's cordinates around (0,0). If returnNew is specified, a new Vec2 will be created and populated with the result and returned. Otherwise the result is applied to this vector and this is returned.

inverse - inverts the direction of the rotation

returnNew - causes the result to be applied to a new Vec2, otherwise the result is applied to this

Vec

returns: Vec2

Vec2 pack download

length()

Returns the length of this vector from (0,0)

returns: double

lengthSquared()

Returns the length of this vector prior to the Math.sqrt call.

This is usefull when you don't need to know the actual distance, but need a normalized value to compare with another Vec2#lengthSquared or similar.

Vec package

Pass a fn to remove it from the observers list. Calling this function without a fn will remove all observers.

returns: Vec2

set(x, y [, notify]) or set(vec2 [, notify])

Sets the x and y coordinates of this vector. If false is passed for notify, none of the observers will be called.

returns: Vec2

zero()

Sets the x and y of this vector to 0

returns: Vec2

clone()

Returns a clone of this vector.

Note: this does not clone observers

returns: Vec2

negate([returnNew])

Negate the x and y coords of this vector. If returnNew is truthy, a new vector with the negated coordinates will be returned.

returns: Vec2

add(x, y [, returnNew]) or add(array, [, returnNew]) or add(vec2 [, returnNew])

Add the x and y to this vector's coordinates.

If returnNew is truthy, return a new vector containing the resulting coordinates. Otherwise apply them to this vector and return it.

returns: Vec2

subtract(x, y [, returnNew]) or subtract(array, [, returnNew]) or subtract(vec2 [, returnNew])

returns: Vec2

multiply(scalar [, returnNew]) or multiply(x, y [, returnNew]) or multiply(array, [, returnNew]) or multiply(vec2 [, returnNew])

Multiply this vectors components with the incoming, returning a clone if returnNew is truthy.

returns: Vec2

divide(scalar [, returnNew]) or divide(x, y [, returnNew]) or divide(array, [, returnNew]) or divide(vec2 [, returnNew])

Divide this vectors components by the incoming, returning a clone if returnNew is truthy.

note: this method will throw if you attempt to divide by zero or pass values that cause NaNs

returns: Vec2

rotate(radians [, inverse [, returnNew]])

Rotate this vector's cordinates around (0,0). If returnNew is specified, a new Vec2 will be created and populated with the result and returned. Otherwise the result is applied to this vector and this is returned.

inverse - inverts the direction of the rotation

returnNew - causes the result to be applied to a new Vec2, otherwise the result is applied to this

returns: Vec2

length()

Returns the length of this vector from (0,0)

returns: double

lengthSquared()

Returns the length of this vector prior to the Math.sqrt call.

This is usefull when you don't need to know the actual distance, but need a normalized value to compare with another Vec2#lengthSquared or similar.

returns: double

distance(vec2)

returns: the distance between this vector and the incoming

nearest(array)

returns: closest vector in array to this vector.

normalize([returnNew])

Normalizes this vector. If returnNew is truthy, a new vector populated with the normalized coordinates will be returned.

returns: Vec2

equal(vec2) or equal(x, y) or equal(array)

returns true if the incoming coordinates are the same as this vector's

returns: boolean

abs([returnNew])

Return a Vec2 that contains the absolute value of each of this vector's parts.

Vec2 Sample Pack

If returnNew is truthy, create a new Vec2 and return it. Otherwise apply the absolute values to to this.

returns: Vec2

min(vec)

Return a Vec2 consisting of the smallest values from this vector and the incoming

When returnNew is truthy, a new Vec2 will be returned otherwise the minimum values in either this or vec will be applied to this vector.

returns: Vec2

max(vec)

Return a Vec2 consisting of the largest values from this vector and the incoming

When returnNew is truthy, a new Vec2 will be returned otherwise the maximum values in either this or vec will be applied to this vector.

returns: Vec2

clamp(low, high [, returnNew])

Clamp the coordinates of this vector to the high/low of the incoming vec2s. If returnNew apply the result to the new vector and return. Otherwise apply to this vector.

returns: Vec2

lerp(vec, amount [, returnNew])

Perform linear interpolation between this vector and the incoming.

amount - the percentage along the path to place the vector

returnNew - if truthy, apply the result to a new vector and return it, otherwise return this

returns: Vec2

skew([returnNew])

Returns a vector set with the (-y,x) coordinates of this vector. If returnNew a new vector is created and the operation is applied to the new vector.

returns: Vec2

dot()

returns: double

perpDot()

returns: double

angleTo(vec)

returns the angle from this vector to the incoming.

returns: double

isPointOnLine(start, end)

where start and end are vec2-like (e.g. start.x and start.y)

returns: boolean

toArray()

returns: [x, y]

fromArray(array)

Applies the [0] to this.x and [1] to this.y

returns: Vec2

toJSON()

returns: { x: ..., y: ...}

toString()

returns: '(x, y)'

Install

Browser

Vec2 Pack Download

Node

install with npm

and then require it!

License

Vec Package

MIT (see LICENSE.txt)





broken image