Improve armor, fixes
parent
e9b66fb119
commit
dfa0d5c45f
|
@ -40,7 +40,7 @@ default.armor_update = function(player, heal, list, old_hp)
|
||||||
local stack = armor_inv:get_stack("armor_"..v, 1)
|
local stack = armor_inv:get_stack("armor_"..v, 1)
|
||||||
if stack:get_count() > 0 then
|
if stack:get_count() > 0 then
|
||||||
if heal and old_hp~=nil and now_hp < old_hp then
|
if heal and old_hp~=nil and now_hp < old_hp then
|
||||||
local use = stack:get_definition().groups["armor_use"] or 0
|
local use = stack:get_definition().groups["armor_use"] or 9--0
|
||||||
local heal_p = stack:get_definition().groups["armor_heal"] or 0
|
local heal_p = stack:get_definition().groups["armor_heal"] or 0
|
||||||
local item = stack:get_name()
|
local item = stack:get_name()
|
||||||
local damage_amount = (old_hp-now_hp)/2
|
local damage_amount = (old_hp-now_hp)/2
|
||||||
|
@ -73,9 +73,7 @@ default.armor_update = function(player, heal, list, old_hp)
|
||||||
default.hud.armor[name] = lvl*(items*5)
|
default.hud.armor[name] = lvl*(items*5)
|
||||||
default.hud.event_handler(player, "armor_changed")
|
default.hud.event_handler(player, "armor_changed")
|
||||||
end
|
end
|
||||||
default.armor_update_visual(player)
|
if heal and heal_max > math.random(80) and player:get_hp() > 0 then
|
||||||
if heal and heal_max > math.random(100) and player:get_hp() > 0 then
|
|
||||||
--player:set_hp(old_hp)
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -167,6 +167,7 @@ local function update_hud(player, item)
|
||||||
local arm = tonumber(default.hud.armor[name])
|
local arm = tonumber(default.hud.armor[name])
|
||||||
if not arm then arm = 0 end
|
if not arm then arm = 0 end
|
||||||
if item == "armor" and arm_out ~= arm then
|
if item == "armor" and arm_out ~= arm then
|
||||||
|
default.armor_update_visual(player)
|
||||||
default.hud.armor_out[name] = arm
|
default.hud.armor_out[name] = arm
|
||||||
player:hud_change(armor_hud[name], "number", arm)
|
player:hud_change(armor_hud[name], "number", arm)
|
||||||
if (default.player[name].armor["cnt"] == 0) and arm == 0 then
|
if (default.player[name].armor["cnt"] == 0) and arm == 0 then
|
||||||
|
@ -257,7 +258,7 @@ minetest.register_on_joinplayer(function(player)
|
||||||
default.hud.armor_out[name] = 0
|
default.hud.armor_out[name] = 0
|
||||||
local air = player:get_breath()
|
local air = player:get_breath()
|
||||||
default.hud.air[name] = air
|
default.hud.air[name] = air
|
||||||
minetest.after(0.5, function()
|
minetest.after(0.1, function()
|
||||||
hide_builtin(player)
|
hide_builtin(player)
|
||||||
custom_hud(player)
|
custom_hud(player)
|
||||||
if HUD_ENABLE_HUNGER then default.hud.set_hunger(player) end
|
if HUD_ENABLE_HUNGER then default.hud.set_hunger(player) end
|
||||||
|
|
|
@ -236,6 +236,8 @@ minetest.register_on_joinplayer(function(player)
|
||||||
else
|
else
|
||||||
default.set_player_inventory(player)
|
default.set_player_inventory(player)
|
||||||
end
|
end
|
||||||
|
-- sometimes the model get not applied correct, so do it again
|
||||||
|
minetest.after(0, default.player_set_model, player, "character.x")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Localize for better performance.
|
-- Localize for better performance.
|
||||||
|
|
|
@ -402,7 +402,7 @@ minetest.register_tool("default:armor_helmet_wood", {
|
||||||
minetest.register_tool("default:armor_helmet_steel", {
|
minetest.register_tool("default:armor_helmet_steel", {
|
||||||
description = "Steel Helmet",
|
description = "Steel Helmet",
|
||||||
inventory_image = "default_armor_inv_helmet_steel.png",
|
inventory_image = "default_armor_inv_helmet_steel.png",
|
||||||
groups = {armor_head=10, armor_heal=0, armor_use=500},
|
groups = {armor_head=10, armor_heal=2, armor_use=500},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ minetest.register_tool("default:armor_chestplate_wood", {
|
||||||
minetest.register_tool("default:armor_chestplate_steel", {
|
minetest.register_tool("default:armor_chestplate_steel", {
|
||||||
description = "Steel Chestplate",
|
description = "Steel Chestplate",
|
||||||
inventory_image = "default_armor_inv_chestplate_steel.png",
|
inventory_image = "default_armor_inv_chestplate_steel.png",
|
||||||
groups = {armor_torso=15, armor_heal=0, armor_use=500},
|
groups = {armor_torso=15, armor_heal=2, armor_use=500},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -462,7 +462,7 @@ minetest.register_tool("default:armor_leggings_wood", {
|
||||||
minetest.register_tool("default:armor_leggings_steel", {
|
minetest.register_tool("default:armor_leggings_steel", {
|
||||||
description = "Steel Leggings",
|
description = "Steel Leggings",
|
||||||
inventory_image = "default_armor_inv_leggings_steel.png",
|
inventory_image = "default_armor_inv_leggings_steel.png",
|
||||||
groups = {armor_legs=15, armor_heal=0, armor_use=500},
|
groups = {armor_legs=15, armor_heal=2, armor_use=500},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -492,7 +492,7 @@ minetest.register_tool("default:armor_boots_wood", {
|
||||||
minetest.register_tool("default:armor_boots_steel", {
|
minetest.register_tool("default:armor_boots_steel", {
|
||||||
description = "Steel Boots",
|
description = "Steel Boots",
|
||||||
inventory_image = "default_armor_inv_boots_steel.png",
|
inventory_image = "default_armor_inv_boots_steel.png",
|
||||||
groups = {armor_feet=10, armor_heal=0, armor_use=500},
|
groups = {armor_feet=10, armor_heal=2, armor_use=500},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue