diff options
author | David Athay <ko2fan@gmail.com> | 2008-04-11 14:12:30 +0000 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2008-04-11 14:12:30 +0000 |
commit | b50649ee5e28511df72cc3a08023747727c5b6f0 (patch) | |
tree | 1f1408b4550e70388ed1103747f973dbe77670f5 /src/localplayer.cpp | |
parent | 760967f3c0dae0c352568a2865c57679559806fa (diff) | |
download | mana-client-b50649ee5e28511df72cc3a08023747727c5b6f0.tar.gz mana-client-b50649ee5e28511df72cc3a08023747727c5b6f0.tar.bz2 mana-client-b50649ee5e28511df72cc3a08023747727c5b6f0.tar.xz mana-client-b50649ee5e28511df72cc3a08023747727c5b6f0.zip |
Players now need to
click on the monster sprites rather than the tile. Players will now
move to the target before attacking it.
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r-- | src/localplayer.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 0ed23892..2aae199e 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -48,7 +48,8 @@ LocalPlayer::LocalPlayer(Uint32 id, Uint16 job, Map *map): mInventory(new Inventory), mXp(0), mNetwork(0), mTarget(NULL), mPickUpTarget(NULL), - mTrading(false), mLastAction(-1), + mTrading(false), mGoingToTarget(false), + mLastAction(-1), mWalkingDir(0), mDestX(0), mDestY(0) { } @@ -104,6 +105,16 @@ void LocalPlayer::nextStep() { walk(mWalkingDir); } + + } + + if (mGoingToTarget && mTarget && withinAttackRange(mTarget)) + { + mAction = Being::STAND; + attack(mTarget, true); + mGoingToTarget = false; + mPath.clear(); + return; } Player::nextStep(); @@ -453,3 +464,23 @@ void LocalPlayer::setXp(int xp) } mXp = xp; } + +bool LocalPlayer::withinAttackRange(Being *target) +{ + int dist_x = abs(target->mX - mX); + int dist_y = abs(target->mY - mY); + + if (dist_x > getAttackRange() || dist_y > getAttackRange()) + { + return false; + } + + return true; +} + +void LocalPlayer::setGotoTarget(Being *target) +{ + mTarget = target; + mGoingToTarget = true; + setDestination(target->mX, target->mY); +} |