Top 3 players HUD
This commit is contained in:
parent
d9dc76b726
commit
c51bce4594
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -6,7 +6,9 @@
|
||||
"arena_lib",
|
||||
"PseudoRandom",
|
||||
"flow",
|
||||
"controls"
|
||||
"controls",
|
||||
"Panel",
|
||||
"panel_lib"
|
||||
],
|
||||
"Lua.diagnostics.disable": [
|
||||
"trailing-space"
|
||||
|
@ -15,7 +15,7 @@ fbrawl_settings = {}
|
||||
fbrawl_settings.max_loading_time = 60
|
||||
|
||||
-- The time between the end of the match and the respawn at the hub.
|
||||
fbrawl_settings.celebration_time = 5
|
||||
fbrawl_settings.celebration_time = 6
|
||||
|
||||
-- What's going to appear in most of the lines printed by fantasy brawl.
|
||||
fbrawl_settings.prefix = "Fantasy Brawl > "
|
@ -66,10 +66,13 @@ end)
|
||||
|
||||
|
||||
arena_lib.on_celebration("fantasy_brawl", function(arena, winners)
|
||||
arena_lib.HUD_hide("title", arena)
|
||||
|
||||
for pl_name, _ in pairs(arena.players) do
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
fbrawl.stop_skills(pl_name)
|
||||
player:get_inventory():set_list("main", {})
|
||||
fbrawl.show_podium_HUD(pl_name)
|
||||
end
|
||||
end)
|
||||
|
||||
@ -82,7 +85,7 @@ end)
|
||||
|
||||
|
||||
arena_lib.on_timeout("fantasy_brawl", function(arena)
|
||||
fbrawl.define_winner(arena)
|
||||
arena_lib.load_celebration("fantasy_brawl", arena, "")
|
||||
end)
|
||||
|
||||
|
||||
|
@ -27,6 +27,8 @@ function fbrawl.out_of_match_operations(pl_name)
|
||||
|
||||
player:set_properties({hp_max = minetest.PLAYER_MAX_HP_DEFAULT})
|
||||
player:set_hp(minetest.PLAYER_MAX_HP_DEFAULT)
|
||||
|
||||
panel_lib.get_panel(pl_name, "fbrawl:podium"):hide()
|
||||
end
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
local function get_classes_btns() end
|
||||
local function get_skills_btns() end
|
||||
local function get_classes_tabs() end
|
||||
local function get_skills_tabs() end
|
||||
local function start_match_if_everyone_selected_a_class() end
|
||||
|
||||
local data = {} -- player: ObjectRef = data: table
|
||||
@ -43,7 +43,7 @@ function fbrawl.show_class_selector(pl_name)
|
||||
|
||||
-- SKILLS
|
||||
"container[1,4]"..
|
||||
get_skills_btns(pl_data)..
|
||||
get_skills_tabs(pl_data)..
|
||||
"hypertext[0,1.7;7,1.5;class_name;<global size=24 font=mono color=#472d3c><b>"..selected_skill.name.."</b>]" ..
|
||||
"hypertext[0,2.4;7,1.8;class_desc;<global size=16 font=mono color=#472d3c>"..selected_skill.description.."]" ..
|
||||
"container_end[]" ..
|
||||
@ -52,8 +52,7 @@ function fbrawl.show_class_selector(pl_name)
|
||||
"container_end[]" ..
|
||||
-- END INFO ABOUT CLASS
|
||||
|
||||
-- CLASSES BTNS
|
||||
get_classes_btns(pl_data)..
|
||||
get_classes_tabs(pl_data)..
|
||||
|
||||
-- SELECT BTN
|
||||
"image_button_exit[4.2,8.6;2.8,1.3;fbrawl_gui_btn_choose.png;choose_class;Choose]"
|
||||
@ -108,7 +107,7 @@ minetest.register_craftitem("fantasy_brawl:class_selector", {
|
||||
|
||||
|
||||
|
||||
function get_classes_btns(pl_data)
|
||||
function get_classes_tabs(pl_data)
|
||||
local btns = ""
|
||||
local selected_class_name = pl_data.selected_class_name or "Warrior"
|
||||
|
||||
@ -134,7 +133,7 @@ end
|
||||
|
||||
|
||||
|
||||
function get_skills_btns(pl_data)
|
||||
function get_skills_tabs(pl_data)
|
||||
local btns = ""
|
||||
local selected_skill_name = pl_data.selected_skill_name
|
||||
local selected_class = fbrawl.get_class_by_name(pl_data.selected_class_name)
|
||||
|
@ -163,7 +163,7 @@ function set_callbacks(class)
|
||||
local props = arena.players[pl_name]
|
||||
props.kills = props.kills + 1
|
||||
props.ultimate_recharge = math.min(props.ultimate_recharge + 1, fbrawl.min_kills_to_use_ultimate)
|
||||
|
||||
|
||||
fbrawl.update_hud(pl_name, "kills", props.kills)
|
||||
arena_lib.HUD_send_msg("broadcast", pl_name, T("You've killed @1", killed_pl_name), 2.5)
|
||||
minetest.sound_play({name="fbrawl_class_selected"}, {to_player = pl_name})
|
||||
@ -185,6 +185,8 @@ function set_callbacks(class)
|
||||
|
||||
killer_class:on_kill(arena, killer_name, pl_name)
|
||||
end
|
||||
|
||||
fbrawl.update_score(arena)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -240,14 +240,14 @@ end
|
||||
function move_towards_crush_point(meteor, dtime)
|
||||
local obj = meteor.object
|
||||
local distance = vector.distance(obj:get_pos(), meteor._crush_point)
|
||||
local is_arrived = distance <= 0.7
|
||||
local is_arrived = distance <= 0.8
|
||||
|
||||
if not is_arrived then
|
||||
meteor._time_passed = meteor._time_passed + dtime
|
||||
if meteor._time_passed < 0.5 then return end
|
||||
|
||||
if distance <= 2 then
|
||||
meteor._fall_speed_multiplier = 1
|
||||
meteor._fall_speed_multiplier = 0.5
|
||||
end
|
||||
|
||||
go_towards(meteor, meteor._crush_point, meteor._speed * meteor._fall_speed_multiplier)
|
||||
|
@ -12,8 +12,8 @@ skills.register_skill("fbrawl:hero_fury", {
|
||||
},
|
||||
damage = 2,
|
||||
slot = 4,
|
||||
upward_force = 50,
|
||||
punch_force = 20,
|
||||
upward_force = 60,
|
||||
punch_force = 30,
|
||||
data = {
|
||||
hits = 0,
|
||||
hit_player = nil
|
||||
|
@ -4,7 +4,7 @@ local T = fbrawl.T
|
||||
|
||||
skills.register_skill("fbrawl:iron_skin", {
|
||||
name = T("Iron Skin"),
|
||||
description = T("The damage you take is halven for @1 seconds since you cast the skill.", 6),
|
||||
description = T("The damage you take is halved for @1 seconds since you cast the skill.", 6),
|
||||
icon = "fbrawl_iron_skin_skill.png",
|
||||
slot = 3,
|
||||
cooldown = 20,
|
||||
|
150
hud.lua
150
hud.lua
@ -54,6 +54,124 @@ function fbrawl.generate_HUD(arena, pl_name)
|
||||
size = {x=1, y=1},
|
||||
})
|
||||
|
||||
local imgs_scale = 4
|
||||
|
||||
local pl_name_y_offset = 80
|
||||
|
||||
local crown_x_offset = 16*imgs_scale + 300
|
||||
local crown_y_offset = 16*imgs_scale
|
||||
|
||||
local scores_scale = imgs_scale - 1
|
||||
local score_x_offset = 14*scores_scale + 8
|
||||
local score_y_offset = 18*scores_scale + pl_name_y_offset
|
||||
local score_value_y_offset = 14
|
||||
local score_value_x_offset = 16
|
||||
|
||||
local panel = Panel:new("fbrawl:podium", {
|
||||
player = pl_name,
|
||||
position = {x=0.5, y=0.15},
|
||||
alignment = {x=0, y=0.5},
|
||||
--bg = "fbrawl_transparent.png",
|
||||
bg_scale = {x = 1000, y = 1000},
|
||||
|
||||
-- IMAGES
|
||||
sub_img_elems = {
|
||||
iron_crown = {
|
||||
scale = {x = imgs_scale, y = imgs_scale},
|
||||
offset = {x = -crown_x_offset, y = crown_y_offset},
|
||||
text = "fbrawl_iron_crown.png",
|
||||
},
|
||||
iron_kills = {
|
||||
scale = {x = scores_scale, y = scores_scale},
|
||||
offset = {x = -crown_x_offset - score_x_offset, y = crown_y_offset + score_y_offset},
|
||||
text = "fbrawl_hud_kills_score.png",
|
||||
},
|
||||
iron_deaths = {
|
||||
scale = {x = scores_scale, y = scores_scale},
|
||||
offset = {x = -crown_x_offset + score_x_offset, y = crown_y_offset + score_y_offset},
|
||||
text = "fbrawl_hud_deaths_score.png",
|
||||
},
|
||||
|
||||
golden_crown = {
|
||||
scale = {x = imgs_scale, y = imgs_scale},
|
||||
offset = {x = 0, y = 0},
|
||||
text = "fbrawl_golden_crown.png"
|
||||
},
|
||||
golden_kills = {
|
||||
scale = {x = scores_scale, y = scores_scale},
|
||||
offset = {x = -score_x_offset, y = score_y_offset},
|
||||
text = "fbrawl_hud_kills_score.png",
|
||||
},
|
||||
golden_deaths = {
|
||||
scale = {x = scores_scale, y = scores_scale},
|
||||
offset = {x = score_x_offset, y = score_y_offset},
|
||||
text = "fbrawl_hud_deaths_score.png",
|
||||
},
|
||||
|
||||
bronze_crown = {
|
||||
scale = {x = imgs_scale, y = imgs_scale},
|
||||
offset = {x = crown_x_offset, y = crown_y_offset},
|
||||
text = "fbrawl_bronze_crown.png"
|
||||
},
|
||||
bronze_kills = {
|
||||
scale = {x = scores_scale, y = scores_scale},
|
||||
offset = {x = crown_x_offset - score_x_offset, y = crown_y_offset + score_y_offset},
|
||||
text = "fbrawl_hud_kills_score.png",
|
||||
},
|
||||
bronze_deaths = {
|
||||
scale = {x = scores_scale, y = scores_scale},
|
||||
offset = {x = crown_x_offset + score_x_offset, y = crown_y_offset + score_y_offset},
|
||||
text = "fbrawl_hud_deaths_score.png",
|
||||
},
|
||||
},
|
||||
|
||||
-- TEXTS
|
||||
sub_txt_elems = {
|
||||
iron_pl_name = {
|
||||
offset = {x = -crown_x_offset, y = crown_y_offset + pl_name_y_offset},
|
||||
text = "-",
|
||||
size = {x=2}
|
||||
},
|
||||
iron_kills_value = {
|
||||
offset = {x = -crown_x_offset - score_x_offset + score_value_x_offset, y = crown_y_offset + score_y_offset + score_value_y_offset},
|
||||
text = "-",
|
||||
},
|
||||
iron_deaths_value = {
|
||||
offset = {x = -crown_x_offset + score_x_offset - score_value_x_offset, y = crown_y_offset + score_y_offset + score_value_y_offset},
|
||||
text = "-",
|
||||
},
|
||||
|
||||
golden_pl_name = {
|
||||
offset = {x = 0, y = pl_name_y_offset},
|
||||
text = "-",
|
||||
size = {x=2}
|
||||
},
|
||||
golden_kills_value = {
|
||||
offset = {x = -score_x_offset + score_value_x_offset, y = score_y_offset + score_value_y_offset},
|
||||
text = "-",
|
||||
},
|
||||
golden_deaths_value = {
|
||||
offset = {x = score_x_offset - score_value_x_offset, y = score_y_offset + score_value_y_offset},
|
||||
text = "-",
|
||||
},
|
||||
|
||||
bronze_pl_name = {
|
||||
offset = {x = crown_x_offset, y = crown_y_offset + pl_name_y_offset},
|
||||
text = "-",
|
||||
size = {x=2}
|
||||
},
|
||||
bronze_kills_value = {
|
||||
offset = {x = crown_x_offset - score_x_offset + score_value_x_offset, y = crown_y_offset + score_y_offset + score_value_y_offset},
|
||||
text = "-",
|
||||
},
|
||||
bronze_deaths_value = {
|
||||
offset = {x = crown_x_offset + score_x_offset - score_value_x_offset, y = crown_y_offset + score_y_offset + score_value_y_offset},
|
||||
text = "-",
|
||||
},
|
||||
}
|
||||
})
|
||||
panel:hide()
|
||||
|
||||
saved_huds[pl_name] = {
|
||||
stats_bg = stats_bg,
|
||||
kills = kills,
|
||||
@ -142,4 +260,36 @@ function fbrawl.get_hud(pl_name, name)
|
||||
if not player or not saved_huds[pl_name] or not saved_huds[pl_name][name] then return end
|
||||
|
||||
return saved_huds[pl_name][name]
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
controls.register_on_press(function(player, control_name)
|
||||
local pl_name = player:get_player_name()
|
||||
local mod = arena_lib.get_mod_by_player(pl_name)
|
||||
local arena = arena_lib.get_arena_by_player(pl_name)
|
||||
|
||||
if mod == "fantasy_brawl" and arena.in_game and control_name == "aux1" then
|
||||
fbrawl.show_podium_HUD(pl_name)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
|
||||
controls.register_on_release(function(player, control_name)
|
||||
local pl_name = player:get_player_name()
|
||||
local mod = arena_lib.get_mod_by_player(pl_name)
|
||||
local arena = arena_lib.get_arena_by_player(pl_name)
|
||||
|
||||
if mod == "fantasy_brawl" and arena.in_game and not arena.in_celebration and control_name == "aux1" then
|
||||
panel_lib.get_panel(pl_name, "fbrawl:podium"):hide()
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
|
||||
function fbrawl.show_podium_HUD(pl_name)
|
||||
fbrawl.update_score_hud(pl_name)
|
||||
panel_lib.get_panel(pl_name, "fbrawl:podium"):show()
|
||||
end
|
5
init.lua
5
init.lua
@ -9,12 +9,14 @@ arena_lib.register_minigame("fantasy_brawl", {
|
||||
prefix = fbrawl_settings.prefix,
|
||||
icon = "fbrawl_icon.png",
|
||||
temp_properties = {
|
||||
classes = {}, -- pl_name : string = class : {}
|
||||
classes = {}, -- pl_name: string = class: {}
|
||||
match_started = false,
|
||||
scores = {} -- pl_name: string = score: number
|
||||
},
|
||||
player_properties = {
|
||||
class = "",
|
||||
kills = 0,
|
||||
deaths = 0,
|
||||
ultimate_recharge = 0,
|
||||
},
|
||||
disabled_damage_types = {"fall"},
|
||||
@ -29,6 +31,7 @@ arena_lib.register_minigame("fantasy_brawl", {
|
||||
|
||||
dofile(minetest.get_modpath("fantasy_brawl") .. "/hud.lua")
|
||||
dofile(minetest.get_modpath("fantasy_brawl") .. "/sounds.lua")
|
||||
dofile(minetest.get_modpath("fantasy_brawl") .. "/score.lua")
|
||||
|
||||
dofile(minetest.get_modpath("fantasy_brawl") .. "/chatcmdbuilder.lua")
|
||||
dofile(minetest.get_modpath("fantasy_brawl") .. "/utils.lua")
|
||||
|
@ -18,7 +18,7 @@ There's not enough space here!=Non c'è abbastanza spazio qui!
|
||||
@1 kills left to use the ultimate=@1 uccisioni rimanenti per usare l'abilità finale
|
||||
You have @1 seconds to choose your class=Hai @1 secondi per scegliere la tua classe
|
||||
Wait for everyone to choose their class=Aspetta che tutti scelgano la propria classe
|
||||
You've been killed by @1=Sei stato uccido da @1
|
||||
You've been killed by @1=Sei stato ucciso da @1
|
||||
You've killed @1=Hai ucciso @1
|
||||
|
||||
|
||||
@ -49,6 +49,6 @@ Perfect Combo=Combo Insuperabile
|
||||
Warrior's Jump=Salto del Guerriero
|
||||
Sword=Spada
|
||||
Unleash the fury of a war hero: throw the enemy in the sky and punch them to death. Brr... Merciless.=Scatena la furia di un eroe di guerra: lancia il nemico in cielo e picchialo a morte. Brr... Spietato.
|
||||
The damage you take is halven for @1 seconds since you cast the skill.=Il danno subito si dimezza per @1 secondi da quando lanci l'abilità.
|
||||
The damage you take is halved for @1 seconds since you cast the skill.=Il danno subito si dimezza per @1 secondi da quando lanci l'abilità.
|
||||
Your trusted steel sword *slice slice slice*.@nRIGHT CLICK: sprint damaging whoever gets in the way.=La tua fidata spada *taglia taglia taglia*.@nCLICK DESTRO: scatta danneggiando chiunque sia sulla tua strada.
|
||||
Jump very high to then land on their heads and c r u s h them!=Salta molto in alto così da schiacciarli meglio!
|
@ -49,6 +49,6 @@ Perfect Combo=
|
||||
Warrior's Jump=
|
||||
Sword=
|
||||
Unleash the fury of a war hero: throw the enemy in the sky and punch them to death. Brr... Merciless.=
|
||||
The damage you take is halven for @1 seconds since you cast the skill.=
|
||||
The damage you take is halved for @1 seconds since you cast the skill.=
|
||||
Your trusted steel sword *slice slice slice*.@nRIGHT CLICK: sprint damaging whoever gets in the way.=
|
||||
Jump very high to then land on their heads and c r u s h them!=
|
2
mod.conf
2
mod.conf
@ -1,4 +1,4 @@
|
||||
name = fantasy_brawl
|
||||
depends = skills, arena_lib, controls
|
||||
depends = skills, arena_lib, controls, panel_lib
|
||||
description = To write.
|
||||
author = giov4
|
||||
|
59
score.lua
Normal file
59
score.lua
Normal file
@ -0,0 +1,59 @@
|
||||
local function assign_tier() end
|
||||
local function update_tiers_hud() end
|
||||
|
||||
|
||||
|
||||
function fbrawl.update_score(arena)
|
||||
local scores = {}
|
||||
|
||||
for pl_name, props in pairs(arena.players) do
|
||||
local score = props.kills - (props.deaths / 2)
|
||||
table.insert(scores, {pl_name = pl_name, score = score})
|
||||
end
|
||||
|
||||
table.sort(scores, function (a, b)
|
||||
return a.score >= b.score
|
||||
end)
|
||||
|
||||
arena.scores = scores
|
||||
end
|
||||
|
||||
|
||||
|
||||
function fbrawl.update_score_hud(pl_name)
|
||||
local arena = arena_lib.get_arena_by_player(pl_name)
|
||||
update_tiers_hud(pl_name)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function update_tiers_hud( pl_name)
|
||||
local arena = arena_lib.get_arena_by_player(pl_name)
|
||||
|
||||
for i, props in pairs(arena.scores) do
|
||||
local classified_pl_name = props.pl_name
|
||||
|
||||
if i == 1 then
|
||||
assign_tier("golden", pl_name, classified_pl_name)
|
||||
elseif i == 2 then
|
||||
assign_tier("iron", pl_name, classified_pl_name)
|
||||
elseif i == 3 then
|
||||
assign_tier("bronze", pl_name, classified_pl_name)
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function assign_tier(tier, pl_name, classified_pl_name)
|
||||
local panel = panel_lib.get_panel(pl_name, "fbrawl:podium")
|
||||
local arena = arena_lib.get_arena_by_player(pl_name)
|
||||
|
||||
panel:update(nil, {
|
||||
[tier.."_pl_name"] = {text=classified_pl_name},
|
||||
[tier.."_deaths_value"] = {text=arena.players[classified_pl_name].deaths},
|
||||
[tier.."_kills_value"] = {text=arena.players[classified_pl_name].kills},
|
||||
}, nil)
|
||||
end
|
BIN
textures/celebration_preview.png
Normal file
BIN
textures/celebration_preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
textures/fbrawl_bronze_crown.png
Normal file
BIN
textures/fbrawl_bronze_crown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 341 B |
BIN
textures/fbrawl_golden_crown.png
Normal file
BIN
textures/fbrawl_golden_crown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 310 B |
BIN
textures/fbrawl_hud_deaths_score.png
Normal file
BIN
textures/fbrawl_hud_deaths_score.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 353 B |
BIN
textures/fbrawl_hud_kills_score.png
Normal file
BIN
textures/fbrawl_hud_kills_score.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 336 B |
BIN
textures/fbrawl_iron_crown.png
Normal file
BIN
textures/fbrawl_iron_crown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 310 B |
18
utils.lua
18
utils.lua
@ -237,24 +237,6 @@ end
|
||||
|
||||
|
||||
|
||||
function fbrawl.define_winner(arena)
|
||||
if arena.in_celebration then return end
|
||||
|
||||
local best_pl = T("Nobody")
|
||||
local best_kills = 0
|
||||
|
||||
for pl_name, props in pairs(arena.players) do
|
||||
if props.kills > best_kills then
|
||||
best_pl = pl_name
|
||||
best_kills = props.kills
|
||||
end
|
||||
end
|
||||
|
||||
arena_lib.load_celebration("fantasy_brawl", arena, best_pl)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function fbrawl.can_cast_ultimate(pl_name)
|
||||
local arena = arena_lib.get_arena_by_player(pl_name)
|
||||
return arena.players[pl_name].ultimate_recharge >= fbrawl.min_kills_to_use_ultimate
|
||||
|
Loading…
x
Reference in New Issue
Block a user