diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-12-25 15:55:09 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-12-25 16:02:01 +0300 |
commit | 63446aa820db2a6ad83cb25c64a013e9e1418bd5 (patch) | |
tree | d5560ce9dfacd56a3609abef097abef68b7debca /src/being | |
parent | 2f9fa7415d501337a32111ef123f361cd6d01cab (diff) | |
download | manaverse-63446aa820db2a6ad83cb25c64a013e9e1418bd5.tar.gz manaverse-63446aa820db2a6ad83cb25c64a013e9e1418bd5.tar.bz2 manaverse-63446aa820db2a6ad83cb25c64a013e9e1418bd5.tar.xz manaverse-63446aa820db2a6ad83cb25c64a013e9e1418bd5.zip |
add direction logic to pets.
New pet db attribute: directionType
Possible values: 0 - not change direction.
1 - use same direction as owner.
2 - always look to owner.
3 - always look outside from owner.
Diffstat (limited to 'src/being')
-rw-r--r-- | src/being/being.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index bbf011a68..235bd6455 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -1708,7 +1708,47 @@ void Being::petLogic() { setPath(mMap->findPath(mX, mY, dstX, dstY, walkMask)); Net::getPetHandler()->move(mOwner, mX, mY, dstX, dstY); + return; + } + } + if (mAction == STAND) + { + const int directionType = mInfo->getDirectionType(); + int newDir = 0; + switch (directionType) + { + case 0: + default: + return; + + case 1: + newDir = mOwner->getDirection(); + break; + + case 2: + if (dstX > dstX0) + newDir |= LEFT; + else if (dstX < dstX0) + newDir |= RIGHT; + if (dstY > dstY0) + newDir != UP; + else if (dstY < dstY0) + newDir != DOWN; + break; + + case 3: + if (dstX > dstX0) + newDir |= RIGHT; + else if (dstX < dstX0) + newDir |= LEFT; + if (dstY > dstY0) + newDir != DOWN; + else if (dstY < dstY0) + newDir != UP; + break; } + if (newDir && newDir != getDirection()) + setDirection(newDir); } } |