mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
Fixed bug 143 and possibly 142.
This commit is contained in:
parent
a2861a82d2
commit
c2cb7be227
@ -461,13 +461,13 @@ bool CDefenceAnim::init()
|
||||
|
||||
if(killed)
|
||||
{
|
||||
CGI->soundh->playSound(attacked->creature->sounds.killed);
|
||||
CGI->soundh->playSound(battle_sound(attacked->creature, killed));
|
||||
owner->creAnims[stackID]->setType(5); //death
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: this block doesn't seems correct if the unit is defending.
|
||||
CGI->soundh->playSound(attacked->creature->sounds.wince);
|
||||
CGI->soundh->playSound(battle_sound(attacked->creature, wince));
|
||||
owner->creAnims[stackID]->setType(3); //getting hit
|
||||
}
|
||||
|
||||
@ -566,7 +566,7 @@ bool CBattleStackMoved::init()
|
||||
//unit reversed
|
||||
|
||||
if(owner->moveSh <= 0)
|
||||
owner->moveSh = CGI->soundh->playSound(movedStack->creature->sounds.move, -1);
|
||||
owner->moveSh = CGI->soundh->playSound(battle_sound(movedStack->creature, move), -1);
|
||||
|
||||
//step shift calculation
|
||||
posX = owner->creAnims[stackID]->pos.x, posY = owner->creAnims[stackID]->pos.y; // for precise calculations ;]
|
||||
@ -682,8 +682,7 @@ bool CBattleMoveStart::init()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (movedStack->creature->sounds.startMoving)
|
||||
CGI->soundh->playSound(movedStack->creature->sounds.startMoving);
|
||||
CGI->soundh->playSound(battle_sound(movedStack->creature, startMoving));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -728,11 +727,7 @@ bool CBattleMoveEnd::init()
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (movedStack->creature->sounds.endMoving)
|
||||
{
|
||||
CGI->soundh->playSound(movedStack->creature->sounds.endMoving);
|
||||
}
|
||||
CGI->soundh->playSound(battle_sound(movedStack->creature, endMoving));
|
||||
|
||||
owner->creAnims[stackID]->setType(21);
|
||||
|
||||
@ -779,15 +774,16 @@ void CBattleAttack::nextFrame()
|
||||
// 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(attackingStack->creature->sounds.shoot);
|
||||
if (sh == -1) {
|
||||
sh = CGI->soundh->playSound(battle_sound(attackingStack->creature, shoot));
|
||||
}
|
||||
owner->creAnims[stackID]->setType(group);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: see comment above
|
||||
if (sh == -1)
|
||||
sh = CGI->soundh->playSound(attackingStack->creature->sounds.attack);
|
||||
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
|
||||
@ -4039,4 +4035,4 @@ CStackQueue::StackBox::~StackBox()
|
||||
void CStackQueue::StackBox::hover( bool on )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -202,16 +202,6 @@ void CCreatureHandler::loadCreatures()
|
||||
CCreature ncre;
|
||||
ncre.cost.resize(RESOURCE_QUANTITY);
|
||||
ncre.level=0;
|
||||
ncre.sounds.attack = soundBase::invalid;
|
||||
ncre.sounds.defend = soundBase::invalid;
|
||||
ncre.sounds.killed = soundBase::invalid;
|
||||
ncre.sounds.move = soundBase::invalid;
|
||||
ncre.sounds.shoot = soundBase::invalid;
|
||||
ncre.sounds.wince = soundBase::invalid;
|
||||
ncre.sounds.ext1 = soundBase::invalid;
|
||||
ncre.sounds.ext2 = soundBase::invalid;
|
||||
ncre.sounds.startMoving = soundBase::invalid;
|
||||
ncre.sounds.endMoving = soundBase::invalid;
|
||||
|
||||
int befi=i;
|
||||
for(i; i<andame; ++i)
|
||||
|
@ -45,26 +45,6 @@ public:
|
||||
int troopCountLocationOffset, attackClimaxFrame;
|
||||
///end of anim info
|
||||
|
||||
// Sound infos
|
||||
class sounds {
|
||||
public:
|
||||
soundBase::soundID attack;
|
||||
soundBase::soundID defend;
|
||||
soundBase::soundID killed; // was killed died
|
||||
soundBase::soundID move;
|
||||
soundBase::soundID shoot; // range attack
|
||||
soundBase::soundID wince; // attacked but did not die
|
||||
soundBase::soundID ext1; // creature specific extension
|
||||
soundBase::soundID ext2; // creature specific extension
|
||||
soundBase::soundID startMoving; // usually same as ext1
|
||||
soundBase::soundID endMoving; // usually same as ext2
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & attack & defend & killed & move & shoot & wince & ext1 & ext2 & startMoving & endMoving;
|
||||
}
|
||||
} sounds;
|
||||
|
||||
bool isDoubleWide() const; //returns true if unit is double wide on battlefield
|
||||
bool isFlying() const; //returns true if it is a flying unit
|
||||
bool isShooting() const; //returns true if unit can shoot
|
||||
@ -95,8 +75,6 @@ public:
|
||||
& timeBetweenFidgets & walkAnimationTime & attackAnimationTime & flightAnimationDistance
|
||||
& upperRightMissleOffsetX & rightMissleOffsetX & lowerRightMissleOffsetX & upperRightMissleOffsetY & rightMissleOffsetY & lowerRightMissleOffsetY
|
||||
& missleFrameAngles & troopCountLocationOffset & attackClimaxFrame;
|
||||
|
||||
h & sounds;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -154,6 +154,8 @@ void CSoundHandler::initCreaturesSounds(std::vector<CCreature> &creatures)
|
||||
std::ifstream ifs(DATA_DIR "/config/cr_sounds.txt");
|
||||
std::string line;
|
||||
|
||||
CBattleSounds.resize(creatures.size());
|
||||
|
||||
while(getline(ifs, line))
|
||||
{
|
||||
std::string cname="", attack="", defend="", killed="", move="",
|
||||
@ -179,27 +181,25 @@ void CSoundHandler::initCreaturesSounds(std::vector<CCreature> &creatures)
|
||||
continue;
|
||||
}
|
||||
|
||||
CCreature &c = creatures[id];
|
||||
|
||||
if (c.sounds.killed != soundBase::invalid)
|
||||
if (CBattleSounds[id].killed != soundBase::invalid)
|
||||
tlog1 << "Creature << " << cname << " already has sounds" << std::endl;
|
||||
|
||||
c.sounds.attack = getSoundID(attack);
|
||||
c.sounds.defend = getSoundID(defend);
|
||||
c.sounds.killed = getSoundID(killed);
|
||||
c.sounds.move = getSoundID(move);
|
||||
c.sounds.shoot = getSoundID(shoot);
|
||||
c.sounds.wince = getSoundID(wince);
|
||||
c.sounds.ext1 = getSoundID(ext1);
|
||||
c.sounds.ext2 = getSoundID(ext2);
|
||||
CBattleSounds[id].attack = getSoundID(attack);
|
||||
CBattleSounds[id].defend = getSoundID(defend);
|
||||
CBattleSounds[id].killed = getSoundID(killed);
|
||||
CBattleSounds[id].move = getSoundID(move);
|
||||
CBattleSounds[id].shoot = getSoundID(shoot);
|
||||
CBattleSounds[id].wince = getSoundID(wince);
|
||||
CBattleSounds[id].ext1 = getSoundID(ext1);
|
||||
CBattleSounds[id].ext2 = getSoundID(ext2);
|
||||
|
||||
// Special creatures
|
||||
if (c.idNumber == 55 || // Archdevil
|
||||
c.idNumber == 62 || // Vampire
|
||||
c.idNumber == 62) // Vampire Lord
|
||||
if (id == 55 || // Archdevil
|
||||
id == 62 || // Vampire
|
||||
id == 62) // Vampire Lord
|
||||
{
|
||||
c.sounds.startMoving = c.sounds.ext1;
|
||||
c.sounds.endMoving = c.sounds.ext2;
|
||||
CBattleSounds[id].startMoving = CBattleSounds[id].ext1;
|
||||
CBattleSounds[id].endMoving = CBattleSounds[id].ext2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,32 @@ struct _Mix_Music;
|
||||
typedef struct _Mix_Music Mix_Music;
|
||||
struct Mix_Chunk;
|
||||
|
||||
|
||||
// Sound infos for creatures in combat
|
||||
struct CreaturesBattleSounds {
|
||||
soundBase::soundID attack;
|
||||
soundBase::soundID defend;
|
||||
soundBase::soundID killed; // was killed or died
|
||||
soundBase::soundID move;
|
||||
soundBase::soundID shoot; // range attack
|
||||
soundBase::soundID wince; // attacked but did not die
|
||||
soundBase::soundID ext1; // creature specific extension
|
||||
soundBase::soundID ext2; // creature specific extension
|
||||
soundBase::soundID startMoving; // usually same as ext1
|
||||
soundBase::soundID endMoving; // usually same as ext2
|
||||
|
||||
CreaturesBattleSounds(): attack(soundBase::invalid),
|
||||
defend(soundBase::invalid),
|
||||
killed(soundBase::invalid),
|
||||
move(soundBase::invalid),
|
||||
shoot(soundBase::invalid),
|
||||
wince(soundBase::invalid),
|
||||
ext1(soundBase::invalid),
|
||||
ext2(soundBase::invalid),
|
||||
startMoving(soundBase::invalid),
|
||||
endMoving(soundBase::invalid) {};
|
||||
};
|
||||
|
||||
class CAudioBase {
|
||||
protected:
|
||||
bool initialized;
|
||||
@ -61,12 +87,16 @@ public:
|
||||
int playSound(soundBase::soundID soundID, int repeats=0);
|
||||
int playSoundFromSet(std::vector<soundBase::soundID> &sound_vec);
|
||||
void stopSound(int handler);
|
||||
std::vector <struct CreaturesBattleSounds> CBattleSounds;
|
||||
|
||||
// Sets
|
||||
std::vector<soundBase::soundID> pickupSounds;
|
||||
std::vector<soundBase::soundID> horseSounds;
|
||||
};
|
||||
|
||||
// Helper
|
||||
#define battle_sound(creature,what_sound) CGI->soundh->CBattleSounds[(creature)->idNumber].what_sound
|
||||
|
||||
class CMusicHandler: public CAudioBase
|
||||
{
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user