summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2007-07-11 12:58:11 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2007-07-11 12:58:11 +0000
commit84aafd27dad40f4033561052164c21fe68cf78ad (patch)
tree77fb9224634f95b1ede62c6605976feb4ee9455b /src/resources
parent8dd7eef0402cc6e22642f045e3cfde7f5b011d5b (diff)
downloadmana-client-84aafd27dad40f4033561052164c21fe68cf78ad.tar.gz
mana-client-84aafd27dad40f4033561052164c21fe68cf78ad.tar.bz2
mana-client-84aafd27dad40f4033561052164c21fe68cf78ad.tar.xz
mana-client-84aafd27dad40f4033561052164c21fe68cf78ad.zip
Weapon sprites are now (almost) threated like other equipment sprites through the equipment sprite database. (use -u to ignore updates)
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/equipmentdb.cpp46
-rw-r--r--src/resources/equipmentinfo.h34
-rw-r--r--src/resources/monsterdb.cpp8
-rw-r--r--src/resources/monsterinfo.cpp6
-rw-r--r--src/resources/monsterinfo.h16
5 files changed, 77 insertions, 33 deletions
diff --git a/src/resources/equipmentdb.cpp b/src/resources/equipmentdb.cpp
index 64982ce3..9b963720 100644
--- a/src/resources/equipmentdb.cpp
+++ b/src/resources/equipmentdb.cpp
@@ -81,26 +81,46 @@ EquipmentDB::load()
EquipmentInfo *currentInfo = new EquipmentInfo();
currentInfo->setSlot (XML::getProperty(equipmentNode, "slot", 0));
+ currentInfo->setAttackType (XML::getProperty(equipmentNode, "attacktype", ""));
- //iterate <sprite>s
+ //iterate <sprite>s and <sound>s
for_each_xml_child_node(spriteNode, equipmentNode)
{
- if (!xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
+ if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
{
- continue;
+ std::string gender = XML::getProperty(spriteNode, "gender", "unisex");
+ std::string filename = (const char*) spriteNode->xmlChildrenNode->content;
+
+ if (gender == "male" || gender == "unisex")
+ {
+ currentInfo->setSprite(filename, 0);
+ }
+
+ if (gender == "female" || gender == "unisex")
+ {
+ currentInfo->setSprite(filename, 1);
+ }
}
- std::string gender = XML::getProperty(spriteNode, "gender", "unisex");
- std::string filename = (const char*) spriteNode->xmlChildrenNode->content;
-
- if (gender == "male" || gender == "unisex")
- {
- currentInfo->setSprite(filename, 0);
- }
-
- if (gender == "female" || gender == "unisex")
+ if (xmlStrEqual(spriteNode->name, BAD_CAST "sound"))
{
- currentInfo->setSprite(filename, 1);
+ std::string event = XML::getProperty(spriteNode, "event", "");
+ const char *filename;
+ filename = (const char*) spriteNode->xmlChildrenNode->content;
+
+ if (event == "hit")
+ {
+ currentInfo->addSound(EQUIP_EVENT_HIT, filename);
+ }
+ else if (event == "strike")
+ {
+ currentInfo->addSound(EQUIP_EVENT_STRIKE, filename);
+ }
+ else
+ {
+ logger->log("EquipmentDB: Warning, sound effect %s for unknown event %s",
+ filename, event.c_str());
+ }
}
}
diff --git a/src/resources/equipmentinfo.h b/src/resources/equipmentinfo.h
index 93a1cb42..5cd0643b 100644
--- a/src/resources/equipmentinfo.h
+++ b/src/resources/equipmentinfo.h
@@ -24,29 +24,53 @@
#ifndef _TMW_EQUIPMENTINFO_H_
#define _TMW_EQUIPMENTINFO_H_
-#include <string>
#include <map>
+#include <string>
+#include <vector>
+
+#include "spritedef.h"
+
+enum EquipmentSoundEvent
+{
+ EQUIP_EVENT_STRIKE,
+ EQUIP_EVENT_HIT
+};
class EquipmentInfo
{
public:
EquipmentInfo():
- mSlot (0)
+ mSlot (0),
+ mAttackType(ACTION_DEFAULT)
{
};
void
- setSlot (int slot) { mSlot = slot; };
+ setSlot (int slot) { mSlot = slot; }
const std::string&
- getSprite(int gender) {return animationFiles[gender]; };
+ getSprite(int gender) {return animationFiles[gender]; }
void
- setSprite(std::string animationFile, int gender) {animationFiles[gender] = animationFile; };
+ setSprite(std::string animationFile, int gender) {animationFiles[gender] = animationFile; }
+
+ void
+ setAttackType(std::string attackType);
+
+ const SpriteAction
+ getAttackType() { return mAttackType; }
+
+ void
+ addSound(EquipmentSoundEvent event, std::string filename);
+
+ std::string
+ getSound(EquipmentSoundEvent event) const;
private:
int mSlot; //not used at the moment but maybe useful on our own server
+ SpriteAction mAttackType;
std::map<int, std::string> animationFiles;
+ std::map<EquipmentSoundEvent, std::vector<std::string>* > mSounds;
};
#endif
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index 89afc549..2ea9aebe 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -120,19 +120,19 @@ MonsterDB::load()
if (event == "hit")
{
- currentInfo->addSound(EVENT_HIT, filename);
+ currentInfo->addSound(MONSTER_EVENT_HIT, filename);
}
else if (event == "miss")
{
- currentInfo->addSound(EVENT_MISS, filename);
+ currentInfo->addSound(MONSTER_EVENT_MISS, filename);
}
else if (event == "hurt")
{
- currentInfo->addSound(EVENT_HURT, filename);
+ currentInfo->addSound(MONSTER_EVENT_HURT, filename);
}
else if (event == "die")
{
- currentInfo->addSound(EVENT_DIE, filename);
+ currentInfo->addSound(MONSTER_EVENT_DIE, filename);
}
else
{
diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp
index 43aac32a..b5fe3d29 100644
--- a/src/resources/monsterinfo.cpp
+++ b/src/resources/monsterinfo.cpp
@@ -41,7 +41,7 @@ MonsterInfo::~MonsterInfo()
void
-MonsterInfo::addSound (SoundEvent event, std::string filename)
+MonsterInfo::addSound (MonsterSoundEvent event, std::string filename)
{
if (mSounds.find(event) == mSounds.end())
{
@@ -53,9 +53,9 @@ MonsterInfo::addSound (SoundEvent event, std::string filename)
std::string
-MonsterInfo::getSound (SoundEvent event) const
+MonsterInfo::getSound (MonsterSoundEvent event) const
{
- std::map<SoundEvent, std::vector<std::string>* >::const_iterator i;
+ std::map<MonsterSoundEvent, std::vector<std::string>* >::const_iterator i;
i = mSounds.find(event);
diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h
index 5a820659..7613fee2 100644
--- a/src/resources/monsterinfo.h
+++ b/src/resources/monsterinfo.h
@@ -31,12 +31,12 @@
#include "../being.h"
-enum SoundEvent
+enum MonsterSoundEvent
{
- EVENT_HIT,
- EVENT_MISS,
- EVENT_HURT,
- EVENT_DIE
+ MONSTER_EVENT_HIT,
+ MONSTER_EVENT_MISS,
+ MONSTER_EVENT_HURT,
+ MONSTER_EVENT_DIE
};
/**
@@ -69,7 +69,7 @@ class MonsterInfo
{ mTargetCursorSize = targetCursorSize; }
void
- addSound(SoundEvent event, std::string filename);
+ addSound(MonsterSoundEvent event, std::string filename);
const std::string&
getName() const { return mName; }
@@ -81,13 +81,13 @@ class MonsterInfo
getTargetCursorSize() const { return mTargetCursorSize; }
std::string
- getSound(SoundEvent event) const;
+ getSound(MonsterSoundEvent event) const;
private:
std::string mName;
std::string mSprite;
Being::TargetCursorSize mTargetCursorSize;
- std::map<SoundEvent, std::vector<std::string>* > mSounds;
+ std::map<MonsterSoundEvent, std::vector<std::string>* > mSounds;
};
#endif