diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2008-03-09 22:52:34 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2008-03-09 22:52:34 +0000 |
commit | 16e99dc852affbc8b149d35037694dcdd25948e6 (patch) | |
tree | 2fed35187b803d595559b11b89118f7ef335d359 /src/resources/monsterinfo.cpp | |
parent | 4e2ced304a2013808b2481cceb7622848b073e5b (diff) | |
download | mana-16e99dc852affbc8b149d35037694dcdd25948e6.tar.gz mana-16e99dc852affbc8b149d35037694dcdd25948e6.tar.bz2 mana-16e99dc852affbc8b149d35037694dcdd25948e6.tar.xz mana-16e99dc852affbc8b149d35037694dcdd25948e6.zip |
Actions and particle effect for monster attacks are now obtained from the monster database. Added new tail attack animation to scorpion monster sprite.
Diffstat (limited to 'src/resources/monsterinfo.cpp')
-rw-r--r-- | src/resources/monsterinfo.cpp | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp index 0ee08e42..a7ad51a3 100644 --- a/src/resources/monsterinfo.cpp +++ b/src/resources/monsterinfo.cpp @@ -54,16 +54,15 @@ MonsterInfo::addSound(MonsterSoundEvent event, std::string filename) } -std::string +const std::string & MonsterInfo::getSound(MonsterSoundEvent event) const { + static std::string nothing(""); std::map<MonsterSoundEvent, std::vector<std::string>* >::const_iterator i; - i = mSounds.find(event); - if (i == mSounds.end()) { - return ""; + return nothing; } else { @@ -74,14 +73,39 @@ MonsterInfo::getSound(MonsterSoundEvent event) const const std::string & MonsterInfo::getAttackParticleEffect(int attackType) const { - static std::string something("graphics/particles/attack.particle.xml"); static std::string nothing(""); - - if (attackType > 1) return something; else return nothing; + std::map<int, MonsterAttack*>::const_iterator i; + i = mMonsterAttacks.find(attackType); + if (i == mMonsterAttacks.end()) + { + return nothing; + } + else + { + return (*i).second->particleEffect; + } } SpriteAction MonsterInfo::getAttackAction(int attackType) const { - return ACTION_ATTACK; + std::map<int, MonsterAttack*>::const_iterator i; + i = mMonsterAttacks.find(attackType); + if (i == mMonsterAttacks.end()) + { + return ACTION_ATTACK; + } + else + { + return (*i).second->action; + } +} + +void +MonsterInfo::addMonsterAttack (int id, const std::string &particleEffect, SpriteAction action) +{ + MonsterAttack* a = new MonsterAttack; + a->particleEffect = particleEffect; + a->action = action; + mMonsterAttacks[id] = a; } |