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/being | |
parent | 3e43345f804886a3a6ed7c0e378612612de4f4a5 (diff) | |
download | mv-2f9fa7415d501337a32111ef123f361cd6d01cab.tar.gz mv-2f9fa7415d501337a32111ef123f361cd6d01cab.tar.bz2 mv-2f9fa7415d501337a32111ef123f361cd6d01cab.tar.xz mv-2f9fa7415d501337a32111ef123f361cd6d01cab.zip |
add pet think time.
New pet db attribute: thinkTime
time in milliseconds.
also remove extra pet logic calls.
Diffstat (limited to 'src/being')
-rw-r--r-- | src/being/being.cpp | 16 | ||||
-rw-r--r-- | src/being/being.h | 2 |
2 files changed, 8 insertions, 10 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() |