Display sword cooldown along with other weapons
This commit is contained in:
parent
1dd27fdc02
commit
95cdf958ee
@ -9,7 +9,7 @@ function block_league.bullets_hud_create(p_name)
|
||||
local inv = minetest.get_player_by_name(p_name):get_inventory()
|
||||
local sub_img_elems = {}
|
||||
local sub_txt_elems = {}
|
||||
local offset_x = -90 -- currently hardcoded for smg and pixelgun
|
||||
local offset_x = -90
|
||||
local offset_y = -125
|
||||
|
||||
for i = 1, 3 do
|
||||
@ -18,7 +18,7 @@ function block_league.bullets_hud_create(p_name)
|
||||
local item_name = stack:get_name()
|
||||
local weapon = minetest.registered_nodes[item_name]
|
||||
|
||||
if weapon ~= nil and weapon.magazine ~= nil then
|
||||
if weapon ~= nil then
|
||||
sub_img_elems[item_name .. "_icon"] = {
|
||||
scale = { x = 2, y = 2 },
|
||||
offset = { x = offset_x, y = offset_y },
|
||||
@ -37,10 +37,10 @@ function block_league.bullets_hud_create(p_name)
|
||||
sub_txt_elems[weapon.name .. "_magazine_txt"] = {
|
||||
alignment = { x = 0, y = 1 },
|
||||
offset = { x = offset_x + 30, y = offset_y + 6 },
|
||||
text = weapon.magazine and weapon.magazine or "-1",
|
||||
text = weapon.magazine and weapon.magazine or "",
|
||||
z_index = 1
|
||||
}
|
||||
offset_x = offset_x + 180 -- same as before
|
||||
offset_x = offset_x + 90
|
||||
end
|
||||
|
||||
end
|
||||
@ -77,20 +77,17 @@ end
|
||||
|
||||
|
||||
|
||||
function block_league.weapons_hud_update(arena, p_name, weapon_name, is_reloading)
|
||||
function block_league.weapons_hud_update(arena, p_name, w_name, is_reloading)
|
||||
|
||||
local weapon = minetest.registered_nodes[w_name]
|
||||
local current_magazine = not weapon.magazine and "" or arena.players[p_name].weapons_magazine[w_name]
|
||||
|
||||
local weapon = minetest.registered_nodes[weapon_name]
|
||||
local panel = panel_lib.get_panel(p_name, "bl_bullets")
|
||||
|
||||
local w_name = weapon.name
|
||||
local magazine = weapon.magazine
|
||||
local current_magazine = arena.players[p_name].weapons_magazine[w_name]
|
||||
|
||||
local bg_pic = ""
|
||||
|
||||
if is_reloading then
|
||||
bg_pic = "bl_hud_bullets_bg_reload.png"
|
||||
elseif current_magazine <= magazine/3 then
|
||||
elseif weapon.magazine and current_magazine <= weapon.magazine/3 then
|
||||
bg_pic = "bl_hud_bullets_bg_low.png"
|
||||
else
|
||||
bg_pic = "bl_hud_bullets_bg.png"
|
||||
|
@ -26,6 +26,7 @@ function block_league.refill_weapons(arena, p_name)
|
||||
arena.players[p_name].weapons_magazine[weapon_name] = magazine
|
||||
block_league.weapons_hud_update(arena, p_name, weapon_name)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -264,7 +264,7 @@ function block_league.apply_damage(user, targets, weapon, decrease_damage_with_d
|
||||
|
||||
local t_name = target:get_player_name()
|
||||
|
||||
-- se player e target sono nella stessa squadra, annullo
|
||||
-- se giocatore e target sono nella stessa squadra, annullo
|
||||
if arena_lib.is_player_in_same_team(arena, p_name, t_name) then return end
|
||||
|
||||
-- eventuale knockback
|
||||
@ -273,7 +273,7 @@ function block_league.apply_damage(user, targets, weapon, decrease_damage_with_d
|
||||
target:add_player_velocity(knk)
|
||||
end
|
||||
|
||||
if weapon.weapon_type == 1 and decrease_damage_with_distance then
|
||||
if weapon.weapon_type == 1 and decrease_damage_with_distance then
|
||||
local dist = get_dist(user:get_pos(), target:get_pos())
|
||||
local damage = damage - (damage * dist / weapon.weapon_range)
|
||||
remaining_HP = target:get_hp() - damage
|
||||
@ -507,15 +507,21 @@ function can_shoot(player, weapon)
|
||||
if p_meta:get_int("bl_weap_delay") == 1 or
|
||||
p_meta:get_int("bl_death_delay") == 1 or
|
||||
p_meta:get_int("bl_reloading") == 1 then
|
||||
return false end
|
||||
return end
|
||||
|
||||
p_meta:set_int("bl_weap_delay", 1)
|
||||
|
||||
-- per le armi bianche, aggiorno l'HUD qui che segnala che son state usate
|
||||
if not weapon.magazine then
|
||||
block_league.weapons_hud_update(arena, p_name, w_name, true)
|
||||
end
|
||||
|
||||
minetest.after(weapon.fire_delay, function()
|
||||
if not arena_lib.is_player_in_arena(p_name, "block_league") then return end
|
||||
if weapon.magazine and p_meta:get_int("bl_reloading") == 0 then
|
||||
p_meta:set_int("bl_weap_delay", 0)
|
||||
elseif not weapon.magazine then
|
||||
block_league.weapons_hud_update(arena, p_name, w_name)
|
||||
p_meta:set_int("bl_weap_delay", 0)
|
||||
end
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user