diff options
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r-- | src/localplayer.cpp | 68 |
1 files changed, 47 insertions, 21 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index c1423190..c9dc771d 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -193,6 +193,8 @@ void LocalPlayer::logic() mLastTarget = -1; } +#endif + if (mTarget) { if (mTarget->getType() == Being::NPC) @@ -203,13 +205,18 @@ void LocalPlayer::logic() } else { +#ifdef TMWSERV_SUPPORT + // Find whether target is in range + const int rangeX = abs(mTarget->getPosition().x - getPosition().x); + const int rangeY = abs(mTarget->getPosition().y - getPosition().y); +#else // Find whether target is in range const int rangeX = abs(mTarget->mX - mX); const int rangeY = abs(mTarget->mY - mY); +#endif const int attackRange = getAttackRange(); const int inRange = rangeX > attackRange || rangeY > attackRange ? 1 : 0; - mTarget->setTargetAnimation( mTargetCursor[inRange][mTarget->getTargetCursorSize()]); @@ -220,7 +227,6 @@ void LocalPlayer::logic() attack(mTarget, true); } } -#endif Player::logic(); } @@ -280,9 +286,7 @@ void LocalPlayer::nextStep() if (mGoingToTarget && mTarget && withinAttackRange(mTarget)) { mAction = Being::STAND; -#ifdef EATHENA_SUPPORT attack(mTarget, true); -#endif mGoingToTarget = false; mPath.clear(); return; @@ -606,7 +610,7 @@ void LocalPlayer::emote(Uint8 emotion) } #ifdef TMWSERV_SUPPORT - +/* void LocalPlayer::attack() { if (mLastAction != -1) @@ -656,16 +660,25 @@ void LocalPlayer::attack() } Net::GameServer::Player::attack(getSpriteDirection()); } - +*/ void LocalPlayer::useSpecial(int special) { Net::GameServer::Player::useSpecial(special); } -#else +#endif void LocalPlayer::attack(Being *target, bool keep) { +#ifdef TMWSERV_SUPPORT + if (mLastAction != -1) + return; + + // Can only attack when standing still + if (mAction != STAND && mAction != ATTACK) + return; +#endif + mKeepAttacking = keep; if (!target || target->getType() == Being::NPC) @@ -676,13 +689,19 @@ void LocalPlayer::attack(Being *target, bool keep) mLastTarget = -1; setTarget(target); } - +#ifdef TMWSERV_SUPPORT + Vector plaPos = this->getPosition(); + Vector tarPos = mTarget->getPosition(); + int dist_x = plaPos.x - tarPos.x; + int dist_y = plaPos.y - tarPos.y; +#else int dist_x = target->mX - mX; int dist_y = target->mY - mY; // Must be standing to attack if (mAction != STAND) return; +#endif if (abs(dist_y) >= abs(dist_x)) { @@ -699,8 +718,12 @@ void LocalPlayer::attack(Being *target, bool keep) setDirection(LEFT); } +#ifdef TMWSERV_SUPPORT + mLastAction = tick_time; +#else mWalkTime = tick_time; mTargetTime = tick_time; +#endif setAction(ATTACK); @@ -715,22 +738,24 @@ void LocalPlayer::attack(Being *target, bool keep) sound.playSfx("sfx/fist-swish.ogg"); } - Net::getPlayerHandler()->attack(target); - +#ifdef TMWSERV_SUPPORT + if (mLastAction == STAND) +#endif + Net::getPlayerHandler()->attack(target->getId()); +#ifdef EATHENA_SUPPORT if (!keep) stopAttack(); +#endif } -#endif // no TMWSERV_SUPPORT - void LocalPlayer::stopAttack() { if (mTarget) { - setAction(STAND); - mLastTarget = -1; + if (mAction == ATTACK) + setAction(STAND); + setTarget(NULL); } - setTarget(NULL); mLastTarget = -1; } @@ -812,8 +837,8 @@ void LocalPlayer::setXp(int xp) // Show XP number particleEngine->addTextRiseFadeOutEffect( text, - getPixelX() + 16, - getPixelY() - 16, + getPixelX(), + getPixelY() - 48, &guiPalette->getColor(Palette::EXP_INFO), gui->getInfoParticleFont(), true); } @@ -829,8 +854,8 @@ void LocalPlayer::pickedUp(const std::string &item) // Show pickup notification particleEngine->addTextRiseFadeOutEffect( item, - getPixelX() + 16, - getPixelY() - 16, + getPixelX(), + getPixelY() - 48, &guiPalette->getColor(Palette::PICKUP_INFO), gui->getInfoParticleFont(), true); } @@ -845,7 +870,7 @@ int LocalPlayer::getAttackRange() const ItemInfo info = weapon->getInfo(); return info.getAttackRange(); } - return 32; // unarmed range + return 48; // unarmed range #else return mAttackRange; #endif @@ -946,7 +971,8 @@ void LocalPlayer::initTargetCursor() true, TC_LARGE); } -void LocalPlayer::loadTargetCursor(std::string filename, int width, int height, +void LocalPlayer::loadTargetCursor(const std::string &filename, + int width, int height, bool outRange, TargetCursorSize size) { assert(size > -1); |