Only loop NPC movement if the NPC has a looping path assigned

Allows paths to terminate.
Also fixes a bug where follower NPCs sometimes oscillate their positions.
This commit is contained in:
gsemaj
2021-05-09 08:37:36 -04:00
parent e5d9e7217e
commit 6f59001be1
5 changed files with 14 additions and 4 deletions

View File

@@ -310,10 +310,9 @@ static void stepNPCPathing() {
}
/*
* Move processed point to the back to maintain cycle, unless this is a
* dynamically calculated mob route.
* If this path should be repeated, move processed point to the back to maintain cycle.
*/
if (!(npc->type == EntityType::MOB && !((Mob*)npc)->staticPath))
if (npc->loopingPath)
queue->push(point);
it++; // go to next entry in map
@@ -388,6 +387,7 @@ void Transport::constructPathNPC(int32_t id, NPCPath* path) {
BaseNPC* npc = NPCManager::NPCs[id];
if (npc->type == EntityType::MOB)
((Mob*)(npc))->staticPath = true;
npc->loopingPath = path->isLoop;
// Interpolate
std::vector<Vec3> pathPoints = path->points;