summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorBlue <bluesansdouze@gmail.com>2009-05-21 15:14:52 +0200
committerBlue <bluesansdouze@gmail.com>2009-05-21 15:14:52 +0200
commita9df0306b4949f10287657a229e1f8d33cfae5e9 (patch)
treeb3dff4b9f36e12d1492d534943796017a955bc3e /src/localplayer.cpp
parent7b76f0e8c4c489254d7519e2916b951601423801 (diff)
parentb85793ec89e57ae20140957f833a06b874eb3120 (diff)
downloadmana-a9df0306b4949f10287657a229e1f8d33cfae5e9.tar.gz
mana-a9df0306b4949f10287657a229e1f8d33cfae5e9.tar.bz2
mana-a9df0306b4949f10287657a229e1f8d33cfae5e9.tar.xz
mana-a9df0306b4949f10287657a229e1f8d33cfae5e9.zip
Merge branch 'master' of git@gitorious.org:tmw/mainline
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp51
1 files changed, 38 insertions, 13 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index e9bc30f2..c9dc771d 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,13 +205,18 @@ 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);
+#else
// Find whether target is in range
const int rangeX = abs(mTarget->mX - mX);
const int rangeY = abs(mTarget->mY - mY);
+#endif
const int attackRange = getAttackRange();
const int inRange = rangeX > attackRange || rangeY > attackRange
? 1 : 0;
-
mTarget->setTargetAnimation(
mTargetCursor[inRange][mTarget->getTargetCursorSize()]);
@@ -220,7 +227,6 @@ void LocalPlayer::logic()
attack(mTarget, true);
}
}
-#endif
Player::logic();
}
@@ -280,9 +286,7 @@ void LocalPlayer::nextStep()
if (mGoingToTarget && mTarget && withinAttackRange(mTarget))
{
mAction = Being::STAND;
-#ifdef EATHENA_SUPPORT
attack(mTarget, true);
-#endif
mGoingToTarget = false;
mPath.clear();
return;
@@ -606,7 +610,7 @@ void LocalPlayer::emote(Uint8 emotion)
}
#ifdef TMWSERV_SUPPORT
-
+/*
void LocalPlayer::attack()
{
if (mLastAction != -1)
@@ -656,16 +660,25 @@ void LocalPlayer::attack()
}
Net::GameServer::Player::attack(getSpriteDirection());
}
-
+*/
void LocalPlayer::useSpecial(int special)
{
Net::GameServer::Player::useSpecial(special);
}
-#else
+#endif
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)
@@ -676,13 +689,19 @@ void LocalPlayer::attack(Being *target, bool keep)
mLastTarget = -1;
setTarget(target);
}
-
+#ifdef TMWSERV_SUPPORT
+ 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;
// Must be standing to attack
if (mAction != STAND)
return;
+#endif
if (abs(dist_y) >= abs(dist_x))
{
@@ -699,8 +718,12 @@ void LocalPlayer::attack(Being *target, bool keep)
setDirection(LEFT);
}
+#ifdef TMWSERV_SUPPORT
+ mLastAction = tick_time;
+#else
mWalkTime = tick_time;
mTargetTime = tick_time;
+#endif
setAction(ATTACK);
@@ -715,14 +738,16 @@ void LocalPlayer::attack(Being *target, bool keep)
sound.playSfx("sfx/fist-swish.ogg");
}
- Net::getPlayerHandler()->attack(target);
-
+#ifdef TMWSERV_SUPPORT
+ if (mLastAction == STAND)
+#endif
+ Net::getPlayerHandler()->attack(target->getId());
+#ifdef EATHENA_SUPPORT
if (!keep)
stopAttack();
+#endif
}
-#endif // no TMWSERV_SUPPORT
-
void LocalPlayer::stopAttack()
{
if (mTarget)
@@ -845,7 +870,7 @@ int LocalPlayer::getAttackRange()
const ItemInfo info = weapon->getInfo();
return info.getAttackRange();
}
- return 32; // unarmed range
+ return 48; // unarmed range
#else
return mAttackRange;
#endif