Improve armor, fixes

master
BlockMen 2014-05-18 00:25:45 +02:00
parent e9b66fb119
commit dfa0d5c45f
4 changed files with 10 additions and 9 deletions

View File

@ -40,7 +40,7 @@ default.armor_update = function(player, heal, list, old_hp)
local stack = armor_inv:get_stack("armor_"..v, 1)
if stack:get_count() > 0 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 item = stack:get_name()
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.event_handler(player, "armor_changed")
end
default.armor_update_visual(player)
if heal and heal_max > math.random(100) and player:get_hp() > 0 then
--player:set_hp(old_hp)
if heal and heal_max > math.random(80) and player:get_hp() > 0 then
return true
end
end

View File

@ -167,6 +167,7 @@ local function update_hud(player, item)
local arm = tonumber(default.hud.armor[name])
if not arm then arm = 0 end
if item == "armor" and arm_out ~= arm then
default.armor_update_visual(player)
default.hud.armor_out[name] = arm
player:hud_change(armor_hud[name], "number", arm)
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
local air = player:get_breath()
default.hud.air[name] = air
minetest.after(0.5, function()
minetest.after(0.1, function()
hide_builtin(player)
custom_hud(player)
if HUD_ENABLE_HUNGER then default.hud.set_hunger(player) end

View File

@ -236,6 +236,8 @@ minetest.register_on_joinplayer(function(player)
else
default.set_player_inventory(player)
end
-- sometimes the model get not applied correct, so do it again
minetest.after(0, default.player_set_model, player, "character.x")
end)
-- Localize for better performance.

View File

@ -402,7 +402,7 @@ minetest.register_tool("default:armor_helmet_wood", {
minetest.register_tool("default:armor_helmet_steel", {
description = "Steel Helmet",
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,
})
@ -432,7 +432,7 @@ minetest.register_tool("default:armor_chestplate_wood", {
minetest.register_tool("default:armor_chestplate_steel", {
description = "Steel Chestplate",
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,
})
@ -462,7 +462,7 @@ minetest.register_tool("default:armor_leggings_wood", {
minetest.register_tool("default:armor_leggings_steel", {
description = "Steel Leggings",
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,
})
@ -492,7 +492,7 @@ minetest.register_tool("default:armor_boots_wood", {
minetest.register_tool("default:armor_boots_steel", {
description = "Steel Boots",
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,
})