From 1ac019d9a104fe6ae8a5c03d8d14b969143abb00 Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Mon, 24 Jul 2023 00:01:43 -0400 Subject: [PATCH] mods - hbhunger - donot hardcoded max hp value when eating and healting * Related to https://codeberg.org/Wuzzy/minetest_hbhunger/issues/1 * the code has a hardcoded hp > 20 then hp = 20 at hunger.lua line 39 that do not respect the hp_max real value * also do not give inmediate life, eating something gives you healt-satiation so then your character wil have enought conditions to recovery healt --- mods/hbhunger/hunger.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mods/hbhunger/hunger.lua b/mods/hbhunger/hunger.lua index 2e0f49e..ed6f229 100644 --- a/mods/hbhunger/hunger.lua +++ b/mods/hbhunger/hunger.lua @@ -105,10 +105,17 @@ function hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal, sound hbhunger.hunger[name] = h hbhunger.set_hunger_raw(user) end + -- we must respect the real maximun hp of the player already set + max_hp = user:get_properties().hp_max -- Healing - if hp < 20 and heal then - hp = hp + heal - if hp > 20 then hp = 20 end + if hp < max_hp then + -- heal is not defines due way of hbhunger.register_food + if not heal then heal = 1 end + -- eating something not give you inmediate life, give you statiation to get recovery + if hp < 3 and heal > 0 then hp = hp + heal end + -- so do not hardcoded hp to 20 when eating + if hp > max_hp then hp = max_hp end + -- this will work only when valid then user:set_hp(hp) end -- Poison