summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-03-08 08:50:53 -0600
committerJared Adams <jaxad0127@gmail.com>2009-03-08 08:50:53 -0600
commit7bcd1e9ad172157acd369d0ab69694dbeeea2ba8 (patch)
treee3e95a6f9a1ba8c1485d675a470313b6f62f6a6f /src/localplayer.cpp
parentfd1fd6f76758b916fd876a511046e0a1cb46e452 (diff)
downloadmana-7bcd1e9ad172157acd369d0ab69694dbeeea2ba8.tar.gz
mana-7bcd1e9ad172157acd369d0ab69694dbeeea2ba8.tar.bz2
mana-7bcd1e9ad172157acd369d0ab69694dbeeea2ba8.tar.xz
mana-7bcd1e9ad172157acd369d0ab69694dbeeea2ba8.zip
Fix some NPC-related bugs
NPCs are always in range, so show it. Also, don't attack NPCs (causes an infinite talk loop with most).
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 44187a75..abeb134c 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -179,20 +179,30 @@ void LocalPlayer::logic()
if (mTarget)
{
- // Find whether target is in range
- const int rangeX = abs(mTarget->mX - mX);
- const int rangeY = abs(mTarget->mY - mY);
- const int attackRange = getAttackRange();
- const int inRange = rangeX > attackRange || rangeY > attackRange ? 1 : 0;
-
- mTarget->setTargetAnimation(
- mTargetCursor[inRange][mTarget->getTargetCursorSize()]);
-
- if (mTarget->mAction == DEAD)
- stopAttack();
-
- if (mKeepAttacking && mTarget)
- attack(mTarget, true);
+ if (mTarget->getType() == Being::NPC)
+ {
+ // NPCs are always in range
+ mTarget->setTargetAnimation(
+ mTargetCursor[0][mTarget->getTargetCursorSize()]);
+ }
+ else
+ {
+ // Find whether target is in range
+ const int rangeX = abs(mTarget->mX - mX);
+ const int rangeY = abs(mTarget->mY - mY);
+ const int attackRange = getAttackRange();
+ const int inRange = rangeX > attackRange || rangeY > attackRange
+ ? 1 : 0;
+
+ mTarget->setTargetAnimation(
+ mTargetCursor[inRange][mTarget->getTargetCursorSize()]);
+
+ if (mTarget->mAction == DEAD)
+ stopAttack();
+
+ if (mKeepAttacking && mTarget)
+ attack(mTarget, true);
+ }
}
Being::logic();
@@ -520,7 +530,7 @@ void LocalPlayer::attack(Being *target, bool keep)
{
mKeepAttacking = keep;
- if (!target)
+ if (!target || target->getType() == Being::NPC)
return;
if ((mTarget != target) || !mTarget)