diff --git a/bl_arena_lib/arena_manager.lua b/bl_arena_lib/arena_manager.lua index 6e28fe2..f4d1881 100644 --- a/bl_arena_lib/arena_manager.lua +++ b/bl_arena_lib/arena_manager.lua @@ -27,14 +27,8 @@ end) arena_lib.on_start("block_league", function(arena) - - for pl_name, stats in pairs(arena.players) do - minetest.get_player_by_name(pl_name):set_armor_groups({immortal = nil}) - end - block_league.round_start(arena) block_league.energy_refill_loop(arena) - end) @@ -46,8 +40,6 @@ arena_lib.on_join("block_league", function(p_name, arena) create_and_show_HUD(arena, p_name) block_league.refill_weapons(arena, p_name) - minetest.get_player_by_name(p_name):set_armor_groups({immortal = nil}) - minetest.sound_play("bl_voice_fight", {to_player = p_name}) minetest.after(0.01, function() @@ -64,7 +56,7 @@ arena_lib.on_celebration("block_league", function(arena, winner_name) arena.weapons_disabled = true for pl_name, stats in pairs(arena.players) do - minetest.get_player_by_name(pl_name):set_armor_groups({immortal=1}) + minetest.get_player_by_name(pl_name):get_meta():set_int("bl_immunity", 1) panel_lib.get_panel(pl_name, "bl_scoreboard"):show() end end) @@ -76,7 +68,7 @@ arena_lib.on_end("block_league", function(arena, players) for pl_name, stats in pairs(players) do remove_HUD(pl_name) - minetest.get_player_by_name(pl_name):set_armor_groups({immortal = nil}) + reset_meta(pl_name) block_league.update_storage(pl_name) end @@ -101,13 +93,8 @@ end) arena_lib.on_quit("block_league", function(arena, p_name) - remove_HUD(p_name) - - local player = minetest.get_player_by_name(p_name) - - player:set_armor_groups({immortal = nil}) - player:get_meta():set_int("bl_has_ball", 0) + reset_meta(p_name) end) @@ -120,14 +107,15 @@ end) function reset_meta(p_name) - local player = minetest.get_player_by_name(p_name) + local p_meta = minetest.get_player_by_name(p_name):get_meta() - player:get_meta():set_int("bl_has_ball", 0) - player:get_meta():set_int("bl_weap_delay", 0) - player:get_meta():set_int("bl_weap_secondary_delay", 0) - player:get_meta():set_int("bl_bouncer_delay", 0) - player:get_meta():set_int("bl_death_delay", 0) - player:get_meta():set_int("bl_reloading", 0) + p_meta:set_int("bl_has_ball", 0) + p_meta:set_int("bl_weap_delay", 0) + p_meta:set_int("bl_weap_secondary_delay", 0) + p_meta:set_int("bl_bouncer_delay", 0) + p_meta:set_int("bl_death_delay", 0) + p_meta:set_int("bl_immunity", 0) + p_meta:set_int("bl_reloading", 0) end diff --git a/bl_misc/immunity.lua b/bl_misc/immunity.lua index c2832e7..0a8f23b 100644 --- a/bl_misc/immunity.lua +++ b/bl_misc/immunity.lua @@ -1,23 +1,15 @@ function block_league.immunity(player) local p_name = player:get_player_name() + local p_meta = player:get_meta() local immunity_time = arena_lib.get_arena_by_player(p_name).immunity_time - local immunity_ID = 0 - player:set_armor_groups({immortal=1}) - - -- in caso uno spari, perda l'immunità, muoia subito e resusciti, il tempo d'immunità riparte da capo. - -- Ne tengo traccia con un metadato che comparo nell'after - immunity_ID = player:get_meta():get_int("bl_immunity_ID") + 1 - player:get_meta():set_int("bl_immunity_ID", immunity_ID) + p_meta:set_int("bl_immunity", 1) minetest.after(immunity_time, function() if not arena_lib.is_player_in_arena(p_name, "block_league") then return end - if immunity_ID == player:get_meta():get_int("bl_immunity_ID") then - if player:get_armor_groups().immortal and player:get_armor_groups().immortal == 1 then - player:set_armor_groups({immortal = nil}) - end - player:get_meta():set_int("bl_immunity_ID", 0) + if p_meta:get_int("bl_immunity") == 1 then + p_meta:set_int("bl_immunity", 0) end end) diff --git a/bl_weapons/bouncer.lua b/bl_weapons/bouncer.lua index fef8406..242a3a1 100644 --- a/bl_weapons/bouncer.lua +++ b/bl_weapons/bouncer.lua @@ -33,7 +33,7 @@ minetest.register_tool("block_league:bouncer", { local knockback = user:get_player_velocity().y < 1 and -15 or -10 user:add_player_velocity(vector.multiply(dir, knockback)) - minetest.sound_play("bl_bouncer", {to_player = p_name, max_hear_distance = 5}) + minetest.sound_play("bl_bouncer", {to_player = p_name}) arena.players[p_name].energy = arena.players[p_name].energy - 20 end, diff --git a/bl_weapons/weapons.lua b/bl_weapons/weapons.lua index c2f41f4..0b50b2c 100644 --- a/bl_weapons/weapons.lua +++ b/bl_weapons/weapons.lua @@ -229,6 +229,7 @@ function block_league.apply_damage(user, targets, damage, knockback, decrease_da for _, target in pairs(targets) do if target:get_hp() <= 0 then return end + if target:get_meta():get_int("bl_immunity") == 1 then return end local t_name = target:get_player_name() @@ -423,8 +424,8 @@ end function check_immunity(player) - if player:get_armor_groups().immortal and player:get_armor_groups().immortal == 1 then - player:set_armor_groups({immortal = nil}) + if player:get_meta():get_int("bl_immunity") == 1 then + player:get_meta():set_int("bl_immunity", 0) end end diff --git a/init.lua b/init.lua index 79f1a7b..d4919cd 100644 --- a/init.lua +++ b/init.lua @@ -29,7 +29,7 @@ arena_lib.register_minigame("block_league", { sneak_glitch = true, new_move = true }, - disabled_damage_types = {"fall"}, + disabled_damage_types = {"fall", "punch"}, properties = { -- 1 = Touchdown diff --git a/player_manager.lua b/player_manager.lua index 4a949d4..5647ddd 100644 --- a/player_manager.lua +++ b/player_manager.lua @@ -33,6 +33,7 @@ minetest.register_on_dieplayer(function(player) if not arena_lib.is_player_in_arena(player:get_player_name(), "block_league") then return end player:get_meta():set_int("bl_death_delay", 1) + block_league.immunity(player) minetest.after(6, function() if not player or not player:get_meta() then return end @@ -57,7 +58,6 @@ minetest.register_on_respawnplayer(function(player) block_league.energy_update(arena, p_name) block_league.refill_weapons(arena, p_name) - block_league.immunity(player) player:set_physics_override({ speed = block_league.SPEED,