diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-12-25 15:28:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-12-25 15:30:08 +0300 |
commit | 2f9fa7415d501337a32111ef123f361cd6d01cab (patch) | |
tree | bff64eaa4f5db487187f6b604db9ce0317746a16 /src | |
parent | 3e43345f804886a3a6ed7c0e378612612de4f4a5 (diff) | |
download | manaverse-2f9fa7415d501337a32111ef123f361cd6d01cab.tar.gz manaverse-2f9fa7415d501337a32111ef123f361cd6d01cab.tar.bz2 manaverse-2f9fa7415d501337a32111ef123f361cd6d01cab.tar.xz manaverse-2f9fa7415d501337a32111ef123f361cd6d01cab.zip |
add pet think time.
New pet db attribute: thinkTime
time in milliseconds.
also remove extra pet logic calls.
Diffstat (limited to 'src')
-rw-r--r-- | src/being/being.cpp | 16 | ||||
-rw-r--r-- | src/being/being.h | 2 | ||||
-rw-r--r-- | src/net/ea/beinghandler.cpp | 1 | ||||
-rw-r--r-- | src/net/eathena/beinghandler.cpp | 1 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 1 | ||||
-rw-r--r-- | src/resources/beinginfo.h | 7 | ||||
-rw-r--r-- | src/resources/db/petdb.cpp | 2 |
7 files changed, 17 insertions, 13 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index e93675e5a..bbf011a68 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -1337,8 +1337,6 @@ void Being::setDirection(const uint8_t direction) if (mAnimationEffect) mAnimationEffect->setSpriteDirection(dir); recalcSpritesOrder(); - if (mPet) - mPet->petLogic(); } uint8_t Being::calcDirection() const @@ -1633,6 +1631,14 @@ void Being::petLogic() { if (!mOwner || !mMap || !mInfo) return; + + const int time = tick_time; + const int thinkTime = mInfo->getThinkTime(); + if (abs(mMoveTime - time) < thinkTime) + return; + + mMoveTime = time; + const int dstX0 = mOwner->getTileX(); const int dstY0 = mOwner->getTileY(); int dstX = dstX0; @@ -3190,12 +3196,6 @@ void Being::updatePets() } } -void Being::updatePet() -{ - if (mPet) - mPet->petLogic(); -} - void Being::fixPetSpawnPos(int &dstX, int &dstY) const { if (!mInfo || !mOwner) diff --git a/src/being/being.h b/src/being/being.h index 99e9dda45..e8bc7da37 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -881,8 +881,6 @@ class Being : public ActorSprite, public ConfigListener void updatePets(); - void updatePet(); - void fixPetSpawnPos(int &dstX, int &dstY) const; Being *getPet() diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 3fbfdd2d7..0a864bbac 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -515,7 +515,6 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) const if (srcBeing) { srcBeing->setAction(Being::SIT, 0); - srcBeing->updatePet(); if (srcBeing->getType() == Being::PLAYER) { srcBeing->setMoveTime(); diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 196196a07..108e6b50f 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -586,7 +586,6 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, case 2: dstBeing->setAction(Being::SIT, 0); - dstBeing->updatePet(); player_node->imitateAction(dstBeing, Being::SIT); break; diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index de2a25946..cfb25fa49 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -612,7 +612,6 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, case 2: dstBeing->setAction(Being::SIT, 0); - dstBeing->updatePet(); player_node->imitateAction(dstBeing, Being::SIT); break; diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index 769f796f6..9e0e88112 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -260,6 +260,12 @@ class BeingInfo final int getSitOffsetY() const A_WARN_UNUSED { return mSitOffsetY; } + void setThinkTime(const int n) + { mThinkTime = n; } + + int getThinkTime() const A_WARN_UNUSED + { return mThinkTime; } + void setColorsList(const std::string &name); std::string getColor(const int idx) const A_WARN_UNUSED; @@ -296,6 +302,7 @@ class BeingInfo final int mWalkSpeed; int mSitOffsetX; int mSitOffsetY; + int mThinkTime; bool mStaticMaxHP; bool mTargetSelection; }; diff --git a/src/resources/db/petdb.cpp b/src/resources/db/petdb.cpp index 7c84b006b..5f52602fa 100644 --- a/src/resources/db/petdb.cpp +++ b/src/resources/db/petdb.cpp @@ -101,6 +101,8 @@ void PETDB::load() currentInfo->setSitOffsetY(XML::getProperty(petNode, "sitOffsetY", 1)); + currentInfo->setThinkTime(XML::getProperty(petNode, + "thinkTime", 500) / 10); SpriteDisplay display; for_each_xml_child_node(spriteNode, petNode) |