both players must be out of pvp for no damage in protected area
This commit is contained in:
parent
e57216e9d4
commit
5d65449c13
14
pvp.lua
14
pvp.lua
@ -15,12 +15,12 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch,
|
|||||||
end
|
end
|
||||||
|
|
||||||
local player_pos = player:get_pos()
|
local player_pos = player:get_pos()
|
||||||
|
local hitter_pos = hitter:get_pos()
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Player
|
-- Player
|
||||||
--
|
--
|
||||||
if hitter:is_player() then
|
if hitter:is_player() then
|
||||||
|
|
||||||
-- do we enable pvp at night time only ?
|
-- do we enable pvp at night time only ?
|
||||||
-- if x_default.pvp_night_only then
|
-- if x_default.pvp_night_only then
|
||||||
-- -- get time of day
|
-- -- get time of day
|
||||||
@ -43,17 +43,25 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local can_dig, is_pvp = protector.can_dig(5, player_pos, hitter:get_player_name(), true, 1)
|
local player_can_dig, player_is_pvp = protector.can_dig(5, player_pos, hitter:get_player_name(), true, 1)
|
||||||
|
local hitter_can_dig, hitter_is_pvp = protector.can_dig(5, hitter_pos, player:get_player_name(), true, 1)
|
||||||
|
|
||||||
|
-- local both_in_pvp = player_is_pvp == true and hitter_is_pvp == true
|
||||||
|
local both_out_pvp = player_is_pvp == false and hitter_is_pvp == false
|
||||||
|
|
||||||
if x_default.disable_protector then
|
if x_default.disable_protector then
|
||||||
-- no damage if in protected area (e.g. protector redo)
|
-- no damage if in protected area (e.g. protector redo)
|
||||||
if minetest.is_protected(player_pos, hitter:get_player_name()) and not (pvp_block:in_area(player_pos) or is_pvp) then
|
if minetest.is_protected(player_pos, "") and
|
||||||
|
minetest.is_protected(hitter_pos, "") and
|
||||||
|
not pvp_block:in_area(player_pos) and
|
||||||
|
both_out_pvp then
|
||||||
-- print("#1 player in protector")
|
-- print("#1 player in protector")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Entity
|
-- Entity
|
||||||
-- for entities we have special handling with whitelist - will be useful in the future with custom logic
|
-- for entities we have special handling with whitelist - will be useful in the future with custom logic
|
||||||
|
Loading…
x
Reference in New Issue
Block a user