From f03e1cb4ce24e92fa3756d7b9aa9131853783810 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Mon, 11 Feb 2008 23:42:48 +0000 Subject: Implemented getting size and speed from monster.xml --- src/game-server/monster.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/game-server/monster.cpp') diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp index 4cad2311..772942d5 100644 --- a/src/game-server/monster.cpp +++ b/src/game-server/monster.cpp @@ -72,14 +72,15 @@ Monster::Monster(MonsterClass *specy): setAttribute(i, specy->getAttribute(i)); } + setSpeed(specy->getSpeed()); + setSize(specy->getSize()); + // Some bogus stats for testing. // TODO: Get all this stuff from the monster database. mAttackPreDelay = 10; mAttackAftDelay = 10; mAttackRange = 32; mAttackAngle = 10; - setSpeed(300); - setSize(8); // Set positions relative to target from which the monster can attack mAttackPositions.push_back(AttackPosition(+32, 0, DIRECTION_LEFT)); @@ -226,16 +227,19 @@ void Monster::update() else { // We have no target - let's wander around - mCountDown--; - if (mCountDown <= 0) + if (getPosition() == getDestination()) { - unsigned range = mSpecy->getStrollRange(); - if (range) + mCountDown--; + if (mCountDown <= 0) { - Point randomPos(rand() % (range * 2) - range + getPosition().x, - rand() % (range * 2) - range + 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; + } } } } -- cgit v1.2.3-60-g2f50