1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-24 17:50:37 +01:00

fixed npc follow|stop if tamed, consume not diamond

mobs follow but rest at distance
comment code
This commit is contained in:
crabman77 2015-07-14 20:27:36 +02:00
parent bbc295355c
commit c366a481ea
2 changed files with 21 additions and 18 deletions

View File

@ -467,7 +467,7 @@ function mobs:register_mob(name, def)
end
end
if self.type == "npc" and self.order == "follow" and self.owner and self.owner ~= "" and self.state ~= "attack" then
if self.type == "npc" and self.order == "follow" and self.owner and self.owner ~= "" and self.state ~= "attack" then --/MFF (Crabman|07/14/2015) follow diamond if has not owner
-- npc stop following player if not owner
if self.following and self.owner and self.owner ~= self.following:get_player_name() then
self.following = nil
@ -503,7 +503,7 @@ function mobs:register_mob(name, def)
self.object:setyaw(yaw)
-- anyone but standing npc's can move along
if dist > 2 and self.order ~= "stand" then
if dist > 4 and self.order ~= "stand" then --/MFF (Crabman|07/14/2015) follow but at distance
if (self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0)
or (self.object:getvelocity().y == 0 and self.jump_chance > 0) then
self.direction = {x = math.sin(yaw)*-1, y = -20, z = math.cos(yaw)}

View File

@ -97,23 +97,17 @@ mobs:register_mob("mobs:npc", {
local pos = self.object:getpos()
pos.y = pos.y + 0.5
minetest.add_item(pos, {name = mobs.npc_drops[math.random(1,#mobs.npc_drops)]})
elseif item:get_name() == "default:diamond" then
self.diamond_count = (self.diamond_count or 0) + 1
if not minetest.setting_getbool("creative_mode") then
item:take_item()
clicker:set_wielded_item(item)
end
if self.diamond_count < 4 then return end
-- if owner switch between follow and stand
if self.owner and self.owner == clicker:get_player_name() then
self.damages = 3
if self.order == "follow" then
self.order = "stand"
else
self.order = "follow"
elseif item:get_name() == "default:diamond" then --/MFF (Crabman|07/14/2015) tamed with diamond
if (self.diamond_count or 0) < 4 then
self.diamond_count = (self.diamond_count or 0) + 1
if not minetest.setting_getbool("creative_mode") then
item:take_item()
clicker:set_wielded_item(item)
end
if self.diamond_count >= 4 then
self.damages = 3
self.owner = clicker:get_player_name()
end
else
self.owner = clicker:get_player_name()
end
-- pick up npc
elseif item:get_name() == "mobs:magic_lasso"
@ -135,6 +129,15 @@ mobs:register_mob("mobs:npc", {
elseif self.owner ~= name then
minetest.chat_send_player(name, "Not owner!")
end
else --/MFF (Crabman|07/14/2015) follow|stop
-- if owner switch between follow and stand
if self.owner and self.owner == clicker:get_player_name() then
if self.order == "follow" then
self.order = "stand"
else
self.order = "follow"
end
end
end
end,
})