1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-18 16:20:38 +01:00

Full health restoration for the NPC.

This commit is contained in:
Le_Docteur 2015-06-21 11:43:48 +02:00
parent 6ad68b63c2
commit 600eb6187f

View File

@ -73,14 +73,21 @@ mobs:register_mob("mobs:npc", {
or item:get_name() == "farming:bread" then or item:get_name() == "farming:bread" then
-- feed and add health -- feed and add health
local hp = self.object:get_hp() local hp = self.object:get_hp()
if hp + 4 > self.hp_max then return end -- return if full health
self.object:set_hp(hp+4) if hp >= self.hp_max then
minetest.chat_send_player(name, "NPC at full health.")
return
end
hp = hp + 4 -- add restorative value
-- new health shouldn't exceed self.hp_max
if hp > self.hp_max then hp = self.hp_max end
self.object:set_hp(hp)
-- take item -- take item
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
item:take_item() item:take_item()
clicker:set_wielded_item(item) clicker:set_wielded_item(item)
end end
self.object:set_hp(hp + 4)
-- right clicking with gold lump drops random item from mobs.npc_drops -- right clicking with gold lump drops random item from mobs.npc_drops
elseif item:get_name() == "default:gold_lump" then elseif item:get_name() == "default:gold_lump" then
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then