Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
Chalwk77 committed Jul 7, 2023
1 parent 1a854b9 commit ea7073b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
7 changes: 5 additions & 2 deletions INDEV/Battle Royale/commands/repair_weapons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 22 additions & 18 deletions INDEV/Battle Royale/map settings/bloodgulch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,40 +172,44 @@ 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.
-- Default (true)
--
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,
}
},

Expand Down
12 changes: 7 additions & 5 deletions INDEV/Battle Royale/weapon degradation/degradation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ea7073b

Please sign in to comment.