Fix issues with bounty_score

* Set lower limit to bounty
* Check for div-by-0 before calculating bounty_score
* Rounded score after calculation
* Changed the divisor from 10000 to 5000 to prevent very tiny bounties on targets
This commit is contained in:
Anand S 2018-04-08 20:18:33 +05:30 committed by rubenwardy
parent e3b12312e5
commit b7bec9168b

View file

@ -24,15 +24,22 @@ local function bounty_player(target)
bountied_player = target
-- Score * K/D
-- Score * K/D
-- bounty_score = -----------, or 500 (whichever is lesser)
-- 10000
-- 5000
local pstat, _ = ctf_stats.player(target)
if pstat.deaths == 0 then
pstat.deaths = 1
end
bounty_score = (pstat.score * (pstat.kills / pstat.deaths)) / 10000
if bounty_score > 500 then
bounty_score = 500
end
if bounty_score < 50 then
bounty_score = 50
end
bounty_score = math.floor(bounty_score)
minetest.after(0.1, announce_all)
end