diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-03-16 00:37:34 +0100 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-03-16 00:37:34 +0100 |
commit | 786df24ec5d10e4251fa69426c53f9c2e5d545f4 (patch) | |
tree | 272779bd871303204bda526bc5b6841bdc8e1928 /src/localplayer.cpp | |
parent | 001b6f0f7db78bf7987e302a085b9d8469d59f68 (diff) | |
download | mana-786df24ec5d10e4251fa69426c53f9c2e5d545f4.tar.gz mana-786df24ec5d10e4251fa69426c53f9c2e5d545f4.tar.bz2 mana-786df24ec5d10e4251fa69426c53f9c2e5d545f4.tar.xz mana-786df24ec5d10e4251fa69426c53f9c2e5d545f4.zip |
Fixed the attack range handling for both servers.
The attack range is always the default for manaserv, as proper
equipment handling is to be added.
Anyway, now the proper attack range is handled in tmwAthena
and is always set a proper minimum for both protocols.
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r-- | src/localplayer.cpp | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 52168237..5ce21916 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(0), + mAttackRange(-1), mTargetTime(-1), mLastTarget(-1), mTarget(NULL), @@ -114,14 +114,10 @@ void LocalPlayer::logic() { if (mMessageTime == 0) { - //const Vector &pos = getPosition(); - MessagePair info = mMessages.front(); particleEngine->addTextRiseFadeOutEffect( info.first, - /*(int) pos.x, - (int) pos.y - 48,*/ getPixelX(), getPixelY() - 48, &userPalette->getColor(info.second), @@ -913,27 +909,50 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount, } } -int LocalPlayer::getAttackRange() +void LocalPlayer::setAttackRange(int range) { - if (mAttackRange > -1) + // 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) { - return mAttackRange; + mAttackRange = range; } - else + else if (Net::getNetworkType() == ServerInfo::TMWATHENA) { - if (Net::getNetworkType() == ServerInfo::TMWATHENA) + // TODO: Fix this to be more generic + Item *weapon = PlayerInfo::getEquipment( + TmwAthena::EQUIP_FIGHT1_SLOT); + if (weapon) { - // TODO: Fix this to be more generic - Item *weapon = PlayerInfo::getEquipment( - TmwAthena::EQUIP_FIGHT1_SLOT); - if (weapon) - { - const ItemInfo info = weapon->getInfo(); - return info.getAttackRange(); - } + const ItemInfo info = weapon->getInfo(); + if (info.getAttackRange() >= unarmedRange) + mAttackRange = info.getAttackRange(); + else + mAttackRange = unarmedRange; } - return 48; // unarmed range } + 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) |