From e707170f6b4f163e31ebf9624aacb43fb2bfb718 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 24 Dec 2013 14:33:13 +0300 Subject: dehardcode pet logic parameters. New pet db parameters: startFollowDistance - distance from pet start follow owner. followDistance - distance on what pet preffer follow owner. --- src/being/being.cpp | 4 ++-- src/resources/beinginfo.cpp | 2 ++ src/resources/beinginfo.h | 14 ++++++++++++++ src/resources/db/petdb.cpp | 5 +++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/being/being.cpp b/src/being/being.cpp index 0b7010789..72d362eea 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -1617,8 +1617,8 @@ void Being::petLogic() return; int dstX = mOwner->getTileX(); int dstY = mOwner->getTileY(); - const int followDist = 3; - const int dist = 1; + const int followDist = mInfo->getStartFollowDist(); + const int dist = mInfo->getFollowDist(); const int divX = abs(dstX - mX); const int divY = abs(dstY - mY); if (divX > followDist || divY > followDist) diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 92169314a..7a8d1e0ce 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -60,6 +60,8 @@ BeingInfo::BeingInfo() : mAvatarId(0), mWidth(0), mHeight(0), + mStartFollowDist(3), + mFollowDist(1), mStaticMaxHP(false), mTargetSelection(true) { diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index 008af8590..a752898f8 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -224,6 +224,18 @@ class BeingInfo final void setHeight(const int n) { mHeight = n; } + void setStartFollowDist(const int n) + { mStartFollowDist = n; } + + int getStartFollowDist() + { return mStartFollowDist; } + + void setFollowDist(const int n) + { mFollowDist = n; } + + int getFollowDist() + { return mFollowDist; } + void setColorsList(const std::string &name); std::string getColor(const int idx) const; @@ -254,6 +266,8 @@ class BeingInfo final uint16_t mAvatarId; int mWidth; int mHeight; + int mStartFollowDist; + int mFollowDist; bool mStaticMaxHP; bool mTargetSelection; }; diff --git a/src/resources/db/petdb.cpp b/src/resources/db/petdb.cpp index 169c8ee39..829da3ef6 100644 --- a/src/resources/db/petdb.cpp +++ b/src/resources/db/petdb.cpp @@ -82,6 +82,11 @@ void PETDB::load() currentInfo->setDeadSortOffsetY(XML::getProperty(petNode, "deadSortOffsetY", 31)); + currentInfo->setStartFollowDist(XML::getProperty(petNode, + "startFollowDistance", 3)); + currentInfo->setFollowDist(XML::getProperty(petNode, + "followDistance", 1)); + SpriteDisplay display; for_each_xml_child_node(spriteNode, petNode) { -- cgit v1.2.3-70-g09d2