Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --// services
- local tweens = game:GetService("TweenService")
- local sstore = game:GetService("ServerStorage")
- local rpstor = game:GetService("ReplicatedStorage")
- local rpfrst = game:GetService("ReplicatedFirst")
- local player = game:GetService("Players")
- local debris = game:GetService("Debris")
- local uinput = game:GetService("UserInputService")
- local rnserv = game:GetService("RunService")
- local hbeat = rnserv.Heartbeat
- --/ modules
- local mods = script.Parent.Parent:WaitForChild('mods')
- local mget = function(n) return require(mods:WaitForChild(n)) end
- local SH1 = mget("SH1")
- --// vars
- local FRAME = 1/60
- local FRAME2 = 1/30
- --/ main
- local main = script.Parent.Parent
- local vals = main:WaitForChild("vals")
- local rems = main:WaitForChild("remotes")
- local sfx = main:WaitForChild("sfx")
- local mdls = main:WaitForChild("model")
- local anim = main:WaitForChild("anims")
- --/ plr
- local char = main.Parent
- local splr = player:GetPlayerFromCharacter(char)
- local root = char:WaitForChild("HumanoidRootPart")
- local phum = char:WaitForChild("Humanoid")
- local anims = {}
- local naomi = mdls:WaitForChild("naomi")
- naomi.Parent = char
- local njoint = nil
- local lastzmove = tick()
- local combodmg = 0
- local combotime = 0
- --/ etc
- function newcd(m,c) return {max=m,cur=c} end
- local cooldowns = {
- -- specials
- asdq = newcd(6,0),
- adq = newcd(3,0),
- swq = newcd(4,0),
- -- neutrals
- z1 = newcd(.4,0), -- z combos are spammable. give em long cooldowns
- z2 = newcd(.4,0),
- z3 = newcd(.4,0),
- x = newcd(.8,0),
- c = newcd(.9,0)
- }
- local atking = false
- --/ math vars
- pi = math.pi
- rad = math.rad
- deg = math.deg
- sin = math.sin
- cos = math.cos
- tan = math.tan
- sinh = math.sinh
- cosh = math.cosh
- tanh = math.tanh
- acos = math.acos
- atan = math.atan
- asin = math.asin
- rand = math.random
- seed = math.randomseed
- atan2 = math.atan2
- clamp = function(x,min,max) return (x < min and min or x > max and max or x) end
- seed(tick())
- --// funcs
- function init()
- njoint = Instance.new("Motor6D")
- njoint.Name = "sol"
- njoint.Part0 = char['Right Arm']
- njoint.Part1 = naomi
- njoint.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- 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)
- njoint.Parent = char['Right Arm']
- naomi.Anchored = false
- naomi.Massless = true
- naomi:SetNetworkOwner(splr)
- phum.MaxHealth = 300
- phum.Health = phum.MaxHealth
- print(njoint.C0,njoint.C1)
- end
- function magdetect(pos,radius,ignore,cback)
- local hit = {}
- for i,v in next,workspace:GetChildren() do
- local vhum = v:FindFirstChild("Humanoid")
- if vhum and v ~= ignore then
- local eroot = v:FindFirstChild("HumanoidRootPart")
- local dist = (pos-eroot.Position).Magnitude
- if dist <= radius then
- hit[#hit+1] = v
- if cback then cback(vhum,eroot,dist) end
- end
- print(splr.hbox.Value)
- --if splr:FindFirstChild("hbox") and splr.hbox.Value == true then
- if true then
- local hdisp = SH1.nobj("Part",{
- ["CFrame"] = CFrame.new(pos),
- ["Size"] = Vector3.new(radius,radius,radius)*2,
- ["Color"] = Color3.new(1,0,0),
- ["Transparency"] = .9,
- ["Anchored"] = true,
- ["CanCollide"] = false,
- ["Shape"] = "Ball",
- ["Material"] = "SmoothPlastic"
- },.7)
- local htwn = SH1.tween(hdisp,{Transparency=1},TweenInfo.new(.7),true)
- hdisp.Parent = char
- end
- end
- end
- return hit
- end
- function stopanims(fade) -- stop all animations, with optional fadetime
- for i,v in next,phum:GetPlayingAnimationTracks() do
- if v.Name:sub(1,3) == 'atk' or v.Name == "stance" then
- v:Stop(fade)
- end
- end
- end
- function linkstart(cback,link) -- easy link function
- for _,plr in next,player:GetPlayers() do
- spawn(function()
- cback(plr,plr.Character.class.remotes.link)
- end)
- end
- end
- function setvelo(obj,v,rv,stand,hum) -- function for setting & replicating velocity
- local ohum = obj.Parent.Humanoid
- local vplr = player:GetPlayerFromCharacter(obj.Parent)
- ohum.PlatformStand = (stand and true) or ohum.PlatformStand
- rems.velo:FireClient(vplr or splr,obj,v,rv,hum)
- if stand then delay(stand,function() ohum.PlatformStand = false end) end
- end
- function setmodelowner(obj,owner) -- set network ownership of model's descendants
- local pchar = player:GetPlayerFromCharacter(obj)
- if not pchar then
- SH1.printf("%s is not a player",obj.Name)
- for i,v in next,obj:GetDescendants() do
- if v:IsA('BasePart') then
- v:SetNetworkOwner(owner)
- end
- end
- end
- end
- function sethum(spd,jmp) -- set walkspeed & jump height
- phum.WalkSpeed = spd
- phum.JumpPower = jmp
- end
- function setcombotime()
- combotime = 2
- combohits = combohits + 1
- end
- function damage(hum,dmg)
- hum:TakeDamage(dmg)
- combodmg = combodmg + dmg
- end
- --// moves
- moves = {
- ['adq'] = function(name,mousehit)
- stopanims(0.05)
- --root.CFrame = CFrame.new(root.Position,Vector3.new(mousehit.p.X,root.Position.Y,mousehit.p.Z))
- anims.atkadq:Play()
- local ospd,ojmp = phum.WalkSpeed,phum.JumpPower
- sethum(0,0)
- delay(.3,function() sethum(ospd,ojmp) atking = false end)
- anims.atkadq.KeyframeReached:wait()
- for _,plr in next,player:GetPlayers() do
- spawn(function()
- if not plr.Character then return end
- local echar = plr.Character
- local bman = echar.class
- local link = bman.remotes.link
- local waitin = false
- link:InvokeClient(plr,'adq1',root,char)
- end)
- end
- local rspot = Ray.new(root.Position,-root.CFrame.upVector*10)
- local rsv = {workspace:FindPartOnRay(rspot,char)}
- local ocf = root.CFrame * CFrame.new(0,-((root.Position-rsv[2]).magnitude),0)
- local ecf = ocf * CFrame.new(0,0,-30)
- for i = 0.2,1,0.2 do
- local magp = (ocf:lerp(ecf,i)).p
- local bval = false
- local hplr = magdetect(magp,8,char,function(vhum,eroot,dist)
- bval = true
- damage(vhum,12)
- setcombotime()
- linkstart(function(plr)
- plr.Character.class.remotes.link:InvokeClient(plr,'adq2',magp)
- plr.Character.class.remotes.link:InvokeClient(plr,'hitfx',magp,8)
- end)
- end)
- if bval then break end
- wait(0.07)
- end
- end,
- ['z1'] = function(name,mousehit)
- lastzmove = tick()
- stopanims(0)
- root.Velocity = Vector3.new()
- --root.CFrame = CFrame.new(root.Position,Vector3.new(mousehit.p.X,root.Position.Y,mousehit.p.Z))
- sethum(0,0)
- anims.atkz1:Play()
- anims.atkz1.KeyframeReached:wait()
- delay(.05,function() sethum(16,50) atking = false end)
- linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'z1',splr) end)
- spawn(function()
- local nbp = Instance.new("BodyPosition")
- nbp.Position = (root.CFrame * CFrame.new(0,3,-5)).p
- nbp.Parent = root
- wait(.1)
- nbp:Destroy()
- end)
- local magp = root.CFrame * CFrame.new(0,0,-4)
- local hplr = magdetect(magp.p,5,char,function(vhum,eroot,dist)
- damage(vhum,7)
- setcombotime()
- local dir = magp * CFrame.Angles(math.rad(70),0,0)
- setmodelowner(eroot.Parent,splr)
- setvelo(eroot,(dir.lookVector*15),nil,false)
- linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'hitfx',eroot.Position,5,sfx.kick1) end)
- end)
- end,
- ['z2'] = function(name,mousehit)
- lastzmove = tick()
- stopanims(0)
- --root.CFrame = CFrame.new(root.Position,Vector3.new(mousehit.p.X,root.Position.Y,mousehit.p.Z))
- sethum(0,0)
- anims.atkz2:Play()
- anims.atkz2.KeyframeReached:wait()
- delay(.05,function() sethum(16,50) atking = false end)
- linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'z2',splr) end)
- spawn(function()
- local nbp = Instance.new("BodyPosition")
- nbp.Position = (root.CFrame * CFrame.new(0,4,-5)).p
- nbp.Parent = root
- wait(.1)
- nbp:Destroy()
- end)
- local magp = root.CFrame * CFrame.new(0,0,-4)
- local hplr = magdetect(magp.p,5,char,function(vhum,eroot,dist)
- damage(vhum,5)
- setcombotime()
- local dir = magp * CFrame.Angles(math.rad(70),0,0)
- setmodelowner(eroot.Parent,splr)
- setvelo(eroot,(dir.lookVector*35),nil,false)
- linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'hitfx',eroot.Position,5,sfx.kick1) end)
- end)
- end,
- ['z3'] = function(name,mousehit)
- lastzmove = tick()
- stopanims(0)
- --root.CFrame = CFrame.new(root.Position,Vector3.new(mousehit.p.X,root.Position.Y,mousehit.p.Z))
- sethum(0,0)
- anims.atkz3:Play(0)
- anims.atkz3.KeyframeReached:wait()
- delay(.05,function() sethum(16,50) atking = false end)
- linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'z3',splr) end)
- spawn(function()
- local nbp = Instance.new("BodyPosition")
- nbp.Position = (root.CFrame * CFrame.new(0,0,-5)).p
- nbp.Parent = root
- wait(.1)
- nbp:Destroy()
- end)
- local magp = root.CFrame * CFrame.new(0,0,-4)
- local hplr = magdetect(magp.p,5,char,function(vhum,eroot,dist)
- damage(vhum,9)
- setcombotime()
- local dir = magp * CFrame.Angles(math.rad(70),0,0)
- setmodelowner(eroot.Parent,splr)
- setvelo(eroot,(dir.lookVector*35),nil,false)
- linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'hitfx',eroot.Position,5,sfx.sword1) end)
- end)
- end,
- ['x'] = function(name,mousehit)
- local cancel = 0
- if anims.atkz1.isPlaying or anims.atkz2.isPlaying or anims.atkz3.isPlaying then
- anims.atkz1:Stop()
- anims.atkz2:Stop()
- cancel = .17
- end
- stopanims(0)
- --root.CFrame = CFrame.new(root.Position,Vector3.new(mousehit.p.X,root.Position.Y,mousehit.p.Z))
- anims.atkx:Play(0)
- anims.atkx.TimePosition = cancel
- delay(.3-cancel,function() atking = false end)
- anims.atkx.KeyframeReached:wait()
- linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'x',splr,naomi.CFrame) end)
- local magp = (root.CFrame * CFrame.new(0,0,-4))
- local hplr = magdetect(magp.p,6,char,function(vhum,eroot,dist)
- damage(vhum,14)
- setcombotime()
- local dir = magp * CFrame.Angles(math.rad(30),0,0)
- setmodelowner(eroot.Parent,splr)
- setvelo(eroot,(dir.lookVector*20) + Vector3.new(0,40,0),nil,true)
- linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'hitfx',eroot.Position,5,sfx.sword1) end)
- end)
- end,
- ['c'] = function(name,mousehit)
- local cancel = 0
- if anims.atkz1.isPlaying or anims.atkz2.isPlaying or anims.atkx.isPlaying then
- anims.atkz1:Stop()
- anims.atkz2:Stop()
- anims.atkx:Stop()
- cancel = .17
- end
- stopanims(0)
- --root.CFrame = CFrame.new(root.Position,Vector3.new(mousehit.p.X,root.Position.Y,mousehit.p.Z))
- anims.atkc:Play(0)
- anims.atkc.TimePosition = cancel
- delay(.2,function() atking = false end)
- anims.atkc.KeyframeReached:wait()
- linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'c',splr) end)
- local magp = (root.CFrame * CFrame.new(0,0,-6))
- local hplr = magdetect(magp.p,9,char,function(vhum,eroot,dist)
- damage(vhum,16)
- setcombotime()
- local dir = magp * CFrame.Angles(math.rad(-10),0,0)
- setmodelowner(eroot.Parent,splr)
- setvelo(eroot,eroot.Velocity + (dir.lookVector*30),nil,true)
- linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'hitfx',eroot.Position,5,sfx.sword1,1.2) end)
- end)
- end,
- ['swq'] = function(name,trg)
- local nray,rval
- if trg then
- local dir = -(root.Position-trg.HumanoidRootPart.Position).Unit
- nray = Ray.new(root.CFrame.p,dir * 44)
- rval = {workspace:FindPartOnRay(nray,char)}
- else
- nray = Ray.new(root.CFrame.p,root.CFrame.lookVector * 44)
- rval = {workspace:FindPartOnRay(nray,char)}
- end
- anims.atkswq:Play(0)
- if rval[1] and rval[1].Parent:FindFirstChild("Humanoid") then
- anims.atkswq.TimePosition = 0.1
- delay(.8,function() atking = false end)
- linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'swq1',splr) end)
- local enmy = rval[1].Parent
- local enmyroot = rval[1].Parent.HumanoidRootPart
- local rcf = root.CFrame
- local tcf = CFrame.fromMatrix(rval[2]-(rcf.lookVector*6),rcf.rightVector,rcf.upVector,-rcf.lookVector)
- local ospd,ojmp = phum.WalkSpeed,phum.JumpPower
- --SH1.tween( root,{CFrame=tcf},TweenInfo.new(.25),true)
- -- > align
- local align = SH1.nobj("AlignPosition",{RigidityEnabled = true,MaxVelocity=math.huge,Responsiveness=200})
- local alignp0 = Instance.new("Attachment"); alignp0.Parent = root; alignp0.WorldCFrame = rcf;
- local alignp1 = Instance.new("Attachment"); alignp1.Parent = rval[1].Parent.HumanoidRootPart; alignp1.WorldCFrame = enmyroot.CFrame;
- align.Attachment0 = alignp0
- align.Attachment1 = alignp1
- align.Parent = workspace
- sethum(0,0)
- --root.Velocity = Vector3.new(0,0,0)
- anims.atkswq.KeyframeReached:wait()
- alignp0:Destroy()
- alignp1:Destroy()
- align:Destroy()
- -- > reset
- sethum(ospd,ojmp)
- linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'swq2',splr) end)
- else
- anims.atkswq.KeyframeReached:wait()
- delay(.6,function() atking = false end)
- linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'swq2',splr) end)
- end
- -- move the player upwards
- --setmodelowner(char,splr)
- local pdir = Vector3.new(0,1,0)*85
- phum.Jump = true
- setvelo(root,pdir,nil,false,nil)
- -- deal damage and move enemies
- local dir = (root.CFrame * CFrame.Angles(math.rad(80),0,0)).lookVector*120
- local magp = root.CFrame * CFrame.new(0,3,-4)
- magdetect(magp.p,12,char,function(vhum,eroot,dist)
- damage(vhum,34)
- setcombotime()
- setmodelowner(eroot.Parent,splr)
- setvelo(eroot,dir,nil,.3)
- linkstart(function(plr) plr.Character.class.remotes.link:InvokeClient(plr,'hitfx',eroot.Position,8,sfx.sword1) end)
- end)
- end,
- ['asdq'] = function(name,trg)
- if trg then
- local trgroot = trg.HumanoidRootPart
- root.Anchored = true
- trgroot.Anchored = true
- linkstart(function(plr,link) link:InvokeClient(plr,'asdq1',trgroot.CFrame) end)
- local dir = (root.Position - trgroot.Position).Unit
- local drillvals = {workspace:FindPartOnRay(Ray.new(trgroot.Position,dir*10),trg)}
- local endcf = CFrame.new(drillvals[2],dir*1000)
- wait(2)
- root.Anchored = false
- trgroot.Anchored = false
- end
- atking = false
- end
- }
- for i,v in next,anim:GetChildren() do
- anims[v.Name] = phum:LoadAnimation(v)
- end
- --// events
- rems.skill.OnServerInvoke = function(plr,...)
- if plr ~= splr then plr:Kick("sync error") return end
- local args = {...}
- local name = args[1]
- local dely = args[2]
- --SH1.printf("delay: %0.5f")
- if moves[name] then
- local curcd = cooldowns[name]
- if tick() - curcd.cur >= curcd.max and not atking then
- curcd.cur = tick()
- atking = true
- spawn(function() moves[name](unpack(args)) end)
- return true
- end
- return false
- end
- end
- rnserv.Heartbeat:Connect(function(hb)
- combotime = math.clamp(combotime - hb,0,2)
- if combotime == 0 then
- combodmg = 0
- combohits = 0
- end
- vals.attacking.Value = atking
- vals.combodmg.Value = combodmg
- vals.combotime.Value = combotime
- vals.combohits.Value = combohits
- end)
- --// main
- init()
- rems.init:FireClient(splr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement