summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorFate <fate-tmw@googlemail.com>2008-12-07 04:00:55 -0700
committerFate <fate-tmw@googlemail.com>2008-12-07 04:00:55 -0700
commit3fcd6a549fc825f4185a6dc248922e02988caed5 (patch)
tree2def3534088760ec3d06860eb0af936ec1e66b5b /src/being.cpp
parent68923d079602d8a8b7f35e1b56032e03e323ea09 (diff)
downloadmana-3fcd6a549fc825f4185a6dc248922e02988caed5.tar.gz
mana-3fcd6a549fc825f4185a6dc248922e02988caed5.tar.bz2
mana-3fcd6a549fc825f4185a6dc248922e02988caed5.tar.xz
mana-3fcd6a549fc825f4185a6dc248922e02988caed5.zip
Added client-side status change handlers (text, icon, particle effect, audio).
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 7c6d91e7..5f7ad73f 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -33,6 +33,7 @@
#include "sound.h"
#include "localplayer.h"
#include "text.h"
+#include "statuseffect.h"
#include "resources/itemdb.h"
#include "resources/resourcemanager.h"
@@ -72,6 +73,7 @@ Being::Being(int id, int job, Map *map):
mGender(2),
mSpeechTime(0),
mPx(0), mPy(0),
+ mStunMode(0),
mSprites(VECTOREND_SPRITE, NULL),
mSpriteIDs(VECTOREND_SPRITE, 0),
mSpriteColors(VECTOREND_SPRITE, ""),
@@ -441,6 +443,67 @@ Being::getType() const
return UNKNOWN;
}
+void
+Being::setStatusEffectBlock(int offset, Uint16 newEffects)
+{
+ for (int i = 0; i < STATUS_EFFECTS; i++) {
+ int index = StatusEffect::blockEffectIndexToEffectIndex(offset + i);
+ if (index != -1)
+ setStatusEffect(index, (newEffects & (1 << i)) > 0);
+ }
+}
+
+void
+Being::handleStatusEffect(StatusEffect *effect, int effectId)
+{
+ if (!effect)
+ return;
+
+ effect->playSFX();
+
+ SpriteAction action = effect->getAction();
+ if (action != ACTION_INVALID)
+ setAction(action);
+
+ Particle *particle = effect->getParticle();
+
+ if (particle) {
+ if (effectId >= 0)
+ mStatusParticleEffects.setLocally(effectId, particle);
+ else {
+ mStunParticleEffects.clearLocally();
+ mStunParticleEffects.addLocally(particle);
+ }
+ }
+}
+
+void
+Being::updateStunMode(int oldMode, int newMode)
+{
+ handleStatusEffect(StatusEffect::getStatusEffect(oldMode, false), -1);
+ handleStatusEffect(StatusEffect::getStatusEffect(newMode, true), -1);
+}
+
+void
+Being::updateStatusEffect(int index, bool newStatus)
+{
+ handleStatusEffect(StatusEffect::getStatusEffect(index, newStatus), index);
+}
+
+void
+Being::setStatusEffect(int index, bool active)
+{
+ const bool wasActive = mStatusEffects.find(index) != mStatusEffects.end();
+
+ if (active != wasActive) {
+ updateStatusEffect(index, active);
+ if (active)
+ mStatusEffects.insert(index);
+ else
+ mStatusEffects.erase(index);
+ }
+}
+
int
Being::getOffset(char pos, char neg) const
{