block_league-cd2025/player_manager.lua

102 lines
2.7 KiB
Lua
Raw Normal View History

2020-10-27 18:13:15 +01:00
local function death_delay() end
local function remove_weapons() end
minetest.register_on_joinplayer(function(player)
local p_name = player:get_player_name()
-- se non è nello storage degli achievement, lo aggiungo
if not achievements_lib.is_player_in_storage(p_name, "block_league") then
achievements_lib.add_player_to_storage(p_name, "block_league")
end
-- se non è nello storage della mod, lo aggiungo
if not block_league.is_player_in_storage(p_name) then
block_league.add_player_to_storage(p_name)
end
-- genero l'HUD per gli achievement
block_league.HUD_achievements_create(p_name)
-- non è possibile modificare l'inventario da offline. Se sono crashati o hanno chiuso il gioco in partita,
-- questo è l'unico modo per togliere loro l'arma
remove_weapons(player:get_inventory())
end)
minetest.register_on_dieplayer(function(player)
2020-11-08 21:51:16 +01:00
local p_name = player:get_player_name()
local arena = arena_lib.get_arena_by_player(p_name)
2020-11-08 21:51:16 +01:00
if not arena then return end
2020-10-27 18:13:15 +01:00
2020-10-29 10:56:30 +01:00
player:get_meta():set_int("bl_death_delay", 1)
2020-11-06 23:35:31 +01:00
block_league.immunity(player)
2020-10-27 18:13:15 +01:00
minetest.after(6, function()
2020-11-08 21:51:16 +01:00
if not arena_lib.is_player_in_arena(p_name, "block_league") or arena.weapons_disabled then return end
2020-10-29 10:56:30 +01:00
player:get_meta():set_int("bl_death_delay", 0)
player:get_meta():set_int("bl_reloading", 0)
2020-10-27 18:13:15 +01:00
end)
end)
minetest.register_on_respawnplayer(function(player)
if not arena_lib.is_player_in_arena(player:get_player_name(), "block_league") then return end
2020-10-31 15:22:23 +01:00
local p_name = player:get_player_name()
local arena = arena_lib.get_arena_by_player(p_name)
2020-11-07 23:42:00 +01:00
death_delay(p_name, player:get_pos(), arena.weapons_disabled)
2020-10-31 15:22:23 +01:00
arena.players[p_name].energy = 100
block_league.energy_update(arena, p_name)
block_league.refill_weapons(arena, p_name)
2020-10-27 18:13:15 +01:00
player:set_physics_override({
speed = block_league.SPEED,
2020-10-27 18:13:15 +01:00
jump = 1.5
})
end)
----------------------------------------------
---------------FUNZIONI LOCALI----------------
----------------------------------------------
2020-11-07 23:42:00 +01:00
function death_delay(p_name, pos, weapons_disabled)
2020-11-07 23:42:00 +01:00
if not arena_lib.is_player_in_arena(p_name, "block_league") or weapons_disabled then return end
local player = minetest.get_player_by_name(p_name)
if player:get_meta():get_int("bl_death_delay") == 0 then return end
player:set_pos(pos)
2020-11-07 23:42:00 +01:00
minetest.after(0.2, function() death_delay(p_name, pos, weapons_disabled) end)
2020-10-27 18:13:15 +01:00
end
function remove_weapons(inv)
inv:remove_item("main", ItemStack("block_league:smg"))
inv:remove_item("main", ItemStack("block_league:sword"))
inv:remove_item("main", ItemStack("block_league:pixelgun"))
inv:remove_item("main", ItemStack("block_league:rocket_launcher"))
2020-10-29 10:56:30 +01:00
inv:remove_item("main", ItemStack("block_league:bouncer"))
2020-10-27 18:13:15 +01:00
end