Calculate last hitter when dying by rays
This commit is contained in:
parent
3c66fa3017
commit
860b3ca4ad
@ -6,24 +6,7 @@ function block_league.fall_check_loop(arena)
|
||||
|
||||
if player:get_hp() > 0 and player:get_pos().y < arena.min_y then
|
||||
player:set_hp(0)
|
||||
|
||||
-- TODO: trasforma codice sottostante in funzione (da usare anche per raggi)
|
||||
|
||||
local last_hitter = ""
|
||||
local last_hitter_timestamp = 99999
|
||||
|
||||
for pla_name, dmg_data in pairs(stats.dmg_received) do
|
||||
if arena.current_time > dmg_data.timestamp - 5 and last_hitter_timestamp > dmg_data.timestamp then
|
||||
last_hitter = pla_name
|
||||
last_hitter_timestamp = dmg_data.timestamp
|
||||
end
|
||||
end
|
||||
|
||||
if last_hitter ~= "" then
|
||||
block_league.kill(arena, minetest.registered_nodes[stats.dmg_received[last_hitter].weapon], minetest.get_player_by_name(last_hitter), player)
|
||||
else
|
||||
block_league.HUD_log_update(arena, "bl_log_suicide.png", pl_name, "")
|
||||
end
|
||||
block_league.hitter_or_suicide(arena, player, stats.dmg_received, "bl_log_suicide.png")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -38,16 +38,18 @@ minetest.register_globalstep(function(dtime)
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
local p_nodename = minetest.get_node(player:get_pos()).name
|
||||
local arena = arena_lib.get_arena_by_player(pl_name)
|
||||
local p_team = arena.players[pl_name].teamID
|
||||
|
||||
if p_nodename == "block_league:rays_blue" or p_nodename == "block_league:rays_orange" then
|
||||
local p_data = arena.players[pl_name]
|
||||
local p_team = p_team.teamID
|
||||
|
||||
if player:get_meta():get_int("bl_has_ball") == 1 then
|
||||
block_league.get_ball(player):reset() -- TODO non parla di reset ma di palla persa, sistema
|
||||
end
|
||||
|
||||
if player:get_hp() > 0 and ((p_team == 1 and p_nodename == "block_league:rays_blue") or (p_team == 2 and p_nodename == "block_league:rays_orange")) then
|
||||
player:set_hp(0)
|
||||
block_league.HUD_log_update(arena, "bl_log_rays.png", pl_name, "")
|
||||
block_league.hitter_or_suicide(arena, player, p_data.dmg_received, "bl_log_rays.png")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -289,6 +289,23 @@ end
|
||||
|
||||
|
||||
|
||||
function block_league.hitter_or_suicide(arena, player, dmg_rcvd_table, no_hitter_img)
|
||||
local last_hitter = ""
|
||||
local last_hitter_timestamp = 99999
|
||||
|
||||
for pla_name, dmg_data in pairs(dmg_rcvd_table) do
|
||||
if arena.current_time > dmg_data.timestamp - 5 and last_hitter_timestamp > dmg_data.timestamp then
|
||||
last_hitter = pla_name
|
||||
last_hitter_timestamp = dmg_data.timestamp
|
||||
end
|
||||
end
|
||||
|
||||
if last_hitter ~= "" then
|
||||
block_league.kill(arena, minetest.registered_nodes[dmg_rcvd_table[last_hitter].weapon], minetest.get_player_by_name(last_hitter), player)
|
||||
else
|
||||
block_league.HUD_log_update(arena, no_hitter_img, player:get_player_name(), "")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user