summaryrefslogtreecommitdiff
path: root/src/resources/monsterinfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources/monsterinfo.cpp')
-rw-r--r--src/resources/monsterinfo.cpp53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp
index 725e9cf5..06a6d3b6 100644
--- a/src/resources/monsterinfo.cpp
+++ b/src/resources/monsterinfo.cpp
@@ -1,9 +1,8 @@
/*
- * Aethyra
+ * The Mana World
* Copyright (C) 2004 The Mana World Development Team
*
- * This file is part of Aethyra based on original code
- * from The Mana World.
+ * This file is part of The Mana World.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,13 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "monsterinfo.h"
+#include "resources/monsterinfo.h"
-#include "../utils/dtor.h"
+#include "utils/dtor.h"
MonsterInfo::MonsterInfo()
{
-
}
MonsterInfo::~MonsterInfo()
@@ -36,7 +34,7 @@ MonsterInfo::~MonsterInfo()
mSounds.clear();
}
-void MonsterInfo::addSound(MonsterSoundEvent event, std::string filename)
+void MonsterInfo::addSound(MonsterSoundEvent event, const std::string &filename)
{
if (mSounds.find(event) == mSounds.end())
{
@@ -46,24 +44,41 @@ void MonsterInfo::addSound(MonsterSoundEvent event, std::string filename)
mSounds[event]->push_back("sfx/" + filename);
}
+const std::string &MonsterInfo::getSound(MonsterSoundEvent event) const
+{
+ static std::string empty("");
+ std::map<MonsterSoundEvent, std::vector<std::string>* >::const_iterator i =
+ mSounds.find(event);
+ return (i == mSounds.end()) ? empty :
+ i->second->at(rand() % i->second->size());
+}
-std::string MonsterInfo::getSound(MonsterSoundEvent event) const
+const std::string &MonsterInfo::getAttackParticleEffect(int attackType) const
{
- std::map<MonsterSoundEvent, std::vector<std::string>* >::const_iterator i;
+ static std::string empty("");
+ std::map<int, MonsterAttack*>::const_iterator i =
+ mMonsterAttacks.find(attackType);
+ return (i == mMonsterAttacks.end()) ? empty : (*i).second->particleEffect;
+}
- i = mSounds.find(event);
+SpriteAction MonsterInfo::getAttackAction(int attackType) const
+{
+ std::map<int, MonsterAttack*>::const_iterator i =
+ mMonsterAttacks.find(attackType);
+ return (i == mMonsterAttacks.end()) ? ACTION_ATTACK : (*i).second->action;
+}
- if (i == mSounds.end())
- {
- return "";
- }
- else
- {
- return i->second->at(rand()%i->second->size());
- }
+void MonsterInfo::addMonsterAttack(int id,
+ const std::string &particleEffect,
+ SpriteAction action)
+{
+ MonsterAttack *a = new MonsterAttack;
+ a->particleEffect = particleEffect;
+ a->action = action;
+ mMonsterAttacks[id] = a;
}
-void MonsterInfo::addParticleEffect(std::string filename)
+void MonsterInfo::addParticleEffect(const std::string &filename)
{
mParticleEffects.push_back(filename);
}