From be354621d3859164d3563760a9d613e356926686 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Thu, 2 Feb 2012 17:30:50 +0100 Subject: Remove duplicate direction computation by a call to lookAt() It simply does the same thing, in better. Reviewed-by: Erik Schilling --- src/localplayer.cpp | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'src') diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 212b896d..3759e5a3 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -844,25 +844,7 @@ void LocalPlayer::attack(Being *target, bool keep) setTarget(target); } - Vector plaPos = this->getPosition(); - Vector tarPos = mTarget->getPosition(); - int dist_x = plaPos.x - tarPos.x; - int dist_y = plaPos.y - tarPos.y; - - if (abs(dist_y) >= abs(dist_x)) - { - if (dist_y < 0) - setDirection(DOWN); - else - setDirection(UP); - } - else - { - if (dist_x < 0) - setDirection(RIGHT); - else - setDirection(LEFT); - } + lookAt(mTarget->getPosition()); mLastActionTime = tick_time; -- cgit v1.2.3-70-g09d2