diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-05-17 19:16:11 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-05-17 21:49:16 -0600 |
commit | 3b4e7795c9ab3036988a1a7dfe6f5ed2ad12199d (patch) | |
tree | ed0e8cc5b608c31ac79e6d1de03d9ddfc74fa339 /src/resources/monsterdb.cpp | |
parent | 51945aa1af6f2a6dc15027ef40cf0ccf424d46e1 (diff) | |
download | mana-client-3b4e7795c9ab3036988a1a7dfe6f5ed2ad12199d.tar.gz mana-client-3b4e7795c9ab3036988a1a7dfe6f5ed2ad12199d.tar.bz2 mana-client-3b4e7795c9ab3036988a1a7dfe6f5ed2ad12199d.tar.xz mana-client-3b4e7795c9ab3036988a1a7dfe6f5ed2ad12199d.zip |
Remove Monster, Player, and NPC classes
Instead of having these three subclasses with minor differences, this
commit merges them back into Being. In the future, we can make Beings
that are talkable to some, attackable by others, etc. This also puts
back support for monster equipment.
Also changes remaining references to Being::Type and the constants to
refer to ActorSprite::Type.
Reviewed-by: Freeyorp
Diffstat (limited to 'src/resources/monsterdb.cpp')
-rw-r--r-- | src/resources/monsterdb.cpp | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 658321f1..c70cee94 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -23,7 +23,7 @@ #include "log.h" -#include "resources/monsterinfo.h" +#include "resources/beinginfo.h" #include "utils/dtor.h" #include "utils/gettext.h" @@ -35,8 +35,7 @@ namespace { - MonsterDB::MonsterInfos mMonsterInfos; - MonsterInfo mUnknown; + BeingInfos mMonsterInfos; bool mLoaded = false; } @@ -45,17 +44,6 @@ void MonsterDB::load() if (mLoaded) return; - { - SpriteReference *unknownSprite = new SpriteReference; - unknownSprite->sprite = "error.xml"; - unknownSprite->variant = 0; - - SpriteDisplay display; - display.sprites.push_front(unknownSprite); - - mUnknown.setDisplay(display); - } - logger->log("Initializing monster database..."); XML::Document doc("monsters.xml"); @@ -77,7 +65,12 @@ void MonsterDB::load() continue; } - MonsterInfo *currentInfo = new MonsterInfo; + BeingInfo *currentInfo = new BeingInfo; + + currentInfo->setWalkMask(Map::BLOCKMASK_WALL + | Map::BLOCKMASK_CHARACTER + | Map::BLOCKMASK_MONSTER); + currentInfo->setBlockType(Map::BLOCKTYPE_MONSTER); currentInfo->setName(XML::getProperty(monsterNode, "name", _("unnamed"))); @@ -85,22 +78,22 @@ void MonsterDB::load() targetCursor = XML::getProperty(monsterNode, "targetCursor", "medium"); if (targetCursor == "small") { - currentInfo->setTargetCursorSize(Being::TC_SMALL); + currentInfo->setTargetCursorSize(ActorSprite::TC_SMALL); } else if (targetCursor == "medium") { - currentInfo->setTargetCursorSize(Being::TC_MEDIUM); + currentInfo->setTargetCursorSize(ActorSprite::TC_MEDIUM); } else if (targetCursor == "large") { - currentInfo->setTargetCursorSize(Being::TC_LARGE); + currentInfo->setTargetCursorSize(ActorSprite::TC_LARGE); } else { logger->log("MonsterDB: Unknown target cursor type \"%s\" for %s -" "using medium sized one", targetCursor.c_str(), currentInfo->getName().c_str()); - currentInfo->setTargetCursorSize(Being::TC_MEDIUM); + currentInfo->setTargetCursorSize(ActorSprite::TC_MEDIUM); } SpriteDisplay display; @@ -123,19 +116,19 @@ void MonsterDB::load() if (event == "hit") { - currentInfo->addSound(MONSTER_EVENT_HIT, filename); + currentInfo->addSound(SOUND_EVENT_HIT, filename); } else if (event == "miss") { - currentInfo->addSound(MONSTER_EVENT_MISS, filename); + currentInfo->addSound(SOUND_EVENT_MISS, filename); } else if (event == "hurt") { - currentInfo->addSound(MONSTER_EVENT_HURT, filename); + currentInfo->addSound(SOUND_EVENT_HURT, filename); } else if (event == "die") { - currentInfo->addSound(MONSTER_EVENT_DIE, filename); + currentInfo->addSound(SOUND_EVENT_DIE, filename); } else { @@ -154,7 +147,8 @@ void MonsterDB::load() XML::getProperty(spriteNode, "action", "attack")); const std::string missileParticle = XML::getProperty( spriteNode, "missile-particle", ""); - currentInfo->addMonsterAttack(id, particleEffect, spriteAction, missileParticle); + currentInfo->addAttack(id, spriteAction, + particleEffect, missileParticle); } else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx")) { @@ -179,17 +173,17 @@ void MonsterDB::unload() } -const MonsterInfo &MonsterDB::get(int id) +BeingInfo *MonsterDB::get(int id) { - MonsterInfoIterator i = mMonsterInfos.find(id); + BeingInfoIterator i = mMonsterInfos.find(id); if (i == mMonsterInfos.end()) { logger->log("MonsterDB: Warning, unknown monster ID %d requested", id); - return mUnknown; + return BeingInfo::Unknown; } else { - return *(i->second); + return i->second; } } |