mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-28 03:57:02 +02:00
Restores attacking and shooting sounds.
This commit is contained in:
parent
c2cb7be227
commit
17a795015a
@ -765,38 +765,12 @@ void CBattleAttack::nextFrame()
|
|||||||
if(owner->creAnims[stackID]->getType() != group)
|
if(owner->creAnims[stackID]->getType() != group)
|
||||||
owner->creAnims[stackID]->setType(group);
|
owner->creAnims[stackID]->setType(group);
|
||||||
|
|
||||||
if(owner->creAnims[stackID]->getFrame() == 0)
|
if(owner->creAnims[stackID]->onFirstFrameInGroup())
|
||||||
{
|
{
|
||||||
if(shooting)
|
if(shooting)
|
||||||
{
|
CGI->soundh->playSound(battle_sound(attackingStack->creature, shoot));
|
||||||
// TODO: I see that we enter this function twice with
|
|
||||||
// attackingInfo->frame==0, so all the inits are done
|
|
||||||
// twice. The following is just a workaround until
|
|
||||||
// that is fixed. Once done, we can get rid of
|
|
||||||
// sh
|
|
||||||
if (sh == -1) {
|
|
||||||
sh = CGI->soundh->playSound(battle_sound(attackingStack->creature, shoot));
|
|
||||||
}
|
|
||||||
owner->creAnims[stackID]->setType(group);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
CGI->soundh->playSound(battle_sound(attackingStack->creature, attack));
|
||||||
// TODO: see comment above
|
|
||||||
if (sh == -1)
|
|
||||||
sh = CGI->soundh->playSound(battle_sound(attackingStack->creature, attack));
|
|
||||||
|
|
||||||
static std::map<int, int> dirToType = boost::assign::map_list_of (0, 11)(1, 11)(2, 12)(3, 13)(4, 13)(5, 12);
|
|
||||||
int type; //dependent on attack direction
|
|
||||||
if(attackingStack->hasFeatureOfType(StackFeature::DOUBLE_WIDE))
|
|
||||||
{
|
|
||||||
type = dirToType[ BattleInfo::mutualPosition(attackingStackPosBeforeReturn + posShiftDueToDist, dest) ]; //attack direction
|
|
||||||
}
|
|
||||||
else //else for if(aStack->hasFeatureOfType(StackFeature::DOUBLE_WIDE))
|
|
||||||
{
|
|
||||||
type = BattleInfo::mutualPosition(attackingStackPosBeforeReturn, dest);
|
|
||||||
}
|
|
||||||
owner->creAnims[stackID]->setType(type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(owner->creAnims[stackID]->onLastFrameInGroup())
|
else if(owner->creAnims[stackID]->onLastFrameInGroup())
|
||||||
{
|
{
|
||||||
@ -812,7 +786,7 @@ bool CBattleAttack::checkInitialConditions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CBattleAttack::CBattleAttack(CBattleInterface * _owner, int _stackID, int _dest)
|
CBattleAttack::CBattleAttack(CBattleInterface * _owner, int _stackID, int _dest)
|
||||||
: CBattleStackAnimation(_owner, _stackID), sh(-1), dest(_dest)
|
: CBattleStackAnimation(_owner, _stackID), dest(_dest)
|
||||||
{
|
{
|
||||||
attackedStack = LOCPLINT->cb->battleGetStackByPos(_dest, false);
|
attackedStack = LOCPLINT->cb->battleGetStackByPos(_dest, false);
|
||||||
attackingStack = LOCPLINT->cb->battleGetStackByID(_stackID, false);
|
attackingStack = LOCPLINT->cb->battleGetStackByID(_stackID, false);
|
||||||
|
@ -179,7 +179,6 @@ protected:
|
|||||||
int posShiftDueToDist;
|
int posShiftDueToDist;
|
||||||
bool shooting;
|
bool shooting;
|
||||||
int group; //if shooting is true, print this animation group
|
int group; //if shooting is true, print this animation group
|
||||||
int sh; // temporary sound handler
|
|
||||||
const CStack * attackedStack;
|
const CStack * attackedStack;
|
||||||
const CStack * attackingStack;
|
const CStack * attackingStack;
|
||||||
int attackingStackPosBeforeReturn; //for stacks with return_after_strike feature
|
int attackingStackPosBeforeReturn; //for stacks with return_after_strike feature
|
||||||
|
@ -153,6 +153,11 @@ int CCreatureAnimation::getFrame() const
|
|||||||
return curFrame;
|
return curFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CCreatureAnimation::onFirstFrameInGroup()
|
||||||
|
{
|
||||||
|
return internalFrame == 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool CCreatureAnimation::onLastFrameInGroup()
|
bool CCreatureAnimation::onLastFrameInGroup()
|
||||||
{
|
{
|
||||||
if(internalFrame == frameGroups[type].size() - 1)
|
if(internalFrame == frameGroups[type].size() - 1)
|
||||||
|
@ -59,6 +59,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 onFirstFrameInGroup();
|
||||||
bool onLastFrameInGroup();
|
bool onLastFrameInGroup();
|
||||||
|
|
||||||
bool once;
|
bool once;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user