mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-24 20:03:45 +01:00
make horny mobs move towards each other
This commit is contained in:
parent
39a0353a49
commit
cba176be4a
@ -3129,6 +3129,31 @@ local function check_item_pickup(self)
|
||||
end
|
||||
end
|
||||
|
||||
local check_herd_timer = 0
|
||||
local function check_herd(self,dtime)
|
||||
local pos = self.object:get_pos()
|
||||
if not pos then return end
|
||||
check_herd_timer = check_herd_timer + dtime
|
||||
if check_herd_timer < 4 then return end
|
||||
check_herd_timer = 0
|
||||
for _,o in pairs(minetest.get_objects_inside_radius(pos,self.view_range)) do
|
||||
local l = o:get_luaentity()
|
||||
local p,y
|
||||
if l and l.is_mob and l.name == self.name then
|
||||
if self.horny and l.horny then
|
||||
p = l.object:get_pos()
|
||||
else
|
||||
y = o:get_yaw()
|
||||
end
|
||||
if p then
|
||||
go_to_pos(self,p)
|
||||
elseif y then
|
||||
set_yaw(self,y)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function damage_mob(self,reason,damage)
|
||||
if not self.health then return end
|
||||
damage = floor(damage)
|
||||
@ -4016,6 +4041,10 @@ local mob_step = function(self, dtime)
|
||||
yaw = yaw + random(-0.5, 0.5)
|
||||
yaw = set_yaw(self, yaw, 8)
|
||||
end
|
||||
else
|
||||
if self.move_in_group ~= false then
|
||||
check_herd(self,dtime)
|
||||
end
|
||||
end
|
||||
|
||||
-- Add water flowing for mobs from mcl_item_entity
|
||||
|
Loading…
Reference in New Issue
Block a user