From ea7073be5e6b35a276bf11cc564f7f19e88002d0 Mon Sep 17 00:00:00 2001 From: Chalwk77 Date: Fri, 7 Jul 2023 22:45:01 +1200 Subject: [PATCH] ... --- .../Battle Royale/commands/repair_weapons.lua | 7 +++- .../Battle Royale/map settings/bloodgulch.lua | 40 ++++++++++--------- .../weapon degradation/degradation.lua | 12 +++--- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/INDEV/Battle Royale/commands/repair_weapons.lua b/INDEV/Battle Royale/commands/repair_weapons.lua index 84f1c895..6ff8b0bc 100644 --- a/INDEV/Battle Royale/commands/repair_weapons.lua +++ b/INDEV/Battle Royale/commands/repair_weapons.lua @@ -38,9 +38,12 @@ function Command:repairsWeapons(player) local object = get_object_memory(this_weapon) if (this_weapon ~= 0xFFFFFFFF and object ~= 0) then + local weapon = self.decay[object] - if (weapon and weapon.decay > 0) then - weapon.decay = 0 + local max = self.weapon_degradation.max_durability + + if (weapon and weapon.durability < max) then + weapon.durability = max repaired = true end end diff --git a/INDEV/Battle Royale/map settings/bloodgulch.lua b/INDEV/Battle Royale/map settings/bloodgulch.lua index 6ca1983d..3f429dec 100644 --- a/INDEV/Battle Royale/map settings/bloodgulch.lua +++ b/INDEV/Battle Royale/map settings/bloodgulch.lua @@ -172,6 +172,7 @@ return { -- They will progressively jam more often as they get closer to breaking. -- When a weapon jams, it will not fire until it is unjammed. -- The player will have to unjam the weapon by pressing the melee button. + -- Durability will decrease faster when the weapon is fired. weapon_degradation = { -- If enabled, weapons will degrade over time. @@ -179,33 +180,36 @@ return { -- enabled = true, - min = 90, - max = 100, + -- Maximum durability value: + max_durability = 100, - -- Format: ['tag name'] = durability decay rate - decay_rate = { - -- All weapons start with a durability value of 100 (default). - -- The higher the percentage value, the faster the weapon will degrade. - -- Example: 1.98% = 0.066*30% per 30 ticks. - -- [note]: Weapons will only decay while in use (firing, but not reloading). + -- Jamming will never occur above this value: + no_jam_before = 90, - ['weapons\\plasma rifle\\plasma rifle'] = 3.0, - ['weapons\\plasma pistol\\plasma pistol'] = 3.0, - ['weapons\\shotgun\\shotgun'] = 4.5, + --- Durability decay rates: + -- Format: ['tag name'] = durability decay rate + decay_rate = { - ['weapons\\flamethrower\\flamethrower'] = 5.0, + -- Be careful not to set the decay rate too high! + -- Max recommended decay rate: 15.0 + -- Do not set values lower than 0.1 + + ['weapons\\plasma rifle\\plasma rifle'] = 1.0, + ['weapons\\plasma pistol\\plasma pistol'] = 1.0, - ['weapons\\pistol\\pistol'] = 5.3, - ['weapons\\needler\\mp_needler'] = 5.3, + ['weapons\\assault rifle\\assault rifle'] = 3.10, - ['weapons\\assault rifle\\assault rifle'] = 1.5, + ['weapons\\pistol\\pistol'] = 4.1, + ['weapons\\needler\\mp_needler'] = 4.50, - ['weapons\\rocket launcher\\rocket launcher'] = 10.0, + ['weapons\\shotgun\\shotgun'] = 5.0, + ['weapons\\flamethrower\\flamethrower'] = 5.0, - ['weapons\\sniper rifle\\sniper rifle'] = 10.50, - ['weapons\\plasma_cannon\\plasma_cannon'] = 10.50 + ['weapons\\sniper rifle\\sniper rifle'] = 23.0, + ['weapons\\plasma_cannon\\plasma_cannon'] = 25.0, + ['weapons\\rocket launcher\\rocket launcher'] = 45.0, } }, diff --git a/INDEV/Battle Royale/weapon degradation/degradation.lua b/INDEV/Battle Royale/weapon degradation/degradation.lua index 354415f1..0329a358 100644 --- a/INDEV/Battle Royale/weapon degradation/degradation.lua +++ b/INDEV/Battle Royale/weapon degradation/degradation.lua @@ -21,7 +21,7 @@ function weapons:addWeapon(object, weapon) object = object, weapon = weapon, timer = self:new(), - durability = self.weapon_degradation.max, -- 0% = broken + durability = self.weapon_degradation.max_durability, -- 0% = broken, 100% = new notify = true, } end @@ -46,9 +46,9 @@ local function checkDurability(weapon) end function weapons:notifyDurability(weapon) - local min = self.weapon_degradation.min + local min = self.weapon_degradation.no_jam_before local durability = math.floor(weapon.durability) - if (durability >= min) then + if (durability >= 90) then return -- do nothing elseif (durability % 10 == 0 and weapon.notify) then self:newMessage('This weapon is now at ' .. durability .. '% durability', 8) @@ -106,13 +106,15 @@ function weapons:degrade() weapon = self:getWeapon(object) local jammed = self:jamWeapon(weapon, dyn) - local decay = (not jammed and isFiring(dyn) and not in_vehicle and not is_reloading) + local decay = (not jammed and isFiring(dyn) and not in_vehicle) - if (decay) then + if (decay or is_reloading) then local meta_id = read_dword(object) -- weapon tag id local rate = self.decay_rates[meta_id] + rate = (is_reloading and rate/5) or rate + weapon.durability = weapon.durability - (rate / 30) if (weapon.durability <= 0) then