summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/resources/monsterdb.cpp11
-rw-r--r--src/resources/monsterinfo.cpp40
-rw-r--r--src/resources/monsterinfo.h13
-rw-r--r--src/resources/spritedef.cpp30
-rw-r--r--src/resources/spritedef.h22
5 files changed, 98 insertions, 18 deletions
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index 84e3a219..fd200e4e 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -26,6 +26,7 @@
#include "monsterdb.h"
#include "resourcemanager.h"
+#include "spritedef.h"
#include "../log.h"
@@ -113,8 +114,7 @@ MonsterDB::load()
{
currentInfo->setSprite((const char*) spriteNode->xmlChildrenNode->content);
}
-
- if (xmlStrEqual(spriteNode->name, BAD_CAST "sound"))
+ else if (xmlStrEqual(spriteNode->name, BAD_CAST "sound"))
{
std::string event = XML::getProperty(spriteNode, "event", "");
const char *filename;
@@ -142,6 +142,13 @@ MonsterDB::load()
filename, event.c_str(), currentInfo->getName().c_str());
}
}
+ else if (xmlStrEqual(spriteNode->name, BAD_CAST "attack"))
+ {
+ int id = XML::getProperty(spriteNode, "id", 0);
+ std::string particleEffect = XML::getProperty(spriteNode, "particle-effect", "");
+ SpriteAction spriteAction = SpriteDef::makeSpriteAction(XML::getProperty(spriteNode, "action", "attack"));
+ currentInfo->addMonsterAttack(id, particleEffect, spriteAction);
+ }
}
mMonsterInfos[XML::getProperty(monsterNode, "id", 0)] = currentInfo;
}
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;
}
diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h
index 3dd18c0f..840f37be 100644
--- a/src/resources/monsterinfo.h
+++ b/src/resources/monsterinfo.h
@@ -39,6 +39,12 @@ enum MonsterSoundEvent
MONSTER_EVENT_DIE
};
+struct MonsterAttack
+{
+ std::string particleEffect;
+ SpriteAction action;
+};
+
/**
* Holds information about a certain type of monster. This includes the name
* of the monster, the sprite to display and the sounds the monster makes.
@@ -80,10 +86,12 @@ class MonsterInfo
Being::TargetCursorSize
getTargetCursorSize() const { return mTargetCursorSize; }
- std::string
+ const std::string&
getSound(MonsterSoundEvent event) const;
- const std::string &
+ void addMonsterAttack (int id, const std::string &particleEffect, SpriteAction action);
+
+ const std::string&
getAttackParticleEffect(int attackType) const;
SpriteAction
@@ -96,6 +104,7 @@ class MonsterInfo
std::string mSprite;
Being::TargetCursorSize mTargetCursorSize;
std::map<MonsterSoundEvent, std::vector<std::string>* > mSounds;
+ std::map<int, MonsterAttack*> mMonsterAttacks;
};
#endif
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index d2e32c03..d8dfb23d 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -350,6 +350,36 @@ SpriteDef::makeSpriteAction(const std::string& action)
else if (action == "attack_throw") {
return ACTION_ATTACK_THROW;
}
+ else if (action == "special0") {
+ return ACTION_SPECIAL_0;
+ }
+ else if (action == "special1") {
+ return ACTION_SPECIAL_1;
+ }
+ else if (action == "special2") {
+ return ACTION_SPECIAL_2;
+ }
+ else if (action == "special3") {
+ return ACTION_SPECIAL_3;
+ }
+ else if (action == "special4") {
+ return ACTION_SPECIAL_4;
+ }
+ else if (action == "special5") {
+ return ACTION_SPECIAL_5;
+ }
+ else if (action == "special6") {
+ return ACTION_SPECIAL_6;
+ }
+ else if (action == "special7") {
+ return ACTION_SPECIAL_7;
+ }
+ else if (action == "special8") {
+ return ACTION_SPECIAL_8;
+ }
+ else if (action == "special9") {
+ return ACTION_SPECIAL_9;
+ }
else if (action == "cast_magic") {
return ACTION_CAST_MAGIC;
}
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index 5eeaf744..65105973 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -45,6 +45,16 @@ enum SpriteAction
ACTION_ATTACK_STAB,
ACTION_ATTACK_BOW,
ACTION_ATTACK_THROW,
+ ACTION_SPECIAL_0,
+ ACTION_SPECIAL_1,
+ ACTION_SPECIAL_2,
+ ACTION_SPECIAL_3,
+ ACTION_SPECIAL_4,
+ ACTION_SPECIAL_5,
+ ACTION_SPECIAL_6,
+ ACTION_SPECIAL_7,
+ ACTION_SPECIAL_8,
+ ACTION_SPECIAL_9,
ACTION_CAST_MAGIC,
ACTION_USE_ITEM,
ACTION_SIT,
@@ -80,6 +90,12 @@ class SpriteDef : public Resource
*/
Action *getAction(SpriteAction action) const;
+ /**
+ * Converts a string into a SpriteAction enum.
+ */
+ static SpriteAction
+ makeSpriteAction(const std::string &action);
+
private:
/**
@@ -130,12 +146,6 @@ class SpriteDef : public Resource
substituteAction(SpriteAction complete, SpriteAction with);
/**
- * Converts a string into a SpriteAction enum.
- */
- static SpriteAction
- makeSpriteAction(const std::string &action);
-
- /**
* Converts a string into a SpriteDirection enum.
*/
static SpriteDirection