diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2006-12-27 20:39:21 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2006-12-27 20:39:21 +0000 |
commit | b2ef30efb59c8aa4df3bbaab376d46c583a40d98 (patch) | |
tree | bfa5f4b4dbb937b4413e79427bf1bbab8522dbdb /src/localplayer.cpp | |
parent | 8da32105732949b4b0273c718d118bcfae70a1c9 (diff) | |
download | mana-b2ef30efb59c8aa4df3bbaab376d46c583a40d98.tar.gz mana-b2ef30efb59c8aa4df3bbaab376d46c583a40d98.tar.bz2 mana-b2ef30efb59c8aa4df3bbaab376d46c583a40d98.tar.xz mana-b2ef30efb59c8aa4df3bbaab376d46c583a40d98.zip |
Client-sided implementation of attacks
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r-- | src/localplayer.cpp | 55 |
1 files changed, 8 insertions, 47 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index c887dd1c..6918fa60 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -51,11 +51,6 @@ LocalPlayer::~LocalPlayer() void LocalPlayer::logic() { - if (mAction == ATTACK && get_elapsed_time(mWalkTime) >= mAttackSpeed) - { - attack(); - } - // Actions are allowed once per second if (get_elapsed_time(mLastAction) >= 1000) { mLastAction = -1; @@ -166,7 +161,6 @@ void LocalPlayer::pickUp(FloorItem *item) } else { setDestination(item->getX() * 32 + 16, item->getY() * 32 + 16); mPickUpTarget = item; - stopAttack(); } } @@ -352,59 +346,26 @@ bool LocalPlayer::tradeRequestOk() const return !mTrading; } -void LocalPlayer::attack(Being *target, bool keep) +void LocalPlayer::attack() { - // Can only attack when standing still - if (mAction != STAND) + if (mLastAction != -1) return; - if (keep && target) - mTarget = target; - else if (mTarget) - target = mTarget; - - if (!target) + // Can only attack when standing still + if (mAction != STAND && mAction != ATTACK) return; - int dist_x = target->mX - mX; - int dist_y = target->mY - mY; - - if (abs(dist_y) >= abs(dist_x)) - { - if (dist_y > 0) - setDirection(DOWN); - else - setDirection(UP); - } - else - { - if (dist_x > 0) - setDirection(RIGHT); - else - setDirection(LEFT); - } - - // Implement charging attacks here - mLastAttackTime = 0; + mLastAction = tick_time; + mWalkTime = tick_time; setAction(ATTACK); - mWalkTime = tick_time; + if (getWeapon() == 2) sound.playSfx("sfx/bow_shoot_1.ogg"); else sound.playSfx("sfx/fist-swish.ogg"); - // XXX Convert for new server - /* - MessageOut outMsg(0x0089); - outMsg.writeLong(target->getId()); - outMsg.writeByte(0); - */ -} - -void LocalPlayer::stopAttack() -{ - mTarget = NULL; + Net::GameServer::Player::attack(); } Being* LocalPlayer::getTarget() const |