Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- spawn(function()
- local vector={}
- local cframe={}
- local trash={}
- local event={}
- local physics={}
- local sound={}
- local tween={}
- local animation={}
- local replication={}
- if not owner then
- owner = game.Players.LocalPlayer
- end
- local plr = owner
- repeat wait(.2) until plr.Character
- local char = plr.Character
- spawn(function()
- for i = 1,10 do
- if char:FindFirstChild("Shirt Graphic") then
- char:FindFirstChild("Shirt Graphic"):Destroy()
- end
- if char:FindFirstChild("Head") then
- char.Head.Color = Color3.fromRGB(255, 255, 255)
- if char.Head:FindFirstChild("face") then
- char.Head.face.Texture = "rbxasset://textures/face.png"
- end
- plr.Character.Humanoid:RemoveAccessories()
- if char:FindFirstChild("Clothing1") then else
- local pants = Instance.new("Pants")
- pants.Name = "Clothing1"
- pants.PantsTemplate = "http://www.roblox.com/asset/?id=341106594"
- pants.Parent = char
- end
- if char:FindFirstChild("Clothing2") then else
- local pants = Instance.new("Shirt")
- pants.Name = "Clothing2"
- pants.ShirtTemplate = "http://www.roblox.com/asset/?id=399707708"
- pants.Parent = char
- end
- end
- for i,v in pairs(char:GetChildren()) do
- if v.Name == "Clothing1" or v.Name == "Clothing2" then else
- if v.ClassName=="Pants" then
- v:Destroy()
- elseif v.ClassName == "Shirt" then
- v:Destroy()
- end
- end
- end
- end
- end)
- local loltimescale=1
- local lolgravity=Vector3.new(0,-196.2,0)local loltick=tick
- local function tick()
- return loltimescale*loltick()
- end
- math.randomseed(tick())
- local realprint=print
- --local print=function() end
- if loltimescale>=2 then
- local s=Instance.new("Sound",game.Workspace)
- s.SoundId="http://roblox.com/asset/?id=145542130"
- s.Looped=true
- s:Play()
- end
- do
- local sort =table.sort
- local atan2 =math.atan2
- local inf =math.huge
- local cos =math.cos
- local sin =math.sin
- local setmetatable =setmetatable
- local tick =tick
- local dot =Vector3.new().Dot
- physics.spring ={}
- do
- local cos=math.cos
- local sin=math.sin
- local e=2.718281828459045
- local setmt=setmetatable
- local error=error
- local tostring=tostring
- local tick=tick
- local function posvel(d,s,p0,v0,p1,v1,x)
- if s==0 then
- return p0
- elseif d<1-1e-8 then
- local h=(1-d*d)^0.5
- local c1=(p0-p1+2*d/s*v1)
- local c2=d/h*(p0-p1)+v0/(h*s)+(2*d*d-1)/(h*s)*v1
- local co=cos(h*s*x)
- local si=sin(h*s*x)
- local ex=e^(d*s*x)
- return co/ex*c1+si/ex*c2+p1+(x-2*d/s)*v1,
- s*(co*h-d*si)/ex*c2-s*(co*d+h*si)/ex*c1+v1
- elseif d<1+1e-8 then
- local c1=p0-p1+2/s*v1
- local c2=p0-p1+(v0+v1)/s
- local ex=e^(s*x)
- return (c1+c2*s*x)/ex+p1+(x-2/s)*v1,
- v1-s/ex*(c1+(s*x-1)*c2)
- else
- local h=(d*d-1)^0.5
- local a=(v1-v0)/(2*s*h)
- local b=d/s*v1-(p1-p0)/2
- local c1=(1-d/h)*b+a
- local c2=(1+d/h)*b-a
- local co=e^(-(h+d)*s*x)
- local si=e^((h-d)*s*x)
- return c1*co+c2*si+p1+(x-2*d/s)*v1,
- si*(h-d)*s*c2-co*(d+h)*s*c1+v1
- end
- end
- local function targposvel(p1,v1,x)
- return p1+x*v1,v1
- end
- function physics.spring.new(initial)
- local d=1
- local s=1
- local p0=initial or 0
- local v0=0*p0
- local p1=p0
- local v1=v0
- local t0=tick()
- local self={}
- local meta={}
- function self.getpv()
- return posvel(d,s,p0,v0,p1,v1,tick()-t0)
- end
- function self.setpv(p,v)
- local time=tick()
- local tp,tv=targposvel(p1,v1,time-t0)
- p0,v0=p,v
- p1,v1=tp,tv
- t0=time
- end
- function self.settargetpv(tp,tv)
- local time=tick()
- local p,v=posvel(d,s,p0,v0,p1,v1,time-t0)
- p0,v0=p,v
- p1,v1=tp,tv
- t0=time
- end
- function self:accelerate(a)
- local time=tick()
- local p,v=posvel(d,s,p0,v0,p1,v1,time-t0)
- local tp,tv=targposvel(p1,v1,time-t0)
- p0,v0=p,v+a
- p1,v1=tp,tv
- t0=time
- end
- function meta.__index(self,index)
- local time=tick()
- if index=="p" or index=="position" then
- local p,v=posvel(d,s,p0,v0,p1,v1,time-t0)
- return p
- elseif index=="v" or index=="velocity" then
- local p,v=posvel(d,s,p0,v0,p1,v1,time-t0)
- return v
- elseif index=="tp" or index=="t" or index=="targetposition" then
- local tp,tv=targposvel(p1,v1,time-t0)
- return tp
- elseif index=="tv" or index=="targetvelocity" then
- local tp,tv=targposvel(p1,v1,time-t0)
- return tv
- elseif index=="d" or index=="damper" then
- return d
- elseif index=="s" or index=="speed" then
- return s
- else
- error("no value "..tostring(index).." exists")
- end
- end
- function meta.__newindex(self,index,value)
- local time=tick()
- if index=="p" or index=="position" then
- local p,v=posvel(d,s,p0,v0,p1,v1,time-t0)
- local tp,tv=targposvel(p1,v1,time-t0)
- p0,v0=value,v
- p1,v1=tp,tv
- elseif index=="v" or index=="velocity" then
- local p,v=posvel(d,s,p0,v0,p1,v1,time-t0)
- local tp,tv=targposvel(p1,v1,time-t0)
- p0,v0=p,value
- p1,v1=tp,tv
- elseif index=="tp" or index=="t" or index=="targetposition" then
- local p,v=posvel(d,s,p0,v0,p1,v1,time-t0)
- local tp,tv=targposvel(p1,v1,time-t0)
- p0,v0=p,v
- p1,v1=value,tv
- elseif index=="tv" or index=="targetvelocity" then
- local p,v=posvel(d,s,p0,v0,p1,v1,time-t0)
- local tp,tv=targposvel(p1,v1,time-t0)
- p0,v0=p,v
- p1,v1=tp,value
- elseif index=="d" or index=="damper" then
- local p,v=posvel(d,s,p0,v0,p1,v1,time-t0)
- local tp,tv=targposvel(p1,v1,time-t0)
- p0,v0=p,v
- p1,v1=tp,tv
- d=value
- elseif index=="s" or index=="speed" then
- local p,v=posvel(d,s,p0,v0,p1,v1,time-t0)
- local tp,tv=targposvel(p1,v1,time-t0)
- p0,v0=p,v
- p1,v1=tp,tv
- s=value
- elseif index=="a" or index=="acceleration" then
- local time=tick()
- local p,v=posvel(d,s,p0,v0,p1,v1,time-t0)
- local tp,tv=targposvel(p1,v1,time-t0)
- p0,v0=p,v+value
- p1,v1=tp,tv
- t0=time
- else
- error("no value "..tostring(index).." exists")
- end
- t0=time
- end
- return setmt(self,meta)
- end
- end
- local function rootreals4(a,b,c,d,e)
- local x0,x1,x2,x3
- local m10=3*a
- local m0=-b/(4*a)
- local m4=c*c-3*b*d+12*a*e
- local m6=(b*b/(4*a)-2/3*c)/a
- local m9=((b*(4*c-b*b/a))/a-(8*d))/a
- local m5=c*(2*c*c-9*b*d-72*a*e)+27*a*d*d+27*b*b*e
- local m11=m5*m5-4*m4*m4*m4
- local m7
- if m11<0 then--Optimize
- local th=atan2((-m11)^0.5,m5)/3
- local m=((m5*m5-m11)/4)^(1/6)
- m7=(m4/m+m)/m10*cos(th)
- else--MAY NEED CASE FOR WHEN 2*c*c*c-9*b*c*d+27*a*d*d+27*b*b*e-72*a*c*e+((2*c*c*c-9*b*c*d+27*a*d*d+27*b*b*e-72*a*c*e)^2-4*(c*c-3*b*d+12*a*e)^3)^(1/2)=0
- local m8=(m5+m11^0.5)/2
- m8=m8<0 and -(-m8)^(1/3) or m8^(1/3)
- m7=(m4/m8+m8)/m10
- end
- local m2=2*m6-m7
- --print("m2",m2,0)
- local m12=m6+m7
- if m12<0 then
- local m3i=m9/(4*(-m12)^0.5)
- local m13=(m3i*m3i+m2*m2)^(1/4)*cos(atan2(m3i,m2)/2)/2
- --In order
- x0=m0-m13
- x1=m0-m13
- x2=m0+m13
- x3=m0+m13
- else
- local m1=m12^0.5
- --print("m1",m1,0)
- local m3=m9/(4*m1)
- --print("m3",m3,0)
- local m14=m2-m3
- local m15=m2+m3
- if m14<0 then
- x0=m0-m1/2
- x1=m0-m1/2
- else
- local m16=m14^0.5
- x0=m0-(m1+m16)/2
- x1=m0-(m1-m16)/2
- end
- if m15<0 then
- x2=m0+m1/2
- x3=m0+m1/2
- else
- local m17=m15^0.5
- x2=m0+(m1-m17)/2
- x3=m0+(m1+m17)/2
- end
- --bubble sort lel
- if x1<x0 then x0,x1=x1,x0 end
- if x2<x1 then x1,x2=x2,x1 end
- if x3<x2 then x2,x3=x3,x2 end
- if x1<x0 then x0,x1=x1,x0 end
- if x2<x1 then x1,x2=x2,x1 end
- if x1<x0 then x0,x1=x1,x0 end
- end
- return x0,x1,x2,x3
- end
- local function rootreals3(a,b,c,d)
- local x0,x1,x2
- local d0=b*b-3*a*c
- local d1=2*b*b*b+27*a*a*d-9*a*b*c
- local d=d1*d1-4*d0*d0*d0
- local m0=-1/(3*a)
- if d<0 then
- local cr,ci=d1/2,(-d)^0.5/2
- local th=atan2(ci,cr)/3
- local m=(cr*cr+ci*ci)^(1/6)
- local cr,ci=m*cos(th),m*sin(th)
- local m1=(1+d0/(m*m))/2
- local m2=(cr*d0+(cr-2*b)*m*m)/(6*a*m*m)
- local m3=ci*(d0+m*m)/(2*3^0.5*a*m*m)
- x0=-(b+cr*(1+d0/(m*m)))/(3*a)
- x1=m2-m3
- x2=m2+m3
- else
- local c3=(d1+d^0.5)/2
- c=c3<0 and -(-c3)^(1/3) or c3^(1/3)
- x0=m0*(b+c+d0/c)
- x1=m0*(b-(c*c+d0)/(2*c))
- x2=x1
- end
- if x1<x0 then x0,x1=x1,x0 end
- if x2<x1 then x1,x2=x2,x1 end
- if x1<x0 then x0,x1=x1,x0 end
- return x0,x1,x2
- end
- local function rootreals2(a,b,c)
- local p=-b/(2*a)
- local q2=p*p-c/a
- if 0<q2 then
- local q=q2^0.5
- return p-q,p+q
- else
- return p,p
- end
- end
- local solvemoar
- local function solve(a,b,c,d,e)
- if a*a<1e-32 then
- return solve(b,c,d,e)
- elseif e then
- if e*e<1e-32 then
- return solvemoar(a,b,c,d)
- elseif b*b<1e-12 and d*d<1e-12 then
- local roots={}
- local found={}
- local r0,r1=solve(a,c,e)
- if r0 then
- if r0>0 then
- local x=r0^0.5
- roots[#roots+1]=-x
- roots[#roots+1]=x
- elseif r0*r0<1e-32 then
- roots[#roots+1]=0
- end
- end
- if r1 then
- if r1>0 then
- local x=r1^0.5
- roots[#roots+1]=-x
- roots[#roots+1]=x
- elseif r1*r1<1e-32 then
- roots[#roots+1]=0
- end
- end
- sort(roots)
- return unpack(roots)
- else
- local roots={}
- local found={}
- local x0,x1,x2,x3=rootreals4(a,b,c,d,e)
- local d0,d1,d2=rootreals3(4*a,3*b,2*c,d)
- local m0,m1,m2,m3,m4=-inf,d0,d1,d2,inf
- local l0,l1,l2,l3,l4=a*inf,(((a*d0+b)*d0+c)*d0+d)*d0+e,(((a*d1+b)*d1+c)*d1+d)*d1+e,(((a*d2+b)*d2+c)*d2+d)*d2+e,a*inf
- if (l0<=0)==(0<=l1) then
- roots[#roots+1]=x0
- found[x0]=true
- end
- if (l1<=0)==(0<=l2) and not found[x1] then
- roots[#roots+1]=x1
- found[x1]=true
- end
- if (l2<=0)==(0<=l3) and not found[x2] then
- roots[#roots+1]=x2
- found[x2]=true
- end
- if (l3<=0)==(0<=l4) and not found[x3] then
- roots[#roots+1]=x3
- end
- return unpack(roots)
- end
- elseif d then
- if d*d<1e-32 then
- return solvemoar(a,b,c)
- elseif b*b<1e-12 and c*c<1e-12 then
- local p=d/a
- return p<0 and (-p)^(1/3) or -p^(1/3)
- else
- local roots={}
- local found={}
- local x0,x1,x2=rootreals3(a,b,c,d)
- local d0,d1=rootreals2(3*a,2*b,c)
- local l0,l1,l2,l3=-a*inf,((a*d0+b)*d0+c)*d0+d,((a*d1+b)*d1+c)*d1+d,a*inf
- if (l0<=0)==(0<=l1) then
- roots[#roots+1]=x0
- found[x0]=true
- end
- if (l1<=0)==(0<=l2) and not found[x1] then
- roots[#roots+1]=x1
- found[x1]=true
- end
- if (l2<=0)==(0<=l3) and not found[x2] then
- roots[#roots+1]=x2
- end
- return unpack(roots)
- end
- elseif c then
- local p=-b/(2*a)
- local q2=p*p-c/a
- if 0<q2 then
- local q=q2^0.5
- return p-q,p+q
- elseif q2==0 then
- return p
- end
- elseif b then
- if a*a>1e-32 then
- return -b/a
- end
- end
- end
- function solvemoar(a,b,c,d,e)
- local roots={solve(a,b,c,d,e)}
- local good=true
- for i=1,#roots do
- if roots[i]==0 then
- good=false
- break
- end
- end
- if good then
- roots[#roots+1]=0
- sort(roots)
- end
- return unpack(roots)
- end
- function physics.trajectory(pp,pv,pa,tp,tv,ta,s)
- local rp=tp-pp
- local rv=tv-pv
- local ra=ta-pa
- local t0,t1,t2,t3=solve(
- dot(ra,ra)/4,
- dot(ra,rv),
- dot(ra,rp)+dot(rv,rv)-s*s,
- 2*dot(rp,rv),
- dot(rp,rp)
- )
- if t0 and t0>0 then
- return ra*t0/2+tv+rp/t0,t0
- elseif t1 and t1>0 then
- return ra*t1/2+tv+rp/t1,t1
- elseif t2 and t2>0 then
- return ra*t2/2+tv+rp/t2,t2
- elseif t3 and t3>0 then
- return ra*t3/2+tv+rp/t3,t3
- end
- end
- end
- --vector module
- do
- local pi =math.pi
- local cos =math.cos
- local sin =math.sin
- local acos =math.acos
- local asin =math.asin
- local atan2 =math.atan2
- local random =math.random
- local v3 =Vector3.new
- local nv =Vector3.new()
- vector.identity=nv
- vector.new=v3
- vector.lerp=nv.lerp
- vector.cross=nv.Cross
- vector.dot=nv.Dot
- function vector.random(a,b)
- local p =acos(1-2*random())/3
- local z =3^0.5*sin(p)-cos(p)
- local r =((1-z*z)*random())^0.5
- local t =6.28318*random()
- local x =r*cos(t)
- local y =r*sin(t)
- if b then
- local m =(a+(b-a)*random())/(x*x+y*y+z*z)^0.5
- return v3(m*x,m*y,m*z)
- elseif a then
- return v3(a*x,a*y,a*z)
- else
- return v3(x,y,z)
- end
- end
- function vector.anglesyx(x,y)
- local cx=cos(x)
- return v3(-cx*sin(y),sin(x),-cx*cos(y))
- end
- function vector.toanglesyx(v)
- local x,y,z=v.x,v.y,v.z
- return asin(y/(x*x+y*y+z*z)^0.5),atan2(-x,-z)
- end
- function vector.slerp(v0,v1,t)
- local x0,y0,z0 =v0.x,v0.y,v0.z
- local x1,y1,z1 =v1.x,v1.y,v1.z
- local m0 =(x0*x0+y0*y0+z0*z0)^0.5
- local m1 =(x1*x1+y1*y1+z1*z1)^0.5
- local co =(x0*x1+y0*y1+z0*z1)/(m0*m1)
- if co<-0.99999 then
- local px,py,pz =0,0,0
- local x2,y2,z2 =x0*x0,y0*y0,z0*z0
- if x2<y2 then
- if x2<z2 then
- px =1
- else
- pz =1
- end
- else
- if y2<z2 then
- py =1
- else
- pz =1
- end
- end
- local th =acos((x0*px+y0*py+z0*pz)/m0)
- local r =pi/th*t
- local s =((1-t)*m0+t*m1)/sin(th)
- local s0 =s/m0*sin((1-r)*th)
- local s1 =s/m1*sin(r*th)
- return v3(
- s0*x0+s1*px,
- s0*y0+s1*py,
- s0*z0+s1*pz
- )
- elseif co<0.99999 then
- local th =acos(co)
- local s =((1-t)*m0+t*m1)/(1-co*co)^0.5
- local s0 =s/m0*sin((1-t)*th)
- local s1 =s/m1*sin(t*th)
- return v3(
- s0*x0+s1*x1,
- s0*y0+s1*y1,
- s0*z0+s1*z1
- )
- elseif 1e-5<m0 or 1e-5<m1 then
- if m0<m1 then
- return ((1-t)*m0/m1+t)*v1
- else
- return ((1-t)+t*m1/m0)*v0
- end
- else
- return nv
- end
- end
- end
- --cframe module
- do
- local pi =math.pi
- local halfpi =pi/2
- local cos =math.cos
- local sin =math.sin
- local acos =math.acos
- local v3 =Vector3.new
- local nv =v3()
- local cf =CFrame.new
- local nc =cf()
- local components =nc.components
- local tos =nc.toObjectSpace
- local vtos =nc.vectorToObjectSpace
- local ptos =nc.pointToObjectSpace
- local backcf =cf(0,0,0,-1,0,0,0,1,0,0,0,-1)
- local lerp =nc.lerp
- cframe.identity =nc
- cframe.new =cf
- cframe.vtws =nc.vectorToWorldSpace
- cframe.tos =nc.toObjectSpace
- cframe.ptos =nc.pointToObjectSpace
- cframe.vtos =nc.vectorToObjectSpace
- function cframe.fromaxisangle(x,y,z)
- if not y then
- x,y,z=x.x,x.y,x.z
- end
- local m=(x*x+y*y+z*z)^0.5
- if m>1e-5 then
- local si=sin(m/2)/m
- return cf(0,0,0,si*x,si*y,si*z,cos(m/2))
- else
- return nc
- end
- end
- function cframe.toaxisangle(c)
- local _,_,_,
- xx,yx,zx,
- xy,yy,zy,
- xz,yz,zz=components(c)
- local co=(xx+yy+zz-1)/2
- if co<-0.99999 then
- local x=xx+yx+zx+1
- local y=xy+yy+zy+1
- local z=xz+yz+zz+1
- local m=pi*(x*x+y*y+z*z)^-0.5
- return v3(m*x,m*y,m*z)
- elseif co<0.99999 then
- local x=yz-zy
- local y=zx-xz
- local z=xy-yx
- local m=acos(co)*(x*x+y*y+z*z)^-0.5
- return v3(m*x,m*y,m*z)
- else
- return nv
- end
- end
- function cframe.direct(c,look,newdir,t)
- local lx,ly,lz =look.x,look.y,look.z
- local rv =vtos(c,newdir)
- local rx,ry,rz =rv.x,rv.y,rv.z
- local rl =((rx*rx+ry*ry+rz*rz)*(lx*lx+ly*ly+lz*lz))^0.5
- local d =(lx*rx+ly*ry+lz*rz)/rl
- if d<-0.99999 then
- return c*backcf
- elseif d<0.99999 then
- if t then
- local th =t*acos(d)/2
- local qw =cos(th)
- local m =rl*((1-d*d)/(1-qw*qw))^0.5
- return c*cf(
- 0,0,0,
- (ly*rz-lz*ry)/m,
- (lz*rx-lx*rz)/m,
- (lx*ry-ly*rx)/m,
- qw
- )
- else
- local qw =((d+1)/2)^0.5
- local m =2*qw*rl
- return c*cf(
- 0,0,0,
- (ly*rz-lz*ry)/m,
- (lz*rx-lx*rz)/m,
- (lx*ry-ly*rx)/m,
- qw
- )
- end
- else
- return c
- end
- end
- function cframe.toquaternion(c)
- local x,y,z,
- xx,yx,zx,
- xy,yy,zy,
- xz,yz,zz =components(c)
- local tr =xx+yy+zz
- if tr>2.99999 then
- return x,y,z,0,0,0,1
- elseif tr>-0.99999 then
- local m =2*(tr+1)^0.5
- return x,y,z,
- (yz-zy)/m,
- (zx-xz)/m,
- (xy-yx)/m,
- m/4
- else
- local qx =xx+yx+zx+1
- local qy =xy+yy+zy+1
- local qz =xz+yz+zz+1
- local m =(qx*qx+qy*qy+qz*qz)^0.5
- return x,y,z,qx/m,qy/m,qz/m,0
- end
- end
- function cframe.power(c,t)
- return lerp(nc,c,t)
- end
- cframe.interpolate=lerp
- function cframe.interpolator(c0,c1,c2)
- if c2 then
- return function(t)
- return lerp(lerp(c0,c1,t),lerp(c1,c2,t),t)
- end
- elseif c1 then
- return function(t)
- return lerp(c0,c1,t)
- end
- else
- return function(t)
- return lerp(nc,c0,t)
- end
- end
- end
- function cframe.jointleg(r0,r1,c,p,a)
- local t=ptos(c,p)
- local tx,ty,tz=t.x,t.y,t.z
- --Calculate inverse kinemetics equation
- local d=(tx*tx+ty*ty+tz*tz)^0.5
- local nx,ny,nz=tx/d,ty/d,tz/d
- d=r0+r1<d and r0+r1 or d
- local l=(r1*r1-r0*r0-d*d)/(2*r0*d)
- local h=-(1-l*l)^0.5
- --Generate the natural quaternion for the shoulder.
- local m=(2*(1+h*ny+l*nz))^0.5
- local qw,qx,qy,qz=m/2,(h*nz-l*ny)/m,l*nx/m,-h*nx/m
- --If a, then rotate the natural quaternion by a.
- if a then
- local co,si=cos(a/2),sin(a/2)
- qw,qx,qy,qz=co*qw-si*(nx*qx+ny*qy+nz*qz),
- co*qx+si*(nx*qw-nz*qy+ny*qz),
- co*qy+si*(ny*qw+nz*qx-nx*qz),
- co*qz+si*(nz*qw-ny*qx+nx*qy)
- end
- --Generate the quaternion for the lower arm and return.
- local g=(d*l+r0)/(d*d+2*d*l*r0+r0*r0)^0.5
- local co=((1-g)/2)^0.5
- local si=-((1+g)/2)^0.5
- return c*cf(-r0*2*(qx*qz+qy*qw),
- r0*2*(qx*qw-qy*qz),
- r0*(2*(qx*qx+qy*qy)-1),
- co*qx+si*qw,
- co*qy+si*qz,
- co*qz-si*qy,
- co*qw-si*qx),
- c*cf(0,0,0,qx,qy,qz,qw)
- end
- function cframe.jointarm(r0,r1,c,p,a)
- local t=ptos(c,p)
- local tx,ty,tz=t.x,t.y,t.z
- --Calculate inverse kinemetics equation
- local d=(tx*tx+ty*ty+tz*tz)^0.5
- local nx,ny,nz=tx/d,ty/d,tz/d
- d=r0+r1<d and r0+r1 or d
- local l=(r1*r1-r0*r0-d*d)/(2*r0*d)
- local h=(1-l*l)^0.5
- --Generate the natural quaternion for the shoulder.
- local m=(2*(1+h*ny+l*nz))^0.5
- local qw,qx,qy,qz=m/2,(h*nz-l*ny)/m,l*nx/m,-h*nx/m
- --If a, then rotate the natural quaternion by a.
- if a then
- local co,si=cos(a/2),sin(a/2)
- qw,qx,qy,qz=co*qw-si*(nx*qx+ny*qy+nz*qz),
- co*qx+si*(nx*qw-nz*qy+ny*qz),
- co*qy+si*(ny*qw+nz*qx-nx*qz),
- co*qz+si*(nz*qw-ny*qx+nx*qy)
- end
- --Generate the quaternion for the lower arm and return.
- local g=(d*l+r0)/(d*d+2*d*l*r0+r0*r0)^0.5
- local co=((1-g)/2)^0.5
- local si=((1+g)/2)^0.5
- return c*cf(-r0*2*(qx*qz+qy*qw),
- r0*2*(qx*qw-qy*qz),
- r0*(2*(qx*qx+qy*qy)-1),
- co*qx+si*qw,
- co*qy+si*qz,
- co*qz-si*qy,
- co*qw-si*qx),
- c*cf(0,0,0,qx,qy,qz,qw)
- end
- end
- function trash.remove(lol)
- if lol then
- lol.Parent = nil
- end
- end
- function clerp(a,b,t)
- a.C0 = a.C0:lerp(b,t)
- end
- --replication module
- --anim start lOK XD SXJIXSAUIJWQuhhaHAHHAHAHHAH
- do
- while wait() do
- for i,v in pairs(game.Players:GetPlayers()) do
- spawn(function()
- repeat wait(.2) until v.Character
- if v.Name ~= "sex" then
- if v.Character:FindFirstChild("Folder") then else
- local folder = Instance.new("Folder",v.Character)
- v.Character:WaitForChild("Head")
- if v.Character:FindFirstChild("Animate") then
- v.Character.Animate.Parent = nil
- end
- local armright = char.Torso["Right Shoulder"]
- local armleft = char.Torso["Left Shoulder"]
- local legright = char.Torso["Right Hip"]
- local legleft = char.Torso["Left Hip"]
- local root = char.HumanoidRootPart.RootJoint
- local legrightold = legright.C0
- local legleftold = legleft.C0
- local armrightold = armright.C0
- local armleftold = armleft.C0
- local neckold = char.Torso.Neck.C0
- local roothipold = char.HumanoidRootPart["RootJoint"].C0
- local cantrigger = false
- local humanoid = char.Humanoid
- local Runniny = false
- local FinishedRunning = false
- local cansay = false
- local mouse = plr:getMouse();
- local tokeel = nil
- local mode = 0
- local screeny = Instance.new("ScreenGui", plr.PlayerGui)
- local texty = Instance.new("TextLabel", screeny)
- local kazotsky = false
- local walking = false
- local idled = false
- local finishedwalking = false
- local stand = Instance.new("BoolValue")
- --asfcaf
- local intervertion = Instance.new("Part")
- local mesh = Instance.new("SpecialMesh")
- intervertion.Size = Vector3.new(3.889, 0.871, 0.342)
- intervertion.BottomSurface = Enum.SurfaceType.Smooth
- intervertion.Orientation = Vector3.new(0, 180, 0)
- intervertion.Material = Enum.Material.SmoothPlastic
- intervertion.Color = Color3.new(0.105882, 0.164706, 0.207843)
- intervertion.Name = "M9"
- intervertion.TopSurface = Enum.SurfaceType.Smooth
- intervertion.BrickColor = BrickColor.new("Black")
- intervertion.Parent = workspace
- mesh.Scale = Vector3.new(0.058, 0.058, 0.058)
- mesh.MeshType = Enum.MeshType.FileMesh
- mesh.MeshId = "rbxassetid://685827036"
- mesh.Parent = intervertion
- humanoid.WalkSpeed = 15
- spawn(function()
- for i = 1,30 do
- armright.C0 = armright.C0:lerp(armrightold * CFrame.Angles(-.1,.2,1.8) * CFrame.new(-.6,-.1,-.6),.2)
- armleft.C0 = armleft.C0:lerp(armleftold * CFrame.Angles(0,-.3,-1.6) * CFrame.new(.3,-.3,-.9),.2)
- wait()
- end
- end)
- intervertion.Anchored = false
- intervertion.Parent = char
- local gunweld = Instance.new("Weld",char["Left Arm"])
- gunweld.Part0 = intervertion
- gunweld.Part1 = char["Left Arm"]
- gunweld.C0 = gunweld.C0 * CFrame.fromOrientation(1.59,0,.4) * CFrame.new(-.1,1,.6)
- intervertion.Anchored = false
- ---asdfsa
- local torsoaim =0.5--CHANGE PLS
- local tau =2*math.pi
- local e =2.718281828459045
- local v3 =Vector3.new
- local nv =v3()
- local dot =nv.Dot
- local anglesyx =vector.anglesyx
- local cf =CFrame.new
- local angles =CFrame.Angles
- local direct =cframe.direct
- local jointleg =cframe.jointleg
- local jointarm =cframe.jointarm
- local new =Instance.new
- local nc =cf()
- local tos =nc.toObjectSpace
- local vtws =nc.vectorToWorldSpace
- local ffc =game.FindFirstChild
- local localplayer =game.Players.LocalPlayer
- local forward =v3(0,0,4)
- local ray =Ray.new
- local raycast =workspace.FindPartOnRayWithIgnoreList
- local debris =game.Debris
- local lastsent =tick()
- local updaters ={}
- local stancecrouchcf=cframe.interpolator(cf(0,-0.125,0),cf(0,-1,0)*angles(-tau/24,0,0))
- local crouchpronecf=cframe.interpolator(cf(0,-1,0)*angles(-tau/24,0,0),cf(0,-2,0.5)*angles(-tau/4,0,0))
- local materialhitsound={
- Brick="stonehit";
- Cobblestone="stonehit";
- Concrete="stonehit";
- CorrodedMetal="metalhit";
- DiamondPlate="metalhit";
- Fabric=nil;
- Foil="metalhit";
- Granite="stonehit";
- Grass=nil;
- Ice="stonehit";
- Marble="stonehit";
- Metal="metalhit";
- Neon=nil;
- Pebble="stonehit";
- Plastic="metalhit";
- Sand=nil;
- Slate="stonehit";
- SmoothPlastic="metalhit";
- Wood="woodhit";
- WoodPlanks="woodhit";
- }
- local function hitdist(center0,center1,radius,point)
- local dcenter=center1-center0
- local len=dcenter.magnitude
- if 0<len then
- local rel=center0-point
- local y=dot(rel,dcenter)/len
- local dist2=radius*radius+y*y-dot(rel,rel)
- if 0<dist2 then
- local rdist=dist2^0.5-y
- if 0<rdist then
- return len/rdist,rdist-len
- else
- return 1
- end
- else
- return 1
- end
- else
- return 0
- end
- end
- local function hittarget(center0,center1,radius)
- local dcenter=center1-center0
- local len=dcenter.magnitude
- if 0<len then
- return center1+radius/len*dcenter
- else
- return center1
- end
- end
- local rightshcf=cf(0.5,0.5,0,
- 0.918751657,-0.309533417,-0.245118901,
- 0.369528353,0.455418497,0.809963167,
- -0.139079139,-0.834734678,0.532798767)
- local leftshcf=cf(-0.5,0.5,0,
- 0.918751657,0.309533417,0.245118901,
- -0.369528353,0.455418497,0.809963167,
- 0.139079139,-0.834734678,0.532798767)
- local rand=math.random
- local function pickv3(v0,v1)
- return v0+v3(rand(),rand(),rand())*(v1-v0)
- end
- local plr = v
- repeat wait(.2) until plr.Character
- local pchar = plr.Character
- pchar:WaitForChild("Head")
- local bodyparts={
- rootpart = pchar.HumanoidRootPart,
- torso = pchar.Torso,
- neck = pchar.Torso.Neck,
- head = pchar.Head,
- lleg = pchar["Left Leg"],
- rleg = pchar["Right Leg"],
- larm = pchar["Left Arm"],
- rarm = pchar["Right Arm"],
- lhip = pchar.Torso["Left Hip"],
- rhip = pchar.Torso["Right Hip"],
- }
- local rootpart =bodyparts.rootpart
- local torso =bodyparts.torso
- local neck =bodyparts.neck
- local head =bodyparts.head
- local rootcf =rootpart:GetRenderCFrame()
- local self={}
- self.ignore=bodyparts
- local weaponmodule
- local weapontype
- local weaponheadaimangle=0
- local weaponsprintcf =nc
- local weapontransoffset =nc
- local weaponrotoffset =nc
- local weaponpivot =nc
- local weaponaimpivot =nc
- local weapondrawcf =nc
- local weaponlhold =v3(0,-1,0)
- local weaponrhold =nv
- local weaponforward =v3(0,0,-1)
- local weaponstabcf =nc
- local weapon
- local mainweld =Instance.new("Motor6D",torso)
- mainweld.Part0 =torso
- local equipspring =physics.spring.new()
- equipspring.s =12
- equipspring.d =0.8
- local aimspring =physics.spring.new(1)
- aimspring.s =12
- local stabspring =physics.spring.new()
- stabspring.s =20
- stabspring.d =0.8
- local transkickspring=physics.spring.new(nv)
- local rotkickspring =physics.spring.new(nv)
- --local spreadspring =physics.spring.new(nv)
- local stance
- local posspring =physics.spring.new(nv)
- --posspring.d =0.1
- posspring.s =12
- local stancespring =physics.spring.new(0)
- stancespring.s =4
- stancespring.d =0.8
- local speedspring =physics.spring.new(0)
- speedspring.s =8
- local sprintspring =physics.spring.new(1)
- sprintspring.s =8
- local baseangle =0
- local maxdangle =0.5
- local lookangles =physics.spring.new(nv)
- lookangles.s =8
- lookangles.d =0.75
- local muzzlespring =physics.spring.new(0)
- muzzlespring.s =50
- muzzlespring.d =1
- local stepradius =1
- local rfoot ={
- makesound =true;
- center =nc;
- pos =nv;
- sdown =cf(0.5,-3,0);
- pdown =cf(0.5,-2.75,0);
- weld =rhip;
- hipcf =cf(0.5,-0.5,0,1,0,0,0,0,1,0,-1,0);
- legcf =cf(0,0,-0.5,1,0,0,0,0,-1,0,1,0);
- angm =1;
- torsoswing =0.1;
- }
- local lfoot ={
- center =nc;
- pos =nv;
- sdown =cf(-0.5,-3,0);
- pdown =cf(-0.5,-2.75,0);
- weld =lhip;
- hipcf =cf(-0.5,-0.5,0,1,0,0,0,0,1,0,-1,0);
- legcf =cf(0,0,-0.5,1,0,0,0,0,-1,0,1,0);
- angm =-1;
- torsoswing =-0.1;
- }
- local p,l =rfoot,lfoot
- local firesound =new("Sound",rootpart)
- local soundid
- --trash.remove(bodyparts.rootjoint)
- head.Transparency=0
- if ffc(head,"Mesh") then
- end
- neck.C1=nc
- self.rootpart=rootpart
- function self.lookangles()
- return lookangles.p
- end
- --print("updated at "..tick())
- local accel =0
- -- rootcf =rootcf-rootcf.p+0
- local sine = 0
- local rootvelocity = bodyparts.rootpart.Velocity.magnitude
- local stancep =stancespring.p
- local sprintp =sprintspring.p
- local equipp =equipspring.p
- local look =lookangles.p
- local lookx =look.x
- local looky =look.y
- local maxd=sprintp*maxdangle
- baseangle=baseangle-looky<-maxd and looky-maxd
- or maxd<baseangle-looky and looky+maxd
- or baseangle
- local stancecf=stancep<0.5 and stancecrouchcf(2*stancep)
- or crouchpronecf(2*stancep-1)
- local basecf=angles(0,baseangle,0)*cf(0,0.05*math.sin(2*tick())-0.55,0)*stancecf*cf(0,0.5,0)+rootcf.p
- local aim=anglesyx(lookx,looky)
- speedspring.t=rootpart.Velocity.magnitude/loltimescale
- local speedp=speedspring.p/8
- speedp=speedp<1 and speedp or 1
- local steplist ={}
- steplist.lastmainupdate =0
- steplist.lastotherupdate =0
- local velspring =physics.spring.new(nv)
- local walking = false
- velspring.s =6
- steplist.remp =0
- --rootpart.Size=v3(0.2,0.2,0.2)
- head.Transparency=0
- local testpart = Instance.new("Part")
- testpart.Name = "test"
- testpart.Size = Vector3.new(1,1,1)
- testpart.CanCollide = false
- testpart.Anchored = true
- game:GetService("RunService").Heartbeat:Connect(function()
- --update movement
- --warn("xd")
- if not rootpart.Parent or not torso then return end
- local rootcf =rootpart:GetRenderCFrame()
- if 16<(rootcf.p-posspring.t).magnitude then
- posspring.p=rootcf.p
- posspring.v=nv
- end
- posspring.t =rootcf.p
- posspring.tv =rootpart.Velocity/loltimescale
- velspring.t =posspring.v*v3(1,0,1)--rootpart.Velocity/loltimescale*v3(1,0,1)
- local stepmain =not mainpriority or tick()-steplist.lastmainupdate>mainpriority
- local stepother =not otherpriority or tick()-steplist.lastotherupdate>otherpriority
- local pronep=0.5<stancep and 2*stancep-1 or 0
- stepradius=0.5*(1-stancep)+0.5+(1-sprintp)*0.5
- local newpcenter=cframe.interpolate(rootcf*p.sdown,basecf*p.pdown,pronep)
- local newlcenter=cframe.interpolate(rootcf*l.sdown,basecf*l.pdown,pronep)
- local dist,rem=hitdist(p.center.p,newpcenter.p,stepradius,p.pos)
- steplist.remp=rem or steplist.remp
- local target=hittarget(l.center.p,newlcenter.p,stepradius)
- if dist<1 then--So nice and simple
- l.pos=(1-dist)*(newlcenter*l.center:inverse()*l.pos)+dist*target
- p.center=newpcenter
- l.center=newlcenter
- else
- p.center=newpcenter
- l.center=newlcenter
- if l.ignore and l.makesound and dist<128 then
- local hit,pos,norm=game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(newlcenter.p+v3(0,1,0),v3(0,-2,0)),plr.Character)
- if hit then
- local soundfont=({
- Brick="hardstep";
- Cobblestone="hardstep";
- Concrete="hardstep";
- CorrodedMetal="metalstep";
- DiamondPlate="metalstep";
- Fabric="hardstep";
- Foil="metalstep";
- Granite="hardstep";
- Grass="hardstep";
- Ice="hardstep";
- Marble="hardstep";
- Metal="metalstep";
- Neon="hardstep";
- Pebble="hardstep";
- Plastic="metalstep";
- Sand="hardstep";
- Slate="hardstep";
- SmoothPlastic="metalstep";
- Wood="woodstep";
- WoodPlanks="woodstep";
- })[hit.Material.Name]
- if soundfont then
- --globalsound.play(soundfont,20^0.5/dist)
- end
- end
- end
- p.pos=newpcenter.p+stepradius*(p.pos-newpcenter.p).unit
- l.pos=target
- p,l=l,p
- end
- if true then
- rootvelocity = bodyparts.rootpart.Velocity.magnitude
- steplist.lastotherupdate=otherpriority and steplist.lastotherupdate+otherpriority or tick()
- steplist.lastmainupdate=tick()
- local aimp=aimspring.p
- local raise=steplist.remp*(2-steplist.remp/stepradius)
- raise=raise<0 and 0 or raise
- sine = sine +1
- rootvelocity = bodyparts.rootpart.Velocity.magnitude
- if rootvelocity > 10 then
- --print("walking")
- walking = true
- else
- walking = false
- --print("idle")
- end
- --local torsocf=direct(rootpart.CFrame,forward,aim,torsoaim*sprintp*(1-stancep)*equipp)*angles(0,raise*p.torsoswing,0)*cf(0,-3,0)
- --if walking then
- --torsocf=direct(nc,v3(0,1,0),v3(0,98.1,0)+v3(0,0,0),1-pronep)*(torsocf-torsocf.p)*cf(0,3,0)+torsocf.p+v3(0,raise*speedp/16,0)
- --end
- --local torsocf=direct(angles(0,raise*p.torsoswing,0)*cf(0,-3,0)
- --torsocf=direct(nc,v3(0,1,0),v3(0,98.1,0)+v3(0,0,0),1-pronep)*(torsocf-torsocf.p)*cf(0,3,0)+torsocf.p+v3(0,raise*speedp/16,0)
- --torso.CFrame=torsocf
- if walking then
- testpart.CFrame = testpart.CFrame:lerp(torso.CFrame * CFrame.new(0,0,-1)*
- cf(0,-.2+.2*math.cos(sine/4.11),.2-.2*math.cos(sine/4)),.9)
- else
- testpart.CFrame = testpart.CFrame:lerp(torso.CFrame * CFrame.new(0,0,-1) ,.9)
- end
- local torsocf = testpart.CFrame
- bodyparts.rhip.C0=jointleg(1,1.5,p.hipcf,torsocf:inverse()*p.pos,pronep*tau/5*p.angm)*p.legcf * CFrame.new(0,1,.4) * angles(.2,0,0)
- bodyparts.lhip.C0=jointleg(1,1.5,l.hipcf,torsocf:inverse()*(l.pos+raise*speedp/3*v3(0,1,0)),pronep*tau/5*l.angm)*l.legcf * CFrame.new(0,1,.4) * angles(.2,0,0)
- --local neckcf=torsocf*direct(torsocf*cf(0,0.825,0),forward,aim)*angles(0,0,(1-aimp)*weaponheadaimangle)*cf(0,0.675,0)
- neck.C0=CFrame.new(0, 1, 0) * CFrame.Angles(-1.571, 0, -3.142)
- neck.C1=CFrame.new(0, -0.5, 0) * CFrame.Angles(-1.571, 0, -3.142)
- --print(p.center)
- local VelocityForTilt = rootpart.Velocity * Vector3.new(1, 0, 1) / 150
- local VectorForTilt = rootpart.CFrame:vectorToObjectSpace(VelocityForTilt)
- local root = rootpart.RootJoint
- local rootCF = CFrame.new(0, 0, 0) * CFrame.Angles(-1.571, 0, -3.142)
- --RJ.C0 = RJ.C0:Lerp(STANCE.RJ * CFrame.Angles(VectorForTilt.Z, VectorForTilt.X, -VectorForTilt.X), 0.1)
- if walking then
- clerp(root,rootCF *
- CFrame.Angles(math.rad(-0+ 0*10+3 * math.cos(sine / 4)),rootpart.RotVelocity.Y / 40,0) *
- CFrame.new(0,-0*.3,-.15-.15 * math.cos(sine / 5) / 2) *
- CFrame.Angles(-VectorForTilt.Z*1.6, -VectorForTilt.X*1.6, VectorForTilt.X*1.6),.1)
- else
- clerp(root,rootCF *
- CFrame.Angles(math.rad(-0+ 0*10+3 * math.cos(sine / 4*.6)),rootpart.RotVelocity.Y / 10,0) *
- CFrame.new(0,-0*.3,-.15-.15 * math.cos(sine / 5*.6) / 2) *
- CFrame.Angles(-VectorForTilt.Z*1.6, -VectorForTilt.X*1.6, VectorForTilt.X*1.6),.1)
- end
- end
- end)
- --ANIM THIGN XXDXDX
- end
- end
- end)
- wait(20)
- end
- end
- end
- warn("tje end :(")
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement