diff --git a/ctf/core.lua b/ctf/core.lua index 83a50ca..30fcd64 100644 --- a/ctf/core.lua +++ b/ctf/core.lua @@ -145,7 +145,8 @@ function ctf.init() ctf._set("default_diplo_state", "war") ctf._set("hud", true) ctf._set("remove_player_on_leave", false) - ctf._set("autoalloc_on_joinplayer", true) + ctf._set("autoalloc_on_joinplayer", true) + ctf._set("friendly_fire", true) for i = 1, #ctf.registered_on_init do diff --git a/ctf/teams.lua b/ctf/teams.lua index 88f3e3e..61587a3 100644 --- a/ctf/teams.lua +++ b/ctf/teams.lua @@ -420,3 +420,14 @@ minetest.register_on_leaveplayer(function(player) ctf.remove_player(player:get_player_name()) end end) + +-- Disable friendly fire. +minetest.register_on_punchplayer(function(player, hitter) + local to = ctf.player(player:get_player_name()) + local from = ctf.player(hitter:get_player_name()) + + if not ctf.setting("friendly_fire") and to.team == from.team and + to.team ~= "" and to.team ~= nil then + return true + end +end)