diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2008-02-06 16:36:57 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2008-02-06 16:36:57 +0000 |
commit | 983a8587fedec18e08a1d032a76784d8f9a18085 (patch) | |
tree | 6bf142c63b37f85cc1191c0c265cbc35274d7e54 /src/game-server/monstermanager.cpp | |
parent | aa603c3ec05f6143b1c9085b56e3becf45be4bf5 (diff) | |
download | manaserv-983a8587fedec18e08a1d032a76784d8f9a18085.tar.gz manaserv-983a8587fedec18e08a1d032a76784d8f9a18085.tar.bz2 manaserv-983a8587fedec18e08a1d032a76784d8f9a18085.tar.xz manaserv-983a8587fedec18e08a1d032a76784d8f9a18085.zip |
Monster base attributes are now read from monsters.xml.
Diffstat (limited to 'src/game-server/monstermanager.cpp')
-rw-r--r-- | src/game-server/monstermanager.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/game-server/monstermanager.cpp b/src/game-server/monstermanager.cpp index efdb4420..2d59d690 100644 --- a/src/game-server/monstermanager.cpp +++ b/src/game-server/monstermanager.cpp @@ -104,6 +104,7 @@ void MonsterManager::reload() } MonsterDrops drops; + bool attributesSet = false; for (xmlNodePtr subnode = node->xmlChildrenNode; subnode != NULL; subnode = subnode->next) @@ -118,9 +119,36 @@ void MonsterManager::reload() drops.push_back(drop); } } + else if (xmlStrEqual(subnode->name, BAD_CAST "attributes")) + { + attributesSet = true; + monster->setAttribute(BASE_ATTR_HP, XML::getProperty(subnode, "hp", -1)); + monster->setAttribute(BASE_ATTR_PHY_ATK_MIN, XML::getProperty(subnode, "attack-min", -1)); + monster->setAttribute(BASE_ATTR_PHY_ATK_DELTA, XML::getProperty(subnode, "attack-delta", -1)); + monster->setAttribute(BASE_ATTR_MAG_ATK, XML::getProperty(subnode, "attack-magic", -1)); + monster->setAttribute(BASE_ATTR_EVADE, XML::getProperty(subnode, "evade", -1)); + monster->setAttribute(BASE_ATTR_HIT, XML::getProperty(subnode, "hit", -1)); + monster->setAttribute(BASE_ATTR_PHY_RES, XML::getProperty(subnode, "physical-defence", -1)); + monster->setAttribute(BASE_ATTR_MAG_RES, XML::getProperty(subnode, "magical-defence", -1)); + // TODO: speed + // TODO: size + + //check for completeness + bool attributesComplete = true; + for (int i = BASE_ATTR_BEGIN; i < BASE_ATTR_END; i++) + { + if (monster->getAttribute(i) == -1) + { + attributesComplete = false; + monster->setAttribute(i, 0); + } + } + if (!attributesComplete) LOG_WARN(monsterReferenceFile<<": Attributes incomplete for monster #"<<id); + } } monster->setDrops(drops); + if (!attributesSet) LOG_WARN(monsterReferenceFile<<": No attributes defined for monster #"<<id); ++nbMonsters; } |