1
0
Fork 0

Reorder on_step calls

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

View File

@ -239,9 +239,15 @@ function mob_class:is_at_water_danger()
return false return false
end end
local yaw = self.object:get_yaw() 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_x = -math.sin(yaw) * (self.collisionbox[4] + 0.5)
local dir_z = math.cos(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 ypos = pos.y + self.collisionbox[2] -- just above floor
local free_fall, blocker = minetest.line_of_sight( local free_fall, blocker = minetest.line_of_sight(