summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp59
1 files changed, 50 insertions, 9 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 01de3b41..b450c0ba 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -33,9 +33,11 @@
#include "particle.h"
#include "simpleanimation.h"
#include "sound.h"
+#include "statuseffect.h"
#include "text.h"
#include "gui/gui.h"
+#include "gui/ministatus.h"
#include "net/messageout.h"
#include "net/protocol.h"
@@ -72,7 +74,7 @@ LocalPlayer::LocalPlayer(Uint32 id, Uint16 job, Map *map):
mTarget(NULL), mPickUpTarget(NULL),
mTrading(false), mGoingToTarget(false),
mTargetTime(-1), mLastAction(-1),
- mLastTarget(-1), mWalkingDir(0),
+ mLastTarget(-1), mWalkingDir(0),
mDestX(0), mDestY(0),
mInventory(new Inventory(INVENTORY_SIZE)),
mStorage(new Inventory(STORAGE_SIZE))
@@ -176,7 +178,7 @@ void LocalPlayer::logic()
}
void LocalPlayer::setGM()
-{
+{
mIsGM = !mIsGM;
mNameColor = mIsGM ? 0x009000: 0x202020;
setName(getName());
@@ -383,10 +385,7 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y)
void LocalPlayer::setWalkingDir(int dir)
{
- if (mWalkingDir != dir)
- {
- mWalkingDir = dir;
- }
+ mWalkingDir = dir;
// If we're not already walking, start walking.
if (mAction != WALK && dir)
@@ -509,7 +508,7 @@ void LocalPlayer::attack(Being *target, bool keep)
int dist_y = target->mY - mY;
// Must be standing and be within attack range to continue
- if ((mAction != STAND) || (mAttackRange < abs(dist_x)) ||
+ if ((mAction != STAND) || (mAttackRange < abs(dist_x)) ||
(mAttackRange < abs(dist_y)))
return;
@@ -613,6 +612,48 @@ void LocalPlayer::setGotoTarget(Being *target)
setDestination(target->mX, target->mY);
}
+
+extern MiniStatusWindow *miniStatusWindow;
+
+void LocalPlayer::handleStatusEffect(StatusEffect *effect, int effectId)
+{
+ Being::handleStatusEffect(effect, effectId);
+
+
+
+ if (effect) {
+ effect->deliverMessage();
+ effect->playSFX();
+
+ AnimatedSprite *sprite = effect->getIcon();
+
+ if (!sprite) {
+ // delete sprite, if necessary
+ for (unsigned int i = 0; i < mStatusEffectIcons.size();)
+ if (mStatusEffectIcons[i] == effectId) {
+ mStatusEffectIcons.erase(mStatusEffectIcons.begin() + i);
+ miniStatusWindow->eraseIcon(i);
+ } else i++;
+ } else {
+ // replace sprite or append
+ bool found = false;
+
+ for (unsigned int i = 0; i < mStatusEffectIcons.size(); i++)
+ if (mStatusEffectIcons[i] == effectId) {
+ miniStatusWindow->setIcon(i, sprite);
+ found = true;
+ break;
+ }
+
+ if (!found) { // add new
+ int offset = mStatusEffectIcons.size();
+ miniStatusWindow->setIcon(offset, sprite);
+ mStatusEffectIcons.push_back(effectId);
+ }
+ }
+ }
+}
+
void LocalPlayer::initTargetCursor()
{
// Load target cursors
@@ -654,7 +695,7 @@ void LocalPlayer::loadTargetCursor(std::string filename, int width, int height,
mOutRangeImages[size] = currentImageSet;
mTargetCursorOutRange[size] = currentCursor;
}
- else
+ else
{
mInRangeImages[size] = currentImageSet;
mTargetCursorInRange[size] = currentCursor;
@@ -681,7 +722,7 @@ void LocalPlayer::drawTargetCursor(Graphics *graphics, int scrollX, int scrollY)
{
mTarget->mTargetCursor = mTargetCursorOutRange[cursorSize]->getCurrentImage();
}
- else
+ else
{
mTarget->mTargetCursor = mTargetCursorInRange[cursorSize]->getCurrentImage();
}