From dc850acd9d5c45853709a9b2266e1c4d11f62bc5 Mon Sep 17 00:00:00 2001 From: ANAND Date: Fri, 12 Apr 2019 15:22:32 +0530 Subject: [PATCH] Don't end respawn immunity on hitting team-mates (#404) --- .../ctf_respawn_immunity}/init.lua | 20 ++++++++++++------- mods/ctf/ctf_respawn_immunity/mod.conf | 2 ++ mods/pvp/respawn_immunity/depends.txt | 1 - 3 files changed, 15 insertions(+), 8 deletions(-) rename mods/{pvp/respawn_immunity => ctf/ctf_respawn_immunity}/init.lua (73%) create mode 100644 mods/ctf/ctf_respawn_immunity/mod.conf delete mode 100644 mods/pvp/respawn_immunity/depends.txt diff --git a/mods/pvp/respawn_immunity/init.lua b/mods/ctf/ctf_respawn_immunity/init.lua similarity index 73% rename from mods/pvp/respawn_immunity/init.lua rename to mods/ctf/ctf_respawn_immunity/init.lua index 98789ab..25447e3 100644 --- a/mods/pvp/respawn_immunity/init.lua +++ b/mods/ctf/ctf_respawn_immunity/init.lua @@ -36,18 +36,24 @@ end minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage) + if not player or not hitter then + return false + end + + local pname = player:get_player_name() + local hname = hitter:get_player_name() + if player and respawn_immunity.is_immune(player) then - minetest.chat_send_player(hitter:get_player_name(), - player:get_player_name() .. - " just respawned or joined, and is immune to attacks!") + minetest.chat_send_player(hname, minetest.colorize("FF8C77", pname .. + " just respawned or joined, and is immune to attacks!")) return true end - if hitter and respawn_immunity.is_immune(hitter) then - minetest.chat_send_player(hitter:get_player_name(), - minetest.colorize("#FF8C00", + if hitter and respawn_immunity.is_immune(hitter) and + ctf.player(hname).team ~= ctf.player(pname).team then + minetest.chat_send_player(hname, minetest.colorize("#FF8C00", "Your immunity has ended because you attacked a player")) - immune_players[hitter:get_player_name()] = nil + immune_players[hname] = nil respawn_immunity.update_effects(hitter) end end) diff --git a/mods/ctf/ctf_respawn_immunity/mod.conf b/mods/ctf/ctf_respawn_immunity/mod.conf new file mode 100644 index 0000000..04af462 --- /dev/null +++ b/mods/ctf/ctf_respawn_immunity/mod.conf @@ -0,0 +1,2 @@ +name = ctf_respawn_immunity +depends = ctf diff --git a/mods/pvp/respawn_immunity/depends.txt b/mods/pvp/respawn_immunity/depends.txt deleted file mode 100644 index 0dcc91d..0000000 --- a/mods/pvp/respawn_immunity/depends.txt +++ /dev/null @@ -1 +0,0 @@ -ctf