Advertisement
crabb

naomi

Jan 18th, 2021
1,601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.98 KB | None | 0 0
  1. --// services
  2. local tweens = game:GetService("TweenService")
  3. local sstore = game:GetService("ServerStorage")
  4. local rpstor = game:GetService("ReplicatedStorage")
  5. local rpfrst = game:GetService("ReplicatedFirst")
  6. local player = game:GetService("Players")
  7. local debris = game:GetService("Debris")
  8. local uinput = game:GetService("UserInputService")
  9. local rnserv = game:GetService("RunService")
  10.  
  11. local hbeat = rnserv.Heartbeat
  12.  
  13. --/ modules
  14. local mods = script.Parent.Parent:WaitForChild('mods')
  15. local mget = function(n) return require(mods:WaitForChild(n)) end
  16. local SH1 = mget("SH1")
  17.  
  18. --// vars
  19. local FRAME = 1/60
  20. local FRAME2 = 1/30
  21.  
  22. --/ main
  23. local main = script.Parent.Parent
  24. local vals = main:WaitForChild("vals")
  25. local rems = main:WaitForChild("remotes")
  26. local sfx = main:WaitForChild("sfx")
  27. local mdls = main:WaitForChild("model")
  28. local anim = main:WaitForChild("anims")
  29.  
  30. --/ plr
  31. local char = main.Parent
  32. local splr = player:GetPlayerFromCharacter(char)
  33. local root = char:WaitForChild("HumanoidRootPart")
  34. local phum = char:WaitForChild("Humanoid")
  35. local anims = {}
  36.  
  37. local naomi = mdls:WaitForChild("naomi")
  38. naomi.Parent = char
  39. local njoint = nil
  40.  
  41. local lastzmove = tick()
  42. local combodmg = 0
  43. local combotime = 0
  44.  
  45. --/ etc
  46. function newcd(m,c) return {max=m,cur=c} end
  47.  
  48. local cooldowns = {
  49.     -- specials
  50.     asdq = newcd(6,0),
  51.     adq = newcd(3,0),
  52.     swq = newcd(4,0),
  53.     -- neutrals
  54.     z1 = newcd(.4,0), -- z combos are spammable. give em long cooldowns
  55.     z2 = newcd(.4,0),
  56.     z3 = newcd(.4,0),
  57.     x = newcd(.8,0),
  58.     c = newcd(.9,0)
  59. }
  60.  
  61. local atking = false
  62.  
  63. --/ math vars
  64. pi = math.pi
  65. rad = math.rad
  66. deg = math.deg
  67. sin = math.sin
  68. cos = math.cos
  69. tan = math.tan
  70. sinh = math.sinh
  71. cosh = math.cosh
  72. tanh = math.tanh
  73. acos = math.acos
  74. atan = math.atan
  75. asin = math.asin
  76. rand = math.random
  77. seed = math.randomseed
  78. atan2 = math.atan2
  79. clamp = function(x,min,max) return (x < min and min or x > max and max or x) end
  80.  
  81. seed(tick())
  82.  
  83. --// funcs
  84. function init()
  85.    njoint = Instance.new("Motor6D")
  86.    njoint.Name = "sol"
  87.    njoint.Part0 = char['Right Arm']
  88.    njoint.Part1 = naomi
  89.    njoint.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  90.     njoint.C1 = CFrame.new(-0.944999993, 0, -2.90100002, -2.235174e-08, -0.99999994, 0, -1, 2.23517436e-08, 5.21540642e-08, -5.21540642e-08, 1.19348975e-15, -1)
  91.  
  92.    njoint.Parent = char['Right Arm']
  93.    naomi.Anchored = false
  94.    naomi.Massless = true
  95.     naomi:SetNetworkOwner(splr)
  96.    
  97.     phum.MaxHealth = 300
  98.     phum.Health = phum.MaxHealth
  99.  
  100.    print(njoint.C0,njoint.C1)
  101. end
  102.  
  103. function magdetect(pos,radius,ignore,cback)
  104.     local hit = {}
  105.     for i,v in next,workspace:GetChildren() do
  106.         local vhum = v:FindFirstChild("Humanoid")
  107.         if vhum and v ~= ignore then
  108.             local eroot = v:FindFirstChild("HumanoidRootPart")
  109.             local dist = (pos-eroot.Position).Magnitude
  110.             if dist <= radius then
  111.                 hit[#hit+1] = v
  112.                 if cback then cback(vhum,eroot,dist) end
  113.             end
  114.             print(splr.hbox.Value)
  115.             --if splr:FindFirstChild("hbox") and splr.hbox.Value == true then
  116.             if true then
  117.                 local hdisp = SH1.nobj("Part",{
  118.                 ["CFrame"] = CFrame.new(pos),
  119.                 ["Size"] = Vector3.new(radius,radius,radius)*2,
  120.                 ["Color"] = Color3.new(1,0,0),
  121.                 ["Transparency"] = .9,
  122.                 ["Anchored"] = true,
  123.                 ["CanCollide"] = false,
  124.                 ["Shape"] = "Ball",
  125.                 ["Material"] = "SmoothPlastic"
  126.                 },.7)
  127.                 local htwn = SH1.tween(hdisp,{Transparency=1},TweenInfo.new(.7),true)
  128.                 hdisp.Parent = char
  129.             end
  130.         end
  131.     end
  132.     return hit
  133. end
  134.  
  135. function stopanims(fade) -- stop all animations, with optional fadetime
  136.     for i,v in next,phum:GetPlayingAnimationTracks() do
  137.         if v.Name:sub(1,3) == 'atk' or v.Name == "stance" then
  138.             v:Stop(fade)
  139.         end
  140.     end
  141. end
  142.  
  143. function linkstart(cback,link) -- easy link function
  144.     for _,plr in next,player:GetPlayers() do
  145.         spawn(function()
  146.             cback(plr,plr.Character.class.remotes.link)
  147.         end)
  148.     end
  149. end
  150.  
  151. function setvelo(obj,v,rv,stand,hum) -- function for setting & replicating velocity
  152.     local ohum = obj.Parent.Humanoid
  153.     local vplr = player:GetPlayerFromCharacter(obj.Parent)
  154.  
  155.     ohum.PlatformStand = (stand and true) or ohum.PlatformStand
  156.     rems.velo:FireClient(vplr or splr,obj,v,rv,hum)
  157.     if stand then delay(stand,function() ohum.PlatformStand = false end) end
  158. end
  159.  
  160. function setmodelowner(obj,owner) -- set network ownership of model's descendants
  161.     local pchar = player:GetPlayerFromCharacter(obj)
  162.     if not pchar then
  163.         SH1.printf("%s is not a player",obj.Name)
  164.         for i,v in next,obj:GetDescendants() do
  165.             if v:IsA('BasePart') then
  166.                 v:SetNetworkOwner(owner)
  167.             end
  168.         end
  169.     end
  170. end
  171.  
  172. function sethum(spd,jmp) -- set walkspeed & jump height
  173.     phum.WalkSpeed = spd
  174.     phum.JumpPower = jmp
  175. end
  176.  
  177. function setcombotime()
  178.     combotime = 2
  179.     combohits = combohits + 1
  180. end
  181.  
  182. function damage(hum,dmg)
  183.     hum:TakeDamage(dmg)
  184.     combodmg = combodmg + dmg
  185. end
  186.  
  187. --// moves
  188. moves = {
  189.     ['adq'] = function(name,mousehit)
  190.         stopanims(0.05)
  191.         --root.CFrame = CFrame.new(root.Position,Vector3.new(mousehit.p.X,root.Position.Y,mousehit.p.Z))
  192.         anims.atkadq:Play()
  193.         local ospd,ojmp = phum.WalkSpeed,phum.JumpPower
  194.         sethum(0,0)
  195.         delay(.3,function() sethum(ospd,ojmp) atking = false end)
  196.         anims.atkadq.KeyframeReached:wait()
  197.         for _,plr in next,player:GetPlayers() do
  198.             spawn(function()
  199.                 if not plr.Character then return end
  200.                 local echar = plr.Character
  201.                 local bman = echar.class
  202.                 local link = bman.remotes.link
  203.                 local waitin = false
  204.                 link:InvokeClient(plr,'adq1',root,char)
  205.             end)
  206.         end
  207.         local rspot = Ray.new(root.Position,-root.CFrame.upVector*10)
  208.         local rsv = {workspace:FindPartOnRay(rspot,char)}
  209.         local ocf = root.CFrame * CFrame.new(0,-((root.Position-rsv[2]).magnitude),0)
  210.         local ecf = ocf * CFrame.new(0,0,-30)
  211.         for i = 0.2,1,0.2 do
  212.             local magp = (ocf:lerp(ecf,i)).p
  213.             local bval = false
  214.             local hplr = magdetect(magp,8,char,function(vhum,eroot,dist)
  215.                 bval = true
  216.                 damage(vhum,12)
  217.                 setcombotime()
  218.                 linkstart(function(plr)
  219.                     plr.Character.class.remotes.link:InvokeClient(plr,'adq2',magp)
  220.                     plr.Character.class.remotes.link:InvokeClient(plr,'hitfx',magp,8)
  221.                 end)
  222.             end)
  223.             if bval then break end
  224.             wait(0.07)
  225.         end
  226.     end,
  227.     ['z1'] = function(name,mousehit)
  228.         lastzmove = tick()
  229.         stopanims(0)
  230.         root.Velocity = Vector3.new()
  231.         --root.CFrame = CFrame.new(root.Position,Vector3.new(mousehit.p.X,root.Position.Y,mousehit.p.Z))
  232.         sethum(0,0)
  233.         anims.atkz1:Play()
  234.         anims.atkz1.KeyframeReached:wait()
  235.         delay(.05,function() sethum(16,50) atking = false end)
  236.         linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'z1',splr) end)
  237.         spawn(function()
  238.             local nbp = Instance.new("BodyPosition")
  239.             nbp.Position = (root.CFrame * CFrame.new(0,3,-5)).p
  240.             nbp.Parent = root
  241.             wait(.1)
  242.             nbp:Destroy()
  243.         end)
  244.         local magp = root.CFrame * CFrame.new(0,0,-4)
  245.         local hplr = magdetect(magp.p,5,char,function(vhum,eroot,dist)
  246.             damage(vhum,7)
  247.             setcombotime()
  248.             local dir = magp * CFrame.Angles(math.rad(70),0,0)
  249.             setmodelowner(eroot.Parent,splr)
  250.             setvelo(eroot,(dir.lookVector*15),nil,false)
  251.             linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'hitfx',eroot.Position,5,sfx.kick1) end)
  252.         end)
  253.     end,
  254.     ['z2'] = function(name,mousehit)
  255.         lastzmove = tick()
  256.         stopanims(0)
  257.         --root.CFrame = CFrame.new(root.Position,Vector3.new(mousehit.p.X,root.Position.Y,mousehit.p.Z))
  258.         sethum(0,0)
  259.         anims.atkz2:Play()
  260.         anims.atkz2.KeyframeReached:wait()
  261.         delay(.05,function() sethum(16,50) atking = false end)
  262.         linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'z2',splr) end)
  263.         spawn(function()
  264.             local nbp = Instance.new("BodyPosition")
  265.             nbp.Position = (root.CFrame * CFrame.new(0,4,-5)).p
  266.             nbp.Parent = root
  267.             wait(.1)
  268.             nbp:Destroy()
  269.         end)
  270.         local magp = root.CFrame * CFrame.new(0,0,-4)
  271.         local hplr = magdetect(magp.p,5,char,function(vhum,eroot,dist)
  272.             damage(vhum,5)
  273.             setcombotime()
  274.             local dir = magp * CFrame.Angles(math.rad(70),0,0)
  275.             setmodelowner(eroot.Parent,splr)
  276.             setvelo(eroot,(dir.lookVector*35),nil,false)
  277.             linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'hitfx',eroot.Position,5,sfx.kick1) end)
  278.         end)
  279.     end,
  280.     ['z3'] = function(name,mousehit)
  281.         lastzmove = tick()
  282.         stopanims(0)
  283.         --root.CFrame = CFrame.new(root.Position,Vector3.new(mousehit.p.X,root.Position.Y,mousehit.p.Z))
  284.         sethum(0,0)
  285.         anims.atkz3:Play(0)
  286.         anims.atkz3.KeyframeReached:wait()
  287.         delay(.05,function() sethum(16,50) atking = false end)
  288.         linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'z3',splr) end)
  289.         spawn(function()
  290.             local nbp = Instance.new("BodyPosition")
  291.             nbp.Position = (root.CFrame * CFrame.new(0,0,-5)).p
  292.             nbp.Parent = root
  293.             wait(.1)
  294.             nbp:Destroy()
  295.         end)
  296.         local magp = root.CFrame * CFrame.new(0,0,-4)
  297.         local hplr = magdetect(magp.p,5,char,function(vhum,eroot,dist)
  298.             damage(vhum,9)
  299.             setcombotime()
  300.             local dir = magp * CFrame.Angles(math.rad(70),0,0)
  301.             setmodelowner(eroot.Parent,splr)
  302.             setvelo(eroot,(dir.lookVector*35),nil,false)
  303.             linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'hitfx',eroot.Position,5,sfx.sword1) end)
  304.         end)
  305.     end,
  306.     ['x'] = function(name,mousehit)
  307.         local cancel = 0
  308.         if anims.atkz1.isPlaying or anims.atkz2.isPlaying or anims.atkz3.isPlaying then
  309.             anims.atkz1:Stop()
  310.             anims.atkz2:Stop()
  311.             cancel = .17
  312.         end
  313.         stopanims(0)
  314.         --root.CFrame = CFrame.new(root.Position,Vector3.new(mousehit.p.X,root.Position.Y,mousehit.p.Z))
  315.         anims.atkx:Play(0)
  316.         anims.atkx.TimePosition = cancel
  317.         delay(.3-cancel,function() atking = false end)
  318.         anims.atkx.KeyframeReached:wait()
  319.         linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'x',splr,naomi.CFrame) end)
  320.         local magp = (root.CFrame * CFrame.new(0,0,-4))
  321.         local hplr = magdetect(magp.p,6,char,function(vhum,eroot,dist)
  322.             damage(vhum,14)
  323.             setcombotime()
  324.             local dir = magp * CFrame.Angles(math.rad(30),0,0)
  325.             setmodelowner(eroot.Parent,splr)
  326.             setvelo(eroot,(dir.lookVector*20) + Vector3.new(0,40,0),nil,true)
  327.             linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'hitfx',eroot.Position,5,sfx.sword1) end)
  328.         end)
  329.     end,
  330.     ['c'] = function(name,mousehit)
  331.         local cancel = 0
  332.         if anims.atkz1.isPlaying or anims.atkz2.isPlaying or anims.atkx.isPlaying then
  333.             anims.atkz1:Stop()
  334.             anims.atkz2:Stop()
  335.             anims.atkx:Stop()
  336.             cancel = .17
  337.         end
  338.         stopanims(0)
  339.         --root.CFrame = CFrame.new(root.Position,Vector3.new(mousehit.p.X,root.Position.Y,mousehit.p.Z))
  340.         anims.atkc:Play(0)
  341.         anims.atkc.TimePosition = cancel
  342.         delay(.2,function() atking = false end)
  343.         anims.atkc.KeyframeReached:wait()
  344.         linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'c',splr) end)
  345.         local magp = (root.CFrame * CFrame.new(0,0,-6))
  346.         local hplr = magdetect(magp.p,9,char,function(vhum,eroot,dist)
  347.             damage(vhum,16)
  348.             setcombotime()
  349.             local dir = magp * CFrame.Angles(math.rad(-10),0,0)
  350.             setmodelowner(eroot.Parent,splr)
  351.             setvelo(eroot,eroot.Velocity + (dir.lookVector*30),nil,true)
  352.             linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'hitfx',eroot.Position,5,sfx.sword1,1.2) end)
  353.         end)
  354.     end,
  355.     ['swq'] = function(name,trg)
  356.         local nray,rval
  357.         if trg then
  358.             local dir = -(root.Position-trg.HumanoidRootPart.Position).Unit
  359.             nray = Ray.new(root.CFrame.p,dir * 44)
  360.             rval = {workspace:FindPartOnRay(nray,char)}
  361.         else
  362.             nray = Ray.new(root.CFrame.p,root.CFrame.lookVector * 44)
  363.             rval = {workspace:FindPartOnRay(nray,char)}
  364.         end
  365.        
  366.         anims.atkswq:Play(0)
  367.         if rval[1] and rval[1].Parent:FindFirstChild("Humanoid") then
  368.             anims.atkswq.TimePosition = 0.1
  369.             delay(.8,function() atking = false end)
  370.             linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'swq1',splr) end)
  371.             local enmy = rval[1].Parent
  372.             local enmyroot = rval[1].Parent.HumanoidRootPart
  373.             local rcf = root.CFrame
  374.             local tcf = CFrame.fromMatrix(rval[2]-(rcf.lookVector*6),rcf.rightVector,rcf.upVector,-rcf.lookVector)
  375.             local ospd,ojmp = phum.WalkSpeed,phum.JumpPower
  376.             --SH1.tween( root,{CFrame=tcf},TweenInfo.new(.25),true)
  377.            
  378.             -- > align
  379.             local align = SH1.nobj("AlignPosition",{RigidityEnabled = true,MaxVelocity=math.huge,Responsiveness=200})
  380.             local alignp0 =  Instance.new("Attachment"); alignp0.Parent = root; alignp0.WorldCFrame = rcf;
  381.             local alignp1 =  Instance.new("Attachment"); alignp1.Parent = rval[1].Parent.HumanoidRootPart; alignp1.WorldCFrame = enmyroot.CFrame;
  382.             align.Attachment0 = alignp0
  383.             align.Attachment1 = alignp1
  384.             align.Parent = workspace
  385.             sethum(0,0)
  386.             --root.Velocity = Vector3.new(0,0,0)
  387.             anims.atkswq.KeyframeReached:wait()
  388.             alignp0:Destroy()
  389.             alignp1:Destroy()
  390.             align:Destroy()
  391.            
  392.             -- > reset
  393.             sethum(ospd,ojmp)
  394.             linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'swq2',splr) end)
  395.         else
  396.             anims.atkswq.KeyframeReached:wait()
  397.             delay(.6,function() atking = false end)
  398.             linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'swq2',splr) end)
  399.         end
  400.        
  401.         -- move the player upwards
  402.         --setmodelowner(char,splr)
  403.         local pdir = Vector3.new(0,1,0)*85
  404.         phum.Jump = true
  405.         setvelo(root,pdir,nil,false,nil)
  406.        
  407.         -- deal damage and move enemies
  408.         local dir = (root.CFrame * CFrame.Angles(math.rad(80),0,0)).lookVector*120
  409.         local magp = root.CFrame * CFrame.new(0,3,-4)
  410.         magdetect(magp.p,12,char,function(vhum,eroot,dist)
  411.             damage(vhum,34)
  412.             setcombotime()
  413.             setmodelowner(eroot.Parent,splr)
  414.             setvelo(eroot,dir,nil,.3)
  415.             linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'hitfx',eroot.Position,8,sfx.sword1) end)
  416.         end)
  417.     end,
  418.     ['asdq'] = function(name,trg)
  419.         if trg then
  420.             local trgroot = trg.HumanoidRootPart
  421.            
  422.             root.Anchored = true
  423.             trgroot.Anchored = true
  424.             linkstart(function(plr,link) link:InvokeClient(plr,'asdq1',trgroot.CFrame) end)
  425.            
  426.             local dir = (root.Position - trgroot.Position).Unit
  427.             local drillvals = {workspace:FindPartOnRay(Ray.new(trgroot.Position,dir*10),trg)}
  428.             local endcf = CFrame.new(drillvals[2],dir*1000)
  429.            
  430.             wait(2)
  431.             root.Anchored = false
  432.             trgroot.Anchored = false
  433.         end
  434.         atking = false
  435.     end
  436. }
  437.  
  438. for i,v in next,anim:GetChildren() do
  439.    anims[v.Name] = phum:LoadAnimation(v)
  440. end
  441.  
  442. --// events
  443. rems.skill.OnServerInvoke = function(plr,...)
  444.     if plr ~= splr then plr:Kick("sync error") return end
  445.     local args = {...}
  446.     local name = args[1]
  447.     local dely = args[2]
  448.     --SH1.printf("delay: %0.5f")
  449.     if moves[name] then
  450.         local curcd = cooldowns[name]
  451.         if tick() - curcd.cur >= curcd.max and not atking then
  452.             curcd.cur = tick()
  453.             atking = true
  454.             spawn(function() moves[name](unpack(args)) end)
  455.             return true
  456.         end
  457.         return false
  458.     end
  459. end
  460.  
  461. rnserv.Heartbeat:Connect(function(hb)
  462.     combotime = math.clamp(combotime - hb,0,2)
  463.     if combotime == 0 then
  464.         combodmg = 0
  465.         combohits = 0
  466.     end
  467.     vals.attacking.Value = atking
  468.     vals.combodmg.Value = combodmg
  469.     vals.combotime.Value = combotime
  470.     vals.combohits.Value = combohits
  471. end)
  472.  
  473. --// main
  474. init()
  475. rems.init:FireClient(splr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement