mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Support for combat spell sounds.
This commit is contained in:
parent
bbf4394ecc
commit
1f337764bd
@ -1794,11 +1794,16 @@ void CBattleInterface::battleFinished(const BattleResult& br)
|
||||
|
||||
void CBattleInterface::spellCast(SpellCast * sc)
|
||||
{
|
||||
CSpell &spell = CGI->spellh->spells[sc->id];
|
||||
|
||||
if(sc->side == !LOCPLINT->cb->battleGetStackByID(activeStack)->attackerOwned)
|
||||
bSpell->block(true);
|
||||
|
||||
std::vector< std::string > anims; //for magic arrow and ice bolt
|
||||
|
||||
if (spell.soundID != soundBase::invalid)
|
||||
CGI->audioh->playSound(spell.soundID);
|
||||
|
||||
switch(sc->id)
|
||||
{
|
||||
case 15: //magic arrow
|
||||
@ -1861,9 +1866,9 @@ void CBattleInterface::spellCast(SpellCast * sc)
|
||||
}
|
||||
case 17: //lightning bolt
|
||||
displayEffect(1, sc->tile);
|
||||
displayEffect(CGI->spellh->spells[sc->id].mainEffectAnim, sc->tile);
|
||||
displayEffect(spell.mainEffectAnim, sc->tile);
|
||||
case 35: //dispel
|
||||
displayEffect(CGI->spellh->spells[sc->id].mainEffectAnim, sc->tile);
|
||||
displayEffect(spell.mainEffectAnim, sc->tile);
|
||||
} //switch(sc->id)
|
||||
}
|
||||
|
||||
|
1
CMT.cpp
1
CMT.cpp
@ -130,6 +130,7 @@ int main(int argc, char** argv)
|
||||
initDLL(::console,logfile);
|
||||
CGI->setFromLib();
|
||||
cgi->audioh->initCreaturesSounds(CGI->creh->creatures);
|
||||
cgi->audioh->initSpellsSounds(CGI->spellh->spells);
|
||||
tlog0<<"Initializing VCMI_Lib: "<<tmh.getDif()<<std::endl;
|
||||
pomtime.getDif();
|
||||
cgi->curh = new CCursorHandler;
|
||||
|
57
config/sp_sounds.txt
Normal file
57
config/sp_sounds.txt
Normal file
@ -0,0 +1,57 @@
|
||||
# Sounds associated with spells
|
||||
# Format is <spell number> <sound file name>
|
||||
|
||||
15 MAGICBLT.wav # magic arrow
|
||||
16 ICERAY.wav # ice bolt
|
||||
17 LIGHTBLT.wav # lightning bolt
|
||||
#18 # implosion
|
||||
20 FROSTING.wav # frost ring
|
||||
21 FIREBALL.wav # fireball
|
||||
#22 # inferno
|
||||
23 METEOR.wav # meteor shower
|
||||
24 DEATHRIP.wav # death ripple
|
||||
#25 # destroy undead
|
||||
26 ARMGEDN.wav # armageddon
|
||||
27 SHIELD.wav # shield
|
||||
28 AIRSHELD.wav # air shield
|
||||
30 PROTECTA.wav # protection from air
|
||||
31 PROTECTF.wav # protection from fire
|
||||
32 PROTECTW.wav # protection from water
|
||||
33 PROTECTE.wav # protection from earth
|
||||
41 BLESS.wav # bless
|
||||
42 CURSE.wav # curse
|
||||
43 BLOODLUS.wav # bloodlust
|
||||
44 PRECISON.wav # precision
|
||||
45 WEAKNESS.wav # weakness
|
||||
46 TUFFSKIN.wav # stone skin
|
||||
47 DISRUPTR.wav # disrupting ray
|
||||
48 PRAYER.wav # prayer
|
||||
49 MIRTH.wav # mirth
|
||||
50 SORROW.wav # sorrow
|
||||
51 FORTUNE.wav # fortune
|
||||
52 MISFORT.wav # misfortune
|
||||
53 HASTE.wav # haste
|
||||
54 MUCKMIRE.wav # slow
|
||||
55 SLAYER.wav # slayer
|
||||
56 FRENZY.wav # frenzy
|
||||
61 FORGET.wav # forgetfulness
|
||||
|
||||
|
||||
|
||||
|
||||
#BLIND.wav
|
||||
#POISON.wav
|
||||
#CURE.wav
|
||||
#HYPNOTIZ.wav
|
||||
#DEATHCLD.wav
|
||||
#DEATHBLO.wav
|
||||
#DRAINLIF.wav
|
||||
#DRGNSLAY.wav
|
||||
#DISPELL.wav
|
||||
#DISGUISE.wav
|
||||
#DISEASE.wav
|
||||
#QUIKSAND.wav
|
||||
#FIRESHIE.wav fireshield when cast
|
||||
#FIRESHLD.wav fireshield effect
|
||||
#ANIMDEAD.wav
|
||||
#ANTIMAGK.wav
|
@ -10,6 +10,7 @@
|
||||
#include "CSndHandler.h"
|
||||
#include "CMusicHandler.h"
|
||||
#include "CCreatureHandler.h"
|
||||
#include "CSpellHandler.h"
|
||||
#include "../CGameInfo.h"
|
||||
|
||||
/*
|
||||
@ -169,6 +170,34 @@ void CSoundHandler::initCreaturesSounds(std::vector<CCreature> &creatures)
|
||||
}
|
||||
}
|
||||
|
||||
void CSoundHandler::initSpellsSounds(std::vector<CSpell> &spells)
|
||||
{
|
||||
tlog5 << "\t\tReading config/sp_sounds.txt" << std::endl;
|
||||
std::ifstream ifs("config/sp_sounds.txt");
|
||||
std::string line;
|
||||
|
||||
while(getline(ifs, line))
|
||||
{
|
||||
int spellid;
|
||||
std::string soundfile="";
|
||||
std::stringstream str(line);
|
||||
|
||||
str >> spellid >> soundfile;
|
||||
|
||||
if (str.good() || (str.eof() && soundfile != ""))
|
||||
{
|
||||
CSpell &s = CGI->spellh->spells[spellid];
|
||||
|
||||
if (s.soundID != soundBase::invalid)
|
||||
tlog1 << "Spell << " << spellid << " already has a sound" << std::endl;
|
||||
|
||||
s.soundID = getSoundID(soundfile);
|
||||
}
|
||||
}
|
||||
ifs.close();
|
||||
ifs.clear();
|
||||
}
|
||||
|
||||
// Plays a sound, and return its channel so we can fade it out later
|
||||
int CSoundHandler::playSound(soundBase::soundID soundID, int repeats)
|
||||
{
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
class CSndHandler;
|
||||
class CSpell;
|
||||
struct _Mix_Music;
|
||||
typedef struct _Mix_Music Mix_Music;
|
||||
struct Mix_Chunk;
|
||||
@ -39,6 +40,7 @@ public:
|
||||
void initSounds();
|
||||
void freeSounds();
|
||||
void initCreaturesSounds(std::vector<CCreature> &creatures);
|
||||
void initSpellsSounds(std::vector<CSpell> &spells);
|
||||
|
||||
// Sounds
|
||||
int playSound(soundBase::soundID soundID, int repeats=0);
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "../stdafx.h"
|
||||
#include "CSpellHandler.h"
|
||||
#include "CLodHandler.h"
|
||||
#include "CSoundBase.h"
|
||||
#include "../lib/VCMI_Lib.h"
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <cctype>
|
||||
@ -256,6 +257,7 @@ void CSpellHandler::loadSpells()
|
||||
nsp.combatSpell = combSpells;
|
||||
nsp.creatureAbility = creatureAbility;
|
||||
nsp.mainEffectAnim = -1;
|
||||
nsp.soundID = soundBase::invalid;
|
||||
spells.push_back(nsp);
|
||||
}
|
||||
//loading of additional spell traits
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include "CSoundBase.h"
|
||||
|
||||
/*
|
||||
* CSpellHandler.h, part of VCMI engine
|
||||
*
|
||||
@ -39,6 +41,7 @@ public:
|
||||
std::vector<std::string> range; //description of spell's range in SRSL by magic school level
|
||||
std::set<ui16> rangeInHexes(unsigned int centralHex, ui8 schoolLvl ) const; //convert range to specific hexes
|
||||
si16 mainEffectAnim; //main spell effect animation, in AC format (or -1 when none)
|
||||
soundBase::soundID soundID; // spell sound id
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user