From 246bdf9707c98f787cb5264dc7ff638e340d768b Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Thu, 15 Apr 2021 15:55:10 -0400 Subject: [PATCH] Implement basic mob walking animation test --- mods/ENTITIES/mcl_mobs/api/api.lua | 3 +-- mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua | 3 ++- .../mcl_mobs/api/mob_functions/animation.lua | 13 +++---------- mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index fad7b8c28..9ffb4f3e4 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -299,10 +299,9 @@ function mobs:register_mob(name, def) pushable = def.pushable or true, --j4i stuff - --automatic_rotate = 360, yaw = 0, automatic_face_movement_dir = def.rotate or 0, -- 0=front, 90=side, 180=back, 270=side2 - automatic_face_movement_max_rotation_per_sec = 270, --degrees + automatic_face_movement_max_rotation_per_sec = 360, --degrees backface_culling = true, walk_timer = 0, stand_timer = 0, diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index a1f829d84..2b16bfb40 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -20,6 +20,8 @@ local do_states = function(self, dtime) self.state_timer = math.random(0,2) + math.random() --let's do a random state self.yaw = (math_random() * (math.pi * 2)) + + mobs.set_animation(self, "walk") end mobs.set_velocity(self,1) @@ -46,7 +48,6 @@ local jump_check = function(self,dtime) local test_dir = vector.add(pos,dir) if minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0 then - print("jump") mobs.jump(self) end end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua index 8de235ab7..5750a63b8 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua @@ -3,7 +3,7 @@ local math_sin = math.sin local math_cos = math.cos -- set defined animation -local set_animation = function(self, anim, fixed_frame) +mobs.set_animation = function(self, anim, fixed_frame) if not self.animation or not anim then return end @@ -13,9 +13,8 @@ local set_animation = function(self, anim, fixed_frame) self.animation.current = self.animation.current or "" - if (anim == self.animation.current - or not self.animation[anim .. "_start"] - or not self.animation[anim .. "_end"]) and self.state ~= "die" then + if (not self.animation[anim .. "_start"] or not self.animation[anim .. "_end"]) then + print("largablarga") return end @@ -37,12 +36,6 @@ local set_animation = function(self, anim, fixed_frame) end --- above function exported for mount.lua -function mobs:set_animation(self, anim) - set_animation(self, anim) -end - - mobs.death_effect = function(pos, yaw, collisionbox, rotate) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua index 87e1fb8df..a0f7b1def 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua @@ -194,7 +194,7 @@ mobs.mob_activate = function(self, staticdata, def, dtime) self.object:set_properties(self) --update_tag(self) - --set_animation(self, "stand") + --mobs.set_animation(self, "stand") -- run on_spawn function if found if self.on_spawn and not self.on_spawn_run then