non-tamable mobs will not send tame param to feed_tame func,

changed event flow so it tries in order: heal, tame, breed, grow child
This commit is contained in:
SumianVoice 2022-07-19 14:05:04 +10:00 committed by cora
parent e5c1da4380
commit 9d52fed357
6 changed files with 25 additions and 26 deletions

View File

@ -4371,7 +4371,7 @@ function mcl_mobs:feed_tame(self, clicker, feed_count, breed, tame, notake)
-- increase health -- increase health
if self.health < self.hp_max then if not consume_food and self.health < self.hp_max then
consume_food = true consume_food = true
self.health = min(self.health + 4, self.hp_max) self.health = min(self.health + 4, self.hp_max)
@ -4381,41 +4381,40 @@ function mcl_mobs:feed_tame(self, clicker, feed_count, breed, tame, notake)
self.object:set_hp(self.health) self.object:set_hp(self.health)
end end
update_tag(self)
-- make children grow quicker
if self.child == true then
consume_food = true
-- deduct 10% of the time to adulthood
self.hornytimer = self.hornytimer + ((CHILD_GROW_TIME - self.hornytimer) * 0.1)
end
-- feed and tame -- feed and tame
self.food = (self.food or 0) + 1 self.food = (self.food or 0) + 1
if not self.child and self.food >= feed_count then if self.food >= feed_count then
self.food = 0 self.food = 0
if breed and self.hornytimer == 0 and not self.horny then
self.horny = true
consume_food = true
end
if tame then if tame then
self.tamed = true self.tamed = true
if not self.owner or self.owner == "" then if not self.owner or self.owner == "" then
self.owner = clicker:get_player_name() self.owner = clicker:get_player_name()
consume_food = true consume_food = true
end end
end end
if breed and not self.child and not consume_food
and self.hornytimer == 0 and not self.horny then
self.horny = true
consume_food = true
end
-- make sound when fed so many times -- make sound when fed so many times
mob_sound(self, "random", true) mob_sound(self, "random", true)
end end
update_tag(self)
-- make children grow quicker
if not consume_food and self.child == true then
consume_food = true
-- deduct 10% of the time to adulthood
self.hornytimer = self.hornytimer + ((CHILD_GROW_TIME - self.hornytimer) * 0.1)
end
-- if not in creative then take item if it was used -- if not in creative then take item if it was used
if not minetest.is_creative_enabled(clicker:get_player_name()) and consume_food then if not minetest.is_creative_enabled(clicker:get_player_name()) and consume_food then

View File

@ -74,7 +74,7 @@ mcl_mobs:register_mob("mobs_mc:chicken", {
fear_height = 4, fear_height = 4,
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end if mcl_mobs:feed_tame(self, clicker, 1, true, false) then return end
if mcl_mobs:protect(self, clicker) then return end if mcl_mobs:protect(self, clicker) then return end
if mcl_mobs:capture_mob(self, clicker, 0, 60, 5, false, nil) then return end if mcl_mobs:capture_mob(self, clicker, 0, 60, 5, false, nil) then return end
end, end,

View File

@ -48,7 +48,7 @@ local cow_def = {
run_end = 40, run_end = 40,
}, },
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end if mcl_mobs:feed_tame(self, clicker, 1, true, false) then return end
if mcl_mobs:protect(self, clicker) then return end if mcl_mobs:protect(self, clicker) then return end
if self.child then if self.child then
@ -87,7 +87,7 @@ mooshroom_def.spawn_in_group_min = 4
mooshroom_def.spawn_in_group = 8 mooshroom_def.spawn_in_group = 8
mooshroom_def.textures = { {"mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png"}, {"mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" } } mooshroom_def.textures = { {"mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png"}, {"mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" } }
mooshroom_def.on_rightclick = function(self, clicker) mooshroom_def.on_rightclick = function(self, clicker)
if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end if mcl_mobs:feed_tame(self, clicker, 1, true, false) then return end
if mcl_mobs:protect(self, clicker) then return end if mcl_mobs:protect(self, clicker) then return end
if self.child then if self.child then

View File

@ -99,7 +99,7 @@ mcl_mobs:register_mob("mobs_mc:pig", {
local wielditem = clicker:get_wielded_item() local wielditem = clicker:get_wielded_item()
-- Feed pig -- Feed pig
if wielditem:get_name() ~= "mcl_mobitems:carrot_on_a_stick" then if wielditem:get_name() ~= "mcl_mobitems:carrot_on_a_stick" then
if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end if mcl_mobs:feed_tame(self, clicker, 1, true, false) then return end
end end
if mcl_mobs:protect(self, clicker) then return end if mcl_mobs:protect(self, clicker) then return end

View File

@ -75,7 +75,7 @@ local rabbit = {
}, },
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
-- Feed, tame protect or capture -- Feed, tame protect or capture
if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end if mcl_mobs:feed_tame(self, clicker, 1, true, false) then return end
if mcl_mobs:protect(self, clicker) then return end if mcl_mobs:protect(self, clicker) then return end
if mcl_mobs:capture_mob(self, clicker, 0, 50, 80, false, nil) then return end if mcl_mobs:capture_mob(self, clicker, 0, 50, 80, false, nil) then return end
end, end,

View File

@ -195,7 +195,7 @@ mcl_mobs:register_mob("mobs_mc:sheep", {
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item() local item = clicker:get_wielded_item()
if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end if mcl_mobs:feed_tame(self, clicker, 1, true, false) then return end
if mcl_mobs:protect(self, clicker) then return end if mcl_mobs:protect(self, clicker) then return end
if item:get_name() == "mcl_tools:shears" and not self.gotten and not self.child then if item:get_name() == "mcl_tools:shears" and not self.gotten and not self.child then