diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-05-08 00:06:32 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-08-26 22:56:46 +0200 |
commit | 68481094c0d02ba127bcab6c692801b01a27f21b (patch) | |
tree | aad235cc104f2a2445bab9f8e0d274ad89969cf4 /src/game-server/monstermanager.cpp | |
parent | f31277b327df701361391b1d4b8bd6f89f4e3109 (diff) | |
download | manaserv-68481094c0d02ba127bcab6c692801b01a27f21b.tar.gz manaserv-68481094c0d02ba127bcab6c692801b01a27f21b.tar.bz2 manaserv-68481094c0d02ba127bcab6c692801b01a27f21b.tar.xz manaserv-68481094c0d02ba127bcab6c692801b01a27f21b.zip |
[Abilities] Added abilities to monsters
Monsters can now either receive abilities at lifetime via scripts, or
via the <ability> node in the monsters node.
Diffstat (limited to 'src/game-server/monstermanager.cpp')
-rw-r--r-- | src/game-server/monstermanager.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/game-server/monstermanager.cpp b/src/game-server/monstermanager.cpp index df8c6906..19e196e2 100644 --- a/src/game-server/monstermanager.cpp +++ b/src/game-server/monstermanager.cpp @@ -216,6 +216,50 @@ void MonsterManager::readMonsterNode(xmlNodePtr node, const std::string &filenam } } + else if (xmlStrEqual(subnode->name, BAD_CAST "attribute")) + { + const int id = XML::getProperty(subnode, "id", 0); + auto *attributeInfo = attributeManager->getAttributeInfo(id); + + if (!attributeInfo) + { + LOG_WARN(filename + << ": Invalid attribute id " << id + << " for monster Id: " << id + << ". Skipping!"); + continue; + } + + const double value = XML::getFloatProperty(subnode, "value", 0.0); + + monster->setAttribute(id, value); + } + else if (xmlStrEqual(subnode->name, BAD_CAST "ability")) + { + const std::string idText = XML::getProperty(subnode, "id", + std::string()); + AbilityManager::AbilityInfo *info = 0; + if (utils::isNumeric(idText)) + { + const int id = utils::stringToInt(idText); + info = abilityManager->getAbilityInfo(id); + } + else + { + info = abilityManager->getAbilityInfo(idText); + } + + if (!info) + { + LOG_WARN(filename + << ": Invalid ability id " << idText + << " for monster id: " << id + << " Skipping!"); + continue; + } + + monster->addAbility(info); + } else if (xmlStrEqual(subnode->name, BAD_CAST "exp")) { xmlChar *exp = subnode->xmlChildrenNode->content; |