Implement proper dog feeding
This commit is contained in:
parent
dc68f0eee8
commit
6672c1d761
@ -160,6 +160,11 @@ mobs_mc.follow = {
|
|||||||
ocelot = { mobs_mc.items.fish_raw, mobs_mc.items.salmon_raw, mobs_mc.items.clownfish_raw, mobs_mc.items.pufferfish_raw,
|
ocelot = { mobs_mc.items.fish_raw, mobs_mc.items.salmon_raw, mobs_mc.items.clownfish_raw, mobs_mc.items.pufferfish_raw,
|
||||||
mobs_mc.items.chicken_raw, -- Minetest Game extra
|
mobs_mc.items.chicken_raw, -- Minetest Game extra
|
||||||
},
|
},
|
||||||
|
wolf = { mobs_mc.items.bone },
|
||||||
|
dog = { mobs_mc.items.rabbit_raw, mobs_mc.items.rabbit_cooked, mobs_mc.items.mutton_raw, mobs_mc.items.mutton_cooked, mobs_mc.items.beef_raw, mobs_mc.items.beef_cooked, mobs_mc.items.chicken_raw, mobs_mc.items.chicken_cooked, mobs_mc.items.rotten_flesh,
|
||||||
|
-- Mobs Redo items
|
||||||
|
"mobs:meat", "mobs:meat_raw" },
|
||||||
|
e
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Contents for replace_what
|
-- Contents for replace_what
|
||||||
|
@ -24,6 +24,7 @@ local is_food = function(itemstring)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Ocelot
|
-- Ocelot
|
||||||
|
49
wolf.lua
49
wolf.lua
@ -8,20 +8,15 @@ local default_walk_chance = 50
|
|||||||
|
|
||||||
local pr = PseudoRandom(os.time()*10)
|
local pr = PseudoRandom(os.time()*10)
|
||||||
|
|
||||||
local is_flesh = function(itemstring)
|
local is_food = function(itemstring)
|
||||||
-- Minecraft items
|
for f=1, #mobs_mc.follow.dog do
|
||||||
return (itemstring == mobs_mc.items.rabbit_raw or
|
if itemstring == mobs_mc.follow.dog[f] then
|
||||||
itemstring == mobs_mc.items.rabbit_cooked or
|
return true
|
||||||
itemstring == mobs_mc.items.mutton_raw or
|
elseif string.sub(itemstring, 1, 6) == "group:" and minetest.get_item_group(itemstring, string.sub(itemstring, 7, -1)) ~= 0 then
|
||||||
itemstring == mobs_mc.items.mutton_cooked or
|
return true
|
||||||
itemstring == mobs_mc.items.beef_raw or
|
end
|
||||||
itemstring == mobs_mc.items.beef_cooked or
|
end
|
||||||
itemstring == mobs_mc.items.chicken_raw or
|
return false
|
||||||
itemstring == mobs_mc.items.chicken_cooked or
|
|
||||||
itemstring == mobs_mc.items.rotten_flesh or
|
|
||||||
-- Mobs Redo items
|
|
||||||
itemstring == "mobs:meat" or
|
|
||||||
itemstring == "mobs:meat_raw")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Wolf
|
-- Wolf
|
||||||
@ -57,7 +52,7 @@ local wolf = {
|
|||||||
water_damage = 0,
|
water_damage = 0,
|
||||||
lava_damage = 4,
|
lava_damage = 4,
|
||||||
light_damage = 0,
|
light_damage = 0,
|
||||||
follow = mobs_mc.items.bone,
|
follow = mobs_mc.follow.wolf,
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
-- Try to tame wolf (intentionally does NOT use mobs:feed_tame)
|
-- Try to tame wolf (intentionally does NOT use mobs:feed_tame)
|
||||||
local tool = clicker:get_wielded_item()
|
local tool = clicker:get_wielded_item()
|
||||||
@ -136,6 +131,7 @@ dog.order = "roam"
|
|||||||
dog.owner_loyal = true
|
dog.owner_loyal = true
|
||||||
-- Automatically teleport dog to owner
|
-- Automatically teleport dog to owner
|
||||||
dog.do_custom = mobs_mc.make_owner_teleport_function(12)
|
dog.do_custom = mobs_mc.make_owner_teleport_function(12)
|
||||||
|
dog.follow = mobs_mc.follow.dog
|
||||||
dog.on_rightclick = function(self, clicker)
|
dog.on_rightclick = function(self, clicker)
|
||||||
local item = clicker:get_wielded_item()
|
local item = clicker:get_wielded_item()
|
||||||
|
|
||||||
@ -143,15 +139,28 @@ dog.on_rightclick = function(self, clicker)
|
|||||||
return
|
return
|
||||||
elseif item:get_name() ~= "" and mobs:capture_mob(self, clicker, 0, 2, 80, false, nil) then
|
elseif item:get_name() ~= "" and mobs:capture_mob(self, clicker, 0, 2, 80, false, nil) then
|
||||||
return
|
return
|
||||||
elseif is_flesh(item:get_name()) then
|
elseif is_food(item:get_name()) then
|
||||||
-- Feed
|
-- Feed to increase health
|
||||||
local hp = self.object:get_hp()
|
local hp = self.health
|
||||||
if hp + 4 > self.hp_max then return end
|
local hp_add = 0
|
||||||
|
-- Use eatable group to determine health boost
|
||||||
|
local eatable = minetest.get_item_group(item, "eatable")
|
||||||
|
if eatable > 0 then
|
||||||
|
hp_add = eatable
|
||||||
|
elseif item:get_name() == mobs_mc.items.rotten_flesh then
|
||||||
|
hp_add = 4
|
||||||
|
else
|
||||||
|
hp_add = 4
|
||||||
|
end
|
||||||
|
local new_hp = hp + hp_add
|
||||||
|
if new_hp > self.hp_max then
|
||||||
|
new_hp = self.hp_max
|
||||||
|
end
|
||||||
if not minetest.settings:get_bool("creative_mode") then
|
if not minetest.settings:get_bool("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)
|
self.health = new_hp
|
||||||
return
|
return
|
||||||
elseif minetest.get_item_group(item:get_name(), "dye") == 1 then
|
elseif minetest.get_item_group(item:get_name(), "dye") == 1 then
|
||||||
-- Dye (if possible)
|
-- Dye (if possible)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user