From 88e6fb7af98407aec586f3cf9cb49e07d737a32f Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Wed, 10 Feb 2021 19:14:12 -0800 Subject: [PATCH 1/3] Fix potential kill assist bug --- mods/pvp/kill_assist/init.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mods/pvp/kill_assist/init.lua b/mods/pvp/kill_assist/init.lua index ff0fafa..85b424e 100644 --- a/mods/pvp/kill_assist/init.lua +++ b/mods/pvp/kill_assist/init.lua @@ -30,11 +30,14 @@ function kill_assist.add_heal_assist(victim, healed_hp) end function kill_assist.reward_assists(victim, killer, reward) - if not kill_assists[victim] then return end + local max_hp = minetest.get_player_by_name(victim):get_properties().max_hp or 20 + + if not kill_assists[victim] then + kill_assist.add_assist(victim, killer, max_hp) + end for name, damage in pairs(kill_assists[victim].players) do - if name ~= "!offset" and minetest.get_player_by_name(name) then - local max_hp = minetest.get_player_by_name(victim):get_properties().max_hp or 20 + if minetest.get_player_by_name(name) then local help_percent = damage / (max_hp + kill_assists[victim].hp_offset) local main, match = ctf_stats.player(name) local color = "0x00FFFF" From 6a12dcc12a1d4d53bb76d084561231f8933585b4 Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Wed, 10 Feb 2021 20:57:29 -0800 Subject: [PATCH 2/3] Fix kill_assist crash --- mods/pvp/kill_assist/init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mods/pvp/kill_assist/init.lua b/mods/pvp/kill_assist/init.lua index 85b424e..09d4ce4 100644 --- a/mods/pvp/kill_assist/init.lua +++ b/mods/pvp/kill_assist/init.lua @@ -33,7 +33,11 @@ function kill_assist.reward_assists(victim, killer, reward) local max_hp = minetest.get_player_by_name(victim):get_properties().max_hp or 20 if not kill_assists[victim] then - kill_assist.add_assist(victim, killer, max_hp) + if victim ~= killer then + kill_assist.add_assist(victim, killer, max_hp) + else + return + end end for name, damage in pairs(kill_assists[victim].players) do From 5f456a504a4728b6a81aab7db280746e92ba0c1f Mon Sep 17 00:00:00 2001 From: savilli <78875209+savilli@users.noreply.github.com> Date: Thu, 11 Feb 2021 08:18:09 +0300 Subject: [PATCH 3/3] Make ctf_stats award kills again (#788) * Restore register_on_killedplayer callback in ctf_stats * Remove unused args Co-authored-by: savilli Co-authored-by: LoneWolfHT --- mods/ctf/ctf_stats/init.lua | 14 ++++++++++++++ mods/pvp/kill_assist/init.lua | 3 --- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/mods/ctf/ctf_stats/init.lua b/mods/ctf/ctf_stats/init.lua index e3ec456..4c10bd2 100644 --- a/mods/ctf/ctf_stats/init.lua +++ b/mods/ctf/ctf_stats/init.lua @@ -417,6 +417,20 @@ function ctf_stats.calculateKillReward(victim, killer, toolcaps) return reward end +ctf.register_on_killedplayer(function(victim, killer) + -- Suicide is not encouraged here at CTF + if victim == killer then + return + end + local main, match = ctf_stats.player(killer) + if main and match then + main.kills = main.kills + 1 + match.kills = match.kills + 1 + match.kills_since_death = match.kills_since_death + 1 + _needs_save = true + end +end) + minetest.register_on_dieplayer(function(player) local main, match = ctf_stats.player(player:get_player_name()) diff --git a/mods/pvp/kill_assist/init.lua b/mods/pvp/kill_assist/init.lua index 09d4ce4..25d5e38 100644 --- a/mods/pvp/kill_assist/init.lua +++ b/mods/pvp/kill_assist/init.lua @@ -55,9 +55,6 @@ function kill_assist.reward_assists(victim, killer, reward) if name == killer then color = "0x00FF00" - main.kills = main.kills + 1 - match.kills = match.kills + 1 - match.kills_since_death = match.kills_since_death + 1 end hud_score.new(name, {