forked from VoxeLibre/VoxeLibre
Make golem go home. Fixes #3288
This commit is contained in:
parent
fdf823fff6
commit
ae5564e658
|
@ -9,7 +9,8 @@ local S = minetest.get_translator("mobs_mc")
|
|||
--################### IRON GOLEM
|
||||
--###################
|
||||
|
||||
local etime = 0
|
||||
local walk_dist = 40
|
||||
local tele_dist = 80
|
||||
|
||||
mcl_mobs.register_mob("mobs_mc:iron_golem", {
|
||||
description = S("Iron Golem"),
|
||||
|
@ -85,11 +86,23 @@ mcl_mobs.register_mob("mobs_mc:iron_golem", {
|
|||
punch_start = 40, punch_end = 50,
|
||||
},
|
||||
jump = true,
|
||||
on_step = function(self,dtime)
|
||||
etime = etime + dtime
|
||||
if etime > 10 then
|
||||
if self._home and vector.distance(self._home,self.object:get_pos()) > 50 then
|
||||
self:gopath(self._home)
|
||||
do_custom = function(self, dtime)
|
||||
self.home_timer = (self.home_timer or 0) + dtime
|
||||
|
||||
if self.home_timer > 10 then
|
||||
self.home_timer = 0
|
||||
if self._home then
|
||||
local dist = vector.distance(self._home,self.object:get_pos())
|
||||
if dist >= tele_dist then
|
||||
self.object:set_pos(self._home)
|
||||
self.state = "stand"
|
||||
self.order = "follow"
|
||||
elseif dist >= walk_dist then
|
||||
self:gopath(self._home, function(self)
|
||||
self.state = "stand"
|
||||
self.order = "follow"
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
|
Loading…
Reference in New Issue