1
0
Fork 0

Reorder on_step calls

Bamboo-Piston-Dig
ancientmarinerdev 2023-02-05 23:42:36 +00:00 committed by Gitea
parent 4b9482cb09
commit 39d4434df1
2 changed files with 23 additions and 20 deletions

View File

@ -366,8 +366,7 @@ function mob_class:on_step(dtime)
if self:outside_limits() then return end
-- Start: Death/damage processing
-- All damage needs to be undertaken at the start.
-- We need to exit processing if the mob dies.
-- All damage needs to be undertaken at the start. We need to exit processing if the mob dies.
if self:check_death_and_slow_mob() then
--minetest.log("action", "Mob is dying: ".. tostring(self.name))
-- Do we abandon out of here now?
@ -378,8 +377,7 @@ function mob_class:on_step(dtime)
if not self.fire_resistant then
mcl_burning.tick(self.object, dtime, self)
-- mcl_burning.tick may remove object immediately
if not self.object:get_pos() then return end
if not self.object:get_pos() then return end -- mcl_burning.tick may remove object immediately
if self:check_for_death("fire", {type = "fire"}) then
return true
@ -394,38 +392,35 @@ function mob_class:on_step(dtime)
self:check_water_flow()
self:env_danger_movement_checks (dtime)
if mobs_debug then self:update_tag() end
self:follow_flop() -- Mob following code.
self:set_animation_speed() -- set animation speed relitive to velocity
self:set_animation_speed() -- set animation speed relative to velocity
self:check_smooth_rotation(dtime)
self:check_head_swivel(dtime)
if self.jump_sound_cooloff > 0 then
self.jump_sound_cooloff = self.jump_sound_cooloff - dtime
end
if self.jump_sound_cooloff > 0 then self.jump_sound_cooloff = self.jump_sound_cooloff - dtime end
self:do_jump()
self:set_armor_texture()
self:check_runaway_from()
self:monster_attack()
self:npc_attack()
self:check_breeding()
self:check_aggro(dtime)
-- run custom function (defined in mob lua file)
if self.do_custom then
if self.do_custom(self, dtime) == false then
return
end
end
self:check_breeding()
self:check_item_pickup()
self:set_armor_texture()
if self.do_custom and self.do_custom(self, dtime) == false then return end
if update_timers(self, dtime) then return end
self:check_particlespawners(dtime)
self:check_item_pickup()
if self:env_damage (dtime, pos) then return end
if self:do_states(dtime) then return end
if self.opinion_sound_cooloff > 0 then
self.opinion_sound_cooloff = self.opinion_sound_cooloff - dtime
@ -437,6 +432,8 @@ function mob_class:on_step(dtime)
if self:do_states(dtime) then return end
if mobs_debug then self:update_tag() end
if not self.object:get_luaentity() then
return false
end

View File

@ -239,9 +239,15 @@ function mob_class:is_at_water_danger()
return false
end
local yaw = self.object:get_yaw()
local pos = self.object:get_pos()
if not yaw or not pos then
return
end
local dir_x = -math.sin(yaw) * (self.collisionbox[4] + 0.5)
local dir_z = math.cos(yaw) * (self.collisionbox[4] + 0.5)
local pos = self.object:get_pos()
local ypos = pos.y + self.collisionbox[2] -- just above floor
local free_fall, blocker = minetest.line_of_sight(