diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2008-02-07 17:49:56 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2008-02-07 17:49:56 +0000 |
commit | 504b008e264a3213d9802e52b984196ff348f814 (patch) | |
tree | 44c1d0d2e3c0b839c71ca96fccb54444280f500e /src/game-server/monster.cpp | |
parent | e9e633a5b78799311ee765944a7aa52201bcef9d (diff) | |
download | manaserv-504b008e264a3213d9802e52b984196ff348f814.tar.gz manaserv-504b008e264a3213d9802e52b984196ff348f814.tar.bz2 manaserv-504b008e264a3213d9802e52b984196ff348f814.tar.xz manaserv-504b008e264a3213d9802e52b984196ff348f814.zip |
arts of monster behavior are now read from monsters.xml.
Diffstat (limited to 'src/game-server/monster.cpp')
-rw-r--r-- | src/game-server/monster.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp index efbd02c4..4cad2311 100644 --- a/src/game-server/monster.cpp +++ b/src/game-server/monster.cpp @@ -74,8 +74,6 @@ Monster::Monster(MonsterClass *specy): // Some bogus stats for testing. // TODO: Get all this stuff from the monster database. - mAgressive = false; - mAgressionRange = 10; mAttackPreDelay = 10; mAttackAftDelay = 10; mAttackRange = 32; @@ -177,7 +175,7 @@ void Monster::update() { targetPriority = angerIterator->second; } - else if (mAgressive) + else if (mSpecy->isAggressive()) { targetPriority = 1; } @@ -231,10 +229,14 @@ void Monster::update() mCountDown--; if (mCountDown <= 0) { - Point randomPos(rand() % 160 - 80 + getPosition().x, - rand() % 160 - 80 + getPosition().y); - setDestination(randomPos); - mCountDown = 10 + rand() % 10; + unsigned range = mSpecy->getStrollRange(); + if (range) + { + Point randomPos(rand() % (range * 2) - range + getPosition().x, + rand() % (range * 2) - range + getPosition().y); + setDestination(randomPos); + mCountDown = 10 + rand() % 10; + } } } } @@ -243,25 +245,27 @@ int Monster::calculatePositionPriority(Point position, int targetPriority) { Point thisPos = getPosition(); + unsigned range = mSpecy->getTrackRange(); + // Check if we already are on this position if (thisPos.x / 32 == position.x / 32 && thisPos.y / 32 == position.y / 32) { - return targetPriority *= mAgressionRange; + return targetPriority *= range; } std::list<PATH_NODE> path; path = getMap()->getMap()->findPath(thisPos.x / 32, thisPos.y / 32, position.x / 32, position.y / 32, - mAgressionRange); + range); - if (path.empty() || path.size() >= mAgressionRange) + if (path.empty() || path.size() >= range) { return 0; } else { - return targetPriority * (mAgressionRange - path.size()); + return targetPriority * (range - path.size()); } } |