mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-24 17:50:37 +01:00
update mobs, fix tame and tidy code
This commit is contained in:
parent
428127f43d
commit
a038ed0128
@ -1,4 +1,4 @@
|
||||
-- Mobs Api (9th September 2015)
|
||||
-- Mobs Api (17th September 2015)
|
||||
mobs = {}
|
||||
mobs.mod = "redo"
|
||||
|
||||
@ -236,7 +236,7 @@ function mobs:register_mob(name, def)
|
||||
if v.y > 0.1 then
|
||||
self.object:setacceleration({
|
||||
x = 0,
|
||||
y= self.fall_speed,
|
||||
y = self.fall_speed,
|
||||
z = 0
|
||||
})
|
||||
end
|
||||
@ -347,7 +347,7 @@ function mobs:register_mob(name, def)
|
||||
if self.jumptimer < 3 then
|
||||
local pos = self.object:getpos()
|
||||
pos.y = (pos.y + self.collisionbox[2]) - 0.2
|
||||
local nod = minetest.get_node(pos)
|
||||
local nod = minetest.get_node_or_nil(pos)
|
||||
--print ("standing on:", nod.name, pos.y)
|
||||
if not nod
|
||||
or not minetest.registered_nodes[nod.name]
|
||||
@ -355,7 +355,7 @@ function mobs:register_mob(name, def)
|
||||
return
|
||||
end
|
||||
if self.direction then
|
||||
pos.y = pos.y + 0.5
|
||||
pos.y = pos.y + 0.5
|
||||
local nod = minetest.get_node_or_nil({
|
||||
x = pos.x + self.direction.x,
|
||||
y = pos.y,
|
||||
|
@ -50,7 +50,7 @@ mobs:register_mob("mobs:bunny", {
|
||||
replace_with = "air",
|
||||
-- right click to pick up rabbit
|
||||
on_rightclick = function(self, clicker)
|
||||
if not mobs:feed_tame(self, clicker, 4, true) then
|
||||
if not mobs:feed_tame(self, clicker, 4, true, true) then
|
||||
-- Monty Python tribute
|
||||
local item = clicker:get_wielded_item()
|
||||
if item:get_name() == "mobs:lava_orb" then
|
||||
|
@ -58,7 +58,7 @@ mobs:register_mob("mobs:chicken", {
|
||||
replace_what = {"air"},
|
||||
replace_with = "mobs:egg",
|
||||
on_rightclick = function(self, clicker)
|
||||
mobs:feed_tame(self, clicker, 8, true)
|
||||
mobs:feed_tame(self, clicker, 8, true, true)
|
||||
mobs:capture_mob(self, clicker, 30, 50, 80, false, nil)
|
||||
end,
|
||||
})
|
||||
|
@ -59,7 +59,7 @@ mobs:register_mob("mobs:cow", {
|
||||
replace_what = {"default:grass_3", "default:grass_4", "default:grass_5", "farming:wheat_8"},
|
||||
replace_with = "air",
|
||||
on_rightclick = function(self, clicker)
|
||||
if not mobs:feed_tame(self, clicker, 8, true) then
|
||||
if not mobs:feed_tame(self, clicker, 8, true, true) then
|
||||
local tool = clicker:get_wielded_item()
|
||||
|
||||
-- milk cow with empty bucket
|
||||
|
@ -47,7 +47,7 @@ mobs:register_mob("mobs:kitten", {
|
||||
view_range = 10,
|
||||
-- feed with raw fish to tame or right click to pick up
|
||||
on_rightclick = function(self, clicker)
|
||||
mobs:feed_tame(self, clicker, 4, true)
|
||||
mobs:feed_tame(self, clicker, 4, true, true)
|
||||
mobs:capture_mob(self, clicker, 50, 50, 90, false, nil)
|
||||
end
|
||||
})
|
||||
|
@ -91,7 +91,7 @@ mobs:register_mob("mobs:npc", {
|
||||
end
|
||||
return
|
||||
-- feed to heal npc
|
||||
elseif not mobs:feed_tame(self, clicker, 8, true) then
|
||||
elseif not mobs:feed_tame(self, clicker, 8, true, true) then
|
||||
-- right clicking with gold lump drops random item from mobs.npc_drops
|
||||
if item:get_name() == "default:gold_lump" then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
|
@ -95,7 +95,7 @@ mobs:register_mob("mobs:npc_female", {
|
||||
end
|
||||
return
|
||||
-- feed to heal npc
|
||||
elseif not mobs:feed_tame(self, clicker, 8, true) then
|
||||
elseif not mobs:feed_tame(self, clicker, 8, true, true) then
|
||||
-- right clicking with gold lump drops random item from mobs.npc_drops
|
||||
if item:get_name() == "default:gold_lump" then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
|
@ -68,7 +68,7 @@ for _, col in ipairs(all_colours) do
|
||||
end
|
||||
|
||||
--are we feeding?
|
||||
if mobs:feed_tame(self, clicker, 8, true) then
|
||||
if mobs:feed_tame(self, clicker, 8, true, true) then
|
||||
--if full grow fuzz
|
||||
if self.gotten == false then
|
||||
self.object:set_properties({
|
||||
|
@ -55,7 +55,7 @@ mobs:register_mob("mobs:pumba", {
|
||||
},
|
||||
-- can be tamed by feeding 8 wheat (will not attack when tamed)
|
||||
on_rightclick = function(self, clicker)
|
||||
mobs:feed_tame(self, clicker, 8, true)
|
||||
mobs:feed_tame(self, clicker, 8, true, true)
|
||||
mobs:capture_mob(self, clicker, 0, 5, 50, false, nil)
|
||||
end,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user