Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function calculate(base, levels, perk)
- if levels <= 0 then return base end
- local data = M9KPerks.Perks[perk]
- local percentPerLevel = data.percent / 100
- local totalPercent = 1 + (percentPerLevel * math.min(levels, data.totalLevels))
- local newValue = base * totalPercent
- return newValue
- end
- local function calculateZ(base, levels, perk)
- if levels <= 0 then return base end
- local data = M9KPerksZ.Perks[perk]
- local percentPerLevel = data.percent / 100
- local totalPercent = 1 + (percentPerLevel * math.min(levels, data.totalLevels))
- local newValue = base * totalPercent
- return newValue
- end
- hook.Add("ScalePlayerDamage", "m9kperks_damagebuff", function(ply, hitgroup, dmg)
- if dmg:IsDamageType(DMG_BULLET) and ply:Team() == M9KPerks.Teams.zombie and dmg:GetAttacker():Team() == M9KPerks.Teams.human then
- local json = M9KPerks.JSON
- local attacker = dmg:GetAttacker()
- local plyPerks = json.getPlayer(attacker:SteamID())
- if plyPerks.damage >= 1 then
- --print("pre damage", dmg:GetDamage())
- local calculate = calculate(dmg:GetDamage(), plyPerks.damage, "damage")
- dmg:SetDamage(calculate)
- --print("damage", calculate)
- end
- end
- -- zombies
- if ply:Team() == M9KPerks.Teams.human and dmg:GetAttacker():Team() == M9KPerks.Teams.zombie then
- local json = M9KPerks.JSON
- local attacker = dmg:GetAttacker()
- local plyPerks = json.getPlayerZ(attacker:SteamID())
- plyPerks.points = plyPerks.points + M9KPerksZ.PointsPerHit
- json.setPlayerZ(attacker:SteamID(), plyPerks)
- if plyPerks.damage >= 1 then
- --print("ZZpre damage", dmg:GetDamage())
- local calculate = calculateZ(dmg:GetDamage(), plyPerks.damage, "damage")
- dmg:SetDamage(calculate)
- --print("ZZdamage", calculate)
- end
- end
- end)
- hook.Add("WeaponEquip", "m9kperks_clipsizebuff", function(weapon, ply)
- if !weapon:GetClass():StartWith("m9k_") then return end
- if ply:Team() != M9KPerks.Teams.human then return end
- local json = M9KPerks.JSON
- if ply:Team() == M9KPerks.Teams.human then
- local perks = json.getPlayer(ply:SteamID())
- if perks.clipsize >= 1 then
- local default = weapons.Get(weapon:GetClass())
- local new = calculate(default.Primary.ClipSize, perks.clipsize, "clipsize")
- weapon.Primary.ClipSize = new
- weapon:SetClip1(new)
- --print("clipsize", default.Primary.ClipSize, new)
- end
- if perks.rpm >= 1 then
- local default = weapons.Get(weapon:GetClass())
- local new = calculate(default.Primary.RPM, perks.rpm, "rpm")
- weapon.Primary.RPM = new
- --print("rpm", default.Primary.RPM, new)
- end
- end
- end)
- local json = M9KPerks.JSON
- -- zombie damage prop
- hook.Add("EntityTakeDamage", "m9kperks_zombiehitprop", function(ent, dmg)
- print("damage for", ent, "from ", dmg)
- if dmg:GetAttacker() then
- print("attacker found", dmg:GetAttacker())
- if dmg:GetAttacker():IsPlayer() then
- print("attacker is a player")
- if dmg:GetAttacker():Team() then
- print("attacker has a team")
- if dmg:GetAttacker():Team() == M9KPerks.Teams.zombie then
- print("attacker is a zombie", dmg:GetAttacker())
- if ent.IsNailed then
- print("isnailed detected")
- if ent:IsNailed() then
- print("status of isnailed: ", ent:IsNailed())
- local plyTable = json.getPlayerZ(dmg:GetAttacker():SteamID())
- if plyTable then
- plyTable.points = plyTable.points + M9KPerksZ.PointsPerHit
- json.setPlayerZ(dmg:GetAttacker():SteamID(), plyTable)
- return false
- end
- else
- print("IsNailed is false")
- end
- else
- print("not a nailed prop")
- end
- end
- end
- end
- end
- return false
- end)
- /*
- hook.Add("OnTakeDamage", "m9kperks_zombiehitprop", function(dmg)
- if dmg:GetAttacker() then
- if dmg:GetAttacker():IsPlayer() then
- if dmg:GetAttacker():Team() then
- if dmg:GetAttacker():Team() == M9KPerks.Teams.zombie then
- if ent.IsNailed then
- if ent:IsNailed() then
- local plyTable = getPlayerZ(dmg:GetAttacker():SteamID())
- if plyTable then
- plyTable.points = plyTable.points + M9KPerksZ.PointsPerHit
- setPlayerZ(dmg:GetAttacker():SteamID(), plyTable)
- end
- end
- end
- end
- end
- end
- end
- end)
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement