diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/being/being.cpp | 40 | ||||
-rw-r--r-- | src/resources/beinginfo.h | 7 | ||||
-rw-r--r-- | src/resources/db/petdb.cpp | 2 |
3 files changed, 49 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); } } diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index 9e0e88112..c1d53ccde 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -266,6 +266,12 @@ class BeingInfo final int getThinkTime() const A_WARN_UNUSED { return mThinkTime; } + void setDirectionType(const int n) + { mDirectionType = n; } + + int getDirectionType() const A_WARN_UNUSED + { return mDirectionType; } + void setColorsList(const std::string &name); std::string getColor(const int idx) const A_WARN_UNUSED; @@ -303,6 +309,7 @@ class BeingInfo final int mSitOffsetX; int mSitOffsetY; int mThinkTime; + int mDirectionType; bool mStaticMaxHP; bool mTargetSelection; }; diff --git a/src/resources/db/petdb.cpp b/src/resources/db/petdb.cpp index 5f52602fa..072dad7c0 100644 --- a/src/resources/db/petdb.cpp +++ b/src/resources/db/petdb.cpp @@ -103,6 +103,8 @@ void PETDB::load() currentInfo->setThinkTime(XML::getProperty(petNode, "thinkTime", 500) / 10); + currentInfo->setDirectionType(XML::getProperty(petNode, + "directionType", 1)); SpriteDisplay display; for_each_xml_child_node(spriteNode, petNode) |