fix mob floping

This commit is contained in:
epCode 2022-10-15 12:09:25 -07:00
parent 8e28c296ca
commit 677fcb48c9

View File

@ -8,7 +8,7 @@ local HORNY_AGAIN_TIME = 300
local CHILD_GROW_TIME = 60*20 local CHILD_GROW_TIME = 60*20
local DEATH_DELAY = 0.5 local DEATH_DELAY = 0.5
local DEFAULT_FALL_SPEED = -9.81*1.5 local DEFAULT_FALL_SPEED = -9.81*1.5
local FLOP_HEIGHT = 5.0 local FLOP_HEIGHT = 6
local FLOP_HOR_SPEED = 1.5 local FLOP_HOR_SPEED = 1.5
local ENTITY_CRAMMING_MAX = 24 local ENTITY_CRAMMING_MAX = 24
local CRAMMING_DAMAGE = 3 local CRAMMING_DAMAGE = 3
@ -2382,9 +2382,11 @@ local follow_flop = function(self)
self.state = "flop" self.state = "flop"
self.object:set_acceleration({x = 0, y = DEFAULT_FALL_SPEED, z = 0}) self.object:set_acceleration({x = 0, y = DEFAULT_FALL_SPEED, z = 0})
local sdef = minetest.registered_nodes[self.standing_on] local p = self.object:get_pos()
local sdef = minetest.registered_nodes[node_ok(vector.add(p, vector.new(0,self.collisionbox[2]-0.2,0))).name]
-- Flop on ground -- Flop on ground
if sdef and sdef.walkable then if sdef and sdef.walkable then
if self.object:get_velocity().y < 0.1 then
mob_sound(self, "flop") mob_sound(self, "flop")
self.object:set_velocity({ self.object:set_velocity({
x = random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED), x = random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED),
@ -2392,6 +2394,7 @@ local follow_flop = function(self)
z = random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED), z = random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED),
}) })
end end
end
set_animation(self, "stand", true) set_animation(self, "stand", true)