Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Type advatages (note these are offensive (e.g. fire is super on grass, grass is nvery on fire)
- --[[ The types go in this order dont change the order or it will screw up what beats what
- 0 = None (Only for Type2);
- 1 = Normal;
- 2 = Fire;
- 3 = Water;
- 4 = Electric;
- 5 = Grass;
- 6 = Ice;
- 7 = Fighting;
- 8 = Poison;
- 9 = Ground;
- 10 = Flying;
- 11 = Psychic;
- 12 = Bug;
- 13 = Rock;
- 14 = Ghost;
- 15 = Dragon;
- 16 = Dark;
- 17 = Steel;
- 18 = Fairy;
- --]]
- local nv = 3/5
- local sup = 5/3
- local imm = 3/10
- local None = {
- 1, -- none
- 1, -- normal
- 1, -- fire
- 1, -- water
- 1, -- electric
- 1, -- grass
- 1, -- ice
- 1, -- fighting
- 1, -- poison
- 1, -- ground
- 1, -- flying
- 1, -- psychic
- 1, -- bug
- 1, -- rock
- 1, -- ghost
- 1, -- dragon
- 1, -- dark
- 1, -- steel
- 1 -- fairy
- }
- local Normal = {
- 1, -- none
- 1, -- normal
- 1, -- fire
- 1, -- water
- 1, -- electric
- 1, -- grass
- 1, -- ice
- 1, -- fighting
- 1, -- poison
- 1, -- ground
- 1, -- flying
- 1, -- psychic
- 1, -- bug
- nv, -- rock
- imm, -- ghost
- 1, -- dragon
- 1, -- dark
- nv, -- steel
- 1 -- fairy
- }
- local Fire = {
- 1, -- none
- 1, -- normal
- nv, -- fire
- nv, -- water
- 1, -- electric
- sup, -- grass
- sup, -- ice
- 1, -- fighting
- 1, -- poison
- 1, -- ground
- 1, -- flying
- 1, -- psychic
- sup, -- bug
- nv, -- rock
- 1, -- ghost
- nv, -- dragon
- 1, -- dark
- sup, -- steel
- 1 -- fairy
- }
- local Water = {
- 1, -- none
- 1, -- normal
- sup, -- fire
- nv, -- water
- 1, -- electric
- nv, -- grass
- 1, -- ice
- 1, -- fighting
- 1, -- poison
- sup, -- ground
- 1, -- flying
- 1, -- psychic
- 1, -- bug
- sup, -- rock
- 1, -- ghost
- nv, -- dragon
- 1, -- dark
- 1, -- steel
- 1 -- fairy
- }
- local Electric = {
- 1, -- none
- 1, -- normal
- 1, -- fire
- sup, -- water
- nv, -- electric
- nv, -- grass
- 1, -- ice
- 1, -- fighting
- 1, -- poison
- imm, -- ground
- sup, -- flying
- 1, -- psychic
- 1, -- bug
- 1, -- rock
- 1, -- ghost
- nv, -- dragon
- 1, -- dark
- 1, -- steel
- 1 -- fairy
- }
- local Grass = {
- 1, -- none
- 1, -- normal
- nv, -- fire
- sup, -- water
- 1, -- electric
- nv, -- grass
- 1, -- ice
- 1, -- fighting
- 1, -- poison
- sup, -- ground
- nv, -- flying
- 1, -- psychic
- nv, -- bug
- sup, -- rock
- 1, -- ghost
- nv, -- dragon
- 1, -- dark
- nv, -- steel
- 1 -- fairy
- }
- local Ice = {
- 1, -- none
- 1, -- normal
- nv, -- fire
- nv, -- water
- 1, -- electric
- sup, -- grass
- nv, -- ice
- 1, -- fighting
- 1, -- poison
- sup, -- ground
- sup, -- flying
- 1, -- psychic
- 1, -- bug
- 1, -- rock
- 1, -- ghost
- sup, -- dragon
- 1, -- dark
- nv, -- steel
- 1 -- fairy
- }
- local Fighting = {
- 1, -- none
- sup, -- normal
- 1, -- fire
- 1, -- water
- 1, -- electric
- 1, -- grass
- sup, -- ice
- 1, -- fighting
- nv, -- poison
- 1, -- ground
- nv, -- flying
- nv, -- psychic
- nv, -- bug
- sup, -- rock
- imm, -- ghost
- 1, -- dragon
- sup, -- dark
- sup, -- steel
- nv -- fairy
- }
- local Poison = {
- 1, -- none
- 1, -- normal
- 1, -- fire
- 1, -- water
- 1, -- electric
- sup, -- grass
- 1, -- ice
- 1, -- fighting
- nv, -- poison
- nv, -- ground
- 1, -- flying
- 1, -- psychic
- 1, -- bug
- nv, -- rock
- nv, -- ghost
- 1, -- dragon
- 1, -- dark
- imm, -- steel
- sup -- fairy
- }
- local Ground = {
- 1, -- none
- 1, -- normal
- sup, -- fire
- 1, -- water
- sup, -- electric
- nv, -- grass
- 1, -- ice
- 1, -- fighting
- sup, -- poison
- 1, -- ground
- imm, -- flying
- 1, -- psychic
- nv, -- bug
- sup, -- rock
- 1, -- ghost
- 1, -- dragon
- 1, -- dark
- sup, -- steel
- 1 -- fairy
- }
- local Flying = {
- 1, -- none
- 1, -- normal
- 1, -- fire
- 1, -- water
- nv, -- electric
- sup, -- grass
- 1, -- ice
- sup, -- fighting
- 1, -- poison
- 1, -- ground
- 1, -- flying
- 1, -- psychic
- sup, -- bug
- nv, -- rock
- 1, -- ghost
- 1, -- dragon
- 1, -- dark
- nv, -- steel
- 1 -- fairy
- }
- local Psychic = {
- 1, -- none
- 1, -- normal
- 1, -- fire
- 1, -- water
- 1, -- electric
- 1, -- grass
- 1, -- ice
- sup, -- fighting
- sup, -- poison
- 1, -- ground
- 1, -- flying
- nv, -- psychic
- 1, -- bug
- 1, -- rock
- 1, -- ghost
- 1, -- dragon
- imm, -- dark
- nv, -- steel
- 1 -- fairy
- }
- local Bug = {
- 1, -- none
- 1, -- normal
- nv, -- fire
- 1, -- water
- 1, -- electric
- sup, -- grass
- 1, -- ice
- nv, -- fighting
- nv, -- poison
- 1, -- ground
- nv, -- flying
- sup, -- psychic
- 1, -- bug
- nv, -- rock
- nv, -- ghost
- 1, -- dragon
- sup, -- dark
- nv, -- steel
- nv -- fairy
- }
- local Rock = {
- 1, -- none
- 1, -- normal
- sup, -- fire
- 1, -- water
- 1, -- electric
- nv, -- grass
- sup, -- ice
- nv, -- fighting
- 1, -- poison
- 1, -- ground
- sup, -- flying
- 1, -- psychic
- sup, -- bug
- nv, -- rock
- 1, -- ghost
- 1, -- dragon
- 1, -- dark
- nv, -- steel
- 1 -- fairy
- }
- local Ghost = {
- 1, -- none
- imm, -- normal
- 1, -- fire
- 1, -- water
- 1, -- electric
- 1, -- grass
- 1, -- ice
- 1, -- fighting
- 1, -- poison
- 1, -- ground
- 1, -- flying
- sup, -- psychic
- 1, -- bug
- 1, -- rock
- sup, -- ghost
- 1, -- dragon
- nv, -- dark
- 1, -- steel
- 1 -- fairy
- }
- local Dragon = {
- 1, -- none
- 1, -- normal
- 1, -- fire
- 1, -- water
- 1, -- electric
- 1, -- grass
- 1, -- ice
- 1, -- fighting
- 1, -- poison
- 1, -- ground
- 1, -- flying
- 1, -- psychic
- 1, -- bug
- 1, -- rock
- 1, -- ghost
- sup, -- dragon
- 1, -- dark
- nv, -- steel
- imm -- fairy
- }
- local Dark = {
- 1, -- none
- 1, -- normal
- 1, -- fire
- 1, -- water
- 1, -- electric
- 1, -- grass
- 1, -- ice
- nv, -- fighting
- 1, -- poison
- 1, -- ground
- 1, -- flying
- sup, -- psychic
- 1, -- bug
- 1, -- rock
- sup, -- ghost
- 1, -- dragon
- nv, -- dark
- 1, -- steel
- nv -- fairy
- }
- local Steel = {
- 1, -- none
- 1, -- normal
- nv, -- fire
- nv, -- water
- nv, -- electric
- 1, -- grass
- sup, -- ice
- 1, -- fighting
- 1, -- poison
- 1, -- ground
- 1, -- flying
- 1, -- psychic
- 1, -- bug
- sup, -- rock
- 1, -- ghost
- 1, -- dragon
- 1, -- dark
- nv, -- steel
- sup -- fairy
- }
- local Fairy = {
- 1, -- none
- 1, -- normal
- nv, -- fire
- 1, -- water
- 1, -- electric
- 1, -- grass
- 1, -- ice
- sup, -- fighting
- nv, -- poison
- 1, -- ground
- 1, -- flying
- 1, -- psychic
- 1, -- bug
- 1, -- rock
- 1, -- ghost
- sup, -- dragon
- sup, -- dark
- nv, -- steel
- 1 -- fairy
- }
- -- LIBRARIES
- local STATS = require(game:GetService("ServerScriptService"):WaitForChild("Stats"))
- local TOUCH_MANAGER = require(game.ServerScriptService.Libraries.OnTouched)
- local BOSS_HOLDER = game.Workspace:WaitForChild("BossHolder")
- local DS_Teams = {}
- local DS_Teams_Id = 1
- local DamageService = {}
- -- TEAMS
- function DamageService:RegisterTeam(tab)
- local CID = DS_Teams_Id DS_Teams_Id = DS_Teams_Id + 1
- DS_Teams[CID] = {}
- for _, i in pairs(tab) do
- DS_Teams[CID][i.UserId] = true
- end
- local ret = {}
- function ret:Disconnect()
- DS_Teams[CID] = nil
- end
- return ret
- end
- function DamageService:IsTeamed(Handler, Target)
- if not Handler or not Target then return false end
- if not Handler:IsA'Player' or not Target:IsA'Player' then return false end
- for _, holder in pairs(DS_Teams) do
- if holder[Handler.UserId] then
- if holder[Target.UserId] then
- return true
- end
- end
- end
- return false
- end
- function DamageService:GetPlayer(hit)
- if hit.Parent:FindFirstChild("Humanoid") then
- local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
- if plr then
- return plr
- else
- return hit.Parent
- end
- end
- return nil
- end
- -- DAMAGE
- function DamageService:CanDamage(Handler, Target)
- if not Target then return false end
- if Handler == Target then return false end
- if Handler ~= nil then
- if Handler:IsA'Player' then
- if not (STATS.GetStat(Handler, "PvP") == 1) then return false end
- if not (STATS.GetStat(Handler, "SLP") == 0) then return false end
- if not (Handler.Character) then return false end
- if not (Handler.Character:FindFirstChild("Humanoid")) then return false end
- if not (Handler.Character.Humanoid.MaxHealth > 0) or not (Handler.Character.Humanoid.Health > 0) then return false end
- else
- if not (Handler:FindFirstChild("Humanoid")) then return false end
- if not (Handler.Humanoid.MaxHealth > 0) or not (Handler.Humanoid.Health > 0) then return false end
- if (Handler:FindFirstChild("SLP")) then if not (Handler.SLP.Value == 0) then return false end end
- end
- end
- if Target:IsA'Player' then
- if not (STATS.GetStat(Target, "PvP") == 1) then return false end
- if not (STATS.GetStat(Target, "CanDamage") == 1) then return false end
- if not (Target.Character) then return false end
- if not (Target.Character:FindFirstChild("Humanoid")) then return false end
- if not (Target.Character.Humanoid.MaxHealth > 0) or not (Target.Character.Humanoid.Health > 0) then return false end
- else
- if not (Target:FindFirstChild("Humanoid")) then return false end
- if not (Target.Humanoid.MaxHealth > 0) or not (Target.Humanoid.Health > 0) then return false end
- if (Target:FindFirstChild("SLP")) then if not (Target.SLP.Value == 0) then return false end end
- end
- if Handler ~= nil then
- if Handler:IsA'Player' and Target:IsA'Player' then
- if DamageService:IsTeamed(Handler, Target) then return false end
- end
- end
- return true
- end
- function DamageService:CanHeal(Handler, Target)
- if not Target then return false end
- if Handler == Target then return false end
- if Handler ~= nil then
- if Handler:IsA'Player' then
- if not (STATS.GetStat(Handler, "PvP") == 1) then return false end
- if not (STATS.GetStat(Handler, "SLP") == 0) then return false end
- if not (Handler.Character) then return false end
- if not (Handler.Character:FindFirstChild("Humanoid")) then return false end
- if not (Handler.Character.Humanoid.MaxHealth > 0) or not (Handler.Character.Humanoid.Health > 0) then return false end
- else
- if not (Handler:FindFirstChild("Humanoid")) then return false end
- if not (Handler.Humanoid.MaxHealth > 0) or not (Handler.Humanoid.Health > 0) then return false end
- if (Handler:FindFirstChild("SLP")) then if not (Handler.SLP.Value == 0 )then return false end end
- end
- end
- if Target:IsA'Player' then
- if not (STATS.GetStat(Target, "PvP") == 1) then return false end
- if not (Target.Character) then return false end
- if not (Target.Character:FindFirstChild("Humanoid")) then return false end
- if not (Target.Character.Humanoid.MaxHealth > 0) or not (Target.Character.Humanoid.Health > 0) then return false end
- else
- if not (Target:FindFirstChild("Humanoid")) then return false end
- if not (Target.Humanoid.MaxHealth > 0) or not (Target.Humanoid.Health > 0) then return false end
- end
- return true
- end
- function DamageService:RegisterDamage(Handler, Target, Damage, AttackType)
- if Damage < 0 then return false end
- if DamageService:CanDamage(Handler, Target) then
- if Target:IsA'Player' then
- Target.Character.Humanoid:TakeDamage(math.ceil(Damage * AttackType[STATS.GetStat(Target, "Type") + 1] * AttackType[STATS.GetStat(Target, "Type2") + 1]))
- else
- local t1
- local t2
- if Target:FindFirstChild("Type") then t1 = Target.Type elseif Target:FindFirstChild("Type1") then t1 = Target.Type1 else t1 = 0 end
- if Target:FindFirstChild("Type2") then t2 = Target.Type2 else t2 = 0 end
- Target.Humanoid:TakeDamage(math.ceil(Damage * AttackType[t1 + 1] * AttackType[t2 + 1]))
- end
- return true
- end
- return false
- end
- function DamageService:RegisterHeal(Handler, Target, Heal)
- if Heal < 0 then return false end
- if DamageService:CanHeal(Handler, Target) then
- if Target:IsA'Player' then
- Target.Character.Humanoid.Health = Target.Character.Humanoid.Health + Heal
- else
- Target.Humanoid.Health = Target.Humanoid.Health + Heal
- end
- return true
- end
- return false
- end
- function DamageService:RegisterWeaponPart(Handler, Parts, Damage, OnHitFunc, Type)
- spawn(function()
- local attacktype
- if not Type then attacktype = None else
- local tupe = string.upper(tostring(Type))
- if tupe == "1" or tupe == "NOR" or tupe == "NORMAL" then attacktype = Normal end
- if tupe == "2" or tupe == "FIR" or tupe == "FIRE" then attacktype = Fire end
- if tupe == "3" or tupe == "WAT" or tupe == "WATER" then attacktype = Water end
- if tupe == "4" or tupe == "ELE" or tupe == "ELECTRIC" then attacktype = Electric end
- if tupe == "5" or tupe == "GRA" or tupe == "GRASS" then attacktype = Grass end
- if tupe == "6" or tupe == "ICE" then attacktype = Ice end
- if tupe == "7" or tupe == "FIG" or tupe == "FIGHTING" then attacktype = Fighting end
- if tupe == "8" or tupe == "POI" or tupe == "POISON" then attacktype = Poison end
- if tupe == "9" or tupe == "GRO" or tupe == "GROUND" then attacktype = Ground end
- if tupe == "10" or tupe == "FLY" or tupe == "FLYING" then attacktype = Flying end
- if tupe == "11" or tupe == "PSY" or tupe == "PSYCHIC" then attacktype = Psychic end
- if tupe == "12" or tupe == "BUG" then attacktype = Bug end
- if tupe == "13" or tupe == "ROC" or tupe == "ROCK" then attacktype = Rock end
- if tupe == "14" or tupe == "GHO" or tupe == "GHOST" then attacktype = Ghost end
- if tupe == "15" or tupe == "DRA" or tupe == "DRAGON" then attacktype = Dragon end
- if tupe == "16" or tupe == "DAR" or tupe == "DARK" then attacktype = Dark end
- if tupe == "17" or tupe == "STE" or tupe == "STEEL" then attacktype = Steel end
- if tupe == "18" or tupe == "FAI" or tupe == "FAIRY" then attacktype = Fairy end
- if attacktype == nil then attacktype = None end
- end
- local connections = {}
- local debounce = {}
- for _, Part in pairs(Parts) do
- local connection = TOUCH_MANAGER.Touched(Part, function(hit)
- if hit then
- local Player = DamageService:GetPlayer(hit)
- if Player then
- if debounce[Player.Name] == nil then
- if DamageService:RegisterDamage(Handler, Player, Damage, attacktype) then
- debounce[Player.Name] = true
- if OnHitFunc then OnHitFunc(Player) end
- end
- end
- end
- end
- end)
- end
- local count = #Parts
- repeat
- wait(1)
- count = 0
- for _, Part in pairs(Parts) do
- if Part ~= nil then
- if Part.Parent ~= nil then
- count = count + 1
- end
- end
- end
- until count == 0
- for _, connection in pairs(connections) do
- connection:Disconnect()
- end
- end)
- end
- function DamageService:RegisterRangeDamage(Handler, Range, Damage, OnHitFunc, Type)
- spawn(function()
- local attacktype
- if not Type then attacktype = None else
- local tupe = string.upper(tostring(Type))
- if tupe == "1" or tupe == "NOR" or tupe == "NORMAL" then attacktype = Normal end
- if tupe == "2" or tupe == "FIR" or tupe == "FIRE" then attacktype = Fire end
- if tupe == "3" or tupe == "WAT" or tupe == "WATER" then attacktype = Water end
- if tupe == "4" or tupe == "ELE" or tupe == "ELECTRIC" then attacktype = Electric end
- if tupe == "5" or tupe == "GRA" or tupe == "GRASS" then attacktype = Grass end
- if tupe == "6" or tupe == "ICE" then attacktype = Ice end
- if tupe == "7" or tupe == "FIG" or tupe == "FIGHTING" then attacktype = Fighting end
- if tupe == "8" or tupe == "POI" or tupe == "POISON" then attacktype = Poison end
- if tupe == "9" or tupe == "GRO" or tupe == "GROUND" then attacktype = Ground end
- if tupe == "10" or tupe == "FLY" or tupe == "FLYING" then attacktype = Flying end
- if tupe == "11" or tupe == "PSY" or tupe == "PSYCHIC" then attacktype = Psychic end
- if tupe == "12" or tupe == "BUG" then attacktype = Bug end
- if tupe == "13" or tupe == "ROC" or tupe == "ROCK" then attacktype = Rock end
- if tupe == "14" or tupe == "GHO" or tupe == "GHOST" then attacktype = Ghost end
- if tupe == "15" or tupe == "DRA" or tupe == "DRAGON" then attacktype = Dragon end
- if tupe == "16" or tupe == "DAR" or tupe == "DARK" then attacktype = Dark end
- if tupe == "17" or tupe == "STE" or tupe == "STEEL" then attacktype = Steel end
- if tupe == "18" or tupe == "FAI" or tupe == "FAIRY" then attacktype = Fairy end
- if attacktype == nil then attacktype = None end
- end
- for _, plr in pairs(game.Players:GetPlayers()) do
- if plr.Character and Handler.Character then
- if plr.Character:FindFirstChild("Torso") and Handler.Character:FindFirstChild("Torso") then
- if (Handler.Character.Torso.Position - plr.Character.Torso.Position).magnitude <= Range then
- if DamageService:RegisterDamage(Handler, plr, Damage, attacktype) and OnHitFunc then
- OnHitFunc(plr)
- end
- end
- end
- end
- end
- for _, boss in pairs(BOSS_HOLDER:GetChildren()) do
- if boss:IsA'Model' then
- if boss:FindFirstChild("Torso") then
- if (boss.Torso.Position - Handler.Character.Torso.Position).magnitude <= Range then
- if DamageService:RegisterDamage(Handler, boss, Damage) and OnHitFunc then
- OnHitFunc(boss)
- end
- end
- end
- end
- end
- end)
- end
- function DamageService:RegisterHealPart(Handler, Parts, Heal, OnHitFunc)
- spawn(function()
- local connections = {}
- local debounce = {}
- for _, Part in pairs(Parts) do
- local connection = TOUCH_MANAGER.Touched(Part, function(hit)
- if hit then
- local Player = DamageService:GetPlayer(hit)
- if Player then
- if debounce[Player.Name] == nil then
- if DamageService:RegisterHeal(Handler, Player, Heal) then
- debounce[Player.Name] = true
- if OnHitFunc then OnHitFunc(Player) end
- end
- end
- end
- end
- end)
- end
- local count = #Parts
- repeat
- wait(1)
- count = 0
- for _, Part in pairs(Parts) do
- if Part ~= nil then
- if Part.Parent ~= nil then
- count = count + 1
- end
- end
- end
- until count == 0
- for _, connection in pairs(connections) do
- connection:Disconnect()
- end
- end)
- end
- function DamageService:RegisterRangeHeal(Handler, Range, Heal, OnHitFunc)
- spawn(function()
- for _, plr in pairs(game.Players:GetPlayers()) do
- if plr.Character and Handler.Character then
- if plr.Character:FindFirstChild("Torso") and Handler.Character:FindFirstChild("Torso") then
- if (Handler.Character.Torso.Position - plr.Character.Torso.Position).magnitude <= Range then
- if DamageService:RegisterHeal(Handler, plr, Heal) and OnHitFunc then
- OnHitFunc(plr)
- end
- end
- end
- end
- end
- for _, boss in pairs(BOSS_HOLDER:GetChildren()) do
- if boss:IsA'Model' then
- if boss:FindFirstChild("Torso") then
- if (boss.Torso.Position - Handler.Character.Torso.Position).magnitude <= Range then
- if DamageService:RegisterHeal(Handler, boss, Heal) and OnHitFunc then
- OnHitFunc(boss)
- end
- end
- end
- end
- end
- end)
- end
- return DamageService
Add Comment
Please, Sign In to add comment