forked from VoxeLibre/VoxeLibre
Despawn out of range mobs when immobile
This commit is contained in:
parent
c146124a2c
commit
976b9da7d7
|
@ -3602,7 +3602,7 @@ local mob_staticdata = function(self)
|
|||
and ((not self.nametag) or (self.nametag == ""))
|
||||
and self.lifetimer <= 20 then
|
||||
if spawn_logging then
|
||||
minetest.log("action", "[mcl_mobs] Mob "..tostring(self.name).." despawns in mob_staticdata at "..minetest.pos_to_string(vector.round(self.object:get_pos())))
|
||||
minetest.log("action", "[mcl_mobs] Mob "..tostring(self.name).." despawns at "..minetest.pos_to_string(vector.round(self.object:get_pos())) .. " - out of range")
|
||||
end
|
||||
|
||||
return "remove"-- nil
|
||||
|
@ -3826,6 +3826,30 @@ end
|
|||
-- main mob function
|
||||
local mob_step = function(self, dtime)
|
||||
self.lifetimer = self.lifetimer - dtime
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
-- Despawning: when lifetimer expires, remove mob
|
||||
if remove_far
|
||||
and self.can_despawn == true
|
||||
and ((not self.nametag) or (self.nametag == ""))
|
||||
and self.state ~= "attack"
|
||||
and self.following == nil then
|
||||
if self.despawn_immediately or self.lifetimer <= 0 then
|
||||
if spawn_logging then
|
||||
minetest.log("action", "[mcl_mobs] Mob "..self.name.." despawns at "..minetest.pos_to_string(pos, 1) .. " lifetimer ran out")
|
||||
end
|
||||
mcl_burning.extinguish(self.object)
|
||||
self.object:remove()
|
||||
return
|
||||
elseif self.lifetimer <= 10 then
|
||||
if random(10) < 4 then
|
||||
self.despawn_immediately = true
|
||||
else
|
||||
self.lifetimer = 20
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not player_in_active_range(self) then
|
||||
set_animation(self, "stand", true)
|
||||
self.object:set_velocity(vector.new(0,0,0))
|
||||
|
@ -3840,7 +3864,6 @@ local mob_step = function(self, dtime)
|
|||
if not self.object:get_pos() then return end
|
||||
end
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
local yaw = 0
|
||||
|
||||
if mobs_debug then
|
||||
|
@ -4105,28 +4128,6 @@ local mob_step = function(self, dtime)
|
|||
local yaw = self.object:get_yaw() or 0
|
||||
yaw = set_yaw(self, yaw + 0.78, 8)
|
||||
end
|
||||
|
||||
-- Despawning: when lifetimer expires, remove mob
|
||||
if remove_far
|
||||
and self.can_despawn == true
|
||||
and ((not self.nametag) or (self.nametag == ""))
|
||||
and self.state ~= "attack"
|
||||
and self.following == nil then
|
||||
if self.despawn_immediately or self.lifetimer <= 0 then
|
||||
if spawn_logging then
|
||||
minetest.log("action", "[mcl_mobs] Mob "..self.name.." despawns in mob_step at "..minetest.pos_to_string(pos, 1))
|
||||
end
|
||||
mcl_burning.extinguish(self.object)
|
||||
self.object:remove()
|
||||
return
|
||||
elseif self.lifetimer <= 10 then
|
||||
if random(10) < 4 then
|
||||
self.despawn_immediately = true
|
||||
else
|
||||
self.lifetimer = 20
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue