From 7bcd1e9ad172157acd369d0ab69694dbeeea2ba8 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sun, 8 Mar 2009 08:50:53 -0600 Subject: 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). --- src/localplayer.cpp | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'src/localplayer.cpp') 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) -- cgit v1.2.3-70-g09d2