diff --git a/DOCS.md b/DOCS.md index be8c5f2..f8d940c 100644 --- a/DOCS.md +++ b/DOCS.md @@ -112,7 +112,7 @@ To customise your mod even more, there are a few empty callbacks you can use. Th * `arena_lib.on_load(mod, function(arena)` (we saw these 4 earlier) * `arena_lib.on_start(mod, function(arena))` * `arena_lib.on_celebration(mod, function(arena, winner_name)` -* `arena_lib.on_end(mod, function(arena, players))` +* `arena_lib.on_end(mod, function(arena, players, winner_name))` * `arena_lib.on_join(mod, function(p_name, arena))`: called when a player joins an ongoing match * `arena_lib.on_death(mod, function(arena, p_name, reason))`: called when a player dies * `arena_lib.on_time_tick(mod, function(arena))`: called every second if `time_mode` is different from 0 @@ -394,7 +394,7 @@ The 4 functions, intertwined with the previously mentioned phases are: * `arena_lib.load_arena(mod, arena_ID)`: between the waiting and the loading phase. Called when the queue timer reaches 0, it teleports people inside. * `arena_lib.start_arena(mod_ref, arena)`: between the loading and the fighting phase. Called when the loading phase timer reaches 0. * `arena_lib.load_celebration(mod, arena, winner_name)`: between the fighting and the celebration phase. Called when the winning conditions are met. `winner_name` can be both a string and a table (in case of teams) -* `arena_lib.end_arena(mod_ref, mod, arena)`: at the very end of the celebration phase. It teleports people outside the arena +* `arena_lib.end_arena(mod_ref, mod, arena, winner_name)`: at the very end of the celebration phase. It teleports people outside the arena. `winner_name` is taken by `load_celebration(...)` Overriding these functions is **not** recommended. Instead, there are 4 respective callbacks made specifically to customise the behaviour of the formers, sharing (almost) the same variables. They are called *after* the function they're associated with and by default they are empty, so feel free to override them. They are `on_load`, `on_start`, `on_celebration` and `on_end`. diff --git a/api.lua b/api.lua index b77f47b..74e04d4 100755 --- a/api.lua +++ b/api.lua @@ -20,6 +20,7 @@ local function is_arena_name_allowed() end local function assign_team_spawner() end local function operations_before_entering_arena() end local function operations_before_leaving_arena() end +local function show_victory_particles() end local function time_start() end local players_in_game = {} -- KEY: player name, VALUE: {(string) minigame, (int) arenaID} @@ -1126,14 +1127,14 @@ function arena_lib.load_celebration(mod, arena, winner_name) -- l'arena finisce dopo tot secondi minetest.after(mod_ref.celebration_time, function() - arena_lib.end_arena(mod_ref, mod, arena) + arena_lib.end_arena(mod_ref, mod, arena, winner_name) end) end -function arena_lib.end_arena(mod_ref, mod, arena) +function arena_lib.end_arena(mod_ref, mod, arena, winner_name) -- copia da passare a on_end local players = {} @@ -1147,6 +1148,19 @@ function arena_lib.end_arena(mod_ref, mod, arena) operations_before_leaving_arena(mod_ref, arena, pl_name) end + -- effetto particellare + if type(winner_name) == "string" then + local p_pos = minetest.get_player_by_name(winner_name):get_pos() + + show_victory_particles(p_pos) + + elseif type(winner_name) == "table" then + for _, pl_name in pairs(winner_name) do + local p_pos = minetest.get_player_by_name(pl_name):get_pos() + + show_victory_particles(p_pos) + end + end -- azzero il numero di giocatori arena.players_amount = 0 @@ -1175,7 +1189,7 @@ function arena_lib.end_arena(mod_ref, mod, arena) -- eventuale codice aggiuntivo if mod_ref.on_end then - mod_ref.on_end(arena, players) + mod_ref.on_end(arena, players, winner_name) end arena.in_loading = false -- nel caso venga forzata mentre sta caricando, sennò rimane a caricare all'infinito @@ -1184,7 +1198,7 @@ function arena_lib.end_arena(mod_ref, mod, arena) local id = arena_lib.get_arena_by_name(mod, arena.name) - -- aggiorno storage per le properties e cartello + -- aggiorno storage per le proprietà e cartello update_storage(false, mod, id, arena) arena_lib.update_sign(arena) @@ -2137,6 +2151,22 @@ end +function show_victory_particles(p_pos) + minetest.add_particlespawner({ + amount = 50, + time = 0.6, + minpos = p_pos, + maxpos = p_pos, + minvel = {x=-2, y=-2, z=-2}, + maxvel = {x=2, y=2, z=2}, + minsize = 1, + maxsize = 3, + texture = "arenalib_winparticle.png" + }) +end + + + function time_start(mod_ref, arena) if arena.on_celebration or not arena.in_game then return end diff --git a/textures/arenalib_winparticle.png b/textures/arenalib_winparticle.png new file mode 100644 index 0000000..ed9dda4 Binary files /dev/null and b/textures/arenalib_winparticle.png differ