diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-03-17 02:05:52 +0100 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-03-17 02:05:52 +0100 |
commit | 45c3f943b42423dbe162bfac4a57cad013ba0630 (patch) | |
tree | 0bb0caaa15af42f1d2c3bc14061202aacf9bee6d /src/localplayer.cpp | |
parent | fe153c7b2598262281477882a2ef82400b24f5b5 (diff) | |
download | mana-45c3f943b42423dbe162bfac4a57cad013ba0630.tar.gz mana-45c3f943b42423dbe162bfac4a57cad013ba0630.tar.bz2 mana-45c3f943b42423dbe162bfac4a57cad013ba0630.tar.xz mana-45c3f943b42423dbe162bfac4a57cad013ba0630.zip |
Simplified the get/setAttackRange() functions as requested.
The attack range is still hardcoded for Manaserv as long
as generic equipment handling hasn't been implemented.
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r-- | src/localplayer.cpp | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 5ce21916..7daceb0f 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -69,7 +69,7 @@ LocalPlayer *player_node = NULL; LocalPlayer::LocalPlayer(int id, int subtype): Being(id, PLAYER, subtype, 0), - mAttackRange(-1), + mAttackRange(ATTACK_RANGE_NOT_SET), mTargetTime(-1), mLastTarget(-1), mTarget(NULL), @@ -911,48 +911,22 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount, void LocalPlayer::setAttackRange(int range) { - // Still no map, so don't do anything for now. - if (!mMap) - return; // When the range is more than the minimal, we accept it - int unarmedRange = mMap->getTileWidth() / 2 * 3; - if (range >= unarmedRange) + if (range > ATTACK_RANGE_NOT_SET) { mAttackRange = range; } else if (Net::getNetworkType() == ServerInfo::TMWATHENA) { // TODO: Fix this to be more generic - Item *weapon = PlayerInfo::getEquipment( - TmwAthena::EQUIP_FIGHT1_SLOT); + Item *weapon = PlayerInfo::getEquipment(TmwAthena::EQUIP_FIGHT1_SLOT); if (weapon) { const ItemInfo info = weapon->getInfo(); - if (info.getAttackRange() >= unarmedRange) + if (info.getAttackRange() > ATTACK_RANGE_NOT_SET) mAttackRange = info.getAttackRange(); - else - mAttackRange = unarmedRange; } } - else - { - mAttackRange = unarmedRange; - } -} - -int LocalPlayer::getAttackRange() -{ - // Still no map, so don't return anything for now. - if (!mMap) - return -1; - // When the range is realistic, we return it - int unarmedRange = mMap->getTileWidth() / 2 * 3; - if (mAttackRange < unarmedRange) - { - // This will set a proper value to the attack range. - setAttackRange(unarmedRange); - } - return mAttackRange; } bool LocalPlayer::withinAttackRange(Being *target) |