Mobs: Fix climbing failure if starting upwards

This commit is contained in:
Wuzzy 2024-04-04 15:59:32 +02:00
parent 82269b611d
commit b54c5ff9fb

View File

@ -90,7 +90,6 @@ rp_mobs.microtasks.follow_path_climb = function(path, walk_speed, climb_speed, s
local mtask = {}
mtask.label = "follow climb path"
mtask.on_start = function(self, mob)
self.statedata.walking = false
self.statedata.stop = false
self.statedata.success = true
@ -194,7 +193,7 @@ rp_mobs.microtasks.follow_path_climb = function(path, walk_speed, climb_speed, s
vel.y = -climb_speed
end
-- Walk to target
-- Walk/climb to target
local dir_next_pos = table.copy(next_pos)
dir_next_pos.y = mob_pos.y
local hdir = vector.direction(mob_pos, dir_next_pos)
@ -204,10 +203,8 @@ rp_mobs.microtasks.follow_path_climb = function(path, walk_speed, climb_speed, s
vel.x = hvel.x
vel.z = hvel.z
mob.object:set_velocity(vel)
self.statedata.walking = true
rp_mobs.set_animation(mob, anim_walk or "walk")
else
if self.statedata.walking ~= false then
vel.x = 0
vel.z = 0
mob.object:set_velocity(vel)
@ -215,7 +212,6 @@ rp_mobs.microtasks.follow_path_climb = function(path, walk_speed, climb_speed, s
rp_mobs.set_animation(mob, anim_idle or "idle")
end
end
end
mtask.is_finished = function(self, mob)
-- Finish if aborted or path is gone or empty
if self.statedata.stop or not self.statedata.path or #self.statedata.path == 0 then