Tweak feeding, breeding, taming capturing and protecting
parent
e3f206dba1
commit
efb07ffd57
|
@ -113,6 +113,7 @@ mobs_mc.items = {
|
|||
pufferfish_raw = "fishing:pike_raw",
|
||||
bone = "bonemeal:bone",
|
||||
slimeball = "mesecons_materials:glue",
|
||||
cookie = "farming:cookie",
|
||||
|
||||
-- TODO: Add actual ender pearl
|
||||
ender_pearl = "farorb:farorb",
|
||||
|
@ -148,6 +149,7 @@ mobs_mc.follow = {
|
|||
sheep = { mobs_mc.items.wheat },
|
||||
cow = { mobs_mc.items.wheat },
|
||||
chicken = { "farming:seed_wheat", "farming:seed_cotton" },
|
||||
parrot = { "farming:seed_wheat", "farming:seed_cotton" },
|
||||
horse = { mobs_mc.items.apple, mobs_mc.items.sugar, mobs_mc.items.wheat, mobs_mc.items.hay_bale, mobs_mc.items.golden_apple, mobs_mc.items.golden_carrot }, -- TODO
|
||||
pig = { mobs_mc.items.potato, mobs_mc.items.carrot, mobs_mc.items.carrot_on_a_stick,
|
||||
mobs_mc.items.apple, -- Minetest Game extra
|
||||
|
|
|
@ -63,10 +63,9 @@ mobs:register_mob("mobs_mc:chicken", {
|
|||
fear_height = 4,
|
||||
|
||||
on_rightclick = function(self, clicker)
|
||||
|
||||
if mobs:feed_tame(self, clicker, 8, true, true) then return end
|
||||
if mobs:feed_tame(self, clicker, 1, true, true) then return end
|
||||
if mobs:protect(self, clicker) then return end
|
||||
if mobs:capture_mob(self, clicker, 30, 50, 80, false, nil) then return end
|
||||
if mobs:capture_mob(self, clicker, 0, 60, 5, false, nil) then return end
|
||||
end,
|
||||
|
||||
do_custom = function(self, dtime)
|
||||
|
|
|
@ -45,9 +45,13 @@ local cow_def = {
|
|||
},
|
||||
follow = mobs_mc.follow.cow,
|
||||
on_rightclick = function(self, clicker)
|
||||
if mobs:feed_tame(self, clicker, 1, true, true) then return end
|
||||
if mobs:protect(self, clicker) then return end
|
||||
|
||||
if self.child then
|
||||
return
|
||||
end
|
||||
|
||||
local item = clicker:get_wielded_item()
|
||||
if item:get_name() == mobs_mc.items.bucket and clicker:get_inventory() then
|
||||
local inv = clicker:get_inventory()
|
||||
|
@ -60,6 +64,7 @@ local cow_def = {
|
|||
pos.y = pos.y + 0.5
|
||||
minetest.add_item(pos, {name = mobs_mc.items.milk})
|
||||
end
|
||||
return
|
||||
end
|
||||
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
||||
end,
|
||||
|
@ -76,6 +81,9 @@ local mooshroom_def = table.copy(cow_def)
|
|||
mooshroom_def.mesh = "mobs_mc_mooshroom.b3d"
|
||||
mooshroom_def.textures = { {"mobs_mc_mooshroom.png"}, }
|
||||
mooshroom_def.on_rightclick = function(self, clicker)
|
||||
if mobs:feed_tame(self, clicker, 1, true, true) then return end
|
||||
if mobs:protect(self, clicker) then return end
|
||||
|
||||
if self.child then
|
||||
return
|
||||
end
|
||||
|
|
|
@ -33,9 +33,6 @@ mobs:register_mob("mobs_mc:endermite", {
|
|||
fear_height = 4,
|
||||
view_range = 16,
|
||||
damage = 2,
|
||||
on_rightclick = function(self, clicker)
|
||||
mobs:capture_mob(self, clicker, 25, 80, 0, true, nil)
|
||||
end,
|
||||
blood_amount = 0,
|
||||
})
|
||||
|
||||
|
|
10
horse.lua
10
horse.lua
|
@ -158,10 +158,8 @@ local horse = {
|
|||
return
|
||||
end
|
||||
|
||||
-- feed, tame or heal horse
|
||||
if mobs:feed_tame(self, clicker, 1, true, true) then
|
||||
return
|
||||
end
|
||||
if mobs:feed_tame(self, clicker, 1, true, true) then return end
|
||||
if mobs:protect(self, clicker) then return end
|
||||
|
||||
-- Make sure tamed horse is mature and being clicked by owner only
|
||||
if self.tamed and not self.child and self.owner == clicker:get_player_name() then
|
||||
|
@ -234,9 +232,9 @@ local horse = {
|
|||
self.object:set_properties({stepheight = 1.1})
|
||||
mobs.attach(self, clicker)
|
||||
|
||||
-- Used to capture horse with magic lasso
|
||||
-- Used to capture horse
|
||||
elseif not self.driver and clicker:get_wielded_item():get_name() ~= "" then
|
||||
mobs:capture_mob(self, clicker, 0, 0, 80, false, nil)
|
||||
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
10
llama.lua
10
llama.lua
|
@ -103,10 +103,8 @@ mobs:register_mob("mobs_mc:llama", {
|
|||
return
|
||||
end
|
||||
|
||||
-- Feed, tame or heal llama
|
||||
if mobs:feed_tame(self, clicker, 1, true, true) then
|
||||
return
|
||||
end
|
||||
if mobs:feed_tame(self, clicker, 1, true, true) then return end
|
||||
if mobs:protect(self, clicker) then return end
|
||||
|
||||
-- Make sure tamed llama is mature and being clicked by owner only
|
||||
if self.tamed and not self.child and self.owner == clicker:get_player_name() then
|
||||
|
@ -125,9 +123,9 @@ mobs:register_mob("mobs_mc:llama", {
|
|||
mobs.attach(self, clicker)
|
||||
end
|
||||
|
||||
-- Used to capture llama with lasso
|
||||
-- Used to capture llama
|
||||
elseif not self.driver and clicker:get_wielded_item():get_name() ~= "" then
|
||||
mobs:capture_mob(self, clicker, 0, 0, 80, false, nil)
|
||||
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
21
ocelot.lua
21
ocelot.lua
|
@ -66,10 +66,8 @@ local ocelot = {
|
|||
attack_animals = true,
|
||||
specific_attack = { "mobs_mc:chicken" },
|
||||
on_rightclick = function(self, clicker)
|
||||
if self.child then
|
||||
return
|
||||
end
|
||||
-- Try to tame ocelot
|
||||
if self.child then return end
|
||||
-- Try to tame ocelot (mobs:feed_tame is intentionally NOT used)
|
||||
local item = clicker:get_wielded_item()
|
||||
if is_food(item:get_name()) then
|
||||
if not minetest.settings:get_bool("creative_mode") then
|
||||
|
@ -85,11 +83,10 @@ local ocelot = {
|
|||
ent.owner = clicker:get_player_name()
|
||||
ent.tamed = true
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if mobs:protect(self, clicker) then return end
|
||||
if mobs:capture_mob(self, clicker, 30, 50, 80, false, nil) then return end
|
||||
end,
|
||||
}
|
||||
|
||||
|
@ -106,12 +103,11 @@ cat.runaway = false
|
|||
-- Automatically teleport cat to owner
|
||||
cat.do_custom = mobs_mc.make_owner_teleport_function(12)
|
||||
cat.on_rightclick = function(self, clicker)
|
||||
if self.child then
|
||||
return
|
||||
end
|
||||
if mobs:feed_tame(self, clicker, 1, true, false) then
|
||||
return
|
||||
end
|
||||
if mobs:feed_tame(self, clicker, 1, true, false) then return end
|
||||
if mobs:capture_mob(self, clicker, 0, 60, 5, false, nil) then return end
|
||||
if mobs:protect(self, clicker) then return end
|
||||
|
||||
if self.child then return end
|
||||
|
||||
-- Toggle sitting order
|
||||
|
||||
|
@ -132,7 +128,6 @@ cat.on_rightclick = function(self, clicker)
|
|||
self.jump = false
|
||||
end
|
||||
|
||||
if mobs:protect(self, clicker) then return end
|
||||
end
|
||||
|
||||
mobs:register_mob("mobs_mc:cat", cat)
|
||||
|
|
21
parrot.lua
21
parrot.lua
|
@ -62,9 +62,26 @@ mobs:register_mob("mobs_mc:parrot", {
|
|||
fly_in = {"air"},
|
||||
fear_height = 4,
|
||||
view_range = 16,
|
||||
|
||||
follow = mobs_mc.follow.parrot,
|
||||
on_rightclick = function(self, clicker)
|
||||
mobs:capture_mob(self, clicker, 0, 50, 80, false, nil)
|
||||
if self._doomed then return end
|
||||
local item = clicker:get_wielded_item()
|
||||
-- Kill parrot if fed with cookie
|
||||
if item:get_name() == mobs_mc.items.cookie then
|
||||
self.health = 0
|
||||
-- Doomed to die
|
||||
self._doomed = true
|
||||
if not minetest.settings:get_bool("creative_mode") then
|
||||
item:take_item()
|
||||
clicker:set_wielded_item(item)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
-- Feed to tame, but not breed
|
||||
if mobs:feed_tame(self, clicker, 1, true, false) then return end
|
||||
if mobs:protect(self, clicker) then return end
|
||||
if mobs:capture_mob(self, clicker, 0, 50, 80, false, nil) then return end
|
||||
end,
|
||||
|
||||
})
|
||||
|
|
9
pig.lua
9
pig.lua
|
@ -95,10 +95,9 @@ mobs:register_mob("mobs_mc:pig", {
|
|||
local wielditem = clicker:get_wielded_item()
|
||||
-- Feed pig
|
||||
if wielditem:get_name() ~= mobs_mc.items.carrot_on_a_stick then
|
||||
if mobs:feed_tame(self, clicker, 1, true, true) then
|
||||
return
|
||||
end
|
||||
if mobs:feed_tame(self, clicker, 1, true, true) then return end
|
||||
end
|
||||
if mobs:protect(self, clicker) then return end
|
||||
|
||||
if self.child then
|
||||
return
|
||||
|
@ -162,9 +161,9 @@ mobs:register_mob("mobs_mc:pig", {
|
|||
end
|
||||
return
|
||||
|
||||
-- Capture pig with lasso
|
||||
-- Capture pig
|
||||
elseif not self.driver and clicker:get_wielded_item():get_name() ~= "" then
|
||||
mobs:capture_mob(self, clicker, 0, 0, 80, false, nil)
|
||||
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
11
rabbit.lua
11
rabbit.lua
|
@ -53,13 +53,10 @@ local rabbit = {
|
|||
replace_rate = 10,
|
||||
replace_what = mobs_mc.replace.rabbit,
|
||||
on_rightclick = function(self, clicker)
|
||||
|
||||
-- feed or tame
|
||||
if mobs:feed_tame(self, clicker, 4, true, true) then
|
||||
return
|
||||
end
|
||||
|
||||
mobs:capture_mob(self, clicker, 30, 50, 80, false, nil)
|
||||
-- Feed, tame protect or capture
|
||||
if mobs:feed_tame(self, clicker, 1, true, true) then return end
|
||||
if mobs:protect(self, clicker) then return end
|
||||
if mobs:capture_mob(self, clicker, 0, 50, 80, false, nil) then return end
|
||||
end,
|
||||
do_custom = function(self)
|
||||
-- Easter egg: Change texture if rabbit is named “Toast”
|
||||
|
|
31
sheep.lua
31
sheep.lua
|
@ -137,30 +137,10 @@ mobs:register_mob("mobs_mc:sheep", {
|
|||
|
||||
on_rightclick = function(self, clicker)
|
||||
local item = clicker:get_wielded_item()
|
||||
if item:get_name() == mobs_mc.items.wheat then
|
||||
if not self.tamed then
|
||||
if not minetest.settings:get_bool("creative_mode") then
|
||||
item:take_item()
|
||||
clicker:set_wielded_item(item)
|
||||
end
|
||||
self.tamed = true
|
||||
elseif self.gotten then
|
||||
if not minetest.settings:get_bool("creative_mode") then
|
||||
item:take_item()
|
||||
clicker:set_wielded_item(item)
|
||||
end
|
||||
self.food = (self.food or 0) + 1
|
||||
if self.food >= 4 then
|
||||
self.food = 0
|
||||
self.gotten = false
|
||||
self.base_texture = colors[self.color][2]
|
||||
self.object:set_properties({
|
||||
textures = self.base_texture, --was sheep.png
|
||||
})
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if mobs:feed_tame(self, clicker, 1, true, true) then return end
|
||||
if mobs:protect(self, clicker) then return end
|
||||
|
||||
if item:get_name() == mobs_mc.items.shears and not self.gotten then
|
||||
self.gotten = true
|
||||
local pos = self.object:getpos()
|
||||
|
@ -187,6 +167,7 @@ mobs:register_mob("mobs_mc:sheep", {
|
|||
min = 1,
|
||||
max = 2,},
|
||||
}
|
||||
return
|
||||
end
|
||||
-- Dye sheep
|
||||
if minetest.get_item_group(item:get_name(), "dye") == 1 and not self.gotten then
|
||||
|
@ -211,7 +192,9 @@ mobs:register_mob("mobs_mc:sheep", {
|
|||
break
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
if mobs:capture_mob(self, clicker, 0, 5, 70, false, nil) then return end
|
||||
end,
|
||||
})
|
||||
mobs:register_spawn("mobs_mc:sheep", mobs_mc.spawn.grassland, minetest.LIGHT_MAX+1, 0, 15000, 3, 31000)
|
||||
|
|
22
wolf.lua
22
wolf.lua
|
@ -9,11 +9,19 @@ local default_walk_chance = 50
|
|||
local pr = PseudoRandom(os.time()*10)
|
||||
|
||||
local is_flesh = function(itemstring)
|
||||
-- Minecraft items
|
||||
return (itemstring == mobs_mc.items.rabbit_raw or
|
||||
itemstring == mobs_mc.items.rabbit_cooked or
|
||||
itemstring == mobs_mc.items.mutton_raw or
|
||||
itemstring == mobs_mc.items.mutton_cooked or
|
||||
itemstring == mobs_mc.items.beef_raw or
|
||||
itemstring == mobs_mc.items.beef_cooked or
|
||||
itemstring == mobs_mc.items.chicken_raw or
|
||||
itemstring == mobs_mc.items.rotten_flesh)
|
||||
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
|
||||
|
||||
-- Wolf
|
||||
|
@ -50,10 +58,9 @@ local wolf = {
|
|||
lava_damage = 4,
|
||||
light_damage = 0,
|
||||
on_rightclick = function(self, clicker)
|
||||
-- Try to tame wolf
|
||||
-- Try to tame wolf (intentionally does NOT use mobs:feed_tame)
|
||||
local tool = clicker:get_wielded_item()
|
||||
local dog
|
||||
local ent
|
||||
local dog, ent
|
||||
if is_flesh(tool:get_name()) then
|
||||
if not minetest.settings:get_bool("creative_mode") then
|
||||
tool:take_item()
|
||||
|
@ -128,7 +135,12 @@ dog.owner_loyal = true
|
|||
dog.do_custom = mobs_mc.make_owner_teleport_function(12)
|
||||
dog.on_rightclick = function(self, clicker)
|
||||
local item = clicker:get_wielded_item()
|
||||
if is_flesh(item:get_name()) then
|
||||
|
||||
if mobs:protect(self, clicker) then
|
||||
return
|
||||
elseif item:get_name() ~= "" and mobs:capture_mob(self, clicker, 0, 2, 80, false, nil) then
|
||||
return
|
||||
elseif is_flesh(item:get_name()) then
|
||||
-- Feed
|
||||
local hp = self.object:get_hp()
|
||||
if hp + 4 > self.hp_max then return end
|
||||
|
|
Loading…
Reference in New Issue