tremble for 2s when avoiding and 5s when fleeing

This commit is contained in:
nixnoxus 2024-02-26 04:30:40 +01:00
parent 078f5d760b
commit 8d0c3cd137
1 changed files with 8 additions and 0 deletions

View File

@ -669,6 +669,7 @@ function mob_class:check_runaway_from()
end
if self:is_object_in_view(self.runaway_from, self.view_range, self.view_range / 2, true) then
self.shaking = self.shaking or 5
self.state = "runaway"
self.runaway_timer = 3
self.following = nil
@ -899,6 +900,7 @@ function mob_class:do_states_walk()
local distance = self.avoid_distance or self.view_range / 2
-- find specific node to avoid
if self:is_object_in_view(self.avoid_from, distance, distance, true) then
self.shaking = self.shaking or 2
self:set_velocity(self.walk_velocity)
-- otherwise randomly turn
elseif math.random(1, 100) <= 30 then
@ -1061,6 +1063,12 @@ function mob_class:check_smooth_rotation(dtime)
self.delay = self.delay - 1
if self.shaking then
yaw = yaw + (math.random() * 2 - 1) * 5 * dtime
if type(self.shaking) == "number" then
self.shaking = self.shaking - dtime
if self.shaking <= 0 then
self.shaking = nil
end
end
end
self.object:set_yaw(yaw)
--self:update_roll()