daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local function calculate(base, levels, perk)
  2.  
  3.     if levels <= 0 then return base end
  4.  
  5.     local data = M9KPerks.Perks[perk]
  6.  
  7.     local percentPerLevel = data.percent / 100
  8.     local totalPercent = 1 + (percentPerLevel * math.min(levels, data.totalLevels))
  9.  
  10.     local newValue = base * totalPercent
  11.  
  12.     return newValue
  13.  
  14. end
  15.  
  16. local function calculateZ(base, levels, perk)
  17.  
  18.     if levels <= 0 then return base end
  19.  
  20.     local data = M9KPerksZ.Perks[perk]
  21.  
  22.     local percentPerLevel = data.percent / 100
  23.     local totalPercent = 1 + (percentPerLevel * math.min(levels, data.totalLevels))
  24.  
  25.     local newValue = base * totalPercent
  26.  
  27.     return newValue
  28.  
  29. end
  30.  
  31. hook.Add("ScalePlayerDamage", "m9kperks_damagebuff", function(ply, hitgroup, dmg)
  32.  
  33.     if dmg:IsDamageType(DMG_BULLET) and ply:Team() == M9KPerks.Teams.zombie and dmg:GetAttacker():Team() == M9KPerks.Teams.human then
  34.  
  35.         local json = M9KPerks.JSON
  36.         local attacker = dmg:GetAttacker()
  37.  
  38.         local plyPerks = json.getPlayer(attacker:SteamID())
  39.  
  40.         if plyPerks.damage >= 1 then
  41.  
  42.             --print("pre damage", dmg:GetDamage())
  43.             local calculate = calculate(dmg:GetDamage(), plyPerks.damage, "damage")
  44.             dmg:SetDamage(calculate)
  45.             --print("damage", calculate)
  46.  
  47.         end
  48.  
  49.  
  50.     end
  51.  
  52.     -- zombies
  53.     if ply:Team() == M9KPerks.Teams.human and dmg:GetAttacker():Team() == M9KPerks.Teams.zombie then
  54.  
  55.         local json = M9KPerks.JSON
  56.         local attacker = dmg:GetAttacker()
  57.  
  58.         local plyPerks = json.getPlayerZ(attacker:SteamID())
  59.         plyPerks.points = plyPerks.points + M9KPerksZ.PointsPerHit
  60.         json.setPlayerZ(attacker:SteamID(), plyPerks)
  61.  
  62.         if plyPerks.damage >= 1 then
  63.  
  64.             --print("ZZpre damage", dmg:GetDamage())
  65.             local calculate = calculateZ(dmg:GetDamage(), plyPerks.damage, "damage")
  66.             dmg:SetDamage(calculate)
  67.             --print("ZZdamage", calculate)
  68.  
  69.         end
  70.  
  71.  
  72.     end
  73.  
  74. end)
  75.  
  76. hook.Add("WeaponEquip", "m9kperks_clipsizebuff", function(weapon, ply)
  77.  
  78.     if !weapon:GetClass():StartWith("m9k_") then return end
  79.     if ply:Team() != M9KPerks.Teams.human then return end
  80.  
  81.     local json = M9KPerks.JSON
  82.     if ply:Team() == M9KPerks.Teams.human then
  83.  
  84.         local perks = json.getPlayer(ply:SteamID())
  85.         if perks.clipsize >= 1 then
  86.  
  87.             local default = weapons.Get(weapon:GetClass())
  88.             local new = calculate(default.Primary.ClipSize, perks.clipsize, "clipsize")
  89.             weapon.Primary.ClipSize = new
  90.             weapon:SetClip1(new)
  91.             --print("clipsize", default.Primary.ClipSize, new)
  92.  
  93.         end
  94.  
  95.         if perks.rpm >= 1 then
  96.  
  97.             local default = weapons.Get(weapon:GetClass())
  98.             local new = calculate(default.Primary.RPM, perks.rpm, "rpm")
  99.             weapon.Primary.RPM = new
  100.             --print("rpm", default.Primary.RPM, new)
  101.  
  102.         end
  103.  
  104.     end
  105.  
  106. end)
  107.  
  108. local json = M9KPerks.JSON
  109.  
  110. -- zombie damage prop
  111. hook.Add("EntityTakeDamage", "m9kperks_zombiehitprop", function(ent, dmg)
  112.     print("damage for", ent, "from ", dmg)
  113.     if dmg:GetAttacker() then
  114.         print("attacker found", dmg:GetAttacker())
  115.         if dmg:GetAttacker():IsPlayer() then
  116.             print("attacker is a player")
  117.             if dmg:GetAttacker():Team() then
  118.                 print("attacker has a team")
  119.                 if dmg:GetAttacker():Team() == M9KPerks.Teams.zombie then
  120.                     print("attacker is a zombie", dmg:GetAttacker())
  121.                     if ent.IsNailed then
  122.                         print("isnailed detected")
  123.                         if ent:IsNailed() then
  124.                             print("status of isnailed: ", ent:IsNailed())
  125.                             local plyTable = json.getPlayerZ(dmg:GetAttacker():SteamID())
  126.                             if plyTable then
  127.                                 plyTable.points = plyTable.points + M9KPerksZ.PointsPerHit
  128.                                 json.setPlayerZ(dmg:GetAttacker():SteamID(), plyTable)
  129.                                 return false
  130.                             end
  131.                         else
  132.                             print("IsNailed is false")
  133.                         end
  134.                     else
  135.                         print("not a nailed prop")
  136.                     end
  137.                 end
  138.             end
  139.         end
  140.     end
  141.     return false
  142. end)
  143.  
  144.  
  145. /*
  146. hook.Add("OnTakeDamage", "m9kperks_zombiehitprop", function(dmg)
  147.     if dmg:GetAttacker() then
  148.         if dmg:GetAttacker():IsPlayer() then
  149.             if dmg:GetAttacker():Team() then
  150.                 if dmg:GetAttacker():Team() == M9KPerks.Teams.zombie then
  151.                     if ent.IsNailed then
  152.                         if ent:IsNailed() then
  153.                             local plyTable = getPlayerZ(dmg:GetAttacker():SteamID())
  154.                             if plyTable then
  155.                                 plyTable.points = plyTable.points + M9KPerksZ.PointsPerHit
  156.                                 setPlayerZ(dmg:GetAttacker():SteamID(), plyTable)
  157.                             end
  158.                         end
  159.                     end
  160.                 end
  161.             end
  162.         end
  163.     end
  164. end)
  165. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top