summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-03-13 20:02:32 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-03-15 22:53:35 +0100
commit3a31f9139a8ac4c74113392c76599873c18cea62 (patch)
tree63999febcc8646b925c26a3bd05b131c645a3499
parent596c34c03d361f6631f73995a454e4f6dac70d97 (diff)
downloadmanaserv-3a31f9139a8ac4c74113392c76599873c18cea62.tar.gz
manaserv-3a31f9139a8ac4c74113392c76599873c18cea62.tar.bz2
manaserv-3a31f9139a8ac4c74113392c76599873c18cea62.tar.xz
manaserv-3a31f9139a8ac4c74113392c76599873c18cea62.zip
Eliminated one version of Being::performAttack
There was a version taking an attack range, but the range was always the same as the one specified in the Damage class.
-rw-r--r--src/game-server/being.cpp22
-rw-r--r--src/game-server/being.h1
-rw-r--r--src/game-server/monster.cpp3
3 files changed, 12 insertions, 14 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp
index c2228dcc..e0e0dcc1 100644
--- a/src/game-server/being.cpp
+++ b/src/game-server/being.cpp
@@ -398,25 +398,25 @@ int Being::directionToAngle(int direction)
}
}
-int Being::performAttack(Being *target, const Damage &damage) {
- return performAttack(target, damage.range, damage);
-}
-
-int Being::performAttack(Being *target, unsigned range, const Damage &damage)
+int Being::performAttack(Being *target, const Damage &damage)
{
// check target legality
- if (!target || target == this || target->getAction() == DEAD
- || !target->canFight())
- return -1;
- if (getMap()->getPvP() == PVP_NONE && target->getType() == OBJECT_CHARACTER
- && getType() == OBJECT_CHARACTER)
+ if (!target
+ || target == this
+ || target->getAction() == DEAD
+ || !target->canFight())
+ return -1;
+
+ if (getMap()->getPvP() == PVP_NONE
+ && target->getType() == OBJECT_CHARACTER
+ && getType() == OBJECT_CHARACTER)
return -1;
// check if target is in range using the pythagorean theorem
int distx = this->getPosition().x - target->getPosition().x;
int disty = this->getPosition().y - target->getPosition().y;
int distSquare = (distx * distx + disty * disty);
- int maxDist = range + target->getSize();
+ int maxDist = damage.range + target->getSize();
if (maxDist * maxDist < distSquare)
return -1;
diff --git a/src/game-server/being.h b/src/game-server/being.h
index 11c5f753..35457bcb 100644
--- a/src/game-server/being.h
+++ b/src/game-server/being.h
@@ -150,7 +150,6 @@ class Being : public Actor
* Return Value: damage inflicted or -1 when illegal target
*/
int performAttack(Being *target, const Damage &damage);
- int performAttack(Being *target, unsigned range, const Damage &damage);
/**
* Sets the current action.
diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp
index d9083e80..f77cca0b 100644
--- a/src/game-server/monster.cpp
+++ b/src/game-server/monster.cpp
@@ -156,8 +156,7 @@ void Monster::perform()
mCurrentAttack->type,
mCurrentAttack->range);
- int hit = performAttack(mTarget, mCurrentAttack->range,
- dmg);
+ int hit = performAttack(mTarget, dmg);
if (! mCurrentAttack->scriptFunction.empty()
&& mScript