summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2008-10-27 07:19:11 +0000
committerIra Rice <irarice@gmail.com>2008-10-27 07:19:11 +0000
commitf3beda85b284e57caf6e5c685174bcb2e608d9ce (patch)
tree4bf00df16995bf6316581a7ae64e2de805dfcd08 /src/localplayer.cpp
parent8057f36623788c1d675e0311d98362b7d1d9f892 (diff)
downloadmana-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/localplayer.cpp')
-rw-r--r--src/localplayer.cpp21
1 files changed, 14 insertions, 7 deletions
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);