diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-03-28 20:13:17 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-03-28 20:13:17 +0200 |
commit | 25bfbc30fb4958a3a754d74bbe971dec717f831c (patch) | |
tree | a5bfd7308daf89d7d4cd84a2e98db7db77616a65 /src/net/tmwa/beinghandler.cpp | |
parent | 3c8e99cdfeee6b4db1dc56941659b94445601618 (diff) | |
download | mana-25bfbc30fb4958a3a754d74bbe971dec717f831c.tar.gz mana-25bfbc30fb4958a3a754d74bbe971dec717f831c.tar.bz2 mana-25bfbc30fb4958a3a754d74bbe971dec717f831c.tar.xz mana-25bfbc30fb4958a3a754d74bbe971dec717f831c.zip |
Added some tolerance on the tA being position message.
Also made the destination equal to the desired position
in that case since it's what the tA server expects.
This fixes monsters going to strange destinations while fighting
them, and makes it all much smoother.
Diffstat (limited to 'src/net/tmwa/beinghandler.cpp')
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index b7f702c0..5ae11423 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -133,7 +133,17 @@ void handlePosMessage(Uint16 x, Uint16 y, Being *dstBeing, { Vector pos(x * tileWidth + tileWidth / 2, y * tileHeight + tileHeight / 2); - dstBeing->setPosition(pos); + Vector beingPos = dstBeing->getPosition(); + // Don't set the position as the movement algorithm + // can guess it and it would break the animation played, + // when we're close enough. + if (std::abs(beingPos.x - pos.x) > POS_DEST_DIFF_TOLERANCE + || std::abs(beingPos.y - pos.y) > POS_DEST_DIFF_TOLERANCE) + dstBeing->setPosition(pos); + + // Set also the destination to the desired position. + dstBeing->setDestination(pos.x, pos.y); + if (dir) dstBeing->setDirection(dir); } |