Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Damage = {}
- local Physics = require(script.Parent:FindFirstChild("Physics"))
- local DataStore = require(script.Parent:FindFirstChild("DataStore"))
- local TweenService = game:GetService("TweenService")
- local Lighting = game:GetService("Lighting")
- local DELAY_TIME = .2
- local MINIMUM_HP = 10
- local MINIMUM_STAMINA = 10
- function Damage:EffectHumanoid(Attacker, Victim, Purpose, Hitbox)
- local Skills = game:GetService("ServerScriptService").Server
- .Modules.SkillHandler.Skills
- for _,Skill in Skills:GetDescendants() do
- if Skill ~= Purpose or not Skill:IsA("ModuleScript") then continue end
- local Module = require(Skill)
- Module:HitEffects(Attacker, Victim, Hitbox)
- self:TakeHit(Attacker, Victim, Module.Hit)
- end
- warn("No skill called",Purpose,"found.")
- end
- function Damage:TakeHit(Attacker, Victim, Args)
- local Shared = require(script.Parent:FindFirstChild("Shared"))
- if Attacker:FindFirstAncestor("Players") then Attacker = Attacker.Character end
- local VictimHumanoid, VictimHumRP = Victim:WaitForChild("Humanoid"), Victim:WaitForChild("HumanoidRootPart")
- print("Damage =",Args.Damage,"Stamina =",Args.Stamina,"Blockable =",tostring(Args.Blockable))
- local KnockOut = VictimHumanoid.Health - Args.Damage <= MINIMUM_HP
- or DataStore:GetData(Victim, "Stamina") - Args.Damage <= MINIMUM_STAMINA
- local VictimBlocking, VictimPerfectBlock = DataStore:GetData(Victim, "Blocking") and Args.Blockable,
- DataStore:GetData(Victim, "PerfectBlocking") and Args.Blockable
- if VictimPerfectBlock then self:PerfectBlock(Victim) return end
- if KnockOut then self:KnockOut(Attacker, Victim) return end
- if VictimBlocking then self:Block(Victim, Args.Stamina) return end
- task.wait(DELAY_TIME)
- VictimHumRP:WaitForChild("Smack"):Play()
- VictimHumanoid.Health -= Args.Damage
- end
- function Damage:Block(Character, DealtStamina)
- local HumRP = Character:WaitForChild("HumanoidRootPart")
- local Stamina = DataStore:GetData(Character, "Stamina")
- task.wait(DELAY_TIME)
- HumRP:WaitForChild("Block"):Play()
- DataStore:SetData(Character, "Stamina", Stamina - DealtStamina)
- end
- function Damage:PerfectBlock(Character)
- local HumRP = Character:WaitForChild("HumanoidRootPart")
- task.wait(DELAY_TIME)
- HumRP:WaitForChild("PerfectBlock"):Play()
- end
- function Damage:KnockOut(Character, Direction)
- local Humanoid, HumRP = Character:FindFirstChild("Humanoid"), Character:FindFirstChild("HumanoidRootPart")
- local Blur = Lighting:FindFirstChild("Blur")
- Humanoid.Health = 1
- Blur.Enabled = true
- local Fling = Instance.new("BodyVelocity")
- Fling.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
- Fling.Velocity = Direction * 100
- Fling.Parent = HumRP
- game:GetService("Debris"):AddItem(Fling, .7)
- Physics:Ragdoll(Character, true)
- if not Shared:IsDummy(Character) then Shared["ClientServer"]:FireClient(game:GetService("Players"):GetPlayerFromCharacter(Character), "EffectsHandler", "KnockOut") end
- end
- return Damage
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement