From b7bec9168b464e3d1db5ee0e5d92828e67aee46e Mon Sep 17 00:00:00 2001 From: Anand S <36130650+ClobberXD@users.noreply.github.com> Date: Sun, 8 Apr 2018 20:18:33 +0530 Subject: [PATCH] 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 --- mods/ctf_bounties/init.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mods/ctf_bounties/init.lua b/mods/ctf_bounties/init.lua index d563837..a6d34f2 100644 --- a/mods/ctf_bounties/init.lua +++ b/mods/ctf_bounties/init.lua @@ -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