Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.85 KB | None | 0 0
  1. _G.DAMAGE_MASTER = {}
  2. _G.DamageMasterReady = false
  3.  
  4. --vars
  5. local players = game.Players
  6. local DebrisServ = game:GetService("Debris")
  7.  
  8. local ReplicatedData = workspace.ReplicatedData
  9. local PlayerEvents = ReplicatedData.PlayerEvents
  10.  
  11. local ev_Deathcam = PlayerEvents.DeathCam
  12. local ev_KillConfirm = PlayerEvents.KillConfirm
  13.  
  14.  
  15. local ReplicatedStore = game.ReplicatedStorage
  16. local CommonModules = ReplicatedStore.CommonModules
  17. local GameContent = ReplicatedStore.GameContent
  18. local KnifeContent = GameContent.KnifeContent
  19. local RevolverContent = GameContent.RevolverContent
  20. local RevolverSkins = RevolverContent:WaitForChild("RevolverSkins")
  21. local KnifeSkins = KnifeContent:WaitForChild("KnifeSkins")
  22. local KnifeFlares = KnifeContent:WaitForChild("KnifeFlares")
  23.  
  24. _G.DAMAGE_MASTER.KnifeDamageRequest = Instance.new("BindableEvent")
  25. _G.DAMAGE_MASTER.RevolverDamageRequest = Instance.new("BindableEvent")
  26.  
  27.  
  28. local MasterDebris = workspace.MasterDebris
  29. local RagdollsDebris = MasterDebris.Ragdolls
  30.  
  31. local RagdollsModule = require(CommonModules.Ragdolls)
  32.  
  33. local GetItemFromKeyHolder = function(KeyHolder, ItemName)
  34.     for _, holder in pairs(KeyHolder:GetChildren()) do
  35.         if holder.ClassName == "Model" then
  36.             if holder.Name == ItemName then
  37.                 return holder
  38.             end
  39.         elseif holder.ClassName == "Folder" then
  40.             for _, item in pairs(holder:GetChildren()) do
  41.                 if item.ClassName == "Model" then
  42.                     if item.Name == ItemName then
  43.                         return item
  44.                     end
  45.                 end
  46.             end
  47.         end
  48.     end
  49. end
  50.  
  51. --Common Funcs
  52.  
  53. local common_functions = {}
  54.  
  55. local real_body_part_names = {"Head", "Left Arm", "Left Leg", "Right Arm", "Right Leg", "Torso"}
  56. local body_part_names = {"Head", "LeftArm", "LeftLeg", "RightArm", "RightLeg", "Torso"}
  57.  
  58. common_functions.GetAllBodyParts = function(char, func)
  59.     for _, obj in pairs(char:GetChildren()) do
  60.         for _, nm in pairs(real_body_part_names) do
  61.             if nm == obj.Name then
  62.                 func(obj)
  63.                 break
  64.             end
  65.         end
  66.     end
  67. end
  68.  
  69. common_functions.GetAllParts = function(char, func)
  70.     local function scan(ch)
  71.         for _, obj in pairs(ch:GetChildren()) do
  72.             scan(obj)
  73.             if obj:IsA("BasePart") then
  74.                 func(obj)
  75.             end
  76.         end
  77.     end
  78.     scan(char)
  79. end
  80.  
  81.  
  82.    
  83.  
  84. common_functions.Ragdoll = function(Model, Type)
  85.     RagdollsModule[Type](Model, false)
  86. end
  87.  
  88.  
  89. common_functions.skin_recolor = function(Model, BColor)
  90.     --Getting body colors object
  91.     local b_col = Model:FindFirstChild("Body Colors")
  92.     if b_col ~= nil then
  93.         for _, nm in pairs(body_part_names) do
  94.             b_col[nm .. "Color"] = BrickColor.new(BColor)
  95.         end
  96.     end
  97. end
  98.  
  99. common_functions.ApplyVelocity = function(Model, KillVelocity)
  100.     local GetTor = Model:FindFirstChild("Torso")
  101.     if GetTor then
  102.         if KillVelocity then
  103.             GetTor.Velocity = Vector3.new(KillVelocity.x, .25, KillVelocity.z) * 250
  104.         else
  105.             local v1 = (math.random(20) - 10) / 75
  106.             local v2 = (math.random(20) - 10) / 75
  107.             GetTor.Velocity = Vector3.new(v1, 0, v2) * 250
  108.         end
  109.     end
  110.  
  111. end
  112.  
  113. common_functions.materialise = function(Model, Material, BColor)
  114.     --Getting body colors object
  115.     local b_col = Model:FindFirstChild("Body Colors")
  116.     if b_col == nil then
  117.         b_col = Instance.new("BodyColors")
  118.         b_col.Parent = Model
  119.     end
  120.     if b_col ~= nil then
  121.         for _, nm in pairs(body_part_names) do
  122.             b_col[nm .. "Color"] = BrickColor.new(BColor)
  123.         end
  124.     end
  125.     common_functions.GetAllParts(Model, function(obj)
  126.         --removing mesh texture
  127.         for _, v in pairs(obj:GetChildren()) do
  128.             if v:IsA("SpecialMesh") then
  129.                 v.TextureId = ""
  130.             end
  131.         end
  132.         --recoloring part
  133.         obj.BrickColor = BrickColor.new(BColor)
  134.         obj.Material = Material
  135.     end)
  136. end
  137.  
  138. common_functions.Clear_Appearance = function(Model)
  139.     local function scan(ch)
  140.         for _, obj in pairs(ch:GetChildren()) do
  141.             scan(obj)
  142.             if (obj.Name ~= "RadioWeld") and (obj.Name ~= "face")  and (not obj:IsA("SpecialMesh")) and (not obj:IsA("Humanoid")) and (not obj:IsA("BasePart")) then
  143.                 obj:destroy()
  144.             end
  145.             if obj.Name == 'Head' then
  146.                 obj["face"]:Destroy()
  147.             end
  148.         end
  149.     end
  150.     scan(Model)
  151. end
  152.  
  153. common_functions.Remove_Clothes = function( Model)
  154.     local function scan(ch)
  155.         for _, obj in pairs(ch:GetChildren()) do
  156.             scan(obj)
  157.             if obj:IsA("Shirt") or obj:IsA("ShirtGraphic") or obj:IsA("Pants") or obj:IsA("CharacterMesh") or (obj:IsA("Decal") and obj.Name == "roblox")
  158.             or (obj:IsA("Sparkles") or obj:IsA("Fire") or obj:IsA("Smoke") or obj:IsA("ParticleEmitter")) then
  159.                 obj:destroy()
  160.             end
  161.         end
  162.     end
  163.     scan(Model)
  164. end
  165.  
  166.  
  167.  
  168.  
  169. common_functions.fade_part = function(part, fadeTime, startTran)
  170.     local start_tran = startTran
  171.  
  172.     coroutine.resume(coroutine.create(function()
  173.         local start = tick()
  174.         while tick() - start < fadeTime do
  175.             local fractionAlpha =( tick() - start )
  176.             part.Transparency = fractionAlpha /  fadeTime + startTran
  177.             wait()
  178.         end
  179.     end))
  180. end
  181.  
  182. common_functions.PlaySoundInPart = function(part, snd)
  183.     if part == nil then return end
  184.     if type(snd) == "table" then
  185.         snd = snd[math.random(1, #snd)]
  186.     end
  187.    
  188.     local new_sound = Instance.new("Sound")
  189.     new_sound.Volume = 0.5
  190.     new_sound.SoundId = snd
  191.     new_sound.Parent = part
  192.     new_sound:Play()
  193. end
  194.  
  195.  
  196.  
  197. function PrepareCharRagdoll(char)
  198.     char.Archivable = true
  199.     local ragdoll = char:clone()
  200.     char.Archivable = false
  201.    
  202.     ragdoll.Parent = RagdollsDebris
  203.     ragdoll["Humanoid"].DisplayDistanceType = "None"
  204.     if ragdoll:FindFirstChild("CollisionHolder") then
  205.         ragdoll["CollisionHolder"]:Remove()
  206.     end
  207.     --             
  208.     local function scanc(ch)
  209.         for _, obj in pairs(ch:GetChildren()) do
  210.             scanc(obj)
  211.             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"))
  212.                 or obj:IsA("ParticleEmitter") or obj:IsA("BillboardGui")then
  213.                 obj:destroy()
  214.             elseif obj:IsA("BasePart") then
  215.                 obj.Velocity = Vector3.new(0, 0, 0)
  216.                 obj.RotVelocity = Vector3.new(0, 0, 0)
  217.             end
  218.         end
  219.     end
  220.     scanc(ragdoll)
  221.    
  222.     local hum = ragdoll:FindFirstChild("Humanoid")
  223.     if hum ~= nil then
  224.         hum.PlatformStand = true
  225.         return ragdoll, hum
  226.     else
  227.         return nil, nil
  228.     end
  229. end
  230.  
  231. function ClearCharacter(char)
  232.     for _, obj in pairs(char:GetChildren()) do
  233.         if not obj:IsA("Humanoid") then--and not (obj:IsA("BasePart") and obj.Name == "HumanoidRootPart") then
  234.             obj:destroy()
  235.         end
  236.     end
  237. end
  238.  
  239. local function ApplyDamage(hum, dmg)
  240.     if hum ~= nil then
  241.         if hum:IsA("Humanoid") then
  242.             local start_health = hum.Health
  243.             if start_health - dmg <= 0 then
  244.                 return true, true
  245.             else
  246.                 hum:TakeDamage(dmg)
  247.                 return true, false
  248.             end
  249.         end
  250.     end
  251.     return false, false
  252. end
  253.  
  254.  
  255. local function GetInvis()
  256.     local npart = Instance.new("Part")
  257.     npart.CanCollide = false
  258.     npart.Size = Vector3.new(0.2, 0.2, 0.2)
  259.     npart.Transparency = 1
  260.     return npart
  261. end
  262.  
  263. FlareAttatch = function(Model, GetFlareSample)
  264.     common_functions.GetAllBodyParts(Model, function(obj)
  265.         local c = GetFlareSample():Clone()
  266.         c.Parent = obj
  267.     end)
  268. end
  269.  
  270. HeadShotPlayer = function(Model)
  271.     local m = Model["Head"]["Mesh"]
  272.     m.Scale = Vector3.new()
  273.     for _, v in pairs(Model:GetChildren()) do
  274.         if v:IsA("Accessory") then
  275.             v:Remove()
  276.         end
  277.     end
  278.    
  279.     common_functions.PlaySoundInPart(Model['Head'], "rbxassetid://615431942")
  280. end
  281.  
  282. _G.DAMAGE_MASTER.DamageInput = function(Attacker, TargetHum, KillInfo)
  283.    
  284.     local GetDamageType = KillInfo.DamageType
  285.    
  286.     if GetDamageType == "Knife" then
  287.         _G.DAMAGE_MASTER.KnifeDamageRequest:Fire(Attacker, TargetHum, KillInfo)
  288.        
  289.     elseif GetDamageType == "Revolver" then
  290.         _G.DAMAGE_MASTER.RevolverDamageRequest:Fire(Attacker, TargetHum, KillInfo)
  291.     end
  292.  
  293. end
  294.  
  295.  
  296. _G.DAMAGE_MASTER.ConfirmRevolverDamage = function(Attacker, TargetHum, KillInfo)
  297.     if not (TargetHum.Health > 0) then return end  
  298.     local GetTor = TargetHum.Parent:FindFirstChild("Torso")
  299.     if not GetTor then return end
  300.    
  301.     local RevolverSkin = KillInfo.RevolverSkin
  302.     local DamageModule = unpack(require(GetItemFromKeyHolder(RevolverSkins, RevolverSkin):WaitForChild("DamageModule")))
  303.     local KillEffect = unpack(require(GetItemFromKeyHolder(RevolverSkins, RevolverSkin):WaitForChild("KillEffect")))
  304.     local IsPlayer = players:FindFirstChild(KillInfo.TargetName) ~= nil
  305.     local TargetPlayer = players:FindFirstChild(KillInfo.TargetName)
  306.  
  307.     local Attack_Damage = 0
  308.     local TargetModel = TargetHum.Parent
  309.  
  310.  
  311.     Attack_Damage = DamageModule.Main_Damage
  312.    
  313.     if KillInfo.HitPart.Name == "Head" then
  314.         Attack_Damage = Attack_Damage * 3
  315.     elseif KillInfo.HitPart.Name == "Torso" then
  316.         Attack_Damage = Attack_Damage * 1.2
  317.     else   
  318.         Attack_Damage = Attack_Damage * 1
  319.     end
  320.  
  321.  
  322.     if IsPlayer then
  323.         local RevolverEffects = DamageModule.Status_Effects
  324.         if type(RevolverEffects) == "table" then
  325.             for _, stat_data in pairs(RevolverEffects) do
  326.                 _G.STAT_CONTROL["MasterStatInput"](KillInfo.TargetName, stat_data)
  327.             end
  328.         end
  329.     end
  330.    
  331.  
  332.     local Did, Killed = ApplyDamage(TargetHum, Attack_Damage)
  333.    
  334.     if Did and Killed then
  335.         _G.DATA_MANAGER['StopPlayerRadioThread'](KillInfo.TargetName)
  336.         local NewModel, NewHumanoid = PrepareCharRagdoll(TargetModel)
  337.         ClearCharacter(TargetModel)
  338.        
  339.         if KillInfo.HitPart.Name == "Head" then
  340.             HeadShotPlayer(NewModel)
  341.         end
  342.        
  343.         local DeathCamHandle       
  344.  
  345.         DeathCamHandle = KillEffect(NewModel, common_functions, KillInfo, 10)
  346.        
  347.         if IsPlayer then
  348.             ev_Deathcam:FireClient(TargetPlayer, DeathCamHandle)
  349.            
  350.             local kills = _G.DATA_MANAGER["GetPlayerSessionData"](KillInfo.TargetName).stats["CurrentKillStreak"]
  351.                        
  352.             _G.DATA_MANAGER["RemovePlayerStat"](KillInfo.TargetName, "all")
  353.             _G.DATA_MANAGER["PlayerChangeSessionStats"](KillInfo.TargetName, "CurrentKillStreak", -kills)
  354.         end
  355.        
  356.        
  357.        
  358.         _G.DATA_MANAGER["PlayerChangeSessionStats"](Attacker.Name, "CurrentKillStreak", 1)
  359.        
  360.        
  361.         ev_KillConfirm:FireClient(Attacker, KillInfo)
  362.    
  363.        
  364.     end
  365.    
  366. end
  367.  
  368.  
  369. _G.DAMAGE_MASTER.ConfirmKnifeDamage = function(Attacker, TargetHum, KillInfo)
  370.    
  371.     if not (TargetHum.Health > 0) then return end  
  372.     local GetTor = TargetHum.Parent:FindFirstChild("Torso")
  373.     if not GetTor then return end
  374.    
  375.     local KnifeFlare = KillInfo.KnifeFlare
  376.     local KnifeSkin = KillInfo.KnifeSkin
  377.    
  378.     if KnifeSkin == "Chaos" then
  379.         local Inventory = {"Gold", "Reaper", "Crescendo", "BanHammer"} --//Will be actual inven soon
  380.         KnifeSkin = Inventory[math.random(#Inventory)]
  381.     end
  382.    
  383.     local DamageModule = unpack(require(GetItemFromKeyHolder(KnifeSkins, KnifeSkin):WaitForChild("DamageModule")))
  384.     local KillEffect = unpack(require(GetItemFromKeyHolder(KnifeSkins, KnifeSkin):WaitForChild("KillEffect")))
  385.     local AttachFlareControl, GetFlareSample = unpack(require(GetItemFromKeyHolder(KnifeFlares, KnifeFlare):WaitForChild("FlareData")))
  386.     local IsPlayer = players:FindFirstChild(KillInfo.TargetName) ~= nil
  387.     local TargetPlayer = players:FindFirstChild(KillInfo.TargetName)
  388.     local CallBack = Instance.new("BindableEvent")
  389.  
  390.     local Attack_Damage = 0
  391.     local TargetModel = TargetHum.Parent
  392.    
  393.  
  394.     if KillInfo.KnifeKillType == "Throw" then
  395.         Attack_Damage = DamageModule.Main_Damage
  396.        
  397.         if KillInfo.HitPart.Name == "Head" then
  398.             Attack_Damage = Attack_Damage * 2
  399.         elseif KillInfo.HitPart.Name == "Torso" then
  400.             Attack_Damage = Attack_Damage * 1.5
  401.         else   
  402.             Attack_Damage = Attack_Damage * 1
  403.         end
  404.        
  405.     elseif KillInfo.KnifeKillType == "Stab" then
  406.        
  407.         Attack_Damage = DamageModule.Stab_Damage
  408.     end
  409.  
  410.     if IsPlayer then
  411.         local KnifeEffects = DamageModule.Status_Effects
  412.         if type(KnifeEffects) == "table" then
  413.             for _, stat_data in pairs(KnifeEffects) do
  414.                 _G.STAT_CONTROL["MasterStatInput"](KillInfo.TargetName, stat_data, CallBack)
  415.             end
  416.         end
  417.     end
  418.    
  419.     local function DoDeath()
  420.         _G.DATA_MANAGER['StopPlayerRadioThread'](KillInfo.TargetName)
  421.         if not (TargetHum.Health > 0) then return end  
  422.        
  423.         local NewModel, NewHumanoid = PrepareCharRagdoll(TargetModel)
  424.         ClearCharacter(TargetModel)
  425.        
  426.         if KillInfo.HitPart and KillInfo.HitPart.Name == "Head" then
  427.             HeadShotPlayer(NewModel)
  428.         end
  429.        
  430.         local DeathCamHandle       
  431.  
  432.         FlareAttatch(NewModel, GetFlareSample)
  433.         DeathCamHandle = KillEffect(NewModel, common_functions, KillInfo, 10)
  434.        
  435.         if IsPlayer then
  436.             ev_Deathcam:FireClient(TargetPlayer, DeathCamHandle)
  437.            
  438.             local kills = _G.DATA_MANAGER["GetPlayerSessionData"](KillInfo.TargetName).stats["CurrentKillStreak"]
  439.                        
  440.             _G.DATA_MANAGER["RemovePlayerStat"](KillInfo.TargetName, "all")
  441.             _G.DATA_MANAGER["PlayerChangeSessionStats"](KillInfo.TargetName, "CurrentKillStreak", -kills)
  442.         end
  443.        
  444.        
  445.        
  446.         _G.DATA_MANAGER["PlayerChangeSessionStats"](Attacker.Name, "CurrentKillStreak", 1)
  447.        
  448.        
  449.         ev_KillConfirm:FireClient(Attacker, KillInfo)
  450.     end
  451.    
  452.     CallBack.Event:connect(function()
  453.         KillInfo.KillVelocity = nil
  454.         KillInfo.KillVelocity = nil
  455.         KillInfo.HitPart = nil
  456.         DoDeath()
  457.     end)
  458.  
  459.     local _, Killed = ApplyDamage(TargetHum, Attack_Damage)
  460.    
  461.     if Killed then
  462.         DoDeath()
  463.     end
  464.    
  465. end
  466.  
  467.  
  468.  
  469. --Damage master is ready!
  470. _G.DamageMasterReady = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement