diff options
author | Lloyd Bryant <lloyd_bryant@netzero.net> | 2008-07-18 00:48:14 +0000 |
---|---|---|
committer | Lloyd Bryant <lloyd_bryant@netzero.net> | 2008-07-18 00:48:14 +0000 |
commit | 159285c5aa24611ceee7e3847a87bf9ea5f7fb7a (patch) | |
tree | fa48eb8bb8ed1e62ede1e7a2f95632c2243facab /src/localplayer.cpp | |
parent | 4dbc9b7af344d3ff006a40e3e0c06ce160f365f9 (diff) | |
download | mana-client-159285c5aa24611ceee7e3847a87bf9ea5f7fb7a.tar.gz mana-client-159285c5aa24611ceee7e3847a87bf9ea5f7fb7a.tar.bz2 mana-client-159285c5aa24611ceee7e3847a87bf9ea5f7fb7a.tar.xz mana-client-159285c5aa24611ceee7e3847a87bf9ea5f7fb7a.zip |
Import of client tree
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r-- | src/localplayer.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 3929da8b..5f392a52 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -18,7 +18,7 @@ * along with The Mana World; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id$ + * $Id: localplayer.cpp 4347 2008-06-12 09:06:01Z b_lindeijer $ */ #include "localplayer.h" @@ -31,6 +31,7 @@ #include "main.h" #include "particle.h" #include "sound.h" +#include "monster.h" #include "gui/gui.h" @@ -226,6 +227,23 @@ void LocalPlayer::walk(unsigned char dir) } } +void LocalPlayer::setTarget(Being *target) +{ + if (target == mTarget) + { + return; + } + if (mTarget && mTarget->getType() == Being::MONSTER) + { + static_cast<Monster *>(mTarget)->showName(false); + } + mTarget = target; + if (target && target->getType() == Being::MONSTER) + { + static_cast<Monster *>(target)->showName(true); + } +} + void LocalPlayer::setDestination(Uint16 x, Uint16 y) { // Only send a new message to the server when destination changes @@ -363,9 +381,13 @@ void LocalPlayer::attack(Being *target, bool keep) return; if (keep && target) - mTarget = target; + { + setTarget(target); + } else if (mTarget) + { target = mTarget; + } if (!target) return; @@ -411,7 +433,7 @@ void LocalPlayer::attack(Being *target, bool keep) void LocalPlayer::stopAttack() { - mTarget = NULL; + setTarget(NULL); } Being* LocalPlayer::getTarget() const @@ -454,7 +476,7 @@ bool LocalPlayer::withinAttackRange(Being *target) void LocalPlayer::setGotoTarget(Being *target) { - mTarget = target; + setTarget(target); mGoingToTarget = true; setDestination(target->mX, target->mY); } |