From 1821dfad294c0d850be326639946b12cdbdcecaf Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 24 Dec 2013 14:47:11 +0300 Subject: Check collision in pet follow logic. --- src/being/being.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/being') diff --git a/src/being/being.cpp b/src/being/being.cpp index 72d362eea..39cf09741 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -1615,8 +1615,10 @@ void Being::petLogic() { if (!mOwner || !mMap || !mInfo) return; - int dstX = mOwner->getTileX(); - int dstY = mOwner->getTileY(); + const int dstX0 = mOwner->getTileX(); + const int dstY0 = mOwner->getTileY(); + int dstX = dstX0; + int dstY = dstY0; const int followDist = mInfo->getStartFollowDist(); const int dist = mInfo->getFollowDist(); const int divX = abs(dstX - mX); @@ -1647,7 +1649,23 @@ void Being::petLogic() dstY = mY; } - setPath(mMap->findPath(mX, mY, dstX, dstY, getWalkMask())); + const int walkMask = getWalkMask(); + if (!mMap->getWalk(dstX, dstY, walkMask)) + { + if (dstX != dstX0) + { + dstX = dstX0; + if (!mMap->getWalk(dstX, dstY, walkMask)) + dstY = dstY0; + } + else if (dstY != dstY0) + { + dstY = dstY0; + if (!mMap->getWalk(dstX, dstY, walkMask)) + dstX = dstX0; + } + } + setPath(mMap->findPath(mX, mY, dstX, dstY, walkMask)); } } -- cgit v1.2.3-70-g09d2