mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-17 07:50:29 +01:00
Full health restoration for the dog.
This commit is contained in:
parent
600eb6187f
commit
011ad09890
|
@ -39,12 +39,20 @@ mobs:register_mob("mobs:dog", {
|
||||||
local item = clicker:get_wielded_item()
|
local item = clicker:get_wielded_item()
|
||||||
if item:get_name() == "mobs:meat_raw" then
|
if item:get_name() == "mobs:meat_raw" then
|
||||||
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
|
||||||
|
if hp >= self.hp_max then
|
||||||
|
minetest.chat_send_player(name, "Dog 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
|
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)
|
|
||||||
else
|
else
|
||||||
if self.owner == "" then
|
if self.owner == "" then
|
||||||
self.owner = clicker:get_player_name()
|
self.owner = clicker:get_player_name()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user