From 25bfbc30fb4958a3a754d74bbe971dec717f831c Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Mon, 28 Mar 2011 20:13:17 +0200 Subject: 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. --- src/net/tmwa/beinghandler.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') 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); } -- cgit v1.2.3-70-g09d2