summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game-server/monster.cpp6
-rw-r--r--src/game-server/monster.hpp7
2 files changed, 12 insertions, 1 deletions
diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp
index 2412c849..4df000ed 100644
--- a/src/game-server/monster.cpp
+++ b/src/game-server/monster.cpp
@@ -96,7 +96,11 @@ Monster::Monster(MonsterClass *specy):
it2 != it2_end;
++it2)
{
- double attr = specy->getAttribute(it2->first);
+ double attr = 0.0f;
+
+ if (specy->hasAttribute(it2->first))
+ attr = specy->getAttribute(it2->first);
+
setAttribute(it2->first,
mutation ?
attr * (100 + (rand()%(mutation << 1)) - mutation) / 100.0 :
diff --git a/src/game-server/monster.hpp b/src/game-server/monster.hpp
index 0d5d9688..b25e9c17 100644
--- a/src/game-server/monster.hpp
+++ b/src/game-server/monster.hpp
@@ -107,6 +107,13 @@ class MonsterClass
double getAttribute(int attribute) const
{ return mAttributes.at(attribute); }
+ /**
+ * Returns whether the monster has got the attribute.
+ */
+ bool hasAttribute(int attribute) const
+ { return (mAttributes.find(attribute) != mAttributes.end()); }
+
+
/** Sets collision circle radius. */
void setSize(int size) { mSize = size; }