Compare commits

...

6 Commits

Author SHA1 Message Date
TheTermos a4e06bfac2
Merge pull request #14 from TheTermos/dev
hotfix
2019-12-09 20:18:40 +01:00
TheTermos ecf21d6fba
Add files via upload 2019-12-09 17:46:23 +01:00
TheTermos b70e7d59a9
Add files via upload 2019-12-07 18:38:44 +01:00
TheTermos e55304d60e
Add files via upload 2019-12-07 18:11:05 +01:00
TheTermos 8d42b6d936
Merge pull request #13 from TheTermos/dev
is_neighbor_node_reachable fix
2019-12-05 16:37:16 +01:00
TheTermos e7a9e13012
Add files via upload 2019-12-05 15:36:15 +01:00
1 changed files with 13 additions and 9 deletions

View File

@ -449,7 +449,8 @@ 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 height, liquidflag = mobkit.get_terrain_height(tpos)
local recursteps = ceil(self.jump_height)+1
local height, liquidflag = mobkit.get_terrain_height(tpos,recursteps)
if height and abs(height-pos.y) <= self.jump_height then
tpos.y = height
@ -460,12 +461,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)
local h2 = mobkit.get_terrain_height(t2,recursteps)
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)
h2 = mobkit.get_terrain_height(t2,recursteps)
if h2 and h2 - pos.y > 0.02 then return end
end
@ -812,26 +813,29 @@ 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
@ -888,10 +892,6 @@ 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,6 +899,10 @@ 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 = {}