Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  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.  
  109.  
  110. -- zombie damage prop
  111. hook.Add("EntityTakeDamage", "m9kperks_zombiehitprop", function(ent, dmg)
  112. if dmg:GetAttacker() then
  113. if dmg:GetAttacker():IsPlayer() then
  114. if dmg:GetAttacker():Team() then
  115. if dmg:GetAttacker():Team() == M9KPerks.Teams.zombie then
  116. if ent.IsNailed then
  117. if ent:IsNailed() then
  118. local plyTable = getPlayerZ(dmg:GetAttacker():SteamID())
  119. if plyTable then
  120. plyTable.points = plyTable.points + M9KPerksZ.PointsPerHit
  121. setPlayerZ(dmg:GetAttacker():SteamID(), plyTable)
  122. return false
  123. end
  124. end
  125. end
  126. end
  127. end
  128. end
  129. end
  130. return false
  131. end)
  132.  
  133.  
  134. /*
  135. hook.Add("OnTakeDamage", "m9kperks_zombiehitprop", function(dmg)
  136. if dmg:GetAttacker() then
  137. if dmg:GetAttacker():IsPlayer() then
  138. if dmg:GetAttacker():Team() then
  139. if dmg:GetAttacker():Team() == M9KPerks.Teams.zombie then
  140. if ent.IsNailed then
  141. if ent:IsNailed() then
  142. local plyTable = getPlayerZ(dmg:GetAttacker():SteamID())
  143. if plyTable then
  144. plyTable.points = plyTable.points + M9KPerksZ.PointsPerHit
  145. setPlayerZ(dmg:GetAttacker():SteamID(), plyTable)
  146. end
  147. end
  148. end
  149. end
  150. end
  151. end
  152. end
  153. end)
  154. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement