1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-06-30 07:30:22 +02: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
-- feed and add health
local hp = self.object:get_hp()
if hp + 4 > self.hp_max then return end
self.object:set_hp(hp+4)
-- return if full health
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
if not minetest.setting_getbool("creative_mode") then
item:take_item()
clicker:set_wielded_item(item)
end
self.object:set_hp(hp + 4)
-- right clicking with gold lump drops random item from mobs.npc_drops
elseif item:get_name() == "default:gold_lump" then
if not minetest.setting_getbool("creative_mode") then