fixed lifetimer bug
This commit is contained in:
parent
a43542859d
commit
91f5837e75
19
api.lua
19
api.lua
@ -167,10 +167,10 @@ lifetimer = def.lifetimer or 600,
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- if lifetimer run out and not npc, tamed or attacking then remove mob
|
||||||
if self.type ~= "npc" and not self.tamed then
|
if self.type ~= "npc" and not self.tamed then
|
||||||
self.lifetimer = self.lifetimer - dtime
|
self.lifetimer = self.lifetimer - dtime
|
||||||
end
|
if self.lifetimer <= 0 and self.state ~= "attack" then
|
||||||
if self.lifetimer <= 0 and self.state ~= "attack" and not self.tamed then
|
|
||||||
for _,obj in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 10)) do
|
for _,obj in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 10)) do
|
||||||
if obj:is_player() then
|
if obj:is_player() then
|
||||||
minetest.log("action","lifetimer expired, removed mob "..self.name)
|
minetest.log("action","lifetimer expired, removed mob "..self.name)
|
||||||
@ -179,6 +179,7 @@ lifetimer = def.lifetimer or 600,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- check for mob drop/replace (used for chicken egg and sheep eating grass/wheat)
|
-- check for mob drop/replace (used for chicken egg and sheep eating grass/wheat)
|
||||||
if self.replace_rate and math.random(1,self.replace_rate) == 1 and self.child == false then
|
if self.replace_rate and math.random(1,self.replace_rate) == 1 and self.child == false then
|
||||||
@ -669,14 +670,14 @@ lifetimer = def.lifetimer or 600,
|
|||||||
if self.type == "monster" and peaceful_only then
|
if self.type == "monster" and peaceful_only then
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end
|
end
|
||||||
if self.type ~= "npc" then
|
-- if self.type ~= "npc" then
|
||||||
self.lifetimer = self.lifetimer - dtime_s
|
-- self.lifetimer = self.lifetimer - dtime_s
|
||||||
end
|
-- end
|
||||||
if staticdata then
|
if staticdata then
|
||||||
local tmp = minetest.deserialize(staticdata)
|
local tmp = minetest.deserialize(staticdata)
|
||||||
if tmp then
|
if tmp then
|
||||||
if tmp.lifetimer then
|
if tmp.lifetimer then
|
||||||
self.lifetimer = tmp.lifetimer - dtime_s
|
self.lifetimer = tmp.lifetimer -- - dtime_s
|
||||||
end
|
end
|
||||||
if tmp.tamed then
|
if tmp.tamed then
|
||||||
self.tamed = tmp.tamed
|
self.tamed = tmp.tamed
|
||||||
@ -711,9 +712,9 @@ lifetimer = def.lifetimer or 600,
|
|||||||
if self.type == "monster" and self.tamed == true then
|
if self.type == "monster" and self.tamed == true then
|
||||||
self.type = "npc"
|
self.type = "npc"
|
||||||
end
|
end
|
||||||
if self.lifetimer <= 0 and not self.tamed and self.type ~= "npc" then
|
-- if self.lifetimer <= 0 and not self.tamed and self.type ~= "npc" then
|
||||||
self.object:remove()
|
-- self.object:remove()
|
||||||
end
|
-- end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
get_staticdata = function(self)
|
get_staticdata = function(self)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user