1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-16 07:20:31 +01:00

fix dog owner

fix meat_raw not consumed when give to wolf
dog is NPC not monster, monster attack players, NPC attack monster
This commit is contained in:
crabman77 2015-07-02 02:33:55 +02:00
parent eecb2d7efe
commit a81ee9d530
2 changed files with 13 additions and 20 deletions

View File

@ -3,7 +3,7 @@
mobs:register_mob("mobs:dog", { mobs:register_mob("mobs:dog", {
-- animal, monster, npc, barbarian -- animal, monster, npc, barbarian
type = "monster", type = "npc",
-- agressive, does 4 damage to player when hit -- agressive, does 4 damage to player when hit
passive = false, passive = false,
attacks_monsters = true, attacks_monsters = true,
@ -35,10 +35,8 @@ mobs:register_mob("mobs:dog", {
step = 1.2, step = 1.2,
view_range = 16, view_range = 16,
drops = { drops = {
{name = "mobs:meat_raw", {name = "mobs:meat_raw", chance = 1, min = 2, max = 3,},
chance = 1, },
min = 2,
max = 3,},
-- damaged by -- damaged by
water_damage = 1, water_damage = 1,
lava_damage = 5, lava_damage = 5,

View File

@ -53,24 +53,19 @@ mobs:register_mob("mobs:wolf", {
-- right clicking with "raw meat" 4 times will tame the wolf into a friendly dog -- right clicking with "raw meat" 4 times will tame the wolf into a friendly dog
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item() 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") 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 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
end
}) })
mobs:register_spawn("mobs:wolf", {"default:dirt_with_grass"}, 3, -1, 9500, 1, 31000) 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) mobs:register_egg("mobs:wolf", "Wolf", "mobs_wolf_inv.png", 1)