summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2008-02-06 22:15:39 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2008-02-06 22:15:39 +0000
commitd4ad5de48f7f1e2a84bccd68b2584ce78fed05a4 (patch)
tree488cee232ba62465fb200814bca1514e97fa9667 /src
parent402484c66f2cb4036e1af4bbda6345d8d79ecb41 (diff)
downloadmanaserv-d4ad5de48f7f1e2a84bccd68b2584ce78fed05a4.tar.gz
manaserv-d4ad5de48f7f1e2a84bccd68b2584ce78fed05a4.tar.bz2
manaserv-d4ad5de48f7f1e2a84bccd68b2584ce78fed05a4.tar.xz
manaserv-d4ad5de48f7f1e2a84bccd68b2584ce78fed05a4.zip
Exp reward for killing monsters is now read from monster database.
Diffstat (limited to 'src')
-rw-r--r--src/game-server/monster.cpp4
-rw-r--r--src/game-server/monster.hpp19
-rw-r--r--src/game-server/monstermanager.cpp11
3 files changed, 28 insertions, 6 deletions
diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp
index 3e92e85b..efbd02c4 100644
--- a/src/game-server/monster.cpp
+++ b/src/game-server/monster.cpp
@@ -82,7 +82,6 @@ Monster::Monster(MonsterClass *specy):
mAttackAngle = 10;
setSpeed(300);
setSize(8);
- mExpReward = 100;
// Set positions relative to target from which the monster can attack
mAttackPositions.push_back(AttackPosition(+32, 0, DIRECTION_LEFT));
@@ -332,7 +331,8 @@ void Monster::died()
std::map<Character *, std::set <size_t> > ::iterator iChar;
std::set<size_t>::iterator iSkill;
- float expPerChar = mExpReward / mExpReceivers.size();
+
+ float expPerChar = (float)mSpecy->getExp() / mExpReceivers.size();
for (iChar = mExpReceivers.begin(); iChar != mExpReceivers.end(); iChar++)
{
diff --git a/src/game-server/monster.hpp b/src/game-server/monster.hpp
index c6d43589..f5c7c18f 100644
--- a/src/game-server/monster.hpp
+++ b/src/game-server/monster.hpp
@@ -49,7 +49,7 @@ typedef std::vector< MonsterDrop > MonsterDrops;
class MonsterClass
{
public:
- MonsterClass(int id): mID(id), mAttributes(BASE_ATTR_NB, 0) {}
+ MonsterClass(int id): mID(id), mAttributes(BASE_ATTR_NB, 0), mExp(-1) {}
/**
* Gets monster type.
@@ -76,6 +76,18 @@ class MonsterClass
{ return mAttributes.at(attribute); }
/**
+ * Sets exp reward for killing the monster
+ */
+ void setExp(int exp)
+ { mExp = exp; }
+
+ /**
+ * Gets exp reward for killing the monster
+ */
+ int getExp() const
+ { return mExp; }
+
+ /**
* Randomly selects a monster drop (may return NULL).
* TODO: pass some luck modifier as an argument.
*/
@@ -85,6 +97,7 @@ class MonsterClass
unsigned short mID; /**< ID of the monster class. */
MonsterDrops mDrops; /**< Items the monster drops when dying. */
std::vector<int> mAttributes; /**< Base attributes of the monster*/
+ int mExp; /**< Exp reward for killing the monster */
};
/**
@@ -169,9 +182,7 @@ class Monster : public Being
int mAttackTime; /**< Delay until monster can attack */
// TODO: the following vars should all be the same for all monsters of
- // the same type. So they should be put into some central data structure
- // to save memory.
- int mExpReward; /**< Exp reward for defeating the monster */
+ // the same type. So they should be stored in mSpecy to save memory
int mAttackPreDelay; /**< time between decision to make an attack and performing the attack */
int mAttackAftDelay; /**< time it takes to perform an attack */
int mAttackRange; /**< range of the monsters attacks in pixel */
diff --git a/src/game-server/monstermanager.cpp b/src/game-server/monstermanager.cpp
index 58c146c3..f613969d 100644
--- a/src/game-server/monstermanager.cpp
+++ b/src/game-server/monstermanager.cpp
@@ -154,12 +154,23 @@ void MonsterManager::reload()
if (!attributesComplete) LOG_WARN(monsterReferenceFile
<<": Attributes incomplete for monster #"<<id);
}
+ else if (xmlStrEqual(subnode->name, BAD_CAST "exp"))
+ {
+ xmlChar *exp = subnode->xmlChildrenNode->content;
+ monster->setExp(atoi((const char*)exp));
+ }
}
monster->setDrops(drops);
if (!attributesSet) LOG_WARN(monsterReferenceFile
<<": No attributes defined for monster #"
<<id);
+ if (monster->getExp() == -1)
+ {
+ LOG_WARN(monsterReferenceFile
+ <<": No experience defined for monster #"<<id);
+ monster->setExp(0);
+ }
++nbMonsters;
}