From 9cf5b2a9f638adb56ccb331f4dc3523e44f4f917 Mon Sep 17 00:00:00 2001 From: epCode <64379263+epCode@users.noreply.github.com> Date: Sun, 9 Oct 2022 18:40:41 -0700 Subject: [PATCH] make mobs rotate when punched --- mods/ENTITIES/mcl_mobs/api.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index f67a094035..d4f493c04c 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -339,7 +339,9 @@ local set_yaw = function(self, yaw, delay, dtime) if self.noyaw then return end - self._turn_to = yaw + if self._kb_turn then + self._turn_to = yaw + end --clamp our yaw to a 360 range if math.deg(self.object:get_yaw()) > 360 then self.object:set_yaw(math.rad(10)) @@ -367,9 +369,9 @@ local set_yaw = function(self, yaw, delay, dtime) if math.abs(target_shortest_path) > 280*ddtime then if target_shortest_path > 0 then - self.object:set_yaw(self.object:get_yaw()+1.5*ddtime) + self.object:set_yaw(self.object:get_yaw()+3.6*ddtime) else - self.object:set_yaw(self.object:get_yaw()-1.5*ddtime) + self.object:set_yaw(self.object:get_yaw()-3.6*ddtime) end end @@ -3364,6 +3366,13 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) elseif luaentity and luaentity._knockback then kb = kb + luaentity._knockback end + self._kb_turn = false + self._turn_to=self.object:get_yaw()+1.57 + minetest.after(0.5, function() + if self and self.object then + self._kb_turn = true + end + end) self.object:set_velocity({ x = dir.x * kb,