summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorBertram <bertram@cegetel.net>2009-10-09 03:43:13 +0200
committerBertram <bertram@cegetel.net>2009-10-09 03:43:13 +0200
commit0a3e2c75c5fcc359e257548267d5ffae6726e2db (patch)
treefde0bb90528bc10a12be7a0a9101befbb954f29e /src/being.cpp
parent07c92a402d3455bb2785c1fc69d03263888793b9 (diff)
downloadmana-0a3e2c75c5fcc359e257548267d5ffae6726e2db.tar.gz
mana-0a3e2c75c5fcc359e257548267d5ffae6726e2db.tar.bz2
mana-0a3e2c75c5fcc359e257548267d5ffae6726e2db.tar.xz
mana-0a3e2c75c5fcc359e257548267d5ffae6726e2db.zip
Mostly fixed keyboard movement on TMWserv.
- Making sure that keyboard and mouse are fully working on eAthena. - Making sure the mouse code isn't broken again. There are some glitches left but it's coming! What's left to be fixed: - Come a little closer to walls (localPlyer::nextStep() improvement to be done). - Adapt the next Step range according to the being speed. (again in nextStep()). - Handle more nicely player's direction when walking diagonally. - Get player's speed from server. Enjoy :)
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/being.cpp b/src/being.cpp
index d15c27b3..ef71b748 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -528,12 +528,24 @@ void Being::logic()
Vector dir = dest - mPos;
const float length = dir.length();
- // When we're over 2 pixels from our destination, move to it
- // TODO: Should be possible to make it even pixel exact, but this solves
- // the jigger caused by moving too far.
- if (length > 2.0f) {
+ // When we've not reached our destination, move to it.
+ if (length > 0.0f)
+ {
const float speed = mWalkSpeed / 100.0f;
- setPosition(mPos + (dir / (length / speed)));
+
+ // Test if we don't miss the destination by a move too far:
+ if ((dir / (length / speed)).length() > dir.length())
+ {
+ setPosition(mPos + dir);
+
+ // Also, if the destination is reached, try to get the next
+ // path point, if existing.
+ if (!mPath.empty())
+ mPath.pop_front();
+ }
+ // Otherwise, go to it using the nominal speed.
+ else
+ setPosition(mPos + (dir / (length / speed)));
if (mAction != WALK)
setAction(WALK);
@@ -548,11 +560,14 @@ void Being::logic()
direction |= (dir.y > 0) ? DOWN : UP;
setDirection(direction);
}
- else if (!mPath.empty()) {
- // TODO: Pop as soon as there is a direct unblocked line to the next
- // point on the path.
+ else if (!mPath.empty())
+ {
+ // If the current path node has been reached,
+ // remove it and go to the next one.
mPath.pop_front();
- } else if (mAction == WALK) {
+ }
+ else if (mAction == WALK)
+ {
setAction(STAND);
}
}