Noise on the x and z axis when teleporting back to the hub

master
Zughy 2021-01-03 22:17:48 +01:00
parent bc0950d673
commit 1f6999fd5b
2 changed files with 19 additions and 9 deletions

View File

@ -81,8 +81,8 @@ The second field, on the contrary, is a table of optional parameters: they defin
### 1.1 Per server configuration
There are also a couple of settings that can only be set in game via `/minigamesettings`. This because different servers might need different parameters. They are:
* `hub_spawn_point`: where players will be teleported when a match _in your mod_ ends. Default is `{ x = 0, y = 20, z = 0 }`
* `queue_waiting_time`: the time to wait before the loading phase starts. It gets triggered when the minimium amount of players has been reached to start the queue. Default is 10
* `hub_spawn_point`: where players will be teleported when a match _in your mod_ ends. Default is `{ x = 0, y = 20, z = 0 }`. A bit of noise is applied on the x and z axis, ranging between `-1.5` and `1.5`.
* `queue_waiting_time`: the time to wait before the loading phase starts. It gets triggered when the minimium amount of players has been reached to start the queue. Default is `10`
> **BEWARE**: as you noticed, the hub spawn point is bound to the very minigame. In fact, there is no global spawn point as arena_lib could be used even in a survival server that wants to feature just a couple minigames. If you're looking for a hub manager because your goal is to create a full minigame server, have a look at my other mod [Hub Manager](https://gitlab.com/zughy-friends-minetest/hub-manager). Also, if you want to be sure to join the same arena/team with your friends, you need to install my other mod [Parties](https://gitlab.com/zughy-friends-minetest/parties)

24
api.lua
View File

@ -1150,15 +1150,19 @@ function arena_lib.end_arena(mod_ref, mod, arena, winner_name)
-- effetto particellare
if type(winner_name) == "string" then
local p_pos = minetest.get_player_by_name(winner_name):get_pos()
local winner = minetest.get_player_by_name(winner_name)
show_victory_particles(p_pos)
if winner then
show_victory_particles(winner:get_pos())
end
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()
local winner = minetest.get_player_by_name(pl_name)
show_victory_particles(p_pos)
if winner then
show_victory_particles(winner:get_pos())
end
end
end
@ -2120,14 +2124,20 @@ function operations_before_leaving_arena(mod_ref, arena, p_name)
player:set_fov(players_temp_storage[p_name].fov)
end
-- resetto eventuale camera
-- ripristino eventuale camera
if mod_ref.camera_offset then
player:set_eye_offset(players_temp_storage[p_name].camera_offset[1], players_temp_storage[p_name].camera_offset[2])
end
-- resetto gli HP e teletrasporto fuori dall'arena e
-- ripristino gli HP
player:set_hp(minetest.PLAYER_MAX_HP_DEFAULT)
player:set_pos(mod_ref.settings.hub_spawn_point)
-- teletrasporto con un po' di rumore
local clean_pos = mod_ref.settings.hub_spawn_point
local noise_x = math.random(-1.5, 1.5)
local noise_z = math.random(-1.5, 1.5)
local noise_pos = {x = clean_pos.x + noise_x, y = clean_pos.y, z = clean_pos.z + noise_z}
player:set_pos(noise_pos)
-- se ho hub_manager, restituisco gli oggetti e imposto fisica della lobby
if minetest.get_modpath("hub_manager") then