summaryrefslogtreecommitdiff
path: root/src/game-server/monster.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2008-02-13 22:24:27 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2008-02-13 22:24:27 +0000
commita3e91f58e3aac2c35f70a74187fa2c242e59a647 (patch)
tree03343668f1dc0c023b3ec256b9f6571056deaf8a /src/game-server/monster.cpp
parentf1c364583bc647e7697e564bdaefd41e0caf3017 (diff)
downloadmanaserv-a3e91f58e3aac2c35f70a74187fa2c242e59a647.tar.gz
manaserv-a3e91f58e3aac2c35f70a74187fa2c242e59a647.tar.bz2
manaserv-a3e91f58e3aac2c35f70a74187fa2c242e59a647.tar.xz
manaserv-a3e91f58e3aac2c35f70a74187fa2c242e59a647.zip
Implemented monster mutation.
Diffstat (limited to 'src/game-server/monster.cpp')
-rw-r--r--src/game-server/monster.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp
index 772942d5..4eb90483 100644
--- a/src/game-server/monster.cpp
+++ b/src/game-server/monster.cpp
@@ -28,6 +28,8 @@
#include "game-server/state.hpp"
#include "utils/logger.h"
+#include <cmath>
+
ItemClass *MonsterClass::getRandomDrop() const
{
int p = rand() / (RAND_MAX / 10000);
@@ -67,9 +69,15 @@ Monster::Monster(MonsterClass *specy):
LOG_DEBUG("Monster spawned!");
// get basic attributes from monster database
+ int mutation = specy->getMutation();
for (int i = BASE_ATTR_BEGIN; i < BASE_ATTR_END; i++)
{
- setAttribute(i, specy->getAttribute(i));
+ float attr = (float)specy->getAttribute(i);
+ if (mutation)
+ {
+ attr *= (100 + (rand()%(mutation * 2)) - mutation) / 100.0f;
+ }
+ setAttribute(i, (int)std::ceil(attr));
}
setSpeed(specy->getSpeed());