summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2012-02-06 22:43:36 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2012-02-07 00:08:06 +0100
commit957198ff4fcd42431f2c352e21e9cbd3dabaed3a (patch)
tree15f1682012ae57bd4d823bd599f4918db19158e0 /src/localplayer.cpp
parent762bd357756e35b0a25cc6a66a890dfedb1f6596 (diff)
downloadmana-957198ff4fcd42431f2c352e21e9cbd3dabaed3a.tar.gz
mana-957198ff4fcd42431f2c352e21e9cbd3dabaed3a.tar.bz2
mana-957198ff4fcd42431f2c352e21e9cbd3dabaed3a.tar.xz
mana-957198ff4fcd42431f2c352e21e9cbd3dabaed3a.zip
Hopefully fixed two issues in the go and attack playflow
- Fixed the player attacking when clicking on a monster, and then walking near using the keyboard. - Fixed the walking glitch seen in tile path mode by letting the character reach its nearest tile path node. Reviewed-by: Thorbjørn Lindeijer
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index eb92fbab..92fea956 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -153,22 +153,30 @@ void LocalPlayer::logic()
{
stopAttack();
}
- else if (mGoingToTarget && !withinAttackRange
- && getPath().empty())
+ else if (mGoingToTarget)
{
- setDestination(mTarget->getPosition());
- mKeepAttacking = true;
- }
- else if (withinAttackRange)
- {
- mGoingToTarget = false;
- if (!getPath().empty())
+ if (!withinAttackRange && getPath().empty())
{
- stopWalking();
+ setDestination(mTarget->getPosition());
+ }
+ else if (withinAttackRange)
+ {
+ // Truncate the path to terminate at the next node.
+ // This permits to avoid a walking glitch in tile path
+ // mode.
+ if (!mPath.empty())
+ {
+ pathSetByMouse();
+ setDestination(mPath.front());
+ }
+
mKeepAttacking = true;
+ mGoingToTarget = false;
}
- if (mKeepAttacking)
- attack(mTarget, true);
+ }
+ else if (withinAttackRange && mKeepAttacking)
+ {
+ attack(mTarget, true);
}
break;
}
@@ -616,6 +624,8 @@ void LocalPlayer::pickUp(FloorItem *item)
if (!item)
return;
+ cancelGoToTarget();
+
if (withinRange(item, Net::getGameHandler()->getPickupRange()))
{
Net::getPlayerHandler()->pickUp(item);
@@ -746,6 +756,8 @@ void LocalPlayer::setWalkingDir(int dir)
else if (!dir)
return;
+ cancelGoToTarget();
+
mWalkingDir = dir;
// If we're not already walking, start walking.
@@ -886,7 +898,7 @@ void LocalPlayer::stopAttack()
setTarget(0);
}
mLastTargetTime = -1;
- mKeepAttacking = false;
+ cancelGoToTarget();
}
void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount,