try to implement removing huds and proper HUD messages when players quit out and when gems no longer exist
This commit is contained in:
parent
1abee7be87
commit
3148f30af8
@ -94,7 +94,8 @@ minetest.register_entity("gems_battle:great_gem",{
|
||||
local arena = arena_lib.get_arena_by_pos(self.object:get_pos(), "gems_battle")
|
||||
if arena and arena.in_game and self._teamID and arena.teams[self._teamID] then
|
||||
if arena.teams[self._teamID].team_eliminated then
|
||||
self.object:remove()
|
||||
arena.teams[self._teamID].gem_hp = 0
|
||||
self.object:set_hp(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
12
src/hud.lua
12
src/hud.lua
@ -132,7 +132,7 @@ function gems_battle.update_hud(arena,p_name,as_spectator)
|
||||
|
||||
-- handle timer HUD
|
||||
player:hud_change(p_huds.timer, "text", arena.current_time)
|
||||
|
||||
local active_teams = arena_lib.get_active_teams()
|
||||
-- great gem
|
||||
for t_id,teamdata in ipairs(arena.teams) do
|
||||
|
||||
@ -200,11 +200,17 @@ end
|
||||
function get_great_gem_images(arena,team)
|
||||
|
||||
local team_id = gems_battle.get_team_id_by_name(arena, team)
|
||||
local is_active = arena.teams[team_id].gem_exists
|
||||
local percent = ((arena.teams[team_id].gem_hp/32))*100
|
||||
|
||||
local color = gems_battle.get_color_code(team)
|
||||
|
||||
local great_gem_border = "gems_hud_border.png"
|
||||
local great_gem_border_simple = "gems_hud_border_plain.png"
|
||||
if not(is_active) then
|
||||
great_gem_border = "gems_hud_border_elim.png"
|
||||
end
|
||||
|
||||
if arena.teams[team_id].attack_flash then
|
||||
great_gem_border = "gems_hud_border_attack.png"
|
||||
great_gem_border_simple = "gems_hud_border_plain_attack.png"
|
||||
@ -218,5 +224,9 @@ function get_great_gem_images(arena,team)
|
||||
great_gem_image_simple = [[[combine:16x40:0,0=gems_hud_border_plain.png:4,1=gems_hud_overlay.png]]
|
||||
end
|
||||
|
||||
if not(is_active) then
|
||||
great_gem_image_simple = "blank.png"
|
||||
end
|
||||
|
||||
return great_gem_image,great_gem_image_simple
|
||||
end
|
@ -84,6 +84,12 @@ end)
|
||||
arena_lib.on_prequit(mod, function(arena, p_name)
|
||||
if not arena.spectators[p_name] then
|
||||
leave_arena(arena,p_name)
|
||||
local teamID = arena.players[p_name].teamID
|
||||
local team_name = arena.teams[teamID].name
|
||||
if #arena.teams[teamID] == 1 then
|
||||
arena.teams[teamID].is_eliminated = true
|
||||
arena_lib.HUD_send_msg_all("title", arena, S("@1 team has been eliminated!", gems_battle.get_capname(team_name)), 3, nil, gems_battle.get_color_code(team_name,false,true))
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
@ -93,13 +99,19 @@ arena_lib.on_time_tick(mod, function(arena)
|
||||
-- handle gem destruction
|
||||
for team_id, team_data in ipairs(arena.teams) do
|
||||
local team_name = team_data.name
|
||||
if arena.teams[team_id].gem_hp == 0 and arena.teams[team_id].gem_exists == true then
|
||||
local team_data = arena.teams[team_id]
|
||||
local gem_hp = team_data.gem_hp
|
||||
local is_eliminated = team_data.is_eliminated
|
||||
local gem_exists = team_data.gem_exists
|
||||
if (gem_hp == 0 or is_eliminated == true) and gem_exists == true then
|
||||
--The great gem is missing! Now the players shall die.
|
||||
-- send msg and switch off gem_exists
|
||||
local uc = gems_battle.get_capname(team_name)
|
||||
arena_lib.send_message_in_arena( arena , 'both' , S("@1 team's Great Gem has been destroyed! They will not respawn!",minetest.colorize(gems_battle.get_color_code(team_name),uc)) )
|
||||
local numbercolor = tonumber("0x"..string.sub(gems_battle.get_color_code(team_name),2,-1))
|
||||
arena_lib.HUD_send_msg_all("title", arena, S("@1 team's Great Gem has been destroyed!",uc), 3, nil, numbercolor)
|
||||
if not is_eliminated then -- if is_eliminated is true then they were eliminated by quitting.
|
||||
local uc = gems_battle.get_capname(team_name)
|
||||
arena_lib.send_message_in_arena( arena , 'both' , S("@1 team's Great Gem has been destroyed! They will not respawn!",minetest.colorize(gems_battle.get_color_code(team_name),uc)) )
|
||||
local numbercolor = tonumber("0x"..string.sub(gems_battle.get_color_code(team_name),2,-1))
|
||||
arena_lib.HUD_send_msg_all("title", arena, S("@1 team's Great Gem has been destroyed!",uc), 3, nil, numbercolor)
|
||||
end
|
||||
arena.teams[team_id].gem_exists = false
|
||||
end
|
||||
end
|
||||
|
BIN
textures/gems_hud_border_elim.png
Normal file
BIN
textures/gems_hud_border_elim.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 195 B |
Loading…
x
Reference in New Issue
Block a user