Skip to content

Commit

Permalink
select proper animation for flying mobs
Browse files Browse the repository at this point in the history
  • Loading branch information
tenplus1 committed May 1, 2022
1 parent dd16d63 commit 6f8b6fe
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ local use_cmi = minetest.global_exists("cmi")

mobs = {
mod = "redo",
version = "20220430",
version = "20220501",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}
}
Expand Down Expand Up @@ -2389,11 +2389,22 @@ function mob_class:do_states(dtime)
else
self:set_velocity(self.walk_velocity)

-- figure out which animation to use while in motion
if self:flight_check()
and self.animation
and self.animation.fly_start
and self.animation.fly_end then
self:set_animation("fly")

local on_ground = minetest.registered_nodes[self.standing_on].walkable
local in_water = minetest.registered_nodes[self.standing_in].groups.water

if on_ground and in_water then
self:set_animation("fly")
elseif on_ground then
self:set_animation("walk")
else
self:set_animation("fly")
end
else
self:set_animation("walk")
end
Expand Down

0 comments on commit 6f8b6fe

Please sign in to comment.