summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp49
1 files changed, 45 insertions, 4 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index c6fde7a8..15f5b6b2 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -32,8 +32,10 @@
#include "particle.h"
#include "sound.h"
#include "monster.h"
+#include "statuseffect.h"
#include "gui/gui.h"
+#include "gui/ministatus.h"
#include "net/messageout.h"
#include "net/protocol.h"
@@ -378,10 +380,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)
@@ -608,6 +607,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