diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index 50d744e6c..e8c42b573 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -219,6 +219,7 @@ function mobs:register_mob(name, def) breathes_in_water = def.breathes_in_water or false, physical = true, collisionbox = collisionbox, + collide_with_objects = def.collide_with_objects or false, selectionbox = def.selectionbox or def.collisionbox, visual = def.visual, visual_size = def.visual_size or {x = 1, y = 1}, @@ -306,6 +307,8 @@ function mobs:register_mob(name, def) walk_timer = 0, stand_timer = 0, wandering = true, + current_animation = "", + --set_animation = mobs.set_animation, --end j4i stuff -- MCL2 extensions @@ -331,27 +334,21 @@ function mobs:register_mob(name, def) on_spawn = def.on_spawn, - on_blast = def.on_blast or do_tnt, + --on_blast = def.on_blast or do_tnt, - on_step = mobs.mob_step, + on_step = mobs.mob_step, - do_punch = def.do_punch, + --do_punch = def.do_punch, - on_punch = mob_punch, + --on_punch = mob_punch, - on_breed = def.on_breed, + --on_breed = def.on_breed, - on_grown = def.on_grown, + --on_grown = def.on_grown, - on_detach_child = mob_detach_child, + --on_detach_child = mob_detach_child, on_activate = function(self, staticdata, dtime) - --this is a temporary hack so mobs stop - --glitching and acting really weird with the - --default built in engine collision detection - self.object:set_properties({ - collide_with_objects = false, - }) self.object:set_acceleration(vector_new(0,-9.81, 0)) return mobs.mob_activate(self, staticdata, def, dtime) end, @@ -360,8 +357,7 @@ function mobs:register_mob(name, def) return mobs.mob_staticdata(self) end, - harmed_by_heal = def.harmed_by_heal, - + --harmed_by_heal = def.harmed_by_heal, }) if minetest_get_modpath("doc_identifier") ~= nil then diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index 707835a6a..11954e28a 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -50,7 +50,13 @@ local state_execution = function(self,dtime) if self.state == "stand" then - print("stand") + --do animation + mobs.set_mob_animation(self, "stand") + + --set the velocity of the mob + mobs.set_velocity(self,0) + + --print("stand") elseif self.state == "walk" then @@ -67,7 +73,7 @@ local state_execution = function(self,dtime) end --do animation - mobs.set_animation(self, "walk") + mobs.set_mob_animation(self, "walk") --enable rotation locking mobs.movement_rotation_lock(self) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua index 3056e59d6..2f89333da 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua @@ -1,8 +1,8 @@ local math_pi = math.pi -- set defined animation -mobs.set_animation = function(self, anim, fixed_frame) - +mobs.set_mob_animation = function(self, anim, fixed_frame) + if not self.animation or not anim then return end @@ -11,23 +11,21 @@ mobs.set_animation = function(self, anim, fixed_frame) return end - self.animation.current = self.animation.current or "" - - --animations break if they are constantly set - --so we put this return gate to check if it is - --already at the animation we are trying to implement - if self.animation.current == anim then - return - end if (not self.animation[anim .. "_start"] or not self.animation[anim .. "_end"]) then return end - self.animation.current = anim + --animations break if they are constantly set + --so we put this return gate to check if it is + --already at the animation we are trying to implement + if self.current_animation == anim then + return + end local a_start = self.animation[anim .. "_start"] local a_end + if fixed_frame then a_end = a_start else @@ -39,6 +37,9 @@ mobs.set_animation = function(self, anim, fixed_frame) y = a_end}, self.animation[anim .. "_speed"] or self.animation.speed_normal or 15, 0, self.animation[anim .. "_loop"] ~= false) + + + self.current_animation = anim end