1
0
Fork 0

Tidy on_step function

hardcore_mode_test
ancientmarinerdev 2023-01-06 23:39:56 +00:00 committed by Gitea
parent ef90820f67
commit 01c8009c6a
2 changed files with 15 additions and 16 deletions

View File

@ -306,7 +306,7 @@ function mob_class:do_states(dtime)
end end
local function update_timers (self, dtime) local function update_timers (self, dtime)
-- knockback timer -- knockback timer. set in on_punch
if self.pause_timer > 0 then if self.pause_timer > 0 then
self.pause_timer = self.pause_timer - dtime self.pause_timer = self.pause_timer - dtime
return true return true
@ -330,17 +330,15 @@ end
-- main mob function -- main mob function
function mob_class:on_step(dtime) function mob_class:on_step(dtime)
self.lifetimer = self.lifetimer - dtime
local pos = self.object:get_pos() local pos = self.object:get_pos()
if not pos then return end if not pos then return end
if self:check_despawn(pos) then return true end if self:check_despawn(pos, dtime) then return true end
self:slow_mob() self:slow_mob()
if self:falling(pos) then return end if self:falling(pos) then return end
self:check_suspend() self:check_suspend()
self:check_water_flow() self:check_water_flow()
self:env_danger_movement_checks (dtime) self:env_danger_movement_checks (dtime)
@ -355,21 +353,17 @@ function mob_class:on_step(dtime)
if self.state == "die" then return end if self.state == "die" then return end
if self.jump_sound_cooloff > 0 then self:follow_flop() -- Mob following code.
self.jump_sound_cooloff = self.jump_sound_cooloff - dtime
end
if self.opinion_sound_cooloff > 0 then
self.opinion_sound_cooloff = self.opinion_sound_cooloff - dtime
end
--Mob following code. self:set_animation_speed() -- set animation speed relitive to velocity
self:follow_flop()
--set animation speed relitive to velocity
self:set_animation_speed()
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
self.jump_sound_cooloff = self.jump_sound_cooloff - dtime
end
self:do_jump() self:do_jump()
self:set_armor_texture() self:set_armor_texture()
self:check_runaway_from() self:check_runaway_from()
@ -390,6 +384,9 @@ function mob_class:on_step(dtime)
self:check_particlespawners(dtime) self:check_particlespawners(dtime)
self:check_item_pickup() self:check_item_pickup()
if self.opinion_sound_cooloff > 0 then
self.opinion_sound_cooloff = self.opinion_sound_cooloff - dtime
end
-- mob plays random sound at times. Should be 120. Zombie and mob farms are ridiculous -- mob plays random sound at times. Should be 120. Zombie and mob farms are ridiculous
if math.random(1, 70) == 1 then if math.random(1, 70) == 1 then
self:mob_sound("random", true) self:mob_sound("random", true)

View File

@ -722,7 +722,9 @@ if mobs_spawn then
end) end)
end end
function mob_class:check_despawn(pos) function mob_class:check_despawn(pos, dtime)
self.lifetimer = self.lifetimer - dtime
-- Despawning: when lifetimer expires, remove mob -- Despawning: when lifetimer expires, remove mob
if remove_far if remove_far
and self.can_despawn == true and self.can_despawn == true