diff options
author | David Athay <ko2fan@gmail.com> | 2008-08-29 09:32:39 +0000 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2008-08-29 09:32:39 +0000 |
commit | 970b31227bde94f92af392870fc91844f063f167 (patch) | |
tree | b5568efe8ac1a7516bad164c2d02dea41eb9a3a4 | |
parent | 250fd9d43087d6798e3c2dbb2efa566fefcbebeb (diff) | |
download | mana-0.0.26.tar.gz mana-0.0.26.tar.bz2 mana-0.0.26.tar.xz mana-0.0.26.zip |
#406 by jaxad0127v0.0.26
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/monster.cpp | 29 | ||||
-rw-r--r-- | src/resources/monsterdb.cpp | 4 | ||||
-rw-r--r-- | src/resources/monsterinfo.cpp | 3 | ||||
-rw-r--r-- | src/resources/monsterinfo.h | 8 |
5 files changed, 35 insertions, 15 deletions
@@ -1,3 +1,9 @@ +2008-08-29 David Athay <ko2fan@gmail.com> + + * src/monster.cpp, src/resources/monsterinfo.h, + src/resources/monsterdb.cpp, src/resources/monsterinfo.cpp: Mantis #406 + by jaxad0127 to implement layered sprites. + 2008-08-28 Douglas Boffey <DougABoffey@netscape.net> * src/localplayer.cpp, src/text.h, src/gui/viewport.cpp, src/npc.cpp, diff --git a/src/monster.cpp b/src/monster.cpp index bea37b3f..d7a2add1 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -45,15 +45,24 @@ Monster::Monster(Uint32 id, Uint16 job, Map *map): { const MonsterInfo& info = MonsterDB::get(job - 1002); - std::string filename = info.getSprite(); - if (filename != "") + // Setup Monster sprites + int c = BASE_SPRITE; + const std::list<std::string> &sprites = info.getSprites(); + for (std::list<std::string>::const_iterator i = sprites.begin(); + i != sprites.end(); + i++) { - mSprites[BASE_SPRITE] = AnimatedSprite::load( - "graphics/sprites/" + filename); + if (c == VECTOREND_SPRITE) break; + + std::string file = "graphics/sprites/" + *i; + mSprites[c] = AnimatedSprite::load(file); + c++; } - else + + // Ensure that something is shown + if (c == BASE_SPRITE) { - mSprites[BASE_SPRITE] = AnimatedSprite::load("graphics/sprites/error.xml"); + mSprites[c] = AnimatedSprite::load("graphics/sprites/error.xml"); } const std::list<std::string> &particleEffects = info.getParticleEffects(); @@ -124,7 +133,13 @@ Monster::setAction(Uint8 action) if (currentAction != ACTION_INVALID) { - mSprites[BASE_SPRITE]->play(currentAction); + for (int i = 0; i < VECTOREND_SPRITE; i++) + { + if (mSprites[i]) + { + mSprites[i]->play(currentAction); + } + } mAction = action; } } diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 0a98762f..bf2878bc 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -45,7 +45,7 @@ MonsterDB::load() if (mLoaded) return; - mUnknown.setSprite("error.xml"); + mUnknown.addSprite("error.xml"); mUnknown.setName("unnamed"); logger->log("Initializing monster database..."); @@ -96,7 +96,7 @@ MonsterDB::load() { if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) { - currentInfo->setSprite((const char*) spriteNode->xmlChildrenNode->content); + currentInfo->addSprite((const char*) spriteNode->xmlChildrenNode->content); } if (xmlStrEqual(spriteNode->name, BAD_CAST "sound")) diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp index 8238dc3e..e492ccd3 100644 --- a/src/resources/monsterinfo.cpp +++ b/src/resources/monsterinfo.cpp @@ -27,8 +27,7 @@ #include "../utils/dtor.h" -MonsterInfo::MonsterInfo(): - mSprite("error.xml") +MonsterInfo::MonsterInfo() { } diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h index d9d17510..2f690756 100644 --- a/src/resources/monsterinfo.h +++ b/src/resources/monsterinfo.h @@ -63,7 +63,7 @@ class MonsterInfo setName(std::string name) { mName = name; } void - setSprite(std::string filename) { mSprite = filename; } + addSprite(std::string filename) { mSprites.push_back(filename); } void setTargetCursorSize(Being::TargetCursorSize targetCursorSize) @@ -78,8 +78,8 @@ class MonsterInfo const std::string& getName() const { return mName; } - const std::string& - getSprite() const { return mSprite; } + const std::list<std::string>& + getSprites() const { return mSprites; } Being::TargetCursorSize getTargetCursorSize() const { return mTargetCursorSize; } @@ -92,7 +92,7 @@ class MonsterInfo private: std::string mName; - std::string mSprite; + std::list<std::string> mSprites; Being::TargetCursorSize mTargetCursorSize; std::map<MonsterSoundEvent, std::vector<std::string>* > mSounds; std::list<std::string> mParticleEffects; |