mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-25 16:40:23 +01:00
simplify mobs floating in water
This commit is contained in:
parent
774ce6671f
commit
0f1f3b4fb3
31
api.lua
31
api.lua
@ -8,7 +8,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20210310",
|
version = "20210318",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
@ -2697,34 +2697,17 @@ function mob_class:falling(pos)
|
|||||||
-- sanity check
|
-- sanity check
|
||||||
if not v then return end
|
if not v then return end
|
||||||
|
|
||||||
local fall_speed = -10 -- gravity
|
local fall_speed = self.fall_speed
|
||||||
|
|
||||||
-- don't exceed mob fall speed
|
|
||||||
if v.y < self.fall_speed then
|
|
||||||
fall_speed = self.fall_speed
|
|
||||||
end
|
|
||||||
|
|
||||||
-- in water then use liquid viscosity for float/sink speed
|
-- in water then use liquid viscosity for float/sink speed
|
||||||
if (self.standing_in
|
if self.floats == 1 and self.standing_in
|
||||||
and minetest.registered_nodes[self.standing_in].groups.liquid)
|
and minetest.registered_nodes[self.standing_in].groups.liquid then
|
||||||
or (self.standing_on
|
|
||||||
and minetest.registered_nodes[self.standing_in].groups.liquid) then
|
|
||||||
|
|
||||||
local visc = min(
|
local visc = min(
|
||||||
minetest.registered_nodes[self.standing_in].liquid_viscosity, 7)
|
minetest.registered_nodes[self.standing_in].liquid_viscosity, 7) + 1
|
||||||
|
|
||||||
if self.floats == 1 then
|
self.object:set_velocity({x = v.x, y = 0.6, z = v.z})
|
||||||
|
fall_speed = -1.2 / visc
|
||||||
-- floating up
|
|
||||||
if visc > 0 then
|
|
||||||
fall_speed = max(1, v.y) / (visc + 1)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- sinking down
|
|
||||||
if visc > 0 then
|
|
||||||
fall_speed = -(max(1, v.y) / (visc + 1))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- fall damage onto solid ground
|
-- fall damage onto solid ground
|
||||||
|
Loading…
Reference in New Issue
Block a user