Add armor hud. Correct armor handling in elixirs.
This commit is contained in:
parent
aa9c21bc93
commit
c8c107b300
3 changed files with 92 additions and 37 deletions
17
elixir.lua
17
elixir.lua
|
@ -12,22 +12,11 @@ fun_caves.register_status({
|
|||
player:set_armor_groups(armor)
|
||||
minetest.chat_send_player(player_name, minetest.colorize('#FF0000', 'Your skin feels softer...'))
|
||||
fun_caves.db.status[player_name].armor_elixir = nil
|
||||
fun_caves.display_armor(player)
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
|
||||
if fun_caves.db.status[player_name] and fun_caves.db.status[player_name].armor_elixir then
|
||||
local factor = fun_caves.db.status[player_name].armor_elixir.factor
|
||||
local armor = player:get_armor_groups()
|
||||
armor.fleshy = math.min(100, math.max(1, math.ceil(armor.fleshy * factor)))
|
||||
player:set_armor_groups(armor)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
if fun_caves.expire_elixir_on_death then
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
|
@ -37,6 +26,7 @@ if fun_caves.expire_elixir_on_death then
|
|||
armor.fleshy = math.min(100, math.max(1, math.ceil(armor.fleshy / factor)))
|
||||
player:set_armor_groups(armor)
|
||||
fun_caves.db.status[player_name].armor_elixir = nil
|
||||
fun_caves.display_armor(player)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
@ -48,13 +38,14 @@ local function armor(user, factor)
|
|||
|
||||
if fun_caves.db.status[player_name].armor_elixir then
|
||||
local old_factor = fun_caves.db.status[player_name].armor_elixir.factor
|
||||
armor.fleshy = math.min(100, math.max(1, math.ceil(armor.fleshy / factor)))
|
||||
armor.fleshy = math.min(100, math.max(1, math.ceil(armor.fleshy / old_factor)))
|
||||
end
|
||||
|
||||
armor.fleshy = math.min(100, math.max(1, math.ceil(armor.fleshy * factor)))
|
||||
user:set_armor_groups(armor)
|
||||
minetest.chat_send_player(player_name, 'Your skin feels harder...')
|
||||
fun_caves.set_status(player_name, 'armor_elixir', elixir_duration, {factor = factor})
|
||||
fun_caves.display_armor(user)
|
||||
end
|
||||
|
||||
local descs = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue