diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 5d2b86517..5f7b07a36 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -224,12 +224,12 @@ function mob_class:mob_activate(staticdata, def, dtime) self._current_animation = nil self:set_animation("stand") - if self.riden_by_jock then --- Keep this function before self.on_spawn() is run. + if self.riden_by_jock then --- Keep this function before self:on_spawn() self.object:remove() return end - if self.on_spawn and not self.on_spawn_run and self.on_spawn(self) then self.on_spawn_run = true end + if self.on_spawn and not self.on_spawn_run and self:on_spawn() then self.on_spawn_run = true end if not self.wears_armor and self.armor_list then self.armor_list = nil end diff --git a/mods/ENTITIES/mcl_mobs/combat.lua b/mods/ENTITIES/mcl_mobs/combat.lua index 7b22e5aaf..54e45b71b 100644 --- a/mods/ENTITIES/mcl_mobs/combat.lua +++ b/mods/ENTITIES/mcl_mobs/combat.lua @@ -401,10 +401,7 @@ end -- dogshoot attack switch and counter function function mob_class:dogswitch(dtime) -- switch mode not activated - if not self.dogshoot_switch - or not dtime then - return 0 - end + if not self.dogshoot_switch or not dtime then return 0 end self.dogshoot_count = self.dogshoot_count + dtime @@ -604,8 +601,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) end end -- knock back effect (only on full punch) - if self.knock_back - and tflp >= punch_interval then + if self.knock_back and tflp >= punch_interval then -- direction error check dir = dir or vector_zero() @@ -645,7 +641,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) kb = kb + luaentity._knockback * 0.25 end self._kb_turn = true - self._turn_to=self.object:get_yaw()-1.57 + self:turn_by(HALFPI, .1) -- knockback turn self.frame_speed_multiplier=2.3 if self.animation.run_end then self:set_animation("run") @@ -770,7 +766,7 @@ local function clear_aggro(self) self.path.way = nil end -function mob_class:do_states_attack (dtime) +function mob_class:do_states_attack(dtime) self.timer = self.timer + dtime if self.timer > 100 then self.timer = 1 end @@ -813,7 +809,7 @@ function mob_class:do_states_attack (dtime) if self.attack_type == "explode" then if target_line_of_sight then - self:turn_in_direction(p.x - s.x, p.z - s.z, 1, dtime) + self:turn_in_direction(p.x - s.x, p.z - s.z, 1) end local node_break_radius = self.explosion_radius or 1 @@ -932,7 +928,7 @@ function mob_class:do_states_attack (dtime) p = vector_copy(p1) end - self:turn_in_direction(p.x - s.x, p.z - s.z, 1, dtime) + self:turn_in_direction(p.x - s.x, p.z - s.z, 1) -- move towards enemy if beyond mob reach if dist > self.reach then @@ -1004,7 +1000,7 @@ function mob_class:do_states_attack (dtime) or (self.attack_type == "dogshoot" and (dist > self.reach or dist < self.avoid_distance and self.shooter_avoid_enemy) and self:dogswitch() == 0) then local vec = vector_new(p.x - s.x, p.y - s.y - 1, p.z - s.z) local dist = (vec.x*vec.x + vec.y*vec.y + vec.z*vec.z)^0.5 - self:turn_in_direction(vec.x, vec.z, 1, dtime) + self:turn_in_direction(vec.x, vec.z, 1) if self.strafes then if not self.strafe_direction then self.strafe_direction = HALFPI end diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index df7ee5dc7..d257cda5d 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -247,17 +247,21 @@ function mob_class:update_roll() end -- Relative turn, primarily for random turning +-- @param dtime deprecated: ignored now, because of smooth rotations function mob_class:turn_by(angle, delay, dtime) return self:set_yaw((self.object:get_yaw() or 0) + angle, delay, dtime) end -- Turn into a direction (e.g., to the player, or away) +-- @param dtime deprecated: ignored now, because of smooth rotations function mob_class:turn_in_direction(dx, dz, delay, dtime) if abs(dx) == 0 and abs(dz) == 0 then return self.object:get_yaw() + self.rotate end return self:set_yaw(-atan2(dx, dz) - self.rotate, delay, dtime) end -- set and return valid yaw -function mob_class:set_yaw(yaw, delay, dtime) -- FIXME: dtime unused +-- @param dtime deprecated: ignored now, because of smooth rotations +function mob_class:set_yaw(yaw, delay, dtime) if self.noyaw then return end + if self._kb_turn then return yaw end -- knockback in effect if not self.object:get_yaw() or not self.object:get_pos() then return end self.delay = delay or 0 self.target_yaw = yaw % TWOPI @@ -266,10 +270,6 @@ end -- improved smooth rotation function mob_class:check_smooth_rotation(dtime) - if self._turn_to then - self:set_yaw(self._turn_to, .1) - self._turn_to = nil - end if not self.target_yaw then return end local delay = self.delay