From a4565ff1204bee147416acfd439aec1558c5498a Mon Sep 17 00:00:00 2001 From: Zughy <4279489-marco_a@users.noreply.gitlab.com> Date: Wed, 26 Jul 2023 23:27:18 +0200 Subject: [PATCH] Let entities damage people in minigames --- src/hud/hud_main.lua | 3 -- src/player_manager.lua | 63 ++++++++++++++++++++++-------------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/hud/hud_main.lua b/src/hud/hud_main.lua index c6d1244..30a8c87 100644 --- a/src/hud/hud_main.lua +++ b/src/hud/hud_main.lua @@ -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 }) diff --git a/src/player_manager.lua b/src/player_manager.lua index 100cec8..2c5e0e8 100644 --- a/src/player_manager.lua +++ b/src/player_manager.lua @@ -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)