Clean up ball notifications code (sound and HUD) (closes #114)

This commit is contained in:
marco_a 2024-02-16 20:31:50 +01:00
parent 507737eede
commit e61263c648
3 changed files with 32 additions and 27 deletions

View File

@ -27,6 +27,18 @@ end
function block_league.HUD_ball_update_team(arena, teamID, msg, hex_color)
arena_lib.HUD_send_msg_team("title", arena, teamID, msg, 3, nil, hex_color)
end
function block_league.HUD_ball_update_all(arena, msg, hex_color)
arena_lib.HUD_send_msg_all("title", arena, msg, 3, nil, hex_color)
end
function block_league.HUD_kill_update(p_name, msg)
local panel = panel_lib.get_panel(p_name, "bl_broadcast")

View File

@ -201,10 +201,7 @@ function ball:reset()
-- annuncio
arena_lib.sound_play_all(arena, "bl_voice_ball_reset")
for psp_name, _ in pairs(arena.players_and_spectators) do
block_league.HUD_ball_update(psp_name, S("Ball reset"))
end
block_league.HUD_ball_update_all(arena, S("Ball reset"))
-- se è agganciata a qualcunə...
if self.p_name then
@ -231,20 +228,17 @@ function ball:announce_ball_possession_change(is_ball_lost)
local arena = self.arena
local teamID = self.team_id
local enemy_teamID = teamID == 1 and 2 or 1
local team = arena_lib.get_players_in_team(arena, teamID)
local enemy_team = arena_lib.get_players_in_team(arena, enemy_teamID)
if is_ball_lost then
arena_lib.sound_play_team(arena, teamID, "bl_crowd_ohno")
arena_lib.sound_play_team(arena, enemy_teamID, "bl_crowd_cheer")
for _, pl_name in pairs(team) do
block_league.HUD_ball_update(pl_name, S("Your team has lost the ball!"), "0xff8e8e")
for sp_name, _ in pairs(arena_lib.get_target_spectators("block_league", arena.name, "entity", "Ball")) do
arena_lib.sound_play(sp_name, "bl_crowd_ohno")
end
for _, pl_name in pairs(enemy_team) do
block_league.HUD_ball_update(pl_name, S("Enemy team has lost the ball!"), "0xabf877")
end
block_league.HUD_ball_update_team(arena, teamID, S("Your team has lost the ball!"), "0xff8e8e")
block_league.HUD_ball_update_team(arena, enemy_teamID, S("Enemy team has lost the ball!"), "0xabf877")
else
local p_name = self.p_name
@ -253,14 +247,14 @@ function ball:announce_ball_possession_change(is_ball_lost)
arena_lib.sound_play_team(arena, teamID, "bl_crowd_cheer")
arena_lib.sound_play_team(arena, enemy_teamID, "bl_crowd_ohno")
for _, pl_name in pairs(team) do
block_league.HUD_ball_update(pl_name, S("Your team has got the ball!"), "0xabf877")
for sp_name, _ in pairs(arena_lib.get_target_spectators("block_league", arena.name, "entity", "Ball")) do
arena_lib.sound_play(sp_name, "bl_crowd_cheer")
end
block_league.HUD_ball_update(p_name, S("You've got the ball!"), "0xabf877")
for _, pl_name in pairs(enemy_team) do
block_league.HUD_ball_update(pl_name, S("Enemy team has got the ball!"), "0xff8e8e")
end
block_league.HUD_ball_update_team(arena, teamID, S("Your team has got the ball!"), "0xabf877")
block_league.HUD_ball_update_team(arena, enemy_teamID, S("Enemy team has got the ball!"), "0xff8e8e")
block_league.HUD_ball_update(p_name, S("You've got the ball!"), "0xabf877")
end
end
@ -318,23 +312,20 @@ end
function add_point(p_name, teamID, arena)
local enemy_teamID = teamID == 1 and 2 or 1
local team = arena_lib.get_players_in_team(arena, teamID)
local enemy_team = arena_lib.get_players_in_team(arena, enemy_teamID)
for _, pl_name in pairs(team) do
audio_lib.play_sfx("bl_crowd_cheer", {to_player = pl_name})
block_league.HUD_ball_update(pl_name, S("NICE POINT!"), "0xabf877")
arena_lib.sound_play_team(arena, teamID, "bl_crowd_cheer")
arena_lib.sound_play_team(arena, enemy_teamID, "bl_crowd_ohno")
for sp_name, _ in pairs(arena_lib.get_target_spectators("block_league", arena.name, "entity", "Ball")) do
arena_lib.sound_play(sp_name, "bl_crowd_cheer")
end
for _, pl_name in pairs(enemy_team) do
audio_lib.play_sfx("bl_crowd_ohno", {to_player = pl_name})
block_league.HUD_ball_update(pl_name, S("ENEMY TEAM HAS SCORED..."), "0xff8e8e")
end
block_league.HUD_ball_update_team(arena, teamID, S("NICE POINT!"), "0xabf877")
block_league.HUD_ball_update_team(arena, enemy_teamID, S("ENEMY TEAM HAS SCORED..."), "0xff8e8e")
local scoring_team_color = teamID == 1 and "0xf2a05b" or "0x55aef1"
for sp_name, _ in pairs(arena.spectators) do
audio_lib.play_sfx("bl_crowd_cheer", {to_player = sp_name})
block_league.HUD_ball_update(sp_name, "TOUCHDOWN!", scoring_team_color)
end

View File

@ -37,10 +37,12 @@ function display_and_start_countdown(arena, time_left)
if time_left > 0 then
arena_lib.HUD_send_msg_all("broadcast", arena, time_left)
time_left = time_left -1
minetest.after(1, function()
if arena.in_celebration then return end
display_and_start_countdown(arena, time_left)
end)
else
arena_lib.HUD_hide("broadcast", arena)
round_start(arena)