From 45c3f943b42423dbe162bfac4a57cad013ba0630 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Thu, 17 Mar 2011 02:05:52 +0100 Subject: 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. --- src/localplayer.cpp | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) (limited to 'src/localplayer.cpp') 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) -- cgit v1.2.3-70-g09d2