Bugfix: immunity now actually works (closes #111)

This commit is contained in:
marco_a 2024-01-05 01:30:52 +01:00
parent 64ee2ce882
commit 28ac71812c
7 changed files with 18 additions and 23 deletions

View File

@ -72,8 +72,7 @@ arena_lib.register_minigame("block_league", {
weapons_magazine = {}, -- KEY: w_name, VALUE: curr_ammo
current_weapon = "",
dmg_received = {}, -- KEY: p_name, VALUE: {timestamp, dmg, weapon}
dmg_dealt = 0,
is_immune = false,
dmg_dealt = 0
},
spectator_properties = {
was_following_ball = false

View File

@ -45,8 +45,9 @@ arena_lib.on_death("block_league", function(arena, p_name, reason)
local p_meta = player:get_meta()
p_stats.is_immune = true
p_meta:set_int("bl_weapon_state", 0)
p_meta:set_int("bl_immunity", 1)
p_meta:set_int("bl_death_delay", 1)
block_league.deactivate_zoom(player)
@ -74,11 +75,11 @@ function wait_for_respawn(arena, p_name, time_left)
player:get_meta():set_int("bl_death_delay", 0)
arena_lib.HUD_hide("broadcast", p_name)
-- se è nella sala d'attesa
-- se è nella sala d'attesa quando deve rinascere
if player:get_hp() > 0 then
block_league.HUD_spectate_update(arena, p_name, "alive")
block_league.immunity_countdown(player)
player:set_pos(arena_lib.get_random_spawner(arena, arena.players[p_name].teamID))
block_league.immunity(player)
end
return

View File

@ -10,15 +10,11 @@ arena_lib.on_respawn("block_league", function(arena, p_name)
end
else
block_league.HUD_spectate_update(arena, p_name, "alive")
block_league.immunity_countdown(player)
end
arena.players[p_name].stamina = 100
block_league.HUD_stamina_update(arena, p_name)
block_league.refill_weapons(arena, p_name)
player:set_physics_override({ speed = block_league.SPEED })
minetest.after(arena.immunity_time, function()
if not arena.players[p_name] then return end
arena.players[p_name].is_immune = false
end)
end)

View File

@ -56,8 +56,9 @@ minetest.register_globalstep(function(dtime)
if is_touching_rays then
local p_data = arena.players[pl_name]
local p_team = p_data.teamID
local p_meta = player:get_meta()
if player:get_meta():get_int("bl_has_ball") == 1 then
if p_meta:get_int("bl_has_ball") == 1 then
block_league.get_ball(player):reset()
-- reindirizza sulla palla gli spettatori
@ -68,7 +69,7 @@ minetest.register_globalstep(function(dtime)
end
end
if not p_data.is_immune and ((p_team == 1 and is_ray_blue) or (p_team == 2 and not is_ray_blue)) then
if p_meta:get_int("bl_immunity") == 0 and ((p_team == 1 and is_ray_blue) or (p_team == 2 and not is_ray_blue)) then
player:set_hp(0)
block_league.hitter_or_suicide(arena, player, p_data.dmg_received, "bl_log_rays.png")
end

View File

@ -61,6 +61,7 @@ function round_start(arena)
block_league.refill_weapons(arena, pl_name)
player:get_meta():set_int("bl_weapon_state", 0)
player:get_meta():set_int("bl_death_delay", 0)
player:get_meta():set_int("bl_immunity", 0)
player:set_physics_override({ speed = block_league.SPEED })
player:set_pos(arena_lib.get_random_spawner(arena, stats.teamID))

View File

@ -1,14 +1,11 @@
function block_league.immunity(player)
function block_league.immunity_countdown(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 arena = arena_lib.get_arena_by_player(p_name)
p_meta:set_int("bl_immunity", 1)
minetest.after(arena.immunity_time, function()
local p_meta = player:get_meta()
if not arena.players[p_name] or arena.in_celebration or p_meta:get_int("bl_death_delay") == 1 then return end
minetest.after(immunity_time, function()
if not arena_lib.is_player_in_arena(p_name, "block_league") then return end
if p_meta:get_int("bl_immunity") == 1 then
p_meta:set_int("bl_immunity", 0)
end
p_meta:set_int("bl_immunity", 0)
end)
end
end

View File

@ -164,7 +164,7 @@ function block_league.apply_damage(user, targets, weapon, action)
if headshot and action.type ~= "melee" then
damage = damage * 1.5
block_league.HUD_critical_show(p_name)
block_league.sound_play("bl_hit_critical", p_name, "not_overlappable")
block_league.sound_play("bl_hit_critical", p_name, true)
end
-- eventuale danno decrementato a seconda della distanza