summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2009-05-18 18:43:23 +0100
committerDavid Athay <ko2fan@gmail.com>2009-05-18 18:43:23 +0100
commit5e09f904d48f1b54f44763f8cb13914bddaafc86 (patch)
treeefbefc9560505227b3e67f08dfd1e5f7f585e90d /src/localplayer.cpp
parent72660d2c33773f0f74663efe6f9ac47648cdf283 (diff)
downloadmana-5e09f904d48f1b54f44763f8cb13914bddaafc86.tar.gz
mana-5e09f904d48f1b54f44763f8cb13914bddaafc86.tar.bz2
mana-5e09f904d48f1b54f44763f8cb13914bddaafc86.tar.xz
mana-5e09f904d48f1b54f44763f8cb13914bddaafc86.zip
Hopefully player will now show its got a target. Needs more work still.
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 4c34394b..b9f4b850 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -193,6 +193,8 @@ void LocalPlayer::logic()
mLastTarget = -1;
}
+#endif
+
if (mTarget)
{
if (mTarget->getType() == Being::NPC)
@@ -203,12 +205,21 @@ void LocalPlayer::logic()
}
else
{
+#ifdef TMWSERV_SUPPORT
+ // Find whether target is in range
+ const int rangeX = abs(mTarget->getPosition().x - getPosition().x);
+ const int rangeY = abs(mTarget->getPosition().y - getPosition().y);
+ const int attackRange = getAttackRange();
+ const int inRange = rangeX > attackRange || rangeY > attackRange
+ ? 1 : 0;
+#else
// Find whether target is in range
const int rangeX = abs(mTarget->mX - mX);
const int rangeY = abs(mTarget->mY - mY);
const int attackRange = getAttackRange();
const int inRange = rangeX > attackRange || rangeY > attackRange
? 1 : 0;
+#endif
mTarget->setTargetAnimation(
mTargetCursor[inRange][mTarget->getTargetCursorSize()]);
@@ -220,7 +231,6 @@ void LocalPlayer::logic()
attack(mTarget, true);
}
}
-#endif
Player::logic();
}
@@ -663,10 +673,18 @@ void LocalPlayer::useSpecial(int special)
}
#endif
-//#else
void LocalPlayer::attack(Being *target, bool keep)
{
+#ifdef TMWSERV_SUPPORT
+ if (mLastAction != -1)
+ return;
+
+ // Can only attack when standing still
+ if (mAction != STAND && mAction != ATTACK)
+ return;
+#endif
+
mKeepAttacking = keep;
if (!target || target->getType() == Being::NPC)
@@ -678,8 +696,10 @@ void LocalPlayer::attack(Being *target, bool keep)
setTarget(target);
}
#ifdef TMWSERV_SUPPORT
- int dist_x = target->getPixelX();
- int dist_y = target->getPixelY();
+ Vector plaPos = this->getPosition();
+ Vector tarPos = mTarget->getPosition();
+ int dist_x = plaPos.x - tarPos.x;
+ int dist_y = plaPos.y - tarPos.y;
#else
int dist_x = target->mX - mX;
int dist_y = target->mY - mY;