Compare commits

..

No commits in common. "a4e06bfac2802376251d5bc7aac90a83bcf38e6b" and "e6721f4bcb67a24875cf8b188fbdb67b6935b55e" have entirely different histories.

1 changed files with 9 additions and 13 deletions

View File

@ -449,8 +449,7 @@ function mobkit.is_neighbor_node_reachable(self,neighbor) -- todo: take either n
local offset = neighbors[neighbor]
local pos=mobkit.get_stand_pos(self)
local tpos = mobkit.get_node_pos(mobkit.pos_shift(pos,offset))
local recursteps = ceil(self.jump_height)+1
local height, liquidflag = mobkit.get_terrain_height(tpos,recursteps)
local height, liquidflag = mobkit.get_terrain_height(tpos)
if height and abs(height-pos.y) <= self.jump_height then
tpos.y = height
@ -461,12 +460,12 @@ function mobkit.is_neighbor_node_reachable(self,neighbor) -- todo: take either n
local n2 = neighbor-1 -- left neighbor never < 0
offset = neighbors[n2]
local t2 = mobkit.get_node_pos(mobkit.pos_shift(pos,offset))
local h2 = mobkit.get_terrain_height(t2,recursteps)
local h2 = mobkit.get_terrain_height(t2)
if h2 and h2 - pos.y > 0.02 then return end
n2 = (neighbor+1)%8 -- right neighbor
offset = neighbors[n2]
t2 = mobkit.get_node_pos(mobkit.pos_shift(pos,offset))
h2 = mobkit.get_terrain_height(t2,recursteps)
h2 = mobkit.get_terrain_height(t2)
if h2 and h2 - pos.y > 0.02 then return end
end
@ -813,29 +812,26 @@ function mobkit.physics(self)
-- buoyancy
local surface = nil
local surfnodename = nil
local spos = mobkit.get_stand_pos(self)
spos.y = spos.y+0.01
-- get surface height
local snodepos = mobkit.get_node_pos(spos)
local surfnode = mobkit.nodeatpos(spos)
while surfnode and surfnode.drawtype == 'liquid' do
surfnodename = surfnode.name
surface = snodepos.y+0.5
if surface > spos.y+self.height then break end
snodepos.y = snodepos.y+1
surfnode = mobkit.nodeatpos(snodepos)
end
self.isinliquid = surfnodename
if surface then -- standing in liquid
-- self.isinliquid = true
self.isinliquid = true
local submergence = min(surface-spos.y,self.height)/self.height
-- local balance = self.buoyancy*self.height
local buoyacc = mobkit.gravity*(self.buoyancy-submergence)
mobkit.set_acceleration(self.object,
{x=-vel.x*self.water_drag,y=buoyacc-vel.y*abs(vel.y)*0.4,z=-vel.z*self.water_drag})
else
-- self.isinliquid = false
self.isinliquid = false
self.object:set_acceleration({x=0,y=mobkit.gravity,z=0})
end
@ -892,6 +888,10 @@ function mobkit.actfunc(self, staticdata, dtime_s)
end
end
if self.timeout and self.timeout>0 and dtime_s > self.timeout and next(self.memory)==nil then
self.object:remove()
end
if not self.memory then -- this is the initial activation
self.memory = {}
@ -899,10 +899,6 @@ function mobkit.actfunc(self, staticdata, dtime_s)
if #self.textures > 1 then self.texture_no = random(#self.textures) end
end
if self.timeout and self.timeout>0 and dtime_s > self.timeout and next(self.memory)==nil then
self.object:remove()
end
-- apply texture
if self.texture_no then
local props = {}