mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-04 08:43:45 +01:00
Make villagers hurry for long paths and night
This commit is contained in:
parent
5779be305c
commit
4388152650
@ -657,15 +657,16 @@ function mob_class:flop()
|
||||
end
|
||||
end
|
||||
|
||||
function mob_class:go_to_pos(b)
|
||||
function mob_class:go_to_pos(b, speed)
|
||||
if not self then return end
|
||||
if not b then return end
|
||||
local s = self.object:get_pos()
|
||||
if vector_distance(b,s) < .4 then return true end
|
||||
if b.y > s.y + 0.2 then self:do_jump() end
|
||||
self:turn_in_direction(b.x - s.x, b.z - s.z, 2)
|
||||
self:set_velocity(self.walk_velocity)
|
||||
self:set_animation("walk")
|
||||
speed = speed or self.walk_velocity
|
||||
self:set_velocity(speed)
|
||||
self:set_animation(speed <= self.walk_velocity and "walk" or "run")
|
||||
end
|
||||
|
||||
local check_herd_timer = 0
|
||||
|
@ -476,14 +476,15 @@ function mob_class:check_gowp(dtime)
|
||||
local failed_attempts = self.current_target["failed_attempts"]
|
||||
mcl_log("There after " .. failed_attempts .. " failed attempts. current target:".. minetest.pos_to_string(self.current_target.pos) .. ". Distance: " .. distance_to_current_target)
|
||||
|
||||
local hurry = (self.order == "sleep" or #self.waypoints > 15) and self.run_velocity or self.walk_velocity
|
||||
self.current_target = table.remove(self.waypoints, 1)
|
||||
-- use smoothing -- TODO: check for blockers before cutting corners?
|
||||
if #self.waypoints > 0 and not self.current_target["action"] then
|
||||
local curwp, nextwp = self.current_target.pos, self.waypoints[1].pos
|
||||
self:go_to_pos(vector.new(curwp.x*0.7+nextwp.x*0.3,curwp.y,curwp.z*0.7+nextwp.z*0.3))
|
||||
self:go_to_pos(vector.new(curwp.x*0.7+nextwp.x*0.3,curwp.y,curwp.z*0.7+nextwp.z*0.3), hurry)
|
||||
return
|
||||
end
|
||||
self:go_to_pos(self.current_target.pos)
|
||||
self:go_to_pos(self.current_target.pos, hurry)
|
||||
--if self.current_target["action"] then self:set_velocity(self.walk_velocity * 0.5) end
|
||||
return
|
||||
elseif self.current_target and self.current_target.pos then
|
||||
|
Loading…
Reference in New Issue
Block a user