Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix table used as int #3604

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions items/active/weapons/ranged/gunfire.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ function GunFire:init()
--self.magazineAmount = math.min(config.getParameter("magazineAmount",defaultMag),self.magazineSize) -- current number of bullets in the magazine
--self.magazineAmount=config.getParameter("magazineAmount",defaultMag)
self.magazineAmount=config.getParameter("magazineAmount"..self.abilitySlot,defaultMag)
self.reloadTime = math.max(0,config.getParameter("reloadTime",1) + status.stat("reloadTime")) -- how long does reloading mag take?
-- how long does reloading mag take?
local reloadTimeConfig = config.getParameter("reloadTime", 1)
if type(reloadTimeConfig) == "table" then
reloadTimeConfig = math.random(reloadTimeConfig[1], reloadTimeConfig[2]) -- Ensure reloadTime config value is a number
end
self.reloadTime = math.max(0, (tonumber(reloadTimeConfig) or 1) + (tonumber(status.stat("reloadTime")) or 0))


if (self.isAmmoBased==1) then
self.timerRemoveAmmoBar = 0
Expand Down Expand Up @@ -78,12 +84,20 @@ function GunFire:init()
end

function GunFire:calcAmmo()
local oldSize=self.magazineSize
local magazineTemp=(self.ammoInheritanceMult or 1.0)*config.getParameter("magazineSize",1)
self.magazineSize = magazineTemp*(1+status.stat("magazineMultiplier")) + math.max(0,status.stat("magazineSize")) -- total count of the magazine
if (oldSize and oldSize~= self.magazineSize) then return true,oldSize end
local oldSize = self.magazineSize
local magazineSizeConfig = config.getParameter("magazineSize", 1)
if type(magazineSizeConfig) == "table" then
magazineSizeConfig = math.random(magazineSizeConfig[1], magazineSizeConfig[2]) -- Should done this when creating weapon, check it here if it doesn't
end
local magazineTemp = (self.ammoInheritanceMult or 1.0) * (tonumber(magazineSizeConfig) or 1)
self.magazineSize = magazineTemp * (1 + (tonumber(status.stat("magazineMultiplier")) or 0)) + math.max(0, (tonumber(status.stat("magazineSize")) or 0))

if oldSize and oldSize ~= self.magazineSize then
return true, oldSize
end
end


-- ***********************************************************************************************************
-- ***********************************************************************************************************

Expand Down