From 8e5861c3cfd41574351547a1a518efcf9007666a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 23 Nov 2011 04:40:34 +0300 Subject: Add ability to play different animation depend on monster hp. Disabled for legacy servers because monster hp unknown and compilated hp can be wrong (version <= 0). For usage need add to action tag attribute hp="xx" Example: ... Here 50 mean 50% of health or less. Default action tag mean hp=100 --- src/animatedsprite.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/animatedsprite.cpp') diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index c1f1cac85..4143cb47a 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -42,7 +42,9 @@ AnimatedSprite::AnimatedSprite(SpriteDef *sprite): mSprite(sprite), mAction(nullptr), mAnimation(nullptr), - mFrame(nullptr) + mFrame(nullptr), + mNumber(100), + mNumber1(100) { mAlpha = 1.0f; @@ -51,6 +53,7 @@ AnimatedSprite::AnimatedSprite(SpriteDef *sprite): mSprite->incRef(); // Play the stand animation by default + //+++ need get num? play(SpriteAction::STAND); } @@ -90,7 +93,7 @@ bool AnimatedSprite::play(std::string spriteAction) if (!mSprite) return false; - Action *action = mSprite->getAction(spriteAction); + Action *action = mSprite->getAction(spriteAction, mNumber); if (!action) return false; @@ -313,3 +316,19 @@ void *AnimatedSprite::getHash() // return mAnimation; return this; } + +bool AnimatedSprite::updateNumber(unsigned num) +{ + if (mNumber1 != num) + { + mNumber1 = num; + mNumber = mSprite->findNumber(num); + if (!mNumber) + { + mNumber = 100; + return false; + } + return true; + } + return false; +} -- cgit v1.2.3-60-g2f50