From f3beda85b284e57caf6e5c685174bcb2e608d9ce Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Mon, 27 Oct 2008 07:19:11 +0000 Subject: Revised code so that dead sprites are de-targeted. --- src/being.cpp | 1 + src/gui/viewport.cpp | 2 +- src/localplayer.cpp | 21 ++++++++++++++------- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/being.cpp b/src/being.cpp index c4569d4e..db8b18e6 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -238,6 +238,7 @@ void Being::controlParticle(Particle *particle) void Being::setAction(Action action) { SpriteAction currentAction = ACTION_INVALID; + switch (action) { case WALK: diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index ad0c35e5..ef3f0dff 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -303,7 +303,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) if (player_node->withinAttackRange(being) || keyboard.isKeyActive(keyboard.KEY_ATTACK)) { player_node->setGotoTarget(being); - player_node->attack(being, keyboard.isKeyActive(keyboard.KEY_TARGET)); + player_node->attack(being, true); } else { diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 34a99bc9..85030eb7 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -112,8 +112,8 @@ void LocalPlayer::logic() break; } - // Actions are allowed once per second - if (get_elapsed_time(mLastAction) >= 1000) { + // Actions are allowed twice per second + if (get_elapsed_time(mLastAction) >= 500) { mLastAction = -1; } @@ -125,6 +125,15 @@ void LocalPlayer::logic() mLastAction = -1; } + if (mTarget) + { + if (mTarget->mAction == DEAD) + { + setTarget(mTarget); + mLastAction = -1; + } + } + for (int i = Being::TC_SMALL; i < Being::NUM_TC; i++) { player_node->mTargetCursorInRange[i]->update(10); @@ -439,14 +448,11 @@ void LocalPlayer::attack(Being *target, bool keep) if (mAction != STAND) return; - if (keep && target) + if (keep && (mTarget != target)) { + mLastAction = -1; setTarget(target); } - else if (mTarget) - { - target = mTarget; - } if (!target) return; @@ -535,6 +541,7 @@ bool LocalPlayer::withinAttackRange(Being *target) void LocalPlayer::setGotoTarget(Being *target) { + mLastAction = -1; setTarget(target); mGoingToTarget = true; setDestination(target->mX, target->mY); -- cgit v1.2.3-60-g2f50