From dfa0d5c45f0b4e485a776f60efd7781bea348951 Mon Sep 17 00:00:00 2001 From: BlockMen Date: Sun, 18 May 2014 00:25:45 +0200 Subject: [PATCH] Improve armor, fixes --- mods/default/armor.lua | 6 ++---- mods/default/hud.lua | 3 ++- mods/default/player.lua | 2 ++ mods/default/tools.lua | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/mods/default/armor.lua b/mods/default/armor.lua index 82414fe..65ade08 100644 --- a/mods/default/armor.lua +++ b/mods/default/armor.lua @@ -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 diff --git a/mods/default/hud.lua b/mods/default/hud.lua index 526be04..0ad66a3 100644 --- a/mods/default/hud.lua +++ b/mods/default/hud.lua @@ -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 diff --git a/mods/default/player.lua b/mods/default/player.lua index cd5c32c..d3a97f2 100644 --- a/mods/default/player.lua +++ b/mods/default/player.lua @@ -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. diff --git a/mods/default/tools.lua b/mods/default/tools.lua index f1aba06..792f435 100644 --- a/mods/default/tools.lua +++ b/mods/default/tools.lua @@ -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, })