Skip to content

Commit 8ae2746

Browse files
committed
fixup pathing issues
1 parent 9370171 commit 8ae2746

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

game/world/objects/npc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,8 @@ bool Npc::implGoTo(uint64_t dt) {
13041304
} else {
13051305
// use smaller threshold, to avoid edge-looping in script
13061306
dist = MoveAlgo::closeToPointThreshold*0.5f;
1307+
if(!mvAlgo.checkLastBounce())
1308+
dist = MoveAlgo::closeToPointThreshold*1.5f;
13071309
if(go2.wp!=nullptr && go2.wp->useCounter()>1)
13081310
dist += 100;
13091311
}

game/world/world.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,12 @@ WayPath World::wayTo(const Npc &npc, const WayPoint &end) const {
849849
auto p = npc.position();
850850

851851
auto begin = npc.currentWayPoint();
852+
if(begin==&end && MoveAlgo::isClose(npc.position(),end)) {
853+
return WayPath();
854+
}
852855
if(begin && !begin->isFreePoint() && MoveAlgo::isClose(npc.position(),*begin)) {
853856
return wmatrix->wayTo(&begin,1,p,end);
854857
}
855-
856858
auto near = wmatrix->findWayPoint(p, [&npc](const WayPoint &wp) {
857859
if(!npc.canSeeNpc(wp.x,wp.y+10,wp.z,true))
858860
return false;
@@ -866,8 +868,11 @@ WayPath World::wayTo(const Npc &npc, const WayPoint &end) const {
866868

867869
std::vector<const WayPoint*> wpoint;
868870
wpoint.push_back(near);
869-
for(auto& i:near->connections())
870-
wpoint.push_back(i.point);
871+
for(auto& i:near->connections()) {
872+
auto p = i.point->position();
873+
if(npc.canSeeNpc(p.x,p.y+10,p.z,true))
874+
wpoint.push_back(i.point);
875+
}
871876

872877
return wmatrix->wayTo(wpoint.data(),wpoint.size(),p,end);
873878
}

0 commit comments

Comments
 (0)