Let entities damage people in minigames

This commit is contained in:
Zughy 2023-07-26 23:27:18 +02:00
parent 39217d5578
commit a4565ff120
2 changed files with 33 additions and 33 deletions

View File

@ -16,7 +16,6 @@ function arena_lib.HUD_add(player)
local HUD_BROADCAST_IMG = player:hud_add({
hud_elem_type = "image",
position = { x = 0.5, y = 0.25},
offset = { x = 0, y = 0},
text = "",
scale = { x = 25, y = 2},
number = 0xFFFFFF,
@ -26,9 +25,7 @@ function arena_lib.HUD_add(player)
local HUD_BROADCAST_TXT = player:hud_add({
hud_elem_type = "text",
position = { x = 0.5, y = 0.25},
offset = {x = 0, y = 0},
text = "",
size = { x = 1, y = 1},
number = 0xFFFFFF,
z_index = 1100
})

View File

@ -51,42 +51,45 @@ end)
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
local t_name = player:get_player_name()
local p_name = hitter:get_player_name()
local t_arena = arena_lib.get_arena_by_player(t_name)
local p_arena = arena_lib.get_arena_by_player(p_name)
-- le entità possono far male a prescindere
if not hitter:is_player() then return end
-- se nessuno dei due è perlomeno in coda, lascio spazio agli altri eventuali on_punchplayer
if not p_arena and not t_arena then
return
end
local t_name = player:get_player_name()
local p_name = hitter:get_player_name()
local t_arena = arena_lib.get_arena_by_player(t_name)
local p_arena = arena_lib.get_arena_by_player(p_name)
local is_p_queuing = arena_lib.is_player_in_queue(p_name)
local is_t_queuing = arena_lib.is_player_in_queue(t_name)
local is_p_playing = arena_lib.is_player_in_arena(p_name)
local is_t_playing = arena_lib.is_player_in_arena(t_name)
-- se nessuno dei due è perlomeno in coda, lascio spazio agli altri eventuali on_punchplayer
if not p_arena and not t_arena then
return
end
-- se nessuno dei due è in partita, ma solo al massimo in coda, lascio spazio agli altri eventuali on_punchplayer
if (is_p_queuing and not is_t_playing) or
(is_t_queuing and not is_p_playing) then
return
end
local is_p_queuing = arena_lib.is_player_in_queue(p_name)
local is_t_queuing = arena_lib.is_player_in_queue(t_name)
local is_p_playing = arena_lib.is_player_in_arena(p_name)
local is_t_playing = arena_lib.is_player_in_arena(t_name)
-- se uno è in partita e l'altro no, annullo
if (is_p_playing and not is_t_playing) or
(is_t_playing and not is_p_playing) then
return true
end
-- se nessuno dei due è in partita, ma solo al massimo in coda, lascio spazio agli altri eventuali on_punchplayer
if (is_p_queuing and not is_t_playing) or
(is_t_queuing and not is_p_playing) then
return
end
-- se sono nella stessa partita e l'arena è o in caricamento o in celebrazione, annullo
if p_arena.in_loading or p_arena.in_celebration then
return true
end
-- se uno è in partita e l'altro no, annullo
if (is_p_playing and not is_t_playing) or
(is_t_playing and not is_p_playing) then
return true
end
-- idem se sono nella stessa squadra, annullo
if p_arena.teams_enabled and arena_lib.is_player_in_same_team(p_arena, p_name, t_name) then
return true
end
-- se sono nella stessa partita e l'arena è o in caricamento o in celebrazione, annullo
if p_arena.in_loading or p_arena.in_celebration then
return true
end
-- idem se sono nella stessa squadra, annullo
if p_arena.teams_enabled and arena_lib.is_player_in_same_team(p_arena, p_name, t_name) then
return true
end
end)