From 218ad29dc13b1b89da9804dec15f32692d8709d6 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Mon, 27 Oct 2008 04:23:43 +0000 Subject: Made targets draw on the fringe layer, as well as added t for talking to an NPC, n for targeting an NPC, and changed basic targeting code so that it'll time out after being on a target for longer than a minute. --- src/localplayer.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/localplayer.cpp') diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 4cdaf03c..440ea636 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -117,6 +117,14 @@ void LocalPlayer::logic() mLastAction = -1; } + // Remove target if its been on a being for more than a minute + if (get_elapsed_time(mTargetTime) >= 60000) + { + mTargetTime = -1; + setTarget(mTarget); + mLastAction = -1; + } + for (int i = Being::TC_SMALL; i < Being::NUM_TC; i++) { player_node->mTargetCursorInRange[i]->update(10); @@ -262,8 +270,16 @@ void LocalPlayer::walk(unsigned char dir) void LocalPlayer::setTarget(Being *target) { + if (mLastAction != -1) + return; + mLastAction = tick_time; + if (target == mTarget) { + if (target != NULL) + { + target->mTargetCursor = NULL; + } return; } if (mTarget && mTarget->getType() == Being::MONSTER) @@ -562,7 +578,7 @@ void LocalPlayer::loadTargetCursor(std::string filename, int width, int height, } } -void LocalPlayer::drawTargetCursor(Graphics *graphics, int offsetX, int offsetY) +void LocalPlayer::drawTargetCursor(Graphics *graphics, int scrollX, int scrollY) { // Draw target marker if needed if (mTarget) @@ -587,9 +603,10 @@ void LocalPlayer::drawTargetCursor(Graphics *graphics, int offsetX, int offsetY) } // Draw the target cursor at the correct position - int posX = mTarget->getPixelX() + 16 - mTarget->mTargetCursor->getWidth() / 2 - offsetX; - int posY = mTarget->getPixelY() + 16 - mTarget->mTargetCursor->getHeight() / 2 - offsetY; + int posX = mTarget->getPixelX() + 16 - mTarget->mTargetCursor->getWidth() / 2 - scrollX; + int posY = mTarget->getPixelY() + 16 - mTarget->mTargetCursor->getHeight() / 2 - scrollY; graphics->drawImage(mTarget->mTargetCursor, posX, posY); } + return; } -- cgit v1.2.3-70-g09d2