mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +02:00
* corrected stack death animation
This commit is contained in:
@ -1169,27 +1169,16 @@ void CBattleInterface::stacksAreAttacked(std::vector<CBattleInterface::SStackAtt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//initializing
|
//initializing
|
||||||
std::map<int, int> animLengths;
|
|
||||||
std::map<int, int> increments;
|
|
||||||
int maxLen = 0;
|
int maxLen = 0;
|
||||||
for(size_t g=0; g<attackedInfos.size(); ++g)
|
for(size_t g=0; g<attackedInfos.size(); ++g)
|
||||||
{
|
{
|
||||||
int animLen;
|
|
||||||
if(attackedInfos[g].killed)
|
if(attackedInfos[g].killed)
|
||||||
{
|
{
|
||||||
creAnims[attackedInfos[g].ID]->setType(5); //death
|
creAnims[attackedInfos[g].ID]->setType(5); //death
|
||||||
animLen = creAnims[attackedInfos[g].ID]->framesInGroup(5);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
creAnims[attackedInfos[g].ID]->setType(3); //getting hit
|
creAnims[attackedInfos[g].ID]->setType(3); //getting hit
|
||||||
animLen = creAnims[attackedInfos[g].ID]->framesInGroup(3);
|
|
||||||
}
|
|
||||||
animLengths.insert(std::make_pair(attackedInfos[g].ID, animLen));
|
|
||||||
increments.insert(std::make_pair(attackedInfos[g].ID, 0));
|
|
||||||
if(animLen > maxLen)
|
|
||||||
{
|
|
||||||
maxLen = animLen;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//main showing loop
|
//main showing loop
|
||||||
@ -1201,18 +1190,17 @@ void CBattleInterface::stacksAreAttacked(std::vector<CBattleInterface::SStackAtt
|
|||||||
SDL_framerateDelay(LOCPLINT->mainFPSmng);
|
SDL_framerateDelay(LOCPLINT->mainFPSmng);
|
||||||
for(size_t g=0; g<attackedInfos.size(); ++g)
|
for(size_t g=0; g<attackedInfos.size(); ++g)
|
||||||
{
|
{
|
||||||
if((animCount+1)%(4/animSpeed)==0 && increments[attackedInfos[g].ID]<animLengths[attackedInfos[g].ID])
|
if((animCount+1)%(4/animSpeed)==0 && !creAnims[attackedInfos[g].ID]->onLastFrameInGroup())
|
||||||
{
|
{
|
||||||
creAnims[attackedInfos[g].ID]->incrementFrame();
|
creAnims[attackedInfos[g].ID]->incrementFrame();
|
||||||
++(increments[attackedInfos[g].ID]);
|
|
||||||
}
|
}
|
||||||
if(increments[attackedInfos[g].ID]>=animLengths[attackedInfos[g].ID] && creAnims[attackedInfos[g].ID]->getType() == 3)
|
if(creAnims[attackedInfos[g].ID]->onLastFrameInGroup() && creAnims[attackedInfos[g].ID]->getType() == 3)
|
||||||
creAnims[attackedInfos[g].ID]->setType(2);
|
creAnims[attackedInfos[g].ID]->setType(2);
|
||||||
}
|
}
|
||||||
bool isAnotherOne = false; //if true, there is a stack whose hit/death anim must be continued
|
bool isAnotherOne = false; //if true, there is a stack whose hit/death anim must be continued
|
||||||
for(size_t g=0; g<attackedInfos.size(); ++g)
|
for(size_t g=0; g<attackedInfos.size(); ++g)
|
||||||
{
|
{
|
||||||
if(increments[attackedInfos[g].ID] < animLengths[attackedInfos[g].ID] - 1)
|
if(!creAnims[attackedInfos[g].ID]->onLastFrameInGroup())
|
||||||
{
|
{
|
||||||
isAnotherOne = true;
|
isAnotherOne = true;
|
||||||
break;
|
break;
|
||||||
|
@ -137,6 +137,13 @@ int CCreatureAnimation::getFrame() const
|
|||||||
return curFrame;
|
return curFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CCreatureAnimation::onLastFrameInGroup()
|
||||||
|
{
|
||||||
|
if(internalFrame == frameGroups[type].size() - 1)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CCreatureAnimation::playOnce(int type)
|
void CCreatureAnimation::playOnce(int type)
|
||||||
{
|
{
|
||||||
setType(type);
|
setType(type);
|
||||||
|
@ -50,6 +50,7 @@ public:
|
|||||||
int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
||||||
void incrementFrame();
|
void incrementFrame();
|
||||||
int getFrame() const;
|
int getFrame() const;
|
||||||
|
bool onLastFrameInGroup();
|
||||||
|
|
||||||
bool once;
|
bool once;
|
||||||
void playOnce(int type); //plays once given stage of animation, then resets to 2
|
void playOnce(int type); //plays once given stage of animation, then resets to 2
|
||||||
|
Reference in New Issue
Block a user