From 2f9fa7415d501337a32111ef123f361cd6d01cab Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 25 Dec 2013 15:28:50 +0300 Subject: add pet think time. New pet db attribute: thinkTime time in milliseconds. also remove extra pet logic calls. --- src/being/being.cpp | 16 ++++++++-------- src/being/being.h | 2 -- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/being') 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() -- cgit v1.2.3-70-g09d2