Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _G.DAMAGE_MASTER = {}
- _G.DamageMasterReady = false
- --vars
- local players = game.Players
- local DebrisServ = game:GetService("Debris")
- local ReplicatedData = workspace.ReplicatedData
- local PlayerEvents = ReplicatedData.PlayerEvents
- local ev_Deathcam = PlayerEvents.DeathCam
- local ev_KillConfirm = PlayerEvents.KillConfirm
- local ReplicatedStore = game.ReplicatedStorage
- local CommonModules = ReplicatedStore.CommonModules
- local GameContent = ReplicatedStore.GameContent
- local KnifeContent = GameContent.KnifeContent
- local RevolverContent = GameContent.RevolverContent
- local RevolverSkins = RevolverContent:WaitForChild("RevolverSkins")
- local KnifeSkins = KnifeContent:WaitForChild("KnifeSkins")
- local KnifeFlares = KnifeContent:WaitForChild("KnifeFlares")
- _G.DAMAGE_MASTER.KnifeDamageRequest = Instance.new("BindableEvent")
- _G.DAMAGE_MASTER.RevolverDamageRequest = Instance.new("BindableEvent")
- local MasterDebris = workspace.MasterDebris
- local RagdollsDebris = MasterDebris.Ragdolls
- local RagdollsModule = require(CommonModules.Ragdolls)
- local GetItemFromKeyHolder = function(KeyHolder, ItemName)
- for _, holder in pairs(KeyHolder:GetChildren()) do
- if holder.ClassName == "Model" then
- if holder.Name == ItemName then
- return holder
- end
- elseif holder.ClassName == "Folder" then
- for _, item in pairs(holder:GetChildren()) do
- if item.ClassName == "Model" then
- if item.Name == ItemName then
- return item
- end
- end
- end
- end
- end
- end
- --Common Funcs
- local common_functions = {}
- local real_body_part_names = {"Head", "Left Arm", "Left Leg", "Right Arm", "Right Leg", "Torso"}
- local body_part_names = {"Head", "LeftArm", "LeftLeg", "RightArm", "RightLeg", "Torso"}
- common_functions.GetAllBodyParts = function(char, func)
- for _, obj in pairs(char:GetChildren()) do
- for _, nm in pairs(real_body_part_names) do
- if nm == obj.Name then
- func(obj)
- break
- end
- end
- end
- end
- common_functions.GetAllParts = function(char, func)
- local function scan(ch)
- for _, obj in pairs(ch:GetChildren()) do
- scan(obj)
- if obj:IsA("BasePart") then
- func(obj)
- end
- end
- end
- scan(char)
- end
- common_functions.Ragdoll = function(Model, Type)
- RagdollsModule[Type](Model, false)
- end
- common_functions.skin_recolor = function(Model, BColor)
- --Getting body colors object
- local b_col = Model:FindFirstChild("Body Colors")
- if b_col ~= nil then
- for _, nm in pairs(body_part_names) do
- b_col[nm .. "Color"] = BrickColor.new(BColor)
- end
- end
- end
- common_functions.ApplyVelocity = function(Model, KillVelocity)
- local GetTor = Model:FindFirstChild("Torso")
- if GetTor then
- if KillVelocity then
- GetTor.Velocity = Vector3.new(KillVelocity.x, .25, KillVelocity.z) * 250
- else
- local v1 = (math.random(20) - 10) / 75
- local v2 = (math.random(20) - 10) / 75
- GetTor.Velocity = Vector3.new(v1, 0, v2) * 250
- end
- end
- end
- common_functions.materialise = function(Model, Material, BColor)
- --Getting body colors object
- local b_col = Model:FindFirstChild("Body Colors")
- if b_col == nil then
- b_col = Instance.new("BodyColors")
- b_col.Parent = Model
- end
- if b_col ~= nil then
- for _, nm in pairs(body_part_names) do
- b_col[nm .. "Color"] = BrickColor.new(BColor)
- end
- end
- common_functions.GetAllParts(Model, function(obj)
- --removing mesh texture
- for _, v in pairs(obj:GetChildren()) do
- if v:IsA("SpecialMesh") then
- v.TextureId = ""
- end
- end
- --recoloring part
- obj.BrickColor = BrickColor.new(BColor)
- obj.Material = Material
- end)
- end
- common_functions.Clear_Appearance = function(Model)
- local function scan(ch)
- for _, obj in pairs(ch:GetChildren()) do
- scan(obj)
- if (obj.Name ~= "RadioWeld") and (obj.Name ~= "face") and (not obj:IsA("SpecialMesh")) and (not obj:IsA("Humanoid")) and (not obj:IsA("BasePart")) then
- obj:destroy()
- end
- if obj.Name == 'Head' then
- obj["face"]:Destroy()
- end
- end
- end
- scan(Model)
- end
- common_functions.Remove_Clothes = function( Model)
- local function scan(ch)
- for _, obj in pairs(ch:GetChildren()) do
- scan(obj)
- if obj:IsA("Shirt") or obj:IsA("ShirtGraphic") or obj:IsA("Pants") or obj:IsA("CharacterMesh") or (obj:IsA("Decal") and obj.Name == "roblox")
- or (obj:IsA("Sparkles") or obj:IsA("Fire") or obj:IsA("Smoke") or obj:IsA("ParticleEmitter")) then
- obj:destroy()
- end
- end
- end
- scan(Model)
- end
- common_functions.fade_part = function(part, fadeTime, startTran)
- local start_tran = startTran
- coroutine.resume(coroutine.create(function()
- local start = tick()
- while tick() - start < fadeTime do
- local fractionAlpha =( tick() - start )
- part.Transparency = fractionAlpha / fadeTime + startTran
- wait()
- end
- end))
- end
- common_functions.PlaySoundInPart = function(part, snd)
- if part == nil then return end
- if type(snd) == "table" then
- snd = snd[math.random(1, #snd)]
- end
- local new_sound = Instance.new("Sound")
- new_sound.Volume = 0.5
- new_sound.SoundId = snd
- new_sound.Parent = part
- new_sound:Play()
- end
- function PrepareCharRagdoll(char)
- char.Archivable = true
- local ragdoll = char:clone()
- char.Archivable = false
- ragdoll.Parent = RagdollsDebris
- ragdoll["Humanoid"].DisplayDistanceType = "None"
- if ragdoll:FindFirstChild("CollisionHolder") then
- ragdoll["CollisionHolder"]:Remove()
- end
- --
- local function scanc(ch)
- for _, obj in pairs(ch:GetChildren()) do
- scanc(obj)
- if obj.Name ~= "RadioWeld" and (obj:IsA("Script") or obj:IsA("LocalScript") or obj:IsA("Motor6D") or (obj:IsA("Weld") and (obj.Name ~= "RadioWeld" and obj.Name ~= "AccessoryWeld")) or obj:IsA("ForceField") or (obj:IsA("Snap") and obj.Parent.Name == "Torso"))
- or obj:IsA("ParticleEmitter") or obj:IsA("BillboardGui")then
- obj:destroy()
- elseif obj:IsA("BasePart") then
- obj.Velocity = Vector3.new(0, 0, 0)
- obj.RotVelocity = Vector3.new(0, 0, 0)
- end
- end
- end
- scanc(ragdoll)
- local hum = ragdoll:FindFirstChild("Humanoid")
- if hum ~= nil then
- hum.PlatformStand = true
- return ragdoll, hum
- else
- return nil, nil
- end
- end
- function ClearCharacter(char)
- for _, obj in pairs(char:GetChildren()) do
- if not obj:IsA("Humanoid") then--and not (obj:IsA("BasePart") and obj.Name == "HumanoidRootPart") then
- obj:destroy()
- end
- end
- end
- local function ApplyDamage(hum, dmg)
- if hum ~= nil then
- if hum:IsA("Humanoid") then
- local start_health = hum.Health
- if start_health - dmg <= 0 then
- return true, true
- else
- hum:TakeDamage(dmg)
- return true, false
- end
- end
- end
- return false, false
- end
- local function GetInvis()
- local npart = Instance.new("Part")
- npart.CanCollide = false
- npart.Size = Vector3.new(0.2, 0.2, 0.2)
- npart.Transparency = 1
- return npart
- end
- FlareAttatch = function(Model, GetFlareSample)
- common_functions.GetAllBodyParts(Model, function(obj)
- local c = GetFlareSample():Clone()
- c.Parent = obj
- end)
- end
- HeadShotPlayer = function(Model)
- local m = Model["Head"]["Mesh"]
- m.Scale = Vector3.new()
- for _, v in pairs(Model:GetChildren()) do
- if v:IsA("Accessory") then
- v:Remove()
- end
- end
- common_functions.PlaySoundInPart(Model['Head'], "rbxassetid://615431942")
- end
- _G.DAMAGE_MASTER.DamageInput = function(Attacker, TargetHum, KillInfo)
- local GetDamageType = KillInfo.DamageType
- if GetDamageType == "Knife" then
- _G.DAMAGE_MASTER.KnifeDamageRequest:Fire(Attacker, TargetHum, KillInfo)
- elseif GetDamageType == "Revolver" then
- _G.DAMAGE_MASTER.RevolverDamageRequest:Fire(Attacker, TargetHum, KillInfo)
- end
- end
- _G.DAMAGE_MASTER.ConfirmRevolverDamage = function(Attacker, TargetHum, KillInfo)
- if not (TargetHum.Health > 0) then return end
- local GetTor = TargetHum.Parent:FindFirstChild("Torso")
- if not GetTor then return end
- local RevolverSkin = KillInfo.RevolverSkin
- local DamageModule = unpack(require(GetItemFromKeyHolder(RevolverSkins, RevolverSkin):WaitForChild("DamageModule")))
- local KillEffect = unpack(require(GetItemFromKeyHolder(RevolverSkins, RevolverSkin):WaitForChild("KillEffect")))
- local IsPlayer = players:FindFirstChild(KillInfo.TargetName) ~= nil
- local TargetPlayer = players:FindFirstChild(KillInfo.TargetName)
- local Attack_Damage = 0
- local TargetModel = TargetHum.Parent
- Attack_Damage = DamageModule.Main_Damage
- if KillInfo.HitPart.Name == "Head" then
- Attack_Damage = Attack_Damage * 3
- elseif KillInfo.HitPart.Name == "Torso" then
- Attack_Damage = Attack_Damage * 1.2
- else
- Attack_Damage = Attack_Damage * 1
- end
- if IsPlayer then
- local RevolverEffects = DamageModule.Status_Effects
- if type(RevolverEffects) == "table" then
- for _, stat_data in pairs(RevolverEffects) do
- _G.STAT_CONTROL["MasterStatInput"](KillInfo.TargetName, stat_data)
- end
- end
- end
- local Did, Killed = ApplyDamage(TargetHum, Attack_Damage)
- if Did and Killed then
- _G.DATA_MANAGER['StopPlayerRadioThread'](KillInfo.TargetName)
- local NewModel, NewHumanoid = PrepareCharRagdoll(TargetModel)
- ClearCharacter(TargetModel)
- if KillInfo.HitPart.Name == "Head" then
- HeadShotPlayer(NewModel)
- end
- local DeathCamHandle
- DeathCamHandle = KillEffect(NewModel, common_functions, KillInfo, 10)
- if IsPlayer then
- ev_Deathcam:FireClient(TargetPlayer, DeathCamHandle)
- local kills = _G.DATA_MANAGER["GetPlayerSessionData"](KillInfo.TargetName).stats["CurrentKillStreak"]
- _G.DATA_MANAGER["RemovePlayerStat"](KillInfo.TargetName, "all")
- _G.DATA_MANAGER["PlayerChangeSessionStats"](KillInfo.TargetName, "CurrentKillStreak", -kills)
- end
- _G.DATA_MANAGER["PlayerChangeSessionStats"](Attacker.Name, "CurrentKillStreak", 1)
- ev_KillConfirm:FireClient(Attacker, KillInfo)
- end
- end
- _G.DAMAGE_MASTER.ConfirmKnifeDamage = function(Attacker, TargetHum, KillInfo)
- if not (TargetHum.Health > 0) then return end
- local GetTor = TargetHum.Parent:FindFirstChild("Torso")
- if not GetTor then return end
- local KnifeFlare = KillInfo.KnifeFlare
- local KnifeSkin = KillInfo.KnifeSkin
- if KnifeSkin == "Chaos" then
- local Inventory = {"Gold", "Reaper", "Crescendo", "BanHammer"} --//Will be actual inven soon
- KnifeSkin = Inventory[math.random(#Inventory)]
- end
- local DamageModule = unpack(require(GetItemFromKeyHolder(KnifeSkins, KnifeSkin):WaitForChild("DamageModule")))
- local KillEffect = unpack(require(GetItemFromKeyHolder(KnifeSkins, KnifeSkin):WaitForChild("KillEffect")))
- local AttachFlareControl, GetFlareSample = unpack(require(GetItemFromKeyHolder(KnifeFlares, KnifeFlare):WaitForChild("FlareData")))
- local IsPlayer = players:FindFirstChild(KillInfo.TargetName) ~= nil
- local TargetPlayer = players:FindFirstChild(KillInfo.TargetName)
- local CallBack = Instance.new("BindableEvent")
- local Attack_Damage = 0
- local TargetModel = TargetHum.Parent
- if KillInfo.KnifeKillType == "Throw" then
- Attack_Damage = DamageModule.Main_Damage
- if KillInfo.HitPart.Name == "Head" then
- Attack_Damage = Attack_Damage * 2
- elseif KillInfo.HitPart.Name == "Torso" then
- Attack_Damage = Attack_Damage * 1.5
- else
- Attack_Damage = Attack_Damage * 1
- end
- elseif KillInfo.KnifeKillType == "Stab" then
- Attack_Damage = DamageModule.Stab_Damage
- end
- if IsPlayer then
- local KnifeEffects = DamageModule.Status_Effects
- if type(KnifeEffects) == "table" then
- for _, stat_data in pairs(KnifeEffects) do
- _G.STAT_CONTROL["MasterStatInput"](KillInfo.TargetName, stat_data, CallBack)
- end
- end
- end
- local function DoDeath()
- _G.DATA_MANAGER['StopPlayerRadioThread'](KillInfo.TargetName)
- if not (TargetHum.Health > 0) then return end
- local NewModel, NewHumanoid = PrepareCharRagdoll(TargetModel)
- ClearCharacter(TargetModel)
- if KillInfo.HitPart and KillInfo.HitPart.Name == "Head" then
- HeadShotPlayer(NewModel)
- end
- local DeathCamHandle
- FlareAttatch(NewModel, GetFlareSample)
- DeathCamHandle = KillEffect(NewModel, common_functions, KillInfo, 10)
- if IsPlayer then
- ev_Deathcam:FireClient(TargetPlayer, DeathCamHandle)
- local kills = _G.DATA_MANAGER["GetPlayerSessionData"](KillInfo.TargetName).stats["CurrentKillStreak"]
- _G.DATA_MANAGER["RemovePlayerStat"](KillInfo.TargetName, "all")
- _G.DATA_MANAGER["PlayerChangeSessionStats"](KillInfo.TargetName, "CurrentKillStreak", -kills)
- end
- _G.DATA_MANAGER["PlayerChangeSessionStats"](Attacker.Name, "CurrentKillStreak", 1)
- ev_KillConfirm:FireClient(Attacker, KillInfo)
- end
- CallBack.Event:connect(function()
- KillInfo.KillVelocity = nil
- KillInfo.KillVelocity = nil
- KillInfo.HitPart = nil
- DoDeath()
- end)
- local _, Killed = ApplyDamage(TargetHum, Attack_Damage)
- if Killed then
- DoDeath()
- end
- end
- --Damage master is ready!
- _G.DamageMasterReady = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement