diff options
author | Ira Rice <irarice@gmail.com> | 2008-10-27 07:19:11 +0000 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-10-27 07:19:11 +0000 |
commit | f3beda85b284e57caf6e5c685174bcb2e608d9ce (patch) | |
tree | 4bf00df16995bf6316581a7ae64e2de805dfcd08 /src | |
parent | 8057f36623788c1d675e0311d98362b7d1d9f892 (diff) | |
download | mana-f3beda85b284e57caf6e5c685174bcb2e608d9ce.tar.gz mana-f3beda85b284e57caf6e5c685174bcb2e608d9ce.tar.bz2 mana-f3beda85b284e57caf6e5c685174bcb2e608d9ce.tar.xz mana-f3beda85b284e57caf6e5c685174bcb2e608d9ce.zip |
Revised code so that dead sprites are de-targeted.
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 1 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 2 | ||||
-rw-r--r-- | 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); |