Removing skills when match ends

This commit is contained in:
Giov4 2022-11-01 16:14:53 +01:00
parent 68b88c715c
commit 57ad79ac20
4 changed files with 46 additions and 66 deletions

View File

@ -20,4 +20,8 @@ function fbrawl.out_of_match_operations(pl_name)
arena_lib.HUD_hide("broadcast", pl_name) arena_lib.HUD_hide("broadcast", pl_name)
arena_lib.HUD_hide("hotbar", pl_name) arena_lib.HUD_hide("hotbar", pl_name)
for skill_name, def in pairs(skillz.get_registered_skills("fbrawl")) do
pl_name:remove_skill(skill_name)
end
end end

View File

@ -71,7 +71,7 @@ function append_slot_texture_and_change_pointer(arena, skill, pl_name, slots, i,
local pointer_hud = fbrawl.get_hud(pl_name, "status_pointer") local pointer_hud = fbrawl.get_hud(pl_name, "status_pointer")
local pointer_hud_table = player:hud_get(pointer_hud) local pointer_hud_table = player:hud_get(pointer_hud)
local slot_color
local remaining_recharge_seconds = 0 local remaining_recharge_seconds = 0
local wielded_idx = player:get_wield_index() local wielded_idx = player:get_wield_index()
@ -91,46 +91,32 @@ function append_slot_texture_and_change_pointer(arena, skill, pl_name, slots, i,
end end
end end
-- appends a yellow or red slot to slots and change the pointer HUD
-- yellow
if remaining_recharge_seconds > 0 and remaining_recharge_seconds <= max_yellow_recharge_seconds then if remaining_recharge_seconds > 0 and remaining_recharge_seconds <= max_yellow_recharge_seconds then
if i == 1 then -- the item with the double skill slot_color = "yellow"
table.insert(slots, "fbrawl_slot_yellow_1_"..side..".png")
if not string.find(pointer_hud_table.text, "fbrawl_pointer_yellow_") then
player:hud_change(pointer_hud, "text", pointer_hud_table.text .."^fbrawl_pointer_yellow_"..side..".png")
end
if wielded_idx == 1 then
selected_slot_texture = selected_slot_texture.."^fbrawl_slot_yellow_"..side..".png"
end
else
if wielded_idx == i then
selected_slot_texture = selected_slot_texture.."^fbrawl_slot_yellow.png"
end
table.insert(slots, "fbrawl_slot_yellow_"..i..".png")
end
-- red
elseif remaining_recharge_seconds > max_yellow_recharge_seconds then elseif remaining_recharge_seconds > max_yellow_recharge_seconds then
if i == 1 then slot_color = "red"
table.insert(slots, "fbrawl_slot_red_1_"..side..".png") end
if not string.find(pointer_hud_table.text, "fbrawl_pointer_red_") then
player:hud_change(pointer_hud, "text", pointer_hud_table.text .."^fbrawl_pointer_red_"..side..".png") -- appends a yellow or red slot to slots and change the pointer HUD
end if i == 1 and slot_color then -- the item with the double skill
table.insert(slots, "fbrawl_slot_"..slot_color.."_1_"..side..".png")
if wielded_idx == 1 then
selected_slot_texture = selected_slot_texture.."^fbrawl_slot_red_"..side..".png" if not string.find(pointer_hud_table.text, "fbrawl_pointer_"..slot_color) then
end player:hud_change(pointer_hud, "text", pointer_hud_table.text .."^fbrawl_pointer_"..slot_color.."_"..side..".png")
else
if wielded_idx == i then
selected_slot_texture = selected_slot_texture.."^fbrawl_slot_red.png"
end
table.insert(slots, "fbrawl_slot_red_"..i..".png")
end end
if wielded_idx == 1 then
selected_slot_texture = selected_slot_texture.."^fbrawl_slot_"..slot_color.."_"..side..".png"
end
elseif slot_color then
if wielded_idx == i then
selected_slot_texture = selected_slot_texture.."^fbrawl_slot_"..slot_color..".png"
end
table.insert(slots, "fbrawl_slot_"..slot_color.."_"..i..".png")
end end
-- remove the left/right hud when the recharge is over -- remove the left/right hud when the recharge is over
if (i == 1 and remaining_recharge_seconds == 0) then if i == 1 and remaining_recharge_seconds == 0 then
local texture = pointer_hud_table.text local texture = pointer_hud_table.text
texture = texture:gsub("%^fbrawl_pointer_red_"..side..".png", "") texture = texture:gsub("%^fbrawl_pointer_red_"..side..".png", "")
texture = texture:gsub("%^fbrawl_pointer_yellow_"..side..".png", "") texture = texture:gsub("%^fbrawl_pointer_yellow_"..side..".png", "")

View File

@ -64,7 +64,8 @@ skillz.register_skill("fbrawl:smash", {
}, },
data = { data = {
hit_players = {}, hit_players = {},
started = false started = false,
fall_damage = false
}, },
loop_params = { loop_params = {
cast_rate = 0 cast_rate = 0
@ -223,4 +224,22 @@ end
minetest.register_entity("fantasy_brawl:seismic_wave", seismic_wave) minetest.register_entity("fantasy_brawl:seismic_wave", seismic_wave)
minetest.register_on_player_hpchange(function(player, hp_change, reason)
local pl_name = player:get_player_name()
local smash = pl_name:get_skill("fbrawl:smash")
-- Smash
if
reason.type == "fall"
and smash
and not smash.data.fall_damage
then
return 0
end
return hp_change
end, true)

View File

@ -21,32 +21,3 @@ dofile(minetest.get_modpath("fantasy_brawl") .. "/_classes/warrior/skills/sword.
dofile(minetest.get_modpath("fantasy_brawl") .. "/_classes/warrior/skills/warrior_jump.lua") dofile(minetest.get_modpath("fantasy_brawl") .. "/_classes/warrior/skills/warrior_jump.lua")
dofile(minetest.get_modpath("fantasy_brawl") .. "/_classes/warrior/skills/iron_skin.lua") dofile(minetest.get_modpath("fantasy_brawl") .. "/_classes/warrior/skills/iron_skin.lua")
dofile(minetest.get_modpath("fantasy_brawl") .. "/_classes/warrior/skills/hero_fury.lua") dofile(minetest.get_modpath("fantasy_brawl") .. "/_classes/warrior/skills/hero_fury.lua")
-- Preventing fall damage if smash or hero_fury is active
minetest.register_on_player_hpchange(function(player, hp_change, reason)
local pl_name = player:get_player_name()
local hero_fury = pl_name:get_skill("fbrawl:hero_fury")
local smash = pl_name:get_skill("fbrawl:smash")
-- Hero fury
if
reason.type == "fall"
and hero_fury
and hero_fury.is_active
then
return 0
end
-- Smash
if
reason.type == "fall"
and smash
and not smash.data.fall_damage
then
return 0
end
return hp_change
end, true)