slightly smoother golem movement (probably change everything later anyway though)
parent
4e004029ec
commit
15a8175842
|
@ -129,7 +129,7 @@ local function astar(s_pos, e_pos, min_cost, max_tries, max_queue, valid_node)
|
|||
end
|
||||
end
|
||||
end
|
||||
for i = max_queue, table.maxn(stack) do
|
||||
for i = max_queue, #stack do
|
||||
stack[i] = nil
|
||||
end
|
||||
iters = iters + 1
|
||||
|
@ -228,7 +228,7 @@ function pmb_entity_api.get_default_movement(callable, cost)
|
|||
|
||||
callable(self, dtime, moveresult)
|
||||
|
||||
if (not self._pmb_path or table.maxn(self._pmb_path) == 0) and self._pmb_path_timer > 70 then
|
||||
if (not self._pmb_path or #self._pmb_path == 0) and self._pmb_path_timer > 70 then
|
||||
--local ang = math.random()*6.28
|
||||
if self._pmb_to_pos then
|
||||
self._pmb_path = astar(p, self._pmb_to_pos, cost, nil)
|
||||
|
@ -239,14 +239,14 @@ function pmb_entity_api.get_default_movement(callable, cost)
|
|||
local last_vel = self.object:get_velocity()
|
||||
self.object:set_velocity(vector.offset(last_vel, 0, -12 * dtime, 0))
|
||||
|
||||
if not self._pmb_path or table.maxn(self._pmb_path) == 0 then
|
||||
if not self._pmb_path or #self._pmb_path == 0 then
|
||||
self._pmb_to_pos = nil
|
||||
return
|
||||
end
|
||||
if pmb_entity_api.min_cost_2d(p, self._pmb_path[1]) < 1.2 then
|
||||
table.remove(self._pmb_path, 1)
|
||||
end
|
||||
if table.maxn(self._pmb_path) == 0 then
|
||||
if #self._pmb_path == 0 then
|
||||
self.object:set_velocity(vector.new(0, last_vel.y, 0))
|
||||
self._pmb_to_pos = nil
|
||||
return
|
||||
|
|
|
@ -3,10 +3,12 @@ minetest.register_entity("pmb_golem:golem", {
|
|||
visual = "mesh",
|
||||
mesh = "golem.b3d",
|
||||
textures = {"golem.png"},
|
||||
use_texture_alpha = true,
|
||||
stepheight = 1,
|
||||
hp_max = 10,
|
||||
physical = true,
|
||||
automatic_face_movement_dir = -90.0,
|
||||
automatic_face_movement_max_rotation_per_sec = 180,
|
||||
},
|
||||
--[[
|
||||
on_activate = function(self, staticdata, dtime)
|
||||
|
|
Loading…
Reference in New Issue