From a81ee9d530ebceb18c058000be845ae8aab36163 Mon Sep 17 00:00:00 2001 From: crabman77 Date: Thu, 2 Jul 2015 02:33:55 +0200 Subject: [PATCH] fix dog owner fix meat_raw not consumed when give to wolf dog is NPC not monster, monster attack players, NPC attack monster --- mods/mobs/dog.lua | 8 +++----- mods/mobs/wolf.lua | 25 ++++++++++--------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/mods/mobs/dog.lua b/mods/mobs/dog.lua index 3ef91142..a73b0c06 100755 --- a/mods/mobs/dog.lua +++ b/mods/mobs/dog.lua @@ -3,7 +3,7 @@ mobs:register_mob("mobs:dog", { -- animal, monster, npc, barbarian - type = "monster", + type = "npc", -- agressive, does 4 damage to player when hit passive = false, attacks_monsters = true, @@ -35,10 +35,8 @@ mobs:register_mob("mobs:dog", { step = 1.2, view_range = 16, drops = { - {name = "mobs:meat_raw", - chance = 1, - min = 2, - max = 3,}, + {name = "mobs:meat_raw", chance = 1, min = 2, max = 3,}, + }, -- damaged by water_damage = 1, lava_damage = 5, diff --git a/mods/mobs/wolf.lua b/mods/mobs/wolf.lua index 0fc17851..0d8f18d0 100755 --- a/mods/mobs/wolf.lua +++ b/mods/mobs/wolf.lua @@ -53,24 +53,19 @@ mobs:register_mob("mobs:wolf", { -- right clicking with "raw meat" 4 times will tame the wolf into a friendly dog on_rightclick = function(self, clicker) local item = clicker:get_wielded_item() - if item:get_name() == "mobs:meat_raw" and self.raw_meat_count == 4 then + if item:get_name() == "mobs:meat_raw" then clicker:get_inventory():remove_item("main", "mobs:meat_raw") - local ent = minetest.add_entity(self.object:getpos(), "mobs:dog") - self.object:remove() - local dog_obj = ent:get_luaentity() - if not dog_obj then return end - dog_obj.tamed = true - dog_obj.textures = {"mobs_dog.png"} - dog_obj.damage = 3 - dog_obj.walk_velocity = 4 - dog_obj.run_velocity = 4 - if dog_obj.owner == "" then - self.owner = clicker:get_player_name() - else return end - elseif item:get_name() == "mobs:meat_raw" and self.raw_meat_count ~= 4 then self.raw_meat_count = (self.raw_meat_count or 0) + 1 - else return end + if self.raw_meat_count > 4 then + local ent = minetest.add_entity(self.object:getpos(), "mobs:dog") + self.object:remove() + local dog_obj = ent:get_luaentity() + if not dog_obj then return end + dog_obj.tamed = true + dog_obj.owner = clicker:get_player_name() + end end + end }) mobs:register_spawn("mobs:wolf", {"default:dirt_with_grass"}, 3, -1, 9500, 1, 31000) mobs:register_egg("mobs:wolf", "Wolf", "mobs_wolf_inv.png", 1)