summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-12-24 14:47:11 +0300
committerAndrei Karas <akaras@inbox.ru>2013-12-24 14:47:11 +0300
commit1821dfad294c0d850be326639946b12cdbdcecaf (patch)
tree998b1e22b6c2d7e96b722fd17c0094e135afc7dc /src
parente707170f6b4f163e31ebf9624aacb43fb2bfb718 (diff)
downloadplus-1821dfad294c0d850be326639946b12cdbdcecaf.tar.gz
plus-1821dfad294c0d850be326639946b12cdbdcecaf.tar.bz2
plus-1821dfad294c0d850be326639946b12cdbdcecaf.tar.xz
plus-1821dfad294c0d850be326639946b12cdbdcecaf.zip
Check collision in pet follow logic.
Diffstat (limited to 'src')
-rw-r--r--src/being/being.cpp24
1 files changed, 21 insertions, 3 deletions
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));
}
}