mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-25 02:00: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:
parent
bbc295355c
commit
c366a481ea
@ -467,7 +467,7 @@ function mobs:register_mob(name, def)
|
|||||||
end
|
end
|
||||||
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
|
-- npc stop following player if not owner
|
||||||
if self.following and self.owner and self.owner ~= self.following:get_player_name() then
|
if self.following and self.owner and self.owner ~= self.following:get_player_name() then
|
||||||
self.following = nil
|
self.following = nil
|
||||||
@ -503,7 +503,7 @@ function mobs:register_mob(name, def)
|
|||||||
self.object:setyaw(yaw)
|
self.object:setyaw(yaw)
|
||||||
|
|
||||||
-- anyone but standing npc's can move along
|
-- 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)
|
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
|
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)}
|
self.direction = {x = math.sin(yaw)*-1, y = -20, z = math.cos(yaw)}
|
||||||
|
@ -97,24 +97,18 @@ mobs:register_mob("mobs:npc", {
|
|||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
pos.y = pos.y + 0.5
|
pos.y = pos.y + 0.5
|
||||||
minetest.add_item(pos, {name = mobs.npc_drops[math.random(1,#mobs.npc_drops)]})
|
minetest.add_item(pos, {name = mobs.npc_drops[math.random(1,#mobs.npc_drops)]})
|
||||||
elseif item:get_name() == "default:diamond" then
|
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
|
self.diamond_count = (self.diamond_count or 0) + 1
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
item:take_item()
|
item:take_item()
|
||||||
clicker:set_wielded_item(item)
|
clicker:set_wielded_item(item)
|
||||||
end
|
end
|
||||||
if self.diamond_count < 4 then return end
|
if self.diamond_count >= 4 then
|
||||||
-- if owner switch between follow and stand
|
|
||||||
if self.owner and self.owner == clicker:get_player_name() then
|
|
||||||
self.damages = 3
|
self.damages = 3
|
||||||
if self.order == "follow" then
|
|
||||||
self.order = "stand"
|
|
||||||
else
|
|
||||||
self.order = "follow"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
self.owner = clicker:get_player_name()
|
self.owner = clicker:get_player_name()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
-- pick up npc
|
-- pick up npc
|
||||||
elseif item:get_name() == "mobs:magic_lasso"
|
elseif item:get_name() == "mobs:magic_lasso"
|
||||||
and clicker:is_player()
|
and clicker:is_player()
|
||||||
@ -135,6 +129,15 @@ mobs:register_mob("mobs:npc", {
|
|||||||
elseif self.owner ~= name then
|
elseif self.owner ~= name then
|
||||||
minetest.chat_send_player(name, "Not owner!")
|
minetest.chat_send_player(name, "Not owner!")
|
||||||
end
|
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
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user